const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-Dpmj0iZt.js","assets/usePostcardZones-DN2DpQaD.js","assets/DirectMail-BT1mbUa8.js","assets/LeadSiteEditor-wa9JFUT7.js","assets/VideoUrlField-qnbSaOmz.js","assets/AdminLeadSiteThemes-z6bxcM3Q.js","assets/EmailCampaignComposer-h1rbYnW1.js","assets/EditorModeSelector-DcrJGr8G.js","assets/SharedCampaignTemplates-BWA-RRJh.js","assets/TemplateEditorDialog-Z83IlUHC.js","assets/AgentTemplates-CJV04EeJ.js"])))=>i.map(i=>d[i]); var Omt=Object.defineProperty;var TTe=t=>{throw TypeError(t)};var Rmt=(t,s,r)=>s in t?Omt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var An=(t,s,r)=>Rmt(t,typeof s!="symbol"?s+"":s,r),Lfe=(t,s,r)=>s.has(t)||TTe("Cannot "+r);var is=(t,s,r)=>(Lfe(t,s,"read from private field"),r?r.call(t):s.get(t)),ti=(t,s,r)=>s.has(t)?TTe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Yn=(t,s,r,n)=>(Lfe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Ji=(t,s,r)=>(Lfe(t,s,"access private method"),r);var A7=(t,s,r,n)=>({set _(a){Yn(t,s,a,r)},get _(){return is(t,s,n)}});function Fmt(t,s){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();const zmt="modulepreload",Bmt=function(t){return"/"+t},ATe={},ol=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(c=>{if(c=Bmt(c),c in ATe)return;ATe[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":zmt,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((g,v)=>{f.addEventListener("load",g),f.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return s().catch(o)})};var Yv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Po(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function O9e(t){if(t.__esModule)return t;var s=t.default;if(typeof s=="function"){var r=function n(){return this instanceof n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var a=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return t[n]}})}),r}var R9e={exports:{}},xde={},F9e={exports:{}},bo={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var NO=Symbol.for("react.element"),$mt=Symbol.for("react.portal"),qmt=Symbol.for("react.fragment"),Umt=Symbol.for("react.strict_mode"),Vmt=Symbol.for("react.profiler"),Hmt=Symbol.for("react.provider"),Gmt=Symbol.for("react.context"),Wmt=Symbol.for("react.forward_ref"),Kmt=Symbol.for("react.suspense"),Zmt=Symbol.for("react.memo"),Ymt=Symbol.for("react.lazy"),ETe=Symbol.iterator;function Qmt(t){return t===null||typeof t!="object"?null:(t=ETe&&t[ETe]||t["@@iterator"],typeof t=="function"?t:null)}var z9e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},B9e=Object.assign,$9e={};function UA(t,s,r){this.props=t,this.context=s,this.refs=$9e,this.updater=r||z9e}UA.prototype.isReactComponent={};UA.prototype.setState=function(t,s){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,s,"setState")};UA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function q9e(){}q9e.prototype=UA.prototype;function Cwe(t,s,r){this.props=t,this.context=s,this.refs=$9e,this.updater=r||z9e}var Mwe=Cwe.prototype=new q9e;Mwe.constructor=Cwe;B9e(Mwe,UA.prototype);Mwe.isPureReactComponent=!0;var PTe=Array.isArray,U9e=Object.prototype.hasOwnProperty,Twe={current:null},V9e={key:!0,ref:!0,__self:!0,__source:!0};function H9e(t,s,r){var n,a={},o=null,l=null;if(s!=null)for(n in s.ref!==void 0&&(l=s.ref),s.key!==void 0&&(o=""+s.key),s)U9e.call(s,n)&&!V9e.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,xe=oe[ue];if(0>>1;ue<_e;){var $e=2*(ue+1)-1,Me=oe[$e],Ie=$e+1,ke=oe[Ie];if(0>a(Me,ge))Iea(ke,Me)?(oe[ue]=ke,oe[Ie]=ge,ue=Ie):(oe[ue]=Me,oe[$e]=ge,ue=$e);else if(Iea(ke,ge))oe[ue]=ke,oe[Ie]=ge,ue=Ie;else break e}}return fe}function a(oe,fe){var ge=oe.sortIndex-fe.sortIndex;return ge!==0?ge:oe.id-fe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();t.unstable_now=function(){return l.now()-i}}var c=[],u=[],p=1,f=null,g=3,v=!1,_=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(oe){for(var fe=r(u);fe!==null;){if(fe.callback===null)n(u);else if(fe.startTime<=oe)n(u),fe.sortIndex=fe.expirationTime,s(c,fe);else break;fe=r(u)}}function L(oe){if(w=!1,M(oe),!_)if(r(c)!==null)_=!0,ne(P);else{var fe=r(u);fe!==null&&re(L,fe.startTime-oe)}}function P(oe,fe){_=!1,w&&(w=!1,k(U),U=-1),v=!0;var ge=g;try{for(M(fe),f=r(c);f!==null&&(!(f.expirationTime>fe)||oe&&!X());){var ue=f.callback;if(typeof ue=="function"){f.callback=null,g=f.priorityLevel;var xe=ue(f.expirationTime<=fe);fe=t.unstable_now(),typeof xe=="function"?f.callback=xe:f===r(c)&&n(c),M(fe)}else n(c);f=r(c)}if(f!==null)var _e=!0;else{var $e=r(u);$e!==null&&re(L,$e.startTime-fe),_e=!1}return _e}finally{f=null,g=ge,v=!1}}var O=!1,$=null,U=-1,B=5,V=-1;function X(){return!(t.unstable_now()-Voe||125ue?(oe.sortIndex=ge,s(u,oe),r(c)===null&&oe===r(u)&&(w?(k(U),U=-1):w=!0,re(L,ge-ue))):(oe.sortIndex=xe,s(c,oe),_||v||(_=!0,ne(P))),oe},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(oe){var fe=g;return function(){var ge=g;g=fe;try{return oe.apply(this,arguments)}finally{g=ge}}}})(Y9e);Z9e.exports=Y9e;var lpt=Z9e.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var cpt=N,Mf=lpt;function Xr(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yye=Object.prototype.hasOwnProperty,dpt=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,LTe={},DTe={};function upt(t){return Yye.call(DTe,t)?!0:Yye.call(LTe,t)?!1:dpt.test(t)?DTe[t]=!0:(LTe[t]=!0,!1)}function hpt(t,s,r,n){if(r!==null&&r.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function mpt(t,s,r,n){if(s===null||typeof s>"u"||hpt(t,s,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function Hm(t,s,r,n,a,o,l){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=t,this.type=s,this.sanitizeURL=o,this.removeEmptyString=l}var Lh={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Lh[t]=new Hm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Lh[s]=new Hm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Lh[t]=new Hm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Lh[t]=new Hm(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Lh[t]=new Hm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Lh[t]=new Hm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Lh[t]=new Hm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Lh[t]=new Hm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Lh[t]=new Hm(t,5,!1,t.toLowerCase(),null,!1,!1)});var Pwe=/[\-:]([a-z])/g;function Iwe(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(Pwe,Iwe);Lh[s]=new Hm(s,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(Pwe,Iwe);Lh[s]=new Hm(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(Pwe,Iwe);Lh[s]=new Hm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Lh[t]=new Hm(t,1,!1,t.toLowerCase(),null,!1,!1)});Lh.xlinkHref=new Hm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Lh[t]=new Hm(t,1,!1,t.toLowerCase(),null,!0,!0)});function Lwe(t,s,r,n){var a=Lh.hasOwnProperty(s)?Lh[s]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var c=` `+a[l].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=l&&0<=i);break}}}finally{Rfe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?SI(t):""}function ppt(t){switch(t.tag){case 5:return SI(t.type);case 16:return SI("Lazy");case 13:return SI("Suspense");case 19:return SI("SuspenseList");case 0:case 2:case 15:return t=Ffe(t.type,!1),t;case 11:return t=Ffe(t.type.render,!1),t;case 1:return t=Ffe(t.type,!0),t;default:return""}}function e0e(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case rM:return"Fragment";case sM:return"Portal";case Qye:return"Profiler";case Dwe:return"StrictMode";case Xye:return"Suspense";case Jye:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case J9e:return(t.displayName||"Context")+".Consumer";case X9e:return(t._context.displayName||"Context")+".Provider";case Owe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Rwe:return s=t.displayName||null,s!==null?s:e0e(t.type)||"Memo";case Qb:s=t._payload,t=t._init;try{return e0e(t(s))}catch{}}return null}function fpt(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return e0e(s);case 8:return s===Dwe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function uw(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function tBe(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function xpt(t){var s=tBe(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),n=""+t[s];if(!t.hasOwnProperty(s)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,o=r.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return a.call(this)},set:function(l){n=""+l,o.call(this,l)}}),Object.defineProperty(t,s,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(l){n=""+l},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function I7(t){t._valueTracker||(t._valueTracker=xpt(t))}function sBe(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=tBe(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Kie(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function t0e(t,s){var r=s.checked;return id({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function RTe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=uw(s.value!=null?s.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function rBe(t,s){s=s.checked,s!=null&&Lwe(t,"checked",s,!1)}function s0e(t,s){rBe(t,s);var r=uw(s.value),n=s.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?r0e(t,s.type,r):s.hasOwnProperty("defaultValue")&&r0e(t,s.type,uw(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function FTe(t,s,r){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var n=s.type;if(!(n!=="submit"&&n!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,r||s===t.value||(t.value=s),t.defaultValue=s}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function r0e(t,s,r){(s!=="number"||Kie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var CI=Array.isArray;function CM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=L7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function R8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var GI={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gpt=["Webkit","ms","Moz","O"];Object.keys(GI).forEach(function(t){gpt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),GI[s]=GI[t]})});function oBe(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||GI.hasOwnProperty(t)&&GI[t]?(""+s).trim():s+"px"}function lBe(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=oBe(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var ypt=id({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function i0e(t,s){if(s){if(ypt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Xr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Xr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Xr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Xr(62))}}function o0e(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var l0e=null;function Fwe(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var c0e=null,MM=null,TM=null;function $Te(t){if(t=CO(t)){if(typeof c0e!="function")throw Error(Xr(280));var s=t.stateNode;s&&(s=_de(s),c0e(t.stateNode,t.type,s))}}function cBe(t){MM?TM?TM.push(t):TM=[t]:MM=t}function dBe(){if(MM){var t=MM,s=TM;if(TM=MM=null,$Te(t),s)for(t=0;t>>=0,t===0?32:31-(Tpt(t)/Apt|0)|0}var D7=64,O7=4194304;function MI(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Xie(t,s){var r=t.pendingLanes;if(r===0)return 0;var n=0,a=t.suspendedLanes,o=t.pingedLanes,l=r&268435455;if(l!==0){var i=l&~a;i!==0?n=MI(i):(o&=l,o!==0&&(n=MI(o)))}else l=r&~a,l!==0?n=MI(l):o!==0&&(n=MI(o));if(n===0)return 0;if(s!==0&&s!==n&&!(s&a)&&(a=n&-n,o=s&-s,a>=o||a===16&&(o&4194240)!==0))return s;if(n&4&&(n|=r&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=n;0r;r++)s.push(t);return s}function kO(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Qg(s),t[s]=r}function Lpt(t,s){var r=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=KI),YTe=" ",QTe=!1;function ABe(t,s){switch(t){case"keyup":return lft.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function EBe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var nM=!1;function dft(t,s){switch(t){case"compositionend":return EBe(s);case"keypress":return s.which!==32?null:(QTe=!0,YTe);case"textInput":return t=s.data,t===YTe&&QTe?null:t;default:return null}}function uft(t,s){if(nM)return t==="compositionend"||!Gwe&&ABe(t,s)?(t=MBe(),j9=Uwe=C_=null,nM=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:r,offset:s-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=tAe(r)}}function DBe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?DBe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function OBe(){for(var t=window,s=Kie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Kie(t.document)}return s}function Wwe(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function bft(t){var s=OBe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&DBe(r.ownerDocument.documentElement,r)){if(n!==null&&Wwe(r)){if(s=n.start,t=n.end,t===void 0&&(t=s),"selectionStart"in r)r.selectionStart=s,r.selectionEnd=Math.min(t,r.value.length);else if(t=(s=r.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var a=r.textContent.length,o=Math.min(n.start,a);n=n.end===void 0?o:Math.min(n.end,a),!t.extend&&o>n&&(a=n,n=o,o=a),a=sAe(r,o);var l=sAe(r,n);a&&l&&(t.rangeCount!==1||t.anchorNode!==a.node||t.anchorOffset!==a.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(s=s.createRange(),s.setStart(a.node,a.offset),t.removeAllRanges(),o>n?(t.addRange(s),t.extend(l.node,l.offset)):(s.setEnd(l.node,l.offset),t.addRange(s)))}}for(s=[],t=r;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,aM=null,f0e=null,YI=null,x0e=!1;function rAe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;x0e||aM==null||aM!==Kie(n)||(n=aM,"selectionStart"in n&&Wwe(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),YI&&U8(YI,n)||(YI=n,n=toe(f0e,"onSelect"),0lM||(t.current=w0e[lM],w0e[lM]=null,lM--)}function Jl(t,s){lM++,w0e[lM]=t.current,t.current=s}var hw={},Qh=Mw(hw),wp=Mw(!1),FS=hw;function IT(t,s){var r=t.type.contextTypes;if(!r)return hw;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===s)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in r)a[o]=s[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=a),a}function jp(t){return t=t.childContextTypes,t!=null}function roe(){Cc(wp),Cc(Qh)}function dAe(t,s,r){if(Qh.current!==hw)throw Error(Xr(168));Jl(Qh,s),Jl(wp,r)}function HBe(t,s,r){var n=t.stateNode;if(s=s.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in s))throw Error(Xr(108,fpt(t)||"Unknown",a));return id({},r,n)}function noe(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||hw,FS=Qh.current,Jl(Qh,t),Jl(wp,wp.current),!0}function uAe(t,s,r){var n=t.stateNode;if(!n)throw Error(Xr(169));r?(t=HBe(t,s,FS),n.__reactInternalMemoizedMergedChildContext=t,Cc(wp),Cc(Qh),Jl(Qh,t)):Cc(wp),Jl(wp,r)}var zv=null,wde=!1,Xfe=!1;function GBe(t){zv===null?zv=[t]:zv.push(t)}function Pft(t){wde=!0,GBe(t)}function Tw(){if(!Xfe&&zv!==null){Xfe=!0;var t=0,s=_l;try{var r=zv;for(_l=1;t>=l,a-=l,Qv=1<<32-Qg(s)+a|r<U?(B=$,$=null):B=$.sibling;var V=g(k,$,M[U],L);if(V===null){$===null&&($=B);break}t&&$&&V.alternate===null&&s(k,$),S=o(V,S,U),O===null?P=V:O.sibling=V,O=V,$=B}if(U===M.length)return r(k,$),Bc&&Y2(k,U),P;if($===null){for(;UU?(B=$,$=null):B=$.sibling;var X=g(k,$,V.value,L);if(X===null){$===null&&($=B);break}t&&$&&X.alternate===null&&s(k,$),S=o(X,S,U),O===null?P=X:O.sibling=X,O=X,$=B}if(V.done)return r(k,$),Bc&&Y2(k,U),P;if($===null){for(;!V.done;U++,V=M.next())V=f(k,V.value,L),V!==null&&(S=o(V,S,U),O===null?P=V:O.sibling=V,O=V);return Bc&&Y2(k,U),P}for($=n(k,$);!V.done;U++,V=M.next())V=v($,k,U,V.value,L),V!==null&&(t&&V.alternate!==null&&$.delete(V.key===null?U:V.key),S=o(V,S,U),O===null?P=V:O.sibling=V,O=V);return t&&$.forEach(function(Y){return s(k,Y)}),Bc&&Y2(k,U),P}function j(k,S,M,L){if(typeof M=="object"&&M!==null&&M.type===rM&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case P7:e:{for(var P=M.key,O=S;O!==null;){if(O.key===P){if(P=M.type,P===rM){if(O.tag===7){r(k,O.sibling),S=a(O,M.props.children),S.return=k,k=S;break e}}else if(O.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Qb&&pAe(P)===O.type){r(k,O.sibling),S=a(O,M.props),S.ref=HP(k,O,M),S.return=k,k=S;break e}r(k,O);break}else s(k,O);O=O.sibling}M.type===rM?(S=Y4(M.props.children,k.mode,L,M.key),S.return=k,k=S):(L=E9(M.type,M.key,M.props,null,k.mode,L),L.ref=HP(k,S,M),L.return=k,k=L)}return l(k);case sM:e:{for(O=M.key;S!==null;){if(S.key===O)if(S.tag===4&&S.stateNode.containerInfo===M.containerInfo&&S.stateNode.implementation===M.implementation){r(k,S.sibling),S=a(S,M.children||[]),S.return=k,k=S;break e}else{r(k,S);break}else s(k,S);S=S.sibling}S=ixe(M,k.mode,L),S.return=k,k=S}return l(k);case Qb:return O=M._init,j(k,S,O(M._payload),L)}if(CI(M))return _(k,S,M,L);if(BP(M))return w(k,S,M,L);U7(k,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,S!==null&&S.tag===6?(r(k,S.sibling),S=a(S,M),S.return=k,k=S):(r(k,S),S=axe(M,k.mode,L),S.return=k,k=S),l(k)):r(k,S)}return j}var DT=YBe(!0),QBe=YBe(!1),ooe=Mw(null),loe=null,uM=null,Qwe=null;function Xwe(){Qwe=uM=loe=null}function Jwe(t){var s=ooe.current;Cc(ooe),t._currentValue=s}function k0e(t,s,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,n!==null&&(n.childLanes|=s)):n!==null&&(n.childLanes&s)!==s&&(n.childLanes|=s),t===r)break;t=t.return}}function EM(t,s){loe=t,Qwe=uM=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(gp=!0),t.firstContext=null)}function Dx(t){var s=t._currentValue;if(Qwe!==t)if(t={context:t,memoizedValue:s,next:null},uM===null){if(loe===null)throw Error(Xr(308));uM=t,loe.dependencies={lanes:0,firstContext:t}}else uM=uM.next=t;return s}var b4=null;function e2e(t){b4===null?b4=[t]:b4.push(t)}function XBe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,e2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,A1(t,n)}function A1(t,s){t.lanes|=s;var r=t.alternate;for(r!==null&&(r.lanes|=s),r=t,t=t.return;t!==null;)t.childLanes|=s,r=t.alternate,r!==null&&(r.childLanes|=s),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Xb=!1;function t2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function JBe(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function n1(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function B_(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,zo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,A1(t,r)}return a=n.interleaved,a===null?(s.next=s,e2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,A1(t,r)}function k9(t,s,r){if(s=s.updateQueue,s!==null&&(s=s.shared,(r&4194240)!==0)){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Bwe(t,r)}}function fAe(t,s){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var a=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var l={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?a=o=l:o=o.next=l,r=r.next}while(r!==null);o===null?a=o=s:o=o.next=s}else a=o=s;r={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=s:t.next=s,r.lastBaseUpdate=s}function coe(t,s,r,n){var a=t.updateQueue;Xb=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var c=i,u=c.next;c.next=null,l===null?o=u:l.next=u,l=c;var p=t.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=u:i.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=a.baseState;l=0,p=u=c=null,i=o;do{var g=i.lane,v=i.eventTime;if((n&g)===g){p!==null&&(p=p.next={eventTime:v,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var _=t,w=i;switch(g=s,v=r,w.tag){case 1:if(_=w.payload,typeof _=="function"){f=_.call(v,f,g);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=w.payload,g=typeof _=="function"?_.call(v,f,g):_,g==null)break e;f=id({},f,g);break e;case 2:Xb=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,g=a.effects,g===null?a.effects=[i]:g.push(i))}else v={eventTime:v,lane:g,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=v,c=f):p=p.next=v,l|=g;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;g=i,i=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);if(p===null&&(c=f),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,s=a.shared.interleaved,s!==null){a=s;do l|=a.lane,a=a.next;while(a!==s)}else o===null&&(a.shared.lanes=0);$S|=l,t.lanes=l,t.memoizedState=f}}function xAe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=exe.transition;exe.transition={};try{t(!1),s()}finally{_l=r,exe.transition=n}}function x$e(){return Ox().memoizedState}function Oft(t,s,r){var n=q_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},g$e(t))y$e(s,r);else if(r=XBe(t,s,r,n),r!==null){var a=Im();Xg(r,t,n,a),v$e(r,s,n)}}function Rft(t,s,r){var n=q_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(g$e(t))y$e(s,a);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=s.lastRenderedReducer,o!==null))try{var l=s.lastRenderedState,i=o(l,r);if(a.hasEagerState=!0,a.eagerState=i,iy(i,l)){var c=s.interleaved;c===null?(a.next=a,e2e(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=XBe(t,s,a,n),r!==null&&(a=Im(),Xg(r,t,n,a),v$e(r,s,n))}}function g$e(t){var s=t.alternate;return t===rd||s!==null&&s===rd}function y$e(t,s){QI=uoe=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function v$e(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Bwe(t,r)}}var hoe={readContext:Dx,useCallback:zh,useContext:zh,useEffect:zh,useImperativeHandle:zh,useInsertionEffect:zh,useLayoutEffect:zh,useMemo:zh,useReducer:zh,useRef:zh,useState:zh,useDebugValue:zh,useDeferredValue:zh,useTransition:zh,useMutableSource:zh,useSyncExternalStore:zh,useId:zh,unstable_isNewReconciler:!1},Fft={readContext:Dx,useCallback:function(t,s){return Wy().memoizedState=[t,s===void 0?null:s],t},useContext:Dx,useEffect:yAe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,C9(4194308,4,u$e.bind(null,s,t),r)},useLayoutEffect:function(t,s){return C9(4194308,4,t,s)},useInsertionEffect:function(t,s){return C9(4,2,t,s)},useMemo:function(t,s){var r=Wy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Wy();return s=r!==void 0?r(s):s,n.memoizedState=n.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},n.queue=t,t=t.dispatch=Oft.bind(null,rd,t),[n.memoizedState,t]},useRef:function(t){var s=Wy();return t={current:t},s.memoizedState=t},useState:gAe,useDebugValue:c2e,useDeferredValue:function(t){return Wy().memoizedState=t},useTransition:function(){var t=gAe(!1),s=t[0];return t=Dft.bind(null,t[1]),Wy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=rd,a=Wy();if(Bc){if(r===void 0)throw Error(Xr(407));r=r()}else{if(r=s(),eh===null)throw Error(Xr(349));BS&30||r$e(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,yAe(a$e.bind(null,n,o,t),[t]),n.flags|=2048,Q8(9,n$e.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Wy(),s=eh.identifierPrefix;if(Bc){var r=Xv,n=Qv;r=(n&~(1<<32-Qg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=Z8++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=l.createElement(r,{is:n.is}):(t=l.createElement(r),r==="select"&&(l=t,n.multiple?l.multiple=!0:n.size&&(l.size=n.size))):t=l.createElementNS(t,r),t[n0]=s,t[G8]=n,T$e(t,s,!1,!1),s.stateNode=t;e:{switch(l=o0e(r,n),r){case"dialog":yc("cancel",t),yc("close",t),a=n;break;case"iframe":case"object":case"embed":yc("load",t),a=n;break;case"video":case"audio":for(a=0;aFT&&(s.flags|=128,n=!0,GP(o,!1),s.lanes=4194304)}else{if(!n)if(t=doe(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),GP(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Bc)return Bh(s),null}else 2*Id()-o.renderingStartTime>FT&&r!==1073741824&&(s.flags|=128,n=!0,GP(o,!1),s.lanes=4194304);o.isBackwards?(l.sibling=s.child,s.child=l):(r=o.last,r!==null?r.sibling=l:s.child=l,o.last=l)}return o.tail!==null?(s=o.tail,o.rendering=s,o.tail=s.sibling,o.renderingStartTime=Id(),s.sibling=null,r=Jc.current,Jl(Jc,n?r&1|2:r&1),s):(Bh(s),null);case 22:case 23:return f2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?tf&1073741824&&(Bh(s),s.subtreeFlags&6&&(s.flags|=8192)):Bh(s),null;case 24:return null;case 25:return null}throw Error(Xr(156,s.tag))}function Gft(t,s){switch(Zwe(s),s.tag){case 1:return jp(s.type)&&roe(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return OT(),Cc(wp),Cc(Qh),n2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return r2e(s),null;case 13:if(Cc(Jc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Xr(340));LT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return Cc(Jc),null;case 4:return OT(),null;case 10:return Jwe(s.type._context),null;case 22:case 23:return f2e(),null;case 24:return null;default:return null}}var H7=!1,Hh=!1,Wft=typeof WeakSet=="function"?WeakSet:Set,na=null;function hM(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){fd(t,s,n)}else r.current=null}function L0e(t,s,r){try{r()}catch(n){fd(t,s,n)}}var TAe=!1;function Kft(t,s){if(g0e=Jie,t=OBe(),Wwe(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var l=0,i=-1,c=-1,u=0,p=0,f=t,g=null;t:for(;;){for(var v;f!==r||a!==0&&f.nodeType!==3||(i=l+a),f!==o||n!==0&&f.nodeType!==3||(c=l+n),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)g=f,f=v;for(;;){if(f===t)break t;if(g===r&&++u===a&&(i=l),g===o&&++p===n&&(c=l),(v=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=v}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(y0e={focusedElem:t,selectionRange:r},Jie=!1,na=s;na!==null;)if(s=na,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,na=t;else for(;na!==null;){s=na;try{var _=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var w=_.memoizedProps,j=_.memoizedState,k=s.stateNode,S=k.getSnapshotBeforeUpdate(s.elementType===s.type?w:Lg(s.type,w),j);k.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var M=s.stateNode.containerInfo;M.nodeType===1?M.textContent="":M.nodeType===9&&M.documentElement&&M.removeChild(M.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Xr(163))}}catch(L){fd(s,s.return,L)}if(t=s.sibling,t!==null){t.return=s.return,na=t;break}na=s.return}return _=TAe,TAe=!1,_}function XI(t,s,r){var n=s.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&t)===t){var o=a.destroy;a.destroy=void 0,o!==void 0&&L0e(s,r,o)}a=a.next}while(a!==n)}}function kde(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==s)}}function D0e(t){var s=t.ref;if(s!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof s=="function"?s(t):s.current=t}}function P$e(t){var s=t.alternate;s!==null&&(t.alternate=null,P$e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[n0],delete s[G8],delete s[_0e],delete s[Aft],delete s[Eft])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function I$e(t){return t.tag===5||t.tag===3||t.tag===4}function AAe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||I$e(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function O0e(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.nodeType===8?r.parentNode.insertBefore(t,s):r.insertBefore(t,s):(r.nodeType===8?(s=r.parentNode,s.insertBefore(t,r)):(s=r,s.appendChild(t)),r=r._reactRootContainer,r!=null||s.onclick!==null||(s.onclick=soe));else if(n!==4&&(t=t.child,t!==null))for(O0e(t,s,r),t=t.sibling;t!==null;)O0e(t,s,r),t=t.sibling}function R0e(t,s,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,s?r.insertBefore(t,s):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(R0e(t,s,r),t=t.sibling;t!==null;)R0e(t,s,r),t=t.sibling}var vh=null,Fg=!1;function Db(t,s,r){for(r=r.child;r!==null;)L$e(t,s,r),r=r.sibling}function L$e(t,s,r){if(m0&&typeof m0.onCommitFiberUnmount=="function")try{m0.onCommitFiberUnmount(gde,r)}catch{}switch(r.tag){case 5:Hh||hM(r,s);case 6:var n=vh,a=Fg;vh=null,Db(t,s,r),vh=n,Fg=a,vh!==null&&(Fg?(t=vh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):vh.removeChild(r.stateNode));break;case 18:vh!==null&&(Fg?(t=vh,r=r.stateNode,t.nodeType===8?Qfe(t.parentNode,r):t.nodeType===1&&Qfe(t,r),$8(t)):Qfe(vh,r.stateNode));break;case 4:n=vh,a=Fg,vh=r.stateNode.containerInfo,Fg=!0,Db(t,s,r),vh=n,Fg=a;break;case 0:case 11:case 14:case 15:if(!Hh&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){a=n=n.next;do{var o=a,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&L0e(r,s,l),a=a.next}while(a!==n)}Db(t,s,r);break;case 1:if(!Hh&&(hM(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){fd(r,s,i)}Db(t,s,r);break;case 21:Db(t,s,r);break;case 22:r.mode&1?(Hh=(n=Hh)||r.memoizedState!==null,Db(t,s,r),Hh=n):Db(t,s,r);break;default:Db(t,s,r)}}function EAe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Wft),s.forEach(function(n){var a=rxt.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function kg(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Id()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Yft(n/1960))-n,10t?16:t,M_===null)var n=!1;else{if(t=M_,M_=null,foe=0,zo&6)throw Error(Xr(331));var a=zo;for(zo|=4,na=t.current;na!==null;){var o=na,l=o.child;if(na.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cId()-m2e?Z4(t,0):h2e|=r),Np(t,s)}function q$e(t,s){s===0&&(t.mode&1?(s=O7,O7<<=1,!(O7&130023424)&&(O7=4194304)):s=1);var r=Im();t=A1(t,s),t!==null&&(kO(t,s,r),Np(t,r))}function sxt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),q$e(t,r)}function rxt(t,s){var r=0;switch(t.tag){case 13:var n=t.stateNode,a=t.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Xr(314))}n!==null&&n.delete(s),q$e(t,r)}var U$e;U$e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||wp.current)gp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return gp=!1,Vft(t,s,r);gp=!!(t.flags&131072)}else gp=!1,Bc&&s.flags&1048576&&WBe(s,ioe,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;M9(t,s),t=s.pendingProps;var a=IT(s,Qh.current);EM(s,r),a=i2e(null,s,n,t,a,r);var o=o2e();return s.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,jp(n)?(o=!0,noe(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,t2e(s),a.updater=Nde,s.stateNode=a,a._reactInternals=s,C0e(s,n,t,r),s=A0e(null,s,n,!0,o,r)):(s.tag=0,Bc&&o&&Kwe(s),_m(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(M9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=axt(n),t=Lg(n,t),a){case 0:s=T0e(null,s,n,t,r);break e;case 1:s=SAe(null,s,n,t,r);break e;case 11:s=NAe(null,s,n,t,r);break e;case 14:s=kAe(null,s,n,Lg(n.type,t),r);break e}throw Error(Xr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Lg(n,a),T0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Lg(n,a),SAe(t,s,n,a,r);case 3:e:{if(S$e(s),t===null)throw Error(Xr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,JBe(t,s),coe(s,n,null,r);var l=s.memoizedState;if(n=l.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},s.updateQueue.baseState=o,s.memoizedState=o,s.flags&256){a=RT(Error(Xr(423)),s),s=CAe(t,s,n,r,a);break e}else if(n!==a){a=RT(Error(Xr(424)),s),s=CAe(t,s,n,r,a);break e}else for(hf=z_(s.stateNode.containerInfo.firstChild),pf=s,Bc=!0,Ug=null,r=QBe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(LT(),n===a){s=E1(t,s,r);break e}_m(t,s,n,r)}s=s.child}return s;case 5:return e$e(s),t===null&&N0e(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,v0e(n,a)?l=null:o!==null&&v0e(n,o)&&(s.flags|=32),k$e(t,s),_m(t,s,l,r),s.child;case 6:return t===null&&N0e(s),null;case 13:return C$e(t,s,r);case 4:return s2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=DT(s,null,n,r):_m(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Lg(n,a),NAe(t,s,n,a,r);case 7:return _m(t,s,s.pendingProps,r),s.child;case 8:return _m(t,s,s.pendingProps.children,r),s.child;case 12:return _m(t,s,s.pendingProps.children,r),s.child;case 10:e:{if(n=s.type._context,a=s.pendingProps,o=s.memoizedProps,l=a.value,Jl(ooe,n._currentValue),n._currentValue=l,o!==null)if(iy(o.value,l)){if(o.children===a.children&&!wp.current){s=E1(t,s,r);break e}}else for(o=s.child,o!==null&&(o.return=s);o!==null;){var i=o.dependencies;if(i!==null){l=o.child;for(var c=i.firstContext;c!==null;){if(c.context===n){if(o.tag===1){c=n1(-1,r&-r),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),k0e(o.return,r,s),i.lanes|=r;break}c=c.next}}else if(o.tag===10)l=o.type===s.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Xr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),k0e(l,r,s),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===s){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}_m(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,EM(s,r),a=Dx(a),n=n(a),s.flags|=1,_m(t,s,n,r),s.child;case 14:return n=s.type,a=Lg(n,s.pendingProps),a=Lg(n.type,a),kAe(t,s,n,a,r);case 15:return j$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Lg(n,a),M9(t,s),s.tag=1,jp(n)?(t=!0,noe(s)):t=!1,EM(s,r),b$e(s,n,a),C0e(s,n,a,r),A0e(null,s,n,!0,t,r);case 19:return M$e(t,s,r);case 22:return N$e(t,s,r)}throw Error(Xr(156,s.tag))};function V$e(t,s){return gBe(t,s)}function nxt(t,s,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _x(t,s,r,n){return new nxt(t,s,r,n)}function g2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function axt(t){if(typeof t=="function")return g2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Owe)return 11;if(t===Rwe)return 14}return 2}function U_(t,s){var r=t.alternate;return r===null?(r=_x(t.tag,s,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=s,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,s=t.dependencies,r.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function E9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")g2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case rM:return Y4(r.children,a,o,s);case Dwe:l=8,a|=8;break;case Qye:return t=_x(12,r,s,a|2),t.elementType=Qye,t.lanes=o,t;case Xye:return t=_x(13,r,s,a),t.elementType=Xye,t.lanes=o,t;case Jye:return t=_x(19,r,s,a),t.elementType=Jye,t.lanes=o,t;case eBe:return Cde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case X9e:l=10;break e;case J9e:l=9;break e;case Owe:l=11;break e;case Rwe:l=14;break e;case Qb:l=16,n=null;break e}throw Error(Xr(130,t==null?t:typeof t,""))}return s=_x(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function Y4(t,s,r,n){return t=_x(7,t,n,s),t.lanes=r,t}function Cde(t,s,r,n){return t=_x(22,t,n,s),t.elementType=eBe,t.lanes=r,t.stateNode={isHidden:!1},t}function axe(t,s,r){return t=_x(6,t,null,s),t.lanes=r,t}function ixe(t,s,r){return s=_x(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function ixt(t,s,r,n,a){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Bfe(0),this.expirationTimes=Bfe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bfe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function y2e(t,s,r,n,a,o,l,i,c){return t=new ixt(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=_x(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},t2e(o),t}function oxt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(K$e)}catch(t){console.error(t)}}K$e(),K9e.exports=If;var yp=K9e.exports;const w2e=Po(yp);var Z$e,zAe=yp;Z$e=zAe.createRoot,zAe.hydrateRoot;const hxt=1,mxt=1e6;let oxe=0;function pxt(){return oxe=(oxe+1)%Number.MAX_SAFE_INTEGER,oxe.toString()}const lxe=new Map,BAe=t=>{if(lxe.has(t))return;const s=setTimeout(()=>{lxe.delete(t),tL({type:"REMOVE_TOAST",toastId:t})},mxt);lxe.set(t,s)},fxt=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,hxt)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?BAe(r):t.toasts.forEach(n=>{BAe(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==s.toastId)}}},P9=[];let I9={toasts:[]};function tL(t){I9=fxt(I9,t),P9.forEach(s=>{s(I9)})}function jn({...t}){const s=pxt(),r=a=>tL({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>tL({type:"DISMISS_TOAST",toastId:s});return tL({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ha(){const[t,s]=N.useState(I9);return N.useEffect(()=>(P9.push(s),()=>{const r=P9.indexOf(s);r>-1&&P9.splice(r,1)}),[t]),{...t,toast:jn,dismiss:r=>tL({type:"DISMISS_TOAST",toastId:r})}}function Lr(t,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(t==null||t(a),r===!1||!a.defaultPrevented)return s==null?void 0:s(a)}}function $Ae(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function P1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=$Ae(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,c=N.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:c,children:l})};n.displayName=t+"Provider";function a(o){const l=N.useContext(r);if(l)return l;if(s!==void 0)return s;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,a]}function od(t,s=[]){let r=[];function n(o,l){const i=N.createContext(l),c=r.length;r=[...r,l];const u=f=>{var k;const{scope:g,children:v,..._}=f,w=((k=g==null?void 0:g[t])==null?void 0:k[c])||i,j=N.useMemo(()=>_,Object.values(_));return e.jsx(w.Provider,{value:j,children:v})};u.displayName=o+"Provider";function p(f,g){var w;const v=((w=g==null?void 0:g[t])==null?void 0:w[c])||i,_=N.useContext(v);if(_)return _;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>N.createContext(l));return function(i){const c=(i==null?void 0:i[t])||o;return N.useMemo(()=>({[`__scope${t}`]:{...i,[t]:c}}),[i,c])}};return a.scopeName=t,[n,gxt(a,...s)]}function gxt(...t){const s=t[0];if(t.length===1)return s;const r=()=>{const n=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...i,...f}},{});return N.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function mw(t){const s=yxt(t),r=N.forwardRef((n,a)=>{const{children:o,...l}=n,i=N.Children.toArray(o),c=i.find(vxt);if(c){const u=c.props.children,p=i.map(f=>f===c?N.Children.count(u)>1?N.Children.only(null):N.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:N.isValidElement(u)?N.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var j2e=mw("Slot");function yxt(t){const s=N.forwardRef((r,n)=>{const{children:a,...o}=r;if(N.isValidElement(a)){const l=_xt(a),i=bxt(o,a.props);return a.type!==N.Fragment&&(i.ref=n?P1(n,l):l),N.cloneElement(a,i)}return N.Children.count(a)>1?N.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var Y$e=Symbol("radix.slottable");function Q$e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=Y$e,s}function vxt(t){return N.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Y$e}function bxt(t,s){const r={...s};for(const n in s){const a=t[n],o=s[n];/^on[A-Z]/.test(n)?a&&o?r[n]=(...i)=>{const c=o(...i);return a(...i),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...o}:n==="className"&&(r[n]=[a,o].filter(Boolean).join(" "))}return{...t,...r}}function _xt(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function TO(t){const s=t+"CollectionProvider",[r,n]=od(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:j,children:k}=w,S=ht.useRef(null),M=ht.useRef(new Map).current;return e.jsx(a,{scope:j,itemMap:M,collectionRef:S,children:k})};l.displayName=s;const i=t+"CollectionSlot",c=mw(i),u=ht.forwardRef((w,j)=>{const{scope:k,children:S}=w,M=o(i,k),L=Va(j,M.collectionRef);return e.jsx(c,{ref:L,children:S})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",g=mw(p),v=ht.forwardRef((w,j)=>{const{scope:k,children:S,...M}=w,L=ht.useRef(null),P=Va(j,L),O=o(p,k);return ht.useEffect(()=>(O.itemMap.set(L,{ref:L,...M}),()=>void O.itemMap.delete(L))),e.jsx(g,{[f]:"",ref:P,children:S})});v.displayName=p;function _(w){const j=o(t+"CollectionConsumer",w);return ht.useCallback(()=>{const S=j.collectionRef.current;if(!S)return[];const M=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(j.itemMap.values()).sort((O,$)=>M.indexOf(O.ref.current)-M.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:l,Slot:u,ItemSlot:v},_,n]}var wxt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],an=wxt.reduce((t,s)=>{const r=mw(`Primitive.${s}`),n=N.forwardRef((a,o)=>{const{asChild:l,...i}=a,c=l?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...i,ref:o})});return n.displayName=`Primitive.${s}`,{...t,[s]:n}},{});function N2e(t,s){t&&yp.flushSync(()=>t.dispatchEvent(s))}function bd(t){const s=N.useRef(t);return N.useEffect(()=>{s.current=t}),N.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function jxt(t,s=globalThis==null?void 0:globalThis.document){const r=bd(t);N.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var Nxt="DismissableLayer",q0e="dismissableLayer.update",kxt="dismissableLayer.pointerDownOutside",Sxt="dismissableLayer.focusOutside",qAe,X$e=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Aw=N.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=N.useContext(X$e),[p,f]=N.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=N.useState({}),_=Va(s,$=>f($)),w=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(j),S=p?w.indexOf(p):-1,M=u.layersWithOutsidePointerEventsDisabled.size>0,L=S>=k,P=Mxt($=>{const U=$.target,B=[...u.branches].some(V=>V.contains(U));!L||B||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},g),O=Txt($=>{const U=$.target;[...u.branches].some(V=>V.contains(U))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},g);return jxt($=>{S===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},g),N.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(qAe=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),UAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=qAe)}},[p,g,r,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),UAe())},[p,u]),N.useEffect(()=>{const $=()=>v({});return document.addEventListener(q0e,$),()=>document.removeEventListener(q0e,$)},[]),e.jsx(an.div,{...c,ref:_,style:{pointerEvents:M?L?"auto":"none":void 0,...t.style},onFocusCapture:Lr(t.onFocusCapture,O.onFocusCapture),onBlurCapture:Lr(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:Lr(t.onPointerDownCapture,P.onPointerDownCapture)})});Aw.displayName=Nxt;var Cxt="DismissableLayerBranch",J$e=N.forwardRef((t,s)=>{const r=N.useContext(X$e),n=N.useRef(null),a=Va(s,n);return N.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(an.div,{...t,ref:a})});J$e.displayName=Cxt;function Mxt(t,s=globalThis==null?void 0:globalThis.document){const r=bd(t),n=N.useRef(!1),a=N.useRef(()=>{});return N.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){eqe(kxt,r,u,{discrete:!0})};const u={originalEvent:i};i.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{s.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),s.removeEventListener("pointerdown",o),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function Txt(t,s=globalThis==null?void 0:globalThis.document){const r=bd(t),n=N.useRef(!1);return N.useEffect(()=>{const a=o=>{o.target&&!n.current&&eqe(Sxt,r,{originalEvent:o},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function UAe(){const t=new CustomEvent(q0e);document.dispatchEvent(t)}function eqe(t,s,r,{discrete:n}){const a=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?N2e(a,o):a.dispatchEvent(o)}var Axt=Aw,Ext=J$e,jd=globalThis!=null&&globalThis.document?N.useLayoutEffect:()=>{},Pxt="Portal",GA=N.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=N.useState(!1);jd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?w2e.createPortal(e.jsx(an.div,{...n,ref:s}),l):null});GA.displayName=Pxt;function Ixt(t,s){return N.useReducer((r,n)=>s[r][n]??r,t)}var zd=t=>{const{present:s,children:r}=t,n=Lxt(s),a=typeof r=="function"?r({present:n.isPresent}):N.Children.only(r),o=Va(n.ref,Dxt(a));return typeof r=="function"||n.isPresent?N.cloneElement(a,{ref:o}):null};zd.displayName="Presence";function Lxt(t){const[s,r]=N.useState(),n=N.useRef(null),a=N.useRef(t),o=N.useRef("none"),l=t?"mounted":"unmounted",[i,c]=Ixt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return N.useEffect(()=>{const u=K7(n.current);o.current=i==="mounted"?u:"none"},[i]),jd(()=>{const u=n.current,p=a.current;if(p!==t){const g=o.current,v=K7(u);t?c("MOUNT"):v==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),jd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=v=>{const w=K7(n.current).includes(v.animationName);if(v.target===s&&w&&(c("ANIMATION_END"),!a.current)){const j=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=j)})}},g=v=>{v.target===s&&(o.current=K7(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:N.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function K7(t){return(t==null?void 0:t.animationName)||"none"}function Dxt(t){var n,a;let s=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?t.ref:(s=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var Oxt=Ewe[" useInsertionEffect ".trim().toString()]||jd;function oh({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=Rxt({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const p=N.useRef(t!==void 0);N.useEffect(()=>{const f=p.current;f!==i&&console.warn(`${n} is changing from ${f?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const u=N.useCallback(p=>{var f;if(i){const g=Fxt(p)?p(t):p;g!==t&&((f=l.current)==null||f.call(l,g))}else o(p)},[i,t,o,l]);return[c,u]}function Rxt({defaultProp:t,onChange:s}){const[r,n]=N.useState(t),a=N.useRef(r),o=N.useRef(s);return Oxt(()=>{o.current=s},[s]),N.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Fxt(t){return typeof t=="function"}var tqe=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),zxt="VisuallyHidden",Pde=N.forwardRef((t,s)=>e.jsx(an.span,{...t,ref:s,style:{...tqe,...t.style}}));Pde.displayName=zxt;var Bxt=Pde,k2e="ToastProvider",[S2e,$xt,qxt]=TO("Toast"),[sqe]=od("Toast",[qxt]),[Uxt,Ide]=sqe(k2e),rqe=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,c]=N.useState(null),[u,p]=N.useState(0),f=N.useRef(!1),g=N.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${k2e}\`. Expected non-empty \`string\`.`),e.jsx(S2e.Provider,{scope:s,children:e.jsx(Uxt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:N.useCallback(()=>p(v=>v+1),[]),onToastRemove:N.useCallback(()=>p(v=>v-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:g,children:l})})};rqe.displayName=k2e;var nqe="ToastViewport",Vxt=["F8"],U0e="toast.viewportPause",V0e="toast.viewportResume",aqe=N.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=Vxt,label:a="Notifications ({hotkey})",...o}=t,l=Ide(nqe,r),i=$xt(r),c=N.useRef(null),u=N.useRef(null),p=N.useRef(null),f=N.useRef(null),g=Va(s,f,l.onViewportChange),v=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=l.toastCount>0;N.useEffect(()=>{const j=k=>{var M;n.length!==0&&n.every(L=>k[L]||k.code===L)&&((M=f.current)==null||M.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]),N.useEffect(()=>{const j=c.current,k=f.current;if(_&&j&&k){const S=()=>{if(!l.isClosePausedRef.current){const O=new CustomEvent(U0e);k.dispatchEvent(O),l.isClosePausedRef.current=!0}},M=()=>{if(l.isClosePausedRef.current){const O=new CustomEvent(V0e);k.dispatchEvent(O),l.isClosePausedRef.current=!1}},L=O=>{!j.contains(O.relatedTarget)&&M()},P=()=>{j.contains(document.activeElement)||M()};return j.addEventListener("focusin",S),j.addEventListener("focusout",L),j.addEventListener("pointermove",S),j.addEventListener("pointerleave",P),window.addEventListener("blur",S),window.addEventListener("focus",M),()=>{j.removeEventListener("focusin",S),j.removeEventListener("focusout",L),j.removeEventListener("pointermove",S),j.removeEventListener("pointerleave",P),window.removeEventListener("blur",S),window.removeEventListener("focus",M)}}},[_,l.isClosePausedRef]);const w=N.useCallback(({tabbingDirection:j})=>{const S=i().map(M=>{const L=M.ref.current,P=[L,...rgt(L)];return j==="forwards"?P:P.reverse()});return(j==="forwards"?S.reverse():S).flat()},[i]);return N.useEffect(()=>{const j=f.current;if(j){const k=S=>{var P,O,$;const M=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!M){const U=document.activeElement,B=S.shiftKey;if(S.target===j&&B){(P=u.current)==null||P.focus();return}const Y=w({tabbingDirection:B?"backwards":"forwards"}),ee=Y.findIndex(Q=>Q===U);cxe(Y.slice(ee+1))?S.preventDefault():B?(O=u.current)==null||O.focus():($=p.current)==null||$.focus()}};return j.addEventListener("keydown",k),()=>j.removeEventListener("keydown",k)}},[i,w]),e.jsxs(Ext,{ref:c,role:"region","aria-label":a.replace("{hotkey}",v),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&e.jsx(H0e,{ref:u,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"forwards"});cxe(j)}}),e.jsx(S2e.Slot,{scope:r,children:e.jsx(an.ol,{tabIndex:-1,...o,ref:g})}),_&&e.jsx(H0e,{ref:p,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"backwards"});cxe(j)}})]})});aqe.displayName=nqe;var iqe="ToastFocusProxy",H0e=N.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=Ide(iqe,r);return e.jsx(Pde,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:l=>{var u;const i=l.relatedTarget;!((u=o.viewport)!=null&&u.contains(i))&&n()}})});H0e.displayName=iqe;var AO="Toast",Hxt="toast.swipeStart",Gxt="toast.swipeMove",Wxt="toast.swipeCancel",Kxt="toast.swipeEnd",oqe=N.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=oh({prop:n,defaultProp:a??!0,onChange:o,caller:AO});return e.jsx(zd,{present:r||i,children:e.jsx(Qxt,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:bd(t.onPause),onResume:bd(t.onResume),onSwipeStart:Lr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Lr(t.onSwipeMove,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Lr(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Lr(t.onSwipeEnd,u=>{const{x:p,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});oqe.displayName=AO;var[Zxt,Yxt]=sqe(AO,{onClose(){}}),Qxt=N.forwardRef((t,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:c,onResume:u,onSwipeStart:p,onSwipeMove:f,onSwipeCancel:g,onSwipeEnd:v,..._}=t,w=Ide(AO,r),[j,k]=N.useState(null),S=Va(s,Q=>k(Q)),M=N.useRef(null),L=N.useRef(null),P=a||w.duration,O=N.useRef(0),$=N.useRef(P),U=N.useRef(0),{onToastAdd:B,onToastRemove:V}=w,X=bd(()=>{var ce;(j==null?void 0:j.contains(document.activeElement))&&((ce=w.viewport)==null||ce.focus()),l()}),Y=N.useCallback(Q=>{!Q||Q===1/0||(window.clearTimeout(U.current),O.current=new Date().getTime(),U.current=window.setTimeout(X,Q))},[X]);N.useEffect(()=>{const Q=w.viewport;if(Q){const ce=()=>{Y($.current),u==null||u()},ne=()=>{const re=new Date().getTime()-O.current;$.current=$.current-re,window.clearTimeout(U.current),c==null||c()};return Q.addEventListener(U0e,ne),Q.addEventListener(V0e,ce),()=>{Q.removeEventListener(U0e,ne),Q.removeEventListener(V0e,ce)}}},[w.viewport,P,c,u,Y]),N.useEffect(()=>{o&&!w.isClosePausedRef.current&&Y(P)},[o,P,w.isClosePausedRef,Y]),N.useEffect(()=>(B(),()=>V()),[B,V]);const ee=N.useMemo(()=>j?pqe(j):null,[j]);return w.viewport?e.jsxs(e.Fragment,{children:[ee&&e.jsx(Xxt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ee}),e.jsx(Zxt,{scope:r,onClose:X,children:yp.createPortal(e.jsx(S2e.ItemSlot,{scope:r,children:e.jsx(Axt,{asChild:!0,onEscapeKeyDown:Lr(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||X(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(an.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,..._,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Lr(t.onKeyDown,Q=>{Q.key==="Escape"&&(i==null||i(Q.nativeEvent),Q.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,X()))}),onPointerDown:Lr(t.onPointerDown,Q=>{Q.button===0&&(M.current={x:Q.clientX,y:Q.clientY})}),onPointerMove:Lr(t.onPointerMove,Q=>{if(!M.current)return;const ce=Q.clientX-M.current.x,ne=Q.clientY-M.current.y,re=!!L.current,oe=["left","right"].includes(w.swipeDirection),fe=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,ge=oe?fe(0,ce):0,ue=oe?0:fe(0,ne),xe=Q.pointerType==="touch"?10:2,_e={x:ge,y:ue},$e={originalEvent:Q,delta:_e};re?(L.current=_e,Z7(Gxt,f,$e,{discrete:!1})):VAe(_e,w.swipeDirection,xe)?(L.current=_e,Z7(Hxt,p,$e,{discrete:!1}),Q.target.setPointerCapture(Q.pointerId)):(Math.abs(ce)>xe||Math.abs(ne)>xe)&&(M.current=null)}),onPointerUp:Lr(t.onPointerUp,Q=>{const ce=L.current,ne=Q.target;if(ne.hasPointerCapture(Q.pointerId)&&ne.releasePointerCapture(Q.pointerId),L.current=null,M.current=null,ce){const re=Q.currentTarget,oe={originalEvent:Q,delta:ce};VAe(ce,w.swipeDirection,w.swipeThreshold)?Z7(Kxt,v,oe,{discrete:!0}):Z7(Wxt,g,oe,{discrete:!0}),re.addEventListener("click",fe=>fe.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),Xxt=t=>{const{__scopeToast:s,children:r,...n}=t,a=Ide(AO,s),[o,l]=N.useState(!1),[i,c]=N.useState(!1);return tgt(()=>l(!0)),N.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(GA,{asChild:!0,children:e.jsx(Pde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Jxt="ToastTitle",lqe=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(an.div,{...n,ref:s})});lqe.displayName=Jxt;var egt="ToastDescription",cqe=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(an.div,{...n,ref:s})});cqe.displayName=egt;var dqe="ToastAction",uqe=N.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(mqe,{altText:r,asChild:!0,children:e.jsx(C2e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${dqe}\`. Expected non-empty \`string\`.`),null)});uqe.displayName=dqe;var hqe="ToastClose",C2e=N.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Yxt(hqe,r);return e.jsx(mqe,{asChild:!0,children:e.jsx(an.button,{type:"button",...n,ref:s,onClick:Lr(t.onClick,a.onClose)})})});C2e.displayName=hqe;var mqe=N.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(an.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function pqe(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),sgt(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!a)if(o){const l=n.dataset.radixToastAnnounceAlt;l&&s.push(l)}else s.push(...pqe(n))}}),s}function Z7(t,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(t,s,{once:!0}),n?N2e(a,o):a.dispatchEvent(o)}var VAe=(t,s,r=0)=>{const n=Math.abs(t.x),a=Math.abs(t.y),o=n>a;return s==="left"||s==="right"?o&&n>r:!o&&a>r};function tgt(t=()=>{}){const s=bd(t);jd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function sgt(t){return t.nodeType===t.ELEMENT_NODE}function rgt(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function cxe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var ngt=rqe,fqe=aqe,xqe=oqe,gqe=lqe,yqe=cqe,vqe=uqe,bqe=C2e;function _qe(t){var s,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;stypeof t=="boolean"?`${t}`:t===0?"0":t,GAe=Vi,b3=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return GAe(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=s,l=Object.keys(a).map(u=>{const p=r==null?void 0:r[u],f=o==null?void 0:o[u];if(p===null)return null;const g=HAe(p)||HAe(f);return a[u][g]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,g]=p;return g===void 0||(u[f]=g),u},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:g,...v}=p;return Object.entries(v).every(_=>{let[w,j]=_;return Array.isArray(j)?j.includes({...o,...i}[w]):{...o,...i}[w]===j})?[...u,f,g]:u},[]);return GAe(t,l,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const agt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wqe=(...t)=>t.filter((s,r,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var igt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jqe=N.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},c)=>N.createElement("svg",{ref:c,...igt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:wqe("lucide",a),...i},[...l.map(([u,p])=>N.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=N.forwardRef(({className:n,...a},o)=>N.createElement(jqe,{ref:o,iconNode:s,className:wqe(`lucide-${agt(t)}`,n),...a}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L9=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D9=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O9=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R9=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ch=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F9=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z9=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X2=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J2=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B9=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $9=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q9=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U9=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V9=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H9=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q4=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X4=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J4=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sL=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rL=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IM=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nL=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kh=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qa=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a1=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sa=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _d=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aL=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Su=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iL=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const su=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eS=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mh=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i1=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lm=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tS=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Th=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oL=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sx=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LM=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lL=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const th=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ca=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sS=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ah=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cL=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dL=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uL=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Od=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hL=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V_=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ff=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DM=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yo=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mL=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ba=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oo=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xo=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oa=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xf=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cx=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cl=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gi=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sa=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bv=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pp=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jc=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wd=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OM=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H_=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const un=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jv=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rS=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nS=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pL=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o1=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aS=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yi=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mx=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dm=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fL=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hl=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l1=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vi=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jg=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RM=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fx=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xx=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xL=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const en=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kp=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dn=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cu=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hN=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G_=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pN=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c1=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gL=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wn=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FM=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ey=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d1=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sh=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W_=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yL=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kg=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fN=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Om=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xN=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iS=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const So=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gN=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ru=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zh=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yN=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vN=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ix=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mu=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bN=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vL=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bL=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _L=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K_=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zM=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BM=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wL=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ya=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $M=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dn=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _N=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wN=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u1=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vl=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jN=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NN=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jL=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tu=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oS=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f0=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lS=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sp=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kN=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qM=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cS=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cp=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dS=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UM=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VM=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z_=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ml=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bo=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mp=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x0=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rh=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bs=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SN=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CN=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eh=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uS=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hS=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NL=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kL=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lr=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ia=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g0=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mS=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h1=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ph=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pS=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HM=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SL=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qc=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CL=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GM=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ML=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const so=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MN=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TL=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y0=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fS=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xS=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AL=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tx=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nh=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TN=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m1=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $v=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AN=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EN=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Al=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PN=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bl=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IN=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LN=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DN=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ON=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RN=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FN=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zN=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qv=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gS=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nu=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rm=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uv=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y_=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s0=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const za=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yS=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mn=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EL=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q_=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const il=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BN=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PL=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qs=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IL=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ty=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LL=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p1=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f1=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x1=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $N=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vS=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WM=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wo=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DL=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OL=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v0=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qN=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g1=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RL=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UN=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VN=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ax=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uc=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HN=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FL=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zL=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sn=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GN=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $n=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BL=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qo=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nd=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $L=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qL=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WN=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Au=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b0=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vp=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bS=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zse=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yse=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qse=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xse=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y1=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KN=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _0=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o0=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lre=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dre=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fn=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mre=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yre=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZN=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YN=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QN=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XN=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JN=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ek=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tk=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sk=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rk=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gy=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vv=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hk=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mk=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vre=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xk=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yk=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vk=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bk=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _k=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wk=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jk=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nk=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kk=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sk=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ck=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mk=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tk=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ak=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const md=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ek=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pk=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ik=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lk=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dk=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ok=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _re=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rk=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fk=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zk=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bk=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $k=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qk=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uk=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vk=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hk=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w0=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kre=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pre=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KM=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UL=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fre=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zre=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v1=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZM=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qre=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ene=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tne=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YM=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sne=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rne=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nne=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fm=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ane=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ine=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const one=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lne=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cne=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dne=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const une=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zm=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hne=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mne=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pne=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fne=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gk=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xne=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gne=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yne=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vne=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bne=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ne=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wk=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wne=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jne=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nne=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kne=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VL=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HL=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nh=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cne=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ene=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GL=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const One=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rne=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fne=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bne=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qne=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kne=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yne=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kk=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nr=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qne=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zk=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j0=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eae=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _S=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tae=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jo=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yu=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sae=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rae=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vo=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QM=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nae=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aae=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yk=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iae=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oae=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lae=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cae=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dae=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uae=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hae=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WL=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mae=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pae=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wS=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fae=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xae=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gae=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qk=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yae=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jS=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vae=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const di=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bae=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X_=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KL=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZL=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ae=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const El=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xk=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jk=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e4=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wae=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t4=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jae=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s4=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r4=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nae=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kae=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wi=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n4=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a4=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i4=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sae=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XM=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cae=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mae=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tae=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aae=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eae=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pae=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cn=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iae=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lae=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dae=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oae=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rae=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fae=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zae=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bae=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ae=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qae=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uae=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o4=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YL=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vae=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hv=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hae=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gae=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wae=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kae=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QL=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zae=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yae=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qae=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xae=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jae=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eie=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tie=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sie=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rie=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nie=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aie=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iie=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oie=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lie=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cie=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const die=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uie=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hie=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mie=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pie=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sy=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mr=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fie=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xie=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yh=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J_=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JM=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ogt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:L9,AArrowUp:D9,ALargeSmall:O9,Accessibility:R9,Activity:Ch,AirVent:F9,Airplay:z9,AlarmClock:$9,AlarmClockCheck:X2,AlarmClockMinus:J2,AlarmClockOff:B9,AlarmClockPlus:ej,AlarmSmoke:q9,Album:U9,AlignCenter:Q4,AlignCenterHorizontal:V9,AlignCenterVertical:H9,AlignEndHorizontal:G9,AlignEndVertical:W9,AlignHorizontalDistributeCenter:K9,AlignHorizontalDistributeEnd:Z9,AlignHorizontalDistributeStart:Y9,AlignHorizontalJustifyCenter:Q9,AlignHorizontalJustifyEnd:X9,AlignHorizontalJustifyStart:J9,AlignHorizontalSpaceAround:eB,AlignHorizontalSpaceBetween:tB,AlignJustify:sB,AlignLeft:X4,AlignRight:J4,AlignStartHorizontal:rB,AlignStartVertical:nB,AlignVerticalDistributeCenter:aB,AlignVerticalDistributeEnd:iB,AlignVerticalDistributeStart:oB,AlignVerticalJustifyCenter:lB,AlignVerticalJustifyEnd:cB,AlignVerticalJustifyStart:dB,AlignVerticalSpaceAround:uB,AlignVerticalSpaceBetween:hB,Ambulance:mB,Ampersand:pB,Ampersands:fB,Amphora:xB,Anchor:gB,Angry:yB,Annoyed:vB,Antenna:bB,Anvil:_B,Aperture:wB,AppWindow:sL,AppWindowMac:jB,Apple:NB,Archive:IM,ArchiveRestore:rL,ArchiveX:kB,Armchair:SB,ArrowBigDown:MB,ArrowBigDownDash:CB,ArrowBigLeft:AB,ArrowBigLeftDash:TB,ArrowBigRight:PB,ArrowBigRightDash:EB,ArrowBigUp:LB,ArrowBigUpDash:IB,ArrowDown:Kh,ArrowDown01:DB,ArrowDown10:OB,ArrowDownAZ:tj,ArrowDownFromLine:RB,ArrowDownLeft:FB,ArrowDownNarrowWide:zB,ArrowDownRight:nL,ArrowDownToDot:BB,ArrowDownToLine:$B,ArrowDownUp:qB,ArrowDownWideNarrow:sj,ArrowDownZA:rj,ArrowLeft:Qa,ArrowLeftFromLine:UB,ArrowLeftRight:VB,ArrowLeftToLine:HB,ArrowRight:Sa,ArrowRightFromLine:GB,ArrowRightLeft:a1,ArrowRightToLine:WB,ArrowUp:Su,ArrowUp01:KB,ArrowUp10:ZB,ArrowUpAZ:nj,ArrowUpDown:_d,ArrowUpFromDot:YB,ArrowUpFromLine:QB,ArrowUpLeft:XB,ArrowUpNarrowWide:aj,ArrowUpRight:aL,ArrowUpToLine:JB,ArrowUpWideNarrow:e$,ArrowUpZA:ij,ArrowsUpFromLine:t$,Asterisk:s$,AtSign:r$,Atom:n$,AudioLines:a$,AudioWaveform:i$,Award:tc,Axe:o$,Axis3d:oj,Baby:l$,Backpack:c$,Badge:k$,BadgeAlert:d$,BadgeCent:u$,BadgeCheck:lj,BadgeDollarSign:h$,BadgeEuro:m$,BadgeHelp:p$,BadgeIndianRupee:f$,BadgeInfo:x$,BadgeJapaneseYen:g$,BadgeMinus:y$,BadgePercent:v$,BadgePlus:b$,BadgePoundSterling:_$,BadgeRussianRuble:w$,BadgeSwissFranc:j$,BadgeX:N$,BaggageClaim:S$,Ban:iL,Banana:C$,Bandage:M$,Banknote:T$,Barcode:A$,Baseline:E$,Bath:su,Battery:R$,BatteryCharging:P$,BatteryFull:I$,BatteryLow:L$,BatteryMedium:D$,BatteryWarning:O$,Beaker:F$,Bean:B$,BeanOff:z$,Bed:Mh,BedDouble:eS,BedSingle:$$,Beef:q$,Beer:V$,BeerOff:U$,Bell:Lm,BellDot:H$,BellElectric:G$,BellMinus:W$,BellOff:i1,BellPlus:K$,BellRing:Z$,BetweenHorizontalEnd:cj,BetweenHorizontalStart:dj,BetweenVerticalEnd:Y$,BetweenVerticalStart:Q$,BicepsFlexed:X$,Bike:J$,Binary:eq,Binoculars:tq,Biohazard:sq,Bird:rq,Bitcoin:nq,Blend:aq,Blinds:iq,Blocks:oq,Bluetooth:uq,BluetoothConnected:lq,BluetoothOff:cq,BluetoothSearching:dq,Bold:tS,Bolt:hq,Bomb:mq,Bone:pq,Book:Oq,BookA:fq,BookAudio:xq,BookCheck:gq,BookCopy:yq,BookDashed:uj,BookDown:vq,BookHeadphones:bq,BookHeart:_q,BookImage:wq,BookKey:jq,BookLock:Nq,BookMarked:kq,BookMinus:Sq,BookOpen:Th,BookOpenCheck:Cq,BookOpenText:Mq,BookPlus:Tq,BookText:Aq,BookType:Eq,BookUp:Iq,BookUp2:Pq,BookUser:Lq,BookX:Dq,Bookmark:Sx,BookmarkCheck:Rq,BookmarkMinus:Fq,BookmarkPlus:oL,BookmarkX:zq,BoomBox:Bq,Bot:LM,BotMessageSquare:$q,BotOff:qq,Box:Uq,Boxes:Vq,Braces:hj,Brackets:Hq,Brain:lL,BrainCircuit:Gq,BrainCog:Wq,BrickWall:Kq,Briefcase:th,BriefcaseBusiness:Zq,BriefcaseConveyorBelt:Yq,BriefcaseMedical:Qq,BringToFront:Xq,Brush:Jq,Bug:sU,BugOff:eU,BugPlay:tU,Building:sS,Building2:Ca,Bus:nU,BusFront:rU,Cable:iU,CableCar:aU,Cake:Ah,CakeSlice:oU,Calculator:cL,Calendar:hn,Calendar1:lU,CalendarArrowDown:cU,CalendarArrowUp:dU,CalendarCheck:dL,CalendarCheck2:uU,CalendarClock:uL,CalendarCog:hU,CalendarDays:Od,CalendarFold:mU,CalendarHeart:pU,CalendarMinus:xU,CalendarMinus2:fU,CalendarOff:hL,CalendarPlus:V_,CalendarPlus2:gU,CalendarRange:yU,CalendarSearch:vU,CalendarSync:bU,CalendarX:wU,CalendarX2:_U,Camera:ff,CameraOff:jU,Candy:SU,CandyCane:NU,CandyOff:kU,Cannabis:CU,Captions:mj,CaptionsOff:MU,Car:DM,CarFront:TU,CarTaxiFront:AU,Caravan:EU,Carrot:PU,CaseLower:IU,CaseSensitive:LU,CaseUpper:DU,CassetteTape:OU,Cast:RU,Castle:FU,Cat:zU,Cctv:BU,ChartArea:pj,ChartBar:xj,ChartBarBig:fj,ChartBarDecreasing:$U,ChartBarIncreasing:qU,ChartBarStacked:UU,ChartCandlestick:gj,ChartColumn:yo,ChartColumnBig:yj,ChartColumnDecreasing:VU,ChartColumnIncreasing:vj,ChartColumnStacked:HU,ChartGantt:GU,ChartLine:bj,ChartNetwork:WU,ChartNoAxesColumn:wj,ChartNoAxesColumnDecreasing:KU,ChartNoAxesColumnIncreasing:_j,ChartNoAxesCombined:ZU,ChartNoAxesGantt:jj,ChartPie:Nj,ChartScatter:kj,ChartSpline:YU,Check:ba,CheckCheck:mL,ChefHat:QU,Cherry:XU,ChevronDown:oo,ChevronFirst:JU,ChevronLast:eV,ChevronLeft:Xo,ChevronRight:oa,ChevronUp:xf,ChevronsDown:sV,ChevronsDownUp:tV,ChevronsLeft:aV,ChevronsLeftRight:nV,ChevronsLeftRightEllipsis:rV,ChevronsRight:oV,ChevronsRightLeft:iV,ChevronsUp:lV,ChevronsUpDown:Cx,Chrome:cV,Church:dV,Cigarette:hV,CigaretteOff:uV,Circle:wd,CircleAlert:Cl,CircleArrowDown:Sj,CircleArrowLeft:Cj,CircleArrowOutDownLeft:Mj,CircleArrowOutDownRight:Tj,CircleArrowOutUpLeft:Aj,CircleArrowOutUpRight:Ej,CircleArrowRight:Pj,CircleArrowUp:Ij,CircleCheck:sa,CircleCheckBig:gi,CircleChevronDown:Lj,CircleChevronLeft:Dj,CircleChevronRight:Oj,CircleChevronUp:Rj,CircleDashed:mV,CircleDivide:Fj,CircleDollarSign:pV,CircleDot:xV,CircleDotDashed:fV,CircleEllipsis:gV,CircleEqual:yV,CircleFadingArrowUp:vV,CircleFadingPlus:bV,CircleGauge:zj,CircleHelp:Bv,CircleMinus:Bj,CircleOff:_V,CircleParking:qj,CircleParkingOff:$j,CirclePause:Uj,CirclePercent:Vj,CirclePlay:pp,CirclePlus:Hj,CirclePower:Gj,CircleSlash:wV,CircleSlash2:Wj,CircleStop:Kj,CircleUser:Yj,CircleUserRound:Zj,CircleX:jc,CircuitBoard:jV,Citrus:NV,Clapperboard:kV,Clipboard:PV,ClipboardCheck:OM,ClipboardCopy:SV,ClipboardList:H_,ClipboardMinus:CV,ClipboardPaste:MV,ClipboardPen:Xj,ClipboardPenLine:Qj,ClipboardPlus:TV,ClipboardType:AV,ClipboardX:EV,Clock:un,Clock1:IV,Clock10:LV,Clock11:DV,Clock12:OV,Clock2:RV,Clock3:FV,Clock4:zV,Clock5:BV,Clock6:$V,Clock7:qV,Clock8:UV,Clock9:VV,ClockAlert:HV,ClockArrowDown:GV,ClockArrowUp:WV,Cloud:lH,CloudAlert:KV,CloudCog:ZV,CloudDownload:Jj,CloudDrizzle:YV,CloudFog:QV,CloudHail:XV,CloudLightning:JV,CloudMoon:tH,CloudMoonRain:eH,CloudOff:sH,CloudRain:nH,CloudRainWind:rH,CloudSnow:aH,CloudSun:oH,CloudSunRain:iH,CloudUpload:eN,Cloudy:cH,Clover:Jv,Club:dH,Code:rS,CodeXml:tN,Codepen:uH,Codesandbox:hH,Coffee:nS,Cog:mH,Coins:pL,Columns2:sN,Columns3:rN,Columns4:pH,Combine:fH,Command:xH,Compass:o1,Component:gH,Computer:yH,ConciergeBell:vH,Cone:bH,Construction:_H,Contact:aS,ContactRound:nN,Container:wH,Contrast:jH,Cookie:NH,CookingPot:kH,Copy:yi,CopyCheck:SH,CopyMinus:CH,CopyPlus:MH,CopySlash:TH,CopyX:AH,Copyleft:EH,Copyright:PH,CornerDownLeft:IH,CornerDownRight:LH,CornerLeftDown:DH,CornerLeftUp:OH,CornerRightDown:RH,CornerRightUp:FH,CornerUpLeft:zH,CornerUpRight:BH,Cpu:$H,CreativeCommons:qH,CreditCard:Mx,Croissant:UH,Crop:VH,Cross:HH,Crosshair:GH,Crown:Dm,Cuboid:WH,CupSoda:KH,Currency:ZH,Cylinder:YH,Dam:QH,Database:fL,DatabaseBackup:XH,DatabaseZap:JH,Delete:eG,Dessert:tG,Diameter:sG,Diamond:aG,DiamondMinus:rG,DiamondPercent:aN,DiamondPlus:nG,Dice1:iG,Dice2:oG,Dice3:lG,Dice4:cG,Dice5:dG,Dice6:uG,Dices:hG,Diff:mG,Disc:gG,Disc2:pG,Disc3:fG,DiscAlbum:xG,Divide:yG,Dna:bG,DnaOff:vG,Dock:_G,Dog:wG,DollarSign:hl,Donut:jG,DoorClosed:NG,DoorOpen:l1,Dot:kG,Download:vi,DraftingCompass:SG,Drama:CG,Dribbble:MG,Drill:TG,Droplet:AG,Droplets:Jg,Drum:EG,Drumstick:PG,Dumbbell:IG,Ear:DG,EarOff:LG,Earth:iN,EarthLock:OG,Eclipse:RG,Egg:RM,EggFried:FG,EggOff:zG,Ellipsis:xx,EllipsisVertical:fx,Equal:qG,EqualApproximately:BG,EqualNot:$G,Eraser:UG,EthernetPort:VG,Euro:HG,Expand:xL,ExternalLink:en,Eye:Dn,EyeClosed:GG,EyeOff:kp,Facebook:Cu,Factory:WG,Fan:KG,FastForward:ZG,Feather:YG,Fence:QG,FerrisWheel:XG,Figma:JG,File:FM,FileArchive:eW,FileAudio:sW,FileAudio2:tW,FileAxis3d:oN,FileBadge:nW,FileBadge2:rW,FileBox:aW,FileChartColumn:cN,FileChartColumnIncreasing:lN,FileChartLine:dN,FileChartPie:uN,FileCheck:oW,FileCheck2:iW,FileClock:lW,FileCode:dW,FileCode2:cW,FileCog:hN,FileDiff:uW,FileDigit:hW,FileDown:mW,FileHeart:pW,FileImage:G_,FileInput:fW,FileJson:gW,FileJson2:xW,FileKey:vW,FileKey2:yW,FileLock:_W,FileLock2:bW,FileMinus:jW,FileMinus2:wW,FileMusic:NW,FileOutput:kW,FilePen:pN,FilePenLine:mN,FilePlus:CW,FilePlus2:SW,FileQuestion:MW,FileScan:TW,FileSearch:EW,FileSearch2:AW,FileSliders:PW,FileSpreadsheet:c1,FileStack:gL,FileSymlink:IW,FileTerminal:LW,FileText:wn,FileType:OW,FileType2:DW,FileUp:RW,FileUser:FW,FileVideo:BW,FileVideo2:zW,FileVolume:qW,FileVolume2:$W,FileWarning:UW,FileX:HW,FileX2:VW,Files:GW,Film:yu,Filter:ey,FilterX:WW,Fingerprint:KW,FireExtinguisher:ZW,Fish:XW,FishOff:YW,FishSymbol:QW,Flag:d1,FlagOff:JW,FlagTriangleLeft:eK,FlagTriangleRight:tK,Flame:sh,FlameKindling:sK,Flashlight:nK,FlashlightOff:rK,FlaskConical:W_,FlaskConicalOff:aK,FlaskRound:iK,FlipHorizontal:yL,FlipHorizontal2:oK,FlipVertical:cK,FlipVertical2:lK,Flower:dK,Flower2:Kg,Focus:uK,FoldHorizontal:hK,FoldVertical:mK,Folder:BK,FolderArchive:pK,FolderCheck:fK,FolderClock:xK,FolderClosed:gK,FolderCode:yK,FolderCog:fN,FolderDot:vK,FolderDown:bK,FolderGit:wK,FolderGit2:_K,FolderHeart:jK,FolderInput:NK,FolderKanban:kK,FolderKey:SK,FolderLock:CK,FolderMinus:MK,FolderOpen:Om,FolderOpenDot:TK,FolderOutput:AK,FolderPen:xN,FolderPlus:EK,FolderRoot:PK,FolderSearch:LK,FolderSearch2:IK,FolderSymlink:DK,FolderSync:OK,FolderTree:RK,FolderUp:FK,FolderX:zK,Folders:$K,Footprints:qK,Forklift:UK,Forward:VK,Frame:HK,Framer:GK,Frown:WK,Fuel:KK,Fullscreen:ZK,GalleryHorizontal:QK,GalleryHorizontalEnd:YK,GalleryThumbnails:XK,GalleryVertical:eZ,GalleryVerticalEnd:JK,Gamepad:sZ,Gamepad2:tZ,Gauge:rZ,Gavel:nZ,Gem:aZ,Ghost:iS,Gift:So,GitBranch:oZ,GitBranchPlus:iZ,GitCommitHorizontal:gN,GitCommitVertical:lZ,GitCompare:dZ,GitCompareArrows:cZ,GitFork:uZ,GitGraph:hZ,GitMerge:mZ,GitPullRequest:vZ,GitPullRequestArrow:pZ,GitPullRequestClosed:fZ,GitPullRequestCreate:gZ,GitPullRequestCreateArrow:xZ,GitPullRequestDraft:yZ,Github:bZ,Gitlab:_Z,GlassWater:wZ,Glasses:jZ,Globe:ru,GlobeLock:NZ,Goal:kZ,Grab:SZ,GraduationCap:Zh,Grape:CZ,Grid2x2:vN,Grid2x2Check:MZ,Grid2x2Plus:yN,Grid2x2X:TZ,Grid3x3:ix,Grip:EZ,GripHorizontal:AZ,GripVertical:Mu,Group:PZ,Guitar:IZ,Ham:LZ,Hammer:DZ,Hand:vL,HandCoins:OZ,HandHeart:RZ,HandHelping:bN,HandMetal:FZ,HandPlatter:zZ,Handshake:bL,HardDrive:_L,HardDriveDownload:BZ,HardDriveUpload:$Z,HardHat:qZ,Hash:K_,Haze:UZ,HdmiPort:VZ,Heading:KZ,Heading1:zM,Heading2:BM,Heading3:wL,Heading4:HZ,Heading5:GZ,Heading6:WZ,HeadphoneOff:ZZ,Headphones:YZ,Headset:QZ,Heart:Ya,HeartCrack:XZ,HeartHandshake:JZ,HeartOff:eY,HeartPulse:tY,Heater:sY,Hexagon:rY,Highlighter:nY,History:$M,Hop:iY,HopOff:aY,Hospital:oY,Hotel:lY,Hourglass:cY,House:dn,HousePlug:dY,HousePlus:uY,IceCreamBowl:_N,IceCreamCone:wN,IdCard:hY,Image:vl,ImageDown:mY,ImageMinus:pY,ImageOff:fY,ImagePlay:xY,ImagePlus:u1,ImageUp:gY,ImageUpscale:yY,Images:vY,Import:bY,Inbox:_Y,IndentDecrease:jN,IndentIncrease:NN,IndianRupee:wY,Infinity:jY,Info:jL,InspectionPanel:NY,Instagram:Tu,Italic:oS,IterationCcw:kY,IterationCw:SY,JapaneseYen:CY,Joystick:MY,Kanban:f0,Key:Sp,KeyRound:lS,KeySquare:TY,Keyboard:PY,KeyboardMusic:AY,KeyboardOff:EY,Lamp:FY,LampCeiling:IY,LampDesk:LY,LampFloor:DY,LampWallDown:OY,LampWallUp:RY,LandPlot:zY,Landmark:BY,Languages:$Y,Laptop:UY,LaptopMinimal:kN,LaptopMinimalCheck:qY,Lasso:HY,LassoSelect:VY,Laugh:GY,Layers:qM,Layers2:WY,Layers3:KY,LayoutDashboard:cS,LayoutGrid:Cp,LayoutList:ZY,LayoutPanelLeft:YY,LayoutPanelTop:QY,LayoutTemplate:dS,Leaf:XY,LeafyGreen:JY,Lectern:eQ,LetterText:tQ,Library:UM,LibraryBig:sQ,LifeBuoy:VM,Ligature:rQ,Lightbulb:Z_,LightbulbOff:nQ,Link:Bo,Link2:ml,Link2Off:aQ,Linkedin:Mp,List:rh,ListCheck:iQ,ListChecks:oQ,ListCollapse:lQ,ListEnd:cQ,ListFilter:dQ,ListMinus:uQ,ListMusic:hQ,ListOrdered:x0,ListPlus:mQ,ListRestart:pQ,ListStart:fQ,ListTodo:xQ,ListTree:gQ,ListVideo:yQ,ListX:vQ,Loader:_Q,LoaderCircle:bs,LoaderPinwheel:bQ,Locate:NQ,LocateFixed:wQ,LocateOff:jQ,Lock:Eh,LockKeyhole:kQ,LockKeyholeOpen:SN,LockOpen:CN,LogIn:uS,LogOut:hS,Logs:SQ,Lollipop:CQ,Luggage:MQ,Magnet:TQ,Mail:lr,MailCheck:AQ,MailMinus:EQ,MailOpen:PQ,MailPlus:NL,MailQuestion:IQ,MailSearch:LQ,MailWarning:DQ,MailX:kL,Mailbox:OQ,Mails:RQ,Map:g0,MapPin:ia,MapPinCheck:zQ,MapPinCheckInside:FQ,MapPinHouse:BQ,MapPinMinus:qQ,MapPinMinusInside:$Q,MapPinOff:UQ,MapPinPlus:HQ,MapPinPlusInside:VQ,MapPinX:WQ,MapPinXInside:GQ,MapPinned:KQ,Martini:ZQ,Maximize:mS,Maximize2:YQ,Medal:h1,Megaphone:Ph,MegaphoneOff:QQ,Meh:XQ,MemoryStick:JQ,Menu:pS,Merge:eX,MessageCircle:qc,MessageCircleCode:tX,MessageCircleDashed:sX,MessageCircleHeart:HM,MessageCircleMore:rX,MessageCircleOff:nX,MessageCirclePlus:aX,MessageCircleQuestion:SL,MessageCircleReply:iX,MessageCircleWarning:oX,MessageCircleX:lX,MessageSquare:so,MessageSquareCode:cX,MessageSquareDashed:dX,MessageSquareDiff:uX,MessageSquareDot:hX,MessageSquareHeart:mX,MessageSquareLock:pX,MessageSquareMore:CL,MessageSquareOff:fX,MessageSquarePlus:GM,MessageSquareQuote:ML,MessageSquareReply:xX,MessageSquareShare:gX,MessageSquareText:yX,MessageSquareWarning:vX,MessageSquareX:bX,MessagesSquare:_X,Mic:TL,MicOff:wX,MicVocal:MN,Microchip:jX,Microscope:NX,Microwave:kX,Milestone:SX,Milk:MX,MilkOff:CX,Minimize:AX,Minimize2:TX,Minus:y0,Monitor:xS,MonitorCheck:EX,MonitorCog:PX,MonitorDot:IX,MonitorDown:LX,MonitorOff:DX,MonitorPause:OX,MonitorPlay:RX,MonitorSmartphone:FX,MonitorSpeaker:zX,MonitorStop:BX,MonitorUp:fS,MonitorX:$X,Moon:UX,MoonStar:qX,Mountain:AL,MountainSnow:VX,Mouse:KX,MouseOff:HX,MousePointer:Nh,MousePointer2:GX,MousePointerBan:WX,MousePointerClick:Tx,Move:oJ,Move3d:TN,MoveDiagonal:YX,MoveDiagonal2:ZX,MoveDown:JX,MoveDownLeft:QX,MoveDownRight:XX,MoveHorizontal:eJ,MoveLeft:tJ,MoveRight:sJ,MoveUp:aJ,MoveUpLeft:rJ,MoveUpRight:nJ,MoveVertical:iJ,Music:uJ,Music2:lJ,Music3:cJ,Music4:dJ,Navigation:fJ,Navigation2:mJ,Navigation2Off:hJ,NavigationOff:pJ,Network:xJ,Newspaper:m1,Nfc:gJ,Notebook:_J,NotebookPen:yJ,NotebookTabs:vJ,NotebookText:bJ,NotepadText:jJ,NotepadTextDashed:wJ,Nut:kJ,NutOff:NJ,Octagon:CJ,OctagonAlert:$v,OctagonMinus:SJ,OctagonPause:AN,OctagonX:EN,Omega:MJ,Option:TJ,Orbit:AJ,Origami:EJ,Package:Al,Package2:PJ,PackageCheck:IJ,PackageMinus:LJ,PackageOpen:DJ,PackagePlus:OJ,PackageSearch:RJ,PackageX:FJ,PaintBucket:zJ,PaintRoller:BJ,Paintbrush:$J,PaintbrushVertical:PN,Palette:Bl,PanelBottom:VJ,PanelBottomClose:qJ,PanelBottomDashed:IN,PanelBottomOpen:UJ,PanelLeft:RN,PanelLeftClose:LN,PanelLeftDashed:DN,PanelLeftOpen:ON,PanelRight:WJ,PanelRightClose:HJ,PanelRightDashed:FN,PanelRightOpen:GJ,PanelTop:YJ,PanelTopClose:KJ,PanelTopDashed:zN,PanelTopOpen:ZJ,PanelsLeftBottom:QJ,PanelsRightBottom:XJ,PanelsTopLeft:qv,Paperclip:gS,Parentheses:JJ,ParkingMeter:eee,PartyPopper:nu,Pause:Rm,PawPrint:tee,PcCase:see,Pen:s0,PenLine:Uv,PenOff:ree,PenTool:Y_,Pencil:za,PencilLine:nee,PencilOff:aee,PencilRuler:iee,Pentagon:oee,Percent:yS,PersonStanding:lee,PhilippinePeso:cee,Phone:Mn,PhoneCall:dee,PhoneForwarded:uee,PhoneIncoming:hee,PhoneMissed:mee,PhoneOff:pee,PhoneOutgoing:fee,Pi:xee,Piano:gee,Pickaxe:yee,PictureInPicture:bee,PictureInPicture2:vee,PiggyBank:_ee,Pilcrow:Nee,PilcrowLeft:wee,PilcrowRight:jee,Pill:See,PillBottle:kee,Pin:Q_,PinOff:EL,Pipette:Cee,Pizza:Mee,Plane:Eee,PlaneLanding:Tee,PlaneTakeoff:Aee,Play:il,Plug:PL,Plug2:Pee,PlugZap:BN,Plus:qs,Pocket:Lee,PocketKnife:Iee,Podcast:Dee,Pointer:Ree,PointerOff:Oee,Popcorn:Fee,Popsicle:zee,PoundSterling:Bee,Power:IL,PowerOff:$ee,Presentation:ty,Printer:LL,PrinterCheck:qee,Projector:Uee,Proportions:Vee,Puzzle:Hee,Pyramid:Gee,QrCode:p1,Quote:f1,Rabbit:Wee,Radar:Kee,Radiation:Zee,Radical:Yee,Radio:x1,RadioReceiver:Qee,RadioTower:Xee,Radius:Jee,RailSymbol:ete,Rainbow:tte,Rat:ste,Ratio:rte,Receipt:hte,ReceiptCent:nte,ReceiptEuro:ate,ReceiptIndianRupee:ite,ReceiptJapaneseYen:ote,ReceiptPoundSterling:lte,ReceiptRussianRuble:cte,ReceiptSwissFranc:dte,ReceiptText:ute,RectangleEllipsis:$N,RectangleHorizontal:mte,RectangleVertical:pte,Recycle:fte,Redo:vS,Redo2:xte,RedoDot:gte,RefreshCcw:WM,RefreshCcwDot:yte,RefreshCw:Wo,RefreshCwOff:vte,Refrigerator:bte,Regex:_te,RemoveFormatting:wte,Repeat:DL,Repeat1:jte,Repeat2:Nte,Replace:Ste,ReplaceAll:kte,Reply:OL,ReplyAll:Cte,Rewind:Mte,Ribbon:Tte,Rocket:v0,RockingChair:Ate,RollerCoaster:Ete,Rotate3d:qN,RotateCcw:g1,RotateCcwSquare:Pte,RotateCw:RL,RotateCwSquare:Ite,Route:Dte,RouteOff:Lte,Router:Ote,Rows2:UN,Rows3:VN,Rows4:Rte,Rss:Fte,Ruler:Ax,RussianRuble:zte,Sailboat:Bte,Salad:$te,Sandwich:qte,Satellite:Vte,SatelliteDish:Ute,Save:Uc,SaveAll:Hte,SaveOff:Gte,Scale:FL,Scale3d:HN,Scaling:Wte,Scan:tse,ScanBarcode:Kte,ScanEye:Zte,ScanFace:Yte,ScanLine:Qte,ScanQrCode:Xte,ScanSearch:Jte,ScanText:ese,School:sse,Scissors:nse,ScissorsLineDashed:rse,ScreenShare:ise,ScreenShareOff:ase,Scroll:lse,ScrollText:ose,Search:sn,SearchCheck:cse,SearchCode:dse,SearchSlash:use,SearchX:zL,Section:hse,Send:$n,SendHorizontal:GN,SendToBack:mse,SeparatorHorizontal:pse,SeparatorVertical:fse,Server:vse,ServerCog:xse,ServerCrash:gse,ServerOff:yse,Settings:Qo,Settings2:BL,Shapes:bse,Share:$L,Share2:nd,Sheet:_se,Shell:wse,Shield:Au,ShieldAlert:jse,ShieldBan:Nse,ShieldCheck:qL,ShieldEllipsis:kse,ShieldHalf:Sse,ShieldMinus:Cse,ShieldOff:Mse,ShieldPlus:Tse,ShieldQuestion:Ase,ShieldX:WN,Ship:Pse,ShipWheel:Ese,Shirt:Ise,ShoppingBag:b0,ShoppingBasket:Lse,ShoppingCart:vp,Shovel:Dse,ShowerHead:Ose,Shrink:Rse,Shrub:Fse,Shuffle:bS,Sigma:zse,Signal:Vse,SignalHigh:Bse,SignalLow:$se,SignalMedium:qse,SignalZero:Use,Signature:Hse,Signpost:Wse,SignpostBig:Gse,Siren:Kse,SkipBack:Zse,SkipForward:Yse,Skull:Qse,Slack:Xse,Slash:Jse,Slice:ere,SlidersHorizontal:y1,SlidersVertical:KN,Smartphone:_0,SmartphoneCharging:tre,SmartphoneNfc:sre,Smile:nre,SmilePlus:rre,Snail:are,Snowflake:o0,Sofa:ire,Soup:ore,Space:lre,Spade:cre,Sparkle:dre,Sparkles:fn,Speaker:ure,Speech:hre,SpellCheck:pre,SpellCheck2:mre,Spline:fre,Split:xre,SprayCan:gre,Sprout:yre,Square:w0,SquareActivity:ZN,SquareArrowDown:XN,SquareArrowDownLeft:YN,SquareArrowDownRight:QN,SquareArrowLeft:JN,SquareArrowOutDownLeft:ek,SquareArrowOutDownRight:tk,SquareArrowOutUpLeft:sk,SquareArrowOutUpRight:rk,SquareArrowRight:nk,SquareArrowUp:ok,SquareArrowUpLeft:ak,SquareArrowUpRight:ik,SquareAsterisk:lk,SquareBottomDashedScissors:ck,SquareChartGantt:Gy,SquareCheck:dk,SquareCheckBig:Vv,SquareChevronDown:uk,SquareChevronLeft:hk,SquareChevronRight:mk,SquareChevronUp:pk,SquareCode:fk,SquareDashed:yk,SquareDashedBottom:bre,SquareDashedBottomCode:vre,SquareDashedKanban:xk,SquareDashedMousePointer:gk,SquareDivide:vk,SquareDot:bk,SquareEqual:_k,SquareFunction:wk,SquareKanban:jk,SquareLibrary:Nk,SquareM:kk,SquareMenu:Sk,SquareMinus:Ck,SquareMousePointer:Mk,SquareParking:Ak,SquareParkingOff:Tk,SquarePen:md,SquarePercent:Ek,SquarePi:Pk,SquarePilcrow:Ik,SquarePlay:Lk,SquarePlus:Dk,SquarePower:Ok,SquareRadical:_re,SquareScissors:Rk,SquareSigma:Fk,SquareSlash:zk,SquareSplitHorizontal:Bk,SquareSplitVertical:$k,SquareSquare:wre,SquareStack:jre,SquareTerminal:qk,SquareUser:Vk,SquareUserRound:Uk,SquareX:Hk,Squircle:Nre,Squirrel:kre,Stamp:Sre,Star:Jn,StarHalf:Cre,StarOff:Mre,StepBack:Tre,StepForward:Are,Stethoscope:Ere,Sticker:Pre,StickyNote:Ire,Store:KM,StretchHorizontal:Lre,StretchVertical:Dre,Strikethrough:UL,Subscript:Ore,Sun:v1,SunDim:Rre,SunMedium:Fre,SunMoon:zre,SunSnow:Bre,Sunrise:$re,Sunset:qre,Superscript:Ure,SwatchBook:Vre,SwissFranc:Hre,SwitchCamera:Gre,Sword:Wre,Swords:Kre,Syringe:Zre,Table:YM,Table2:ZM,TableCellsMerge:Yre,TableCellsSplit:Qre,TableColumnsSplit:Xre,TableOfContents:Jre,TableProperties:ene,TableRowsSplit:tne,Tablet:rne,TabletSmartphone:sne,Tablets:nne,Tag:Fm,Tags:ane,Tally1:ine,Tally2:one,Tally3:lne,Tally4:cne,Tally5:dne,Tangent:une,Target:zm,Telescope:hne,Tent:pne,TentTree:mne,Terminal:fne,TestTube:xne,TestTubeDiagonal:Gk,TestTubes:gne,Text:wne,TextCursor:vne,TextCursorInput:yne,TextQuote:bne,TextSearch:_ne,TextSelect:Wk,Theater:jne,Thermometer:VL,ThermometerSnowflake:Nne,ThermometerSun:kne,ThumbsDown:HL,ThumbsUp:nh,Ticket:GL,TicketCheck:Sne,TicketMinus:Cne,TicketPercent:Mne,TicketPlus:Tne,TicketSlash:Ane,TicketX:Ene,Tickets:Ine,TicketsPlane:Pne,Timer:One,TimerOff:Lne,TimerReset:Dne,ToggleLeft:Rne,ToggleRight:Fne,Toilet:zne,Tornado:Bne,Torus:$ne,Touchpad:Une,TouchpadOff:qne,TowerControl:Vne,ToyBrick:Hne,Tractor:Gne,TrafficCone:Wne,TrainFront:Zne,TrainFrontTunnel:Kne,TrainTrack:Yne,TramFront:Kk,Trash:Qne,Trash2:Nr,TreeDeciduous:Xne,TreePalm:Zk,TreePine:j0,Trees:Jne,Trello:eae,TrendingDown:_S,TrendingUp:Jo,TrendingUpDown:tae,Triangle:rae,TriangleAlert:Yu,TriangleRight:sae,Trophy:vo,Truck:QM,Turtle:nae,Tv:iae,TvMinimal:Yk,TvMinimalPlay:aae,Twitch:oae,Twitter:lae,Type:dae,TypeOutline:cae,Umbrella:hae,UmbrellaOff:uae,Underline:WL,Undo:wS,Undo2:mae,UndoDot:pae,UnfoldHorizontal:fae,UnfoldVertical:xae,Ungroup:gae,University:Qk,Unlink:jS,Unlink2:yae,Unplug:vae,Upload:di,Usb:bae,User:Wi,UserCheck:X_,UserCog:KL,UserMinus:ZL,UserPen:_ae,UserPlus:El,UserRound:r4,UserRoundCheck:Xk,UserRoundCog:Jk,UserRoundMinus:e4,UserRoundPen:wae,UserRoundPlus:t4,UserRoundSearch:jae,UserRoundX:s4,UserSearch:Nae,UserX:kae,Users:hr,UsersRound:n4,Utensils:i4,UtensilsCrossed:a4,UtilityPole:Sae,Variable:XM,Vault:Cae,Vegan:Mae,VenetianMask:Tae,Vibrate:Eae,VibrateOff:Aae,Video:Cn,VideoOff:Pae,Videotape:Iae,View:Lae,Voicemail:Dae,Volleyball:Oae,Volume:$ae,Volume1:Rae,Volume2:Fae,VolumeOff:zae,VolumeX:Bae,Vote:qae,Wallet:YL,WalletCards:Uae,WalletMinimal:o4,Wallpaper:Vae,Wand:Hae,WandSparkles:Hv,Warehouse:Gae,WashingMachine:Wae,Watch:Kae,Waves:QL,Waypoints:Zae,Webcam:Yae,Webhook:Xae,WebhookOff:Qae,Weight:Jae,Wheat:tie,WheatOff:eie,WholeWord:sie,Wifi:oie,WifiHigh:rie,WifiLow:nie,WifiOff:aie,WifiZero:iie,Wind:cie,WindArrowDown:lie,Wine:uie,WineOff:die,Workflow:hie,Worm:mie,WrapText:pie,Wrench:sy,X:Mr,Youtube:fie,Zap:Yh,ZapOff:xie,ZoomIn:J_,ZoomOut:JM},Symbol.toStringTag,{value:"Module"}));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M2e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:L9,AArrowDownIcon:L9,AArrowUp:D9,AArrowUpIcon:D9,ALargeSmall:O9,ALargeSmallIcon:O9,Accessibility:R9,AccessibilityIcon:R9,Activity:Ch,ActivityIcon:Ch,ActivitySquare:ZN,ActivitySquareIcon:ZN,AirVent:F9,AirVentIcon:F9,Airplay:z9,AirplayIcon:z9,AlarmCheck:X2,AlarmCheckIcon:X2,AlarmClock:$9,AlarmClockCheck:X2,AlarmClockCheckIcon:X2,AlarmClockIcon:$9,AlarmClockMinus:J2,AlarmClockMinusIcon:J2,AlarmClockOff:B9,AlarmClockOffIcon:B9,AlarmClockPlus:ej,AlarmClockPlusIcon:ej,AlarmMinus:J2,AlarmMinusIcon:J2,AlarmPlus:ej,AlarmPlusIcon:ej,AlarmSmoke:q9,AlarmSmokeIcon:q9,Album:U9,AlbumIcon:U9,AlertCircle:Cl,AlertCircleIcon:Cl,AlertOctagon:$v,AlertOctagonIcon:$v,AlertTriangle:Yu,AlertTriangleIcon:Yu,AlignCenter:Q4,AlignCenterHorizontal:V9,AlignCenterHorizontalIcon:V9,AlignCenterIcon:Q4,AlignCenterVertical:H9,AlignCenterVerticalIcon:H9,AlignEndHorizontal:G9,AlignEndHorizontalIcon:G9,AlignEndVertical:W9,AlignEndVerticalIcon:W9,AlignHorizontalDistributeCenter:K9,AlignHorizontalDistributeCenterIcon:K9,AlignHorizontalDistributeEnd:Z9,AlignHorizontalDistributeEndIcon:Z9,AlignHorizontalDistributeStart:Y9,AlignHorizontalDistributeStartIcon:Y9,AlignHorizontalJustifyCenter:Q9,AlignHorizontalJustifyCenterIcon:Q9,AlignHorizontalJustifyEnd:X9,AlignHorizontalJustifyEndIcon:X9,AlignHorizontalJustifyStart:J9,AlignHorizontalJustifyStartIcon:J9,AlignHorizontalSpaceAround:eB,AlignHorizontalSpaceAroundIcon:eB,AlignHorizontalSpaceBetween:tB,AlignHorizontalSpaceBetweenIcon:tB,AlignJustify:sB,AlignJustifyIcon:sB,AlignLeft:X4,AlignLeftIcon:X4,AlignRight:J4,AlignRightIcon:J4,AlignStartHorizontal:rB,AlignStartHorizontalIcon:rB,AlignStartVertical:nB,AlignStartVerticalIcon:nB,AlignVerticalDistributeCenter:aB,AlignVerticalDistributeCenterIcon:aB,AlignVerticalDistributeEnd:iB,AlignVerticalDistributeEndIcon:iB,AlignVerticalDistributeStart:oB,AlignVerticalDistributeStartIcon:oB,AlignVerticalJustifyCenter:lB,AlignVerticalJustifyCenterIcon:lB,AlignVerticalJustifyEnd:cB,AlignVerticalJustifyEndIcon:cB,AlignVerticalJustifyStart:dB,AlignVerticalJustifyStartIcon:dB,AlignVerticalSpaceAround:uB,AlignVerticalSpaceAroundIcon:uB,AlignVerticalSpaceBetween:hB,AlignVerticalSpaceBetweenIcon:hB,Ambulance:mB,AmbulanceIcon:mB,Ampersand:pB,AmpersandIcon:pB,Ampersands:fB,AmpersandsIcon:fB,Amphora:xB,AmphoraIcon:xB,Anchor:gB,AnchorIcon:gB,Angry:yB,AngryIcon:yB,Annoyed:vB,AnnoyedIcon:vB,Antenna:bB,AntennaIcon:bB,Anvil:_B,AnvilIcon:_B,Aperture:wB,ApertureIcon:wB,AppWindow:sL,AppWindowIcon:sL,AppWindowMac:jB,AppWindowMacIcon:jB,Apple:NB,AppleIcon:NB,Archive:IM,ArchiveIcon:IM,ArchiveRestore:rL,ArchiveRestoreIcon:rL,ArchiveX:kB,ArchiveXIcon:kB,AreaChart:pj,AreaChartIcon:pj,Armchair:SB,ArmchairIcon:SB,ArrowBigDown:MB,ArrowBigDownDash:CB,ArrowBigDownDashIcon:CB,ArrowBigDownIcon:MB,ArrowBigLeft:AB,ArrowBigLeftDash:TB,ArrowBigLeftDashIcon:TB,ArrowBigLeftIcon:AB,ArrowBigRight:PB,ArrowBigRightDash:EB,ArrowBigRightDashIcon:EB,ArrowBigRightIcon:PB,ArrowBigUp:LB,ArrowBigUpDash:IB,ArrowBigUpDashIcon:IB,ArrowBigUpIcon:LB,ArrowDown:Kh,ArrowDown01:DB,ArrowDown01Icon:DB,ArrowDown10:OB,ArrowDown10Icon:OB,ArrowDownAZ:tj,ArrowDownAZIcon:tj,ArrowDownAz:tj,ArrowDownAzIcon:tj,ArrowDownCircle:Sj,ArrowDownCircleIcon:Sj,ArrowDownFromLine:RB,ArrowDownFromLineIcon:RB,ArrowDownIcon:Kh,ArrowDownLeft:FB,ArrowDownLeftFromCircle:Mj,ArrowDownLeftFromCircleIcon:Mj,ArrowDownLeftFromSquare:ek,ArrowDownLeftFromSquareIcon:ek,ArrowDownLeftIcon:FB,ArrowDownLeftSquare:YN,ArrowDownLeftSquareIcon:YN,ArrowDownNarrowWide:zB,ArrowDownNarrowWideIcon:zB,ArrowDownRight:nL,ArrowDownRightFromCircle:Tj,ArrowDownRightFromCircleIcon:Tj,ArrowDownRightFromSquare:tk,ArrowDownRightFromSquareIcon:tk,ArrowDownRightIcon:nL,ArrowDownRightSquare:QN,ArrowDownRightSquareIcon:QN,ArrowDownSquare:XN,ArrowDownSquareIcon:XN,ArrowDownToDot:BB,ArrowDownToDotIcon:BB,ArrowDownToLine:$B,ArrowDownToLineIcon:$B,ArrowDownUp:qB,ArrowDownUpIcon:qB,ArrowDownWideNarrow:sj,ArrowDownWideNarrowIcon:sj,ArrowDownZA:rj,ArrowDownZAIcon:rj,ArrowDownZa:rj,ArrowDownZaIcon:rj,ArrowLeft:Qa,ArrowLeftCircle:Cj,ArrowLeftCircleIcon:Cj,ArrowLeftFromLine:UB,ArrowLeftFromLineIcon:UB,ArrowLeftIcon:Qa,ArrowLeftRight:VB,ArrowLeftRightIcon:VB,ArrowLeftSquare:JN,ArrowLeftSquareIcon:JN,ArrowLeftToLine:HB,ArrowLeftToLineIcon:HB,ArrowRight:Sa,ArrowRightCircle:Pj,ArrowRightCircleIcon:Pj,ArrowRightFromLine:GB,ArrowRightFromLineIcon:GB,ArrowRightIcon:Sa,ArrowRightLeft:a1,ArrowRightLeftIcon:a1,ArrowRightSquare:nk,ArrowRightSquareIcon:nk,ArrowRightToLine:WB,ArrowRightToLineIcon:WB,ArrowUp:Su,ArrowUp01:KB,ArrowUp01Icon:KB,ArrowUp10:ZB,ArrowUp10Icon:ZB,ArrowUpAZ:nj,ArrowUpAZIcon:nj,ArrowUpAz:nj,ArrowUpAzIcon:nj,ArrowUpCircle:Ij,ArrowUpCircleIcon:Ij,ArrowUpDown:_d,ArrowUpDownIcon:_d,ArrowUpFromDot:YB,ArrowUpFromDotIcon:YB,ArrowUpFromLine:QB,ArrowUpFromLineIcon:QB,ArrowUpIcon:Su,ArrowUpLeft:XB,ArrowUpLeftFromCircle:Aj,ArrowUpLeftFromCircleIcon:Aj,ArrowUpLeftFromSquare:sk,ArrowUpLeftFromSquareIcon:sk,ArrowUpLeftIcon:XB,ArrowUpLeftSquare:ak,ArrowUpLeftSquareIcon:ak,ArrowUpNarrowWide:aj,ArrowUpNarrowWideIcon:aj,ArrowUpRight:aL,ArrowUpRightFromCircle:Ej,ArrowUpRightFromCircleIcon:Ej,ArrowUpRightFromSquare:rk,ArrowUpRightFromSquareIcon:rk,ArrowUpRightIcon:aL,ArrowUpRightSquare:ik,ArrowUpRightSquareIcon:ik,ArrowUpSquare:ok,ArrowUpSquareIcon:ok,ArrowUpToLine:JB,ArrowUpToLineIcon:JB,ArrowUpWideNarrow:e$,ArrowUpWideNarrowIcon:e$,ArrowUpZA:ij,ArrowUpZAIcon:ij,ArrowUpZa:ij,ArrowUpZaIcon:ij,ArrowsUpFromLine:t$,ArrowsUpFromLineIcon:t$,Asterisk:s$,AsteriskIcon:s$,AsteriskSquare:lk,AsteriskSquareIcon:lk,AtSign:r$,AtSignIcon:r$,Atom:n$,AtomIcon:n$,AudioLines:a$,AudioLinesIcon:a$,AudioWaveform:i$,AudioWaveformIcon:i$,Award:tc,AwardIcon:tc,Axe:o$,AxeIcon:o$,Axis3D:oj,Axis3DIcon:oj,Axis3d:oj,Axis3dIcon:oj,Baby:l$,BabyIcon:l$,Backpack:c$,BackpackIcon:c$,Badge:k$,BadgeAlert:d$,BadgeAlertIcon:d$,BadgeCent:u$,BadgeCentIcon:u$,BadgeCheck:lj,BadgeCheckIcon:lj,BadgeDollarSign:h$,BadgeDollarSignIcon:h$,BadgeEuro:m$,BadgeEuroIcon:m$,BadgeHelp:p$,BadgeHelpIcon:p$,BadgeIcon:k$,BadgeIndianRupee:f$,BadgeIndianRupeeIcon:f$,BadgeInfo:x$,BadgeInfoIcon:x$,BadgeJapaneseYen:g$,BadgeJapaneseYenIcon:g$,BadgeMinus:y$,BadgeMinusIcon:y$,BadgePercent:v$,BadgePercentIcon:v$,BadgePlus:b$,BadgePlusIcon:b$,BadgePoundSterling:_$,BadgePoundSterlingIcon:_$,BadgeRussianRuble:w$,BadgeRussianRubleIcon:w$,BadgeSwissFranc:j$,BadgeSwissFrancIcon:j$,BadgeX:N$,BadgeXIcon:N$,BaggageClaim:S$,BaggageClaimIcon:S$,Ban:iL,BanIcon:iL,Banana:C$,BananaIcon:C$,Bandage:M$,BandageIcon:M$,Banknote:T$,BanknoteIcon:T$,BarChart:_j,BarChart2:wj,BarChart2Icon:wj,BarChart3:yo,BarChart3Icon:yo,BarChart4:vj,BarChart4Icon:vj,BarChartBig:yj,BarChartBigIcon:yj,BarChartHorizontal:xj,BarChartHorizontalBig:fj,BarChartHorizontalBigIcon:fj,BarChartHorizontalIcon:xj,BarChartIcon:_j,Barcode:A$,BarcodeIcon:A$,Baseline:E$,BaselineIcon:E$,Bath:su,BathIcon:su,Battery:R$,BatteryCharging:P$,BatteryChargingIcon:P$,BatteryFull:I$,BatteryFullIcon:I$,BatteryIcon:R$,BatteryLow:L$,BatteryLowIcon:L$,BatteryMedium:D$,BatteryMediumIcon:D$,BatteryWarning:O$,BatteryWarningIcon:O$,Beaker:F$,BeakerIcon:F$,Bean:B$,BeanIcon:B$,BeanOff:z$,BeanOffIcon:z$,Bed:Mh,BedDouble:eS,BedDoubleIcon:eS,BedIcon:Mh,BedSingle:$$,BedSingleIcon:$$,Beef:q$,BeefIcon:q$,Beer:V$,BeerIcon:V$,BeerOff:U$,BeerOffIcon:U$,Bell:Lm,BellDot:H$,BellDotIcon:H$,BellElectric:G$,BellElectricIcon:G$,BellIcon:Lm,BellMinus:W$,BellMinusIcon:W$,BellOff:i1,BellOffIcon:i1,BellPlus:K$,BellPlusIcon:K$,BellRing:Z$,BellRingIcon:Z$,BetweenHorizonalEnd:cj,BetweenHorizonalEndIcon:cj,BetweenHorizonalStart:dj,BetweenHorizonalStartIcon:dj,BetweenHorizontalEnd:cj,BetweenHorizontalEndIcon:cj,BetweenHorizontalStart:dj,BetweenHorizontalStartIcon:dj,BetweenVerticalEnd:Y$,BetweenVerticalEndIcon:Y$,BetweenVerticalStart:Q$,BetweenVerticalStartIcon:Q$,BicepsFlexed:X$,BicepsFlexedIcon:X$,Bike:J$,BikeIcon:J$,Binary:eq,BinaryIcon:eq,Binoculars:tq,BinocularsIcon:tq,Biohazard:sq,BiohazardIcon:sq,Bird:rq,BirdIcon:rq,Bitcoin:nq,BitcoinIcon:nq,Blend:aq,BlendIcon:aq,Blinds:iq,BlindsIcon:iq,Blocks:oq,BlocksIcon:oq,Bluetooth:uq,BluetoothConnected:lq,BluetoothConnectedIcon:lq,BluetoothIcon:uq,BluetoothOff:cq,BluetoothOffIcon:cq,BluetoothSearching:dq,BluetoothSearchingIcon:dq,Bold:tS,BoldIcon:tS,Bolt:hq,BoltIcon:hq,Bomb:mq,BombIcon:mq,Bone:pq,BoneIcon:pq,Book:Oq,BookA:fq,BookAIcon:fq,BookAudio:xq,BookAudioIcon:xq,BookCheck:gq,BookCheckIcon:gq,BookCopy:yq,BookCopyIcon:yq,BookDashed:uj,BookDashedIcon:uj,BookDown:vq,BookDownIcon:vq,BookHeadphones:bq,BookHeadphonesIcon:bq,BookHeart:_q,BookHeartIcon:_q,BookIcon:Oq,BookImage:wq,BookImageIcon:wq,BookKey:jq,BookKeyIcon:jq,BookLock:Nq,BookLockIcon:Nq,BookMarked:kq,BookMarkedIcon:kq,BookMinus:Sq,BookMinusIcon:Sq,BookOpen:Th,BookOpenCheck:Cq,BookOpenCheckIcon:Cq,BookOpenIcon:Th,BookOpenText:Mq,BookOpenTextIcon:Mq,BookPlus:Tq,BookPlusIcon:Tq,BookTemplate:uj,BookTemplateIcon:uj,BookText:Aq,BookTextIcon:Aq,BookType:Eq,BookTypeIcon:Eq,BookUp:Iq,BookUp2:Pq,BookUp2Icon:Pq,BookUpIcon:Iq,BookUser:Lq,BookUserIcon:Lq,BookX:Dq,BookXIcon:Dq,Bookmark:Sx,BookmarkCheck:Rq,BookmarkCheckIcon:Rq,BookmarkIcon:Sx,BookmarkMinus:Fq,BookmarkMinusIcon:Fq,BookmarkPlus:oL,BookmarkPlusIcon:oL,BookmarkX:zq,BookmarkXIcon:zq,BoomBox:Bq,BoomBoxIcon:Bq,Bot:LM,BotIcon:LM,BotMessageSquare:$q,BotMessageSquareIcon:$q,BotOff:qq,BotOffIcon:qq,Box:Uq,BoxIcon:Uq,BoxSelect:yk,BoxSelectIcon:yk,Boxes:Vq,BoxesIcon:Vq,Braces:hj,BracesIcon:hj,Brackets:Hq,BracketsIcon:Hq,Brain:lL,BrainCircuit:Gq,BrainCircuitIcon:Gq,BrainCog:Wq,BrainCogIcon:Wq,BrainIcon:lL,BrickWall:Kq,BrickWallIcon:Kq,Briefcase:th,BriefcaseBusiness:Zq,BriefcaseBusinessIcon:Zq,BriefcaseConveyorBelt:Yq,BriefcaseConveyorBeltIcon:Yq,BriefcaseIcon:th,BriefcaseMedical:Qq,BriefcaseMedicalIcon:Qq,BringToFront:Xq,BringToFrontIcon:Xq,Brush:Jq,BrushIcon:Jq,Bug:sU,BugIcon:sU,BugOff:eU,BugOffIcon:eU,BugPlay:tU,BugPlayIcon:tU,Building:sS,Building2:Ca,Building2Icon:Ca,BuildingIcon:sS,Bus:nU,BusFront:rU,BusFrontIcon:rU,BusIcon:nU,Cable:iU,CableCar:aU,CableCarIcon:aU,CableIcon:iU,Cake:Ah,CakeIcon:Ah,CakeSlice:oU,CakeSliceIcon:oU,Calculator:cL,CalculatorIcon:cL,Calendar:hn,Calendar1:lU,Calendar1Icon:lU,CalendarArrowDown:cU,CalendarArrowDownIcon:cU,CalendarArrowUp:dU,CalendarArrowUpIcon:dU,CalendarCheck:dL,CalendarCheck2:uU,CalendarCheck2Icon:uU,CalendarCheckIcon:dL,CalendarClock:uL,CalendarClockIcon:uL,CalendarCog:hU,CalendarCogIcon:hU,CalendarDays:Od,CalendarDaysIcon:Od,CalendarFold:mU,CalendarFoldIcon:mU,CalendarHeart:pU,CalendarHeartIcon:pU,CalendarIcon:hn,CalendarMinus:xU,CalendarMinus2:fU,CalendarMinus2Icon:fU,CalendarMinusIcon:xU,CalendarOff:hL,CalendarOffIcon:hL,CalendarPlus:V_,CalendarPlus2:gU,CalendarPlus2Icon:gU,CalendarPlusIcon:V_,CalendarRange:yU,CalendarRangeIcon:yU,CalendarSearch:vU,CalendarSearchIcon:vU,CalendarSync:bU,CalendarSyncIcon:bU,CalendarX:wU,CalendarX2:_U,CalendarX2Icon:_U,CalendarXIcon:wU,Camera:ff,CameraIcon:ff,CameraOff:jU,CameraOffIcon:jU,CandlestickChart:gj,CandlestickChartIcon:gj,Candy:SU,CandyCane:NU,CandyCaneIcon:NU,CandyIcon:SU,CandyOff:kU,CandyOffIcon:kU,Cannabis:CU,CannabisIcon:CU,Captions:mj,CaptionsIcon:mj,CaptionsOff:MU,CaptionsOffIcon:MU,Car:DM,CarFront:TU,CarFrontIcon:TU,CarIcon:DM,CarTaxiFront:AU,CarTaxiFrontIcon:AU,Caravan:EU,CaravanIcon:EU,Carrot:PU,CarrotIcon:PU,CaseLower:IU,CaseLowerIcon:IU,CaseSensitive:LU,CaseSensitiveIcon:LU,CaseUpper:DU,CaseUpperIcon:DU,CassetteTape:OU,CassetteTapeIcon:OU,Cast:RU,CastIcon:RU,Castle:FU,CastleIcon:FU,Cat:zU,CatIcon:zU,Cctv:BU,CctvIcon:BU,ChartArea:pj,ChartAreaIcon:pj,ChartBar:xj,ChartBarBig:fj,ChartBarBigIcon:fj,ChartBarDecreasing:$U,ChartBarDecreasingIcon:$U,ChartBarIcon:xj,ChartBarIncreasing:qU,ChartBarIncreasingIcon:qU,ChartBarStacked:UU,ChartBarStackedIcon:UU,ChartCandlestick:gj,ChartCandlestickIcon:gj,ChartColumn:yo,ChartColumnBig:yj,ChartColumnBigIcon:yj,ChartColumnDecreasing:VU,ChartColumnDecreasingIcon:VU,ChartColumnIcon:yo,ChartColumnIncreasing:vj,ChartColumnIncreasingIcon:vj,ChartColumnStacked:HU,ChartColumnStackedIcon:HU,ChartGantt:GU,ChartGanttIcon:GU,ChartLine:bj,ChartLineIcon:bj,ChartNetwork:WU,ChartNetworkIcon:WU,ChartNoAxesColumn:wj,ChartNoAxesColumnDecreasing:KU,ChartNoAxesColumnDecreasingIcon:KU,ChartNoAxesColumnIcon:wj,ChartNoAxesColumnIncreasing:_j,ChartNoAxesColumnIncreasingIcon:_j,ChartNoAxesCombined:ZU,ChartNoAxesCombinedIcon:ZU,ChartNoAxesGantt:jj,ChartNoAxesGanttIcon:jj,ChartPie:Nj,ChartPieIcon:Nj,ChartScatter:kj,ChartScatterIcon:kj,ChartSpline:YU,ChartSplineIcon:YU,Check:ba,CheckCheck:mL,CheckCheckIcon:mL,CheckCircle:gi,CheckCircle2:sa,CheckCircle2Icon:sa,CheckCircleIcon:gi,CheckIcon:ba,CheckSquare:Vv,CheckSquare2:dk,CheckSquare2Icon:dk,CheckSquareIcon:Vv,ChefHat:QU,ChefHatIcon:QU,Cherry:XU,CherryIcon:XU,ChevronDown:oo,ChevronDownCircle:Lj,ChevronDownCircleIcon:Lj,ChevronDownIcon:oo,ChevronDownSquare:uk,ChevronDownSquareIcon:uk,ChevronFirst:JU,ChevronFirstIcon:JU,ChevronLast:eV,ChevronLastIcon:eV,ChevronLeft:Xo,ChevronLeftCircle:Dj,ChevronLeftCircleIcon:Dj,ChevronLeftIcon:Xo,ChevronLeftSquare:hk,ChevronLeftSquareIcon:hk,ChevronRight:oa,ChevronRightCircle:Oj,ChevronRightCircleIcon:Oj,ChevronRightIcon:oa,ChevronRightSquare:mk,ChevronRightSquareIcon:mk,ChevronUp:xf,ChevronUpCircle:Rj,ChevronUpCircleIcon:Rj,ChevronUpIcon:xf,ChevronUpSquare:pk,ChevronUpSquareIcon:pk,ChevronsDown:sV,ChevronsDownIcon:sV,ChevronsDownUp:tV,ChevronsDownUpIcon:tV,ChevronsLeft:aV,ChevronsLeftIcon:aV,ChevronsLeftRight:nV,ChevronsLeftRightEllipsis:rV,ChevronsLeftRightEllipsisIcon:rV,ChevronsLeftRightIcon:nV,ChevronsRight:oV,ChevronsRightIcon:oV,ChevronsRightLeft:iV,ChevronsRightLeftIcon:iV,ChevronsUp:lV,ChevronsUpDown:Cx,ChevronsUpDownIcon:Cx,ChevronsUpIcon:lV,Chrome:cV,ChromeIcon:cV,Church:dV,ChurchIcon:dV,Cigarette:hV,CigaretteIcon:hV,CigaretteOff:uV,CigaretteOffIcon:uV,Circle:wd,CircleAlert:Cl,CircleAlertIcon:Cl,CircleArrowDown:Sj,CircleArrowDownIcon:Sj,CircleArrowLeft:Cj,CircleArrowLeftIcon:Cj,CircleArrowOutDownLeft:Mj,CircleArrowOutDownLeftIcon:Mj,CircleArrowOutDownRight:Tj,CircleArrowOutDownRightIcon:Tj,CircleArrowOutUpLeft:Aj,CircleArrowOutUpLeftIcon:Aj,CircleArrowOutUpRight:Ej,CircleArrowOutUpRightIcon:Ej,CircleArrowRight:Pj,CircleArrowRightIcon:Pj,CircleArrowUp:Ij,CircleArrowUpIcon:Ij,CircleCheck:sa,CircleCheckBig:gi,CircleCheckBigIcon:gi,CircleCheckIcon:sa,CircleChevronDown:Lj,CircleChevronDownIcon:Lj,CircleChevronLeft:Dj,CircleChevronLeftIcon:Dj,CircleChevronRight:Oj,CircleChevronRightIcon:Oj,CircleChevronUp:Rj,CircleChevronUpIcon:Rj,CircleDashed:mV,CircleDashedIcon:mV,CircleDivide:Fj,CircleDivideIcon:Fj,CircleDollarSign:pV,CircleDollarSignIcon:pV,CircleDot:xV,CircleDotDashed:fV,CircleDotDashedIcon:fV,CircleDotIcon:xV,CircleEllipsis:gV,CircleEllipsisIcon:gV,CircleEqual:yV,CircleEqualIcon:yV,CircleFadingArrowUp:vV,CircleFadingArrowUpIcon:vV,CircleFadingPlus:bV,CircleFadingPlusIcon:bV,CircleGauge:zj,CircleGaugeIcon:zj,CircleHelp:Bv,CircleHelpIcon:Bv,CircleIcon:wd,CircleMinus:Bj,CircleMinusIcon:Bj,CircleOff:_V,CircleOffIcon:_V,CircleParking:qj,CircleParkingIcon:qj,CircleParkingOff:$j,CircleParkingOffIcon:$j,CirclePause:Uj,CirclePauseIcon:Uj,CirclePercent:Vj,CirclePercentIcon:Vj,CirclePlay:pp,CirclePlayIcon:pp,CirclePlus:Hj,CirclePlusIcon:Hj,CirclePower:Gj,CirclePowerIcon:Gj,CircleSlash:wV,CircleSlash2:Wj,CircleSlash2Icon:Wj,CircleSlashIcon:wV,CircleSlashed:Wj,CircleSlashedIcon:Wj,CircleStop:Kj,CircleStopIcon:Kj,CircleUser:Yj,CircleUserIcon:Yj,CircleUserRound:Zj,CircleUserRoundIcon:Zj,CircleX:jc,CircleXIcon:jc,CircuitBoard:jV,CircuitBoardIcon:jV,Citrus:NV,CitrusIcon:NV,Clapperboard:kV,ClapperboardIcon:kV,Clipboard:PV,ClipboardCheck:OM,ClipboardCheckIcon:OM,ClipboardCopy:SV,ClipboardCopyIcon:SV,ClipboardEdit:Xj,ClipboardEditIcon:Xj,ClipboardIcon:PV,ClipboardList:H_,ClipboardListIcon:H_,ClipboardMinus:CV,ClipboardMinusIcon:CV,ClipboardPaste:MV,ClipboardPasteIcon:MV,ClipboardPen:Xj,ClipboardPenIcon:Xj,ClipboardPenLine:Qj,ClipboardPenLineIcon:Qj,ClipboardPlus:TV,ClipboardPlusIcon:TV,ClipboardSignature:Qj,ClipboardSignatureIcon:Qj,ClipboardType:AV,ClipboardTypeIcon:AV,ClipboardX:EV,ClipboardXIcon:EV,Clock:un,Clock1:IV,Clock10:LV,Clock10Icon:LV,Clock11:DV,Clock11Icon:DV,Clock12:OV,Clock12Icon:OV,Clock1Icon:IV,Clock2:RV,Clock2Icon:RV,Clock3:FV,Clock3Icon:FV,Clock4:zV,Clock4Icon:zV,Clock5:BV,Clock5Icon:BV,Clock6:$V,Clock6Icon:$V,Clock7:qV,Clock7Icon:qV,Clock8:UV,Clock8Icon:UV,Clock9:VV,Clock9Icon:VV,ClockAlert:HV,ClockAlertIcon:HV,ClockArrowDown:GV,ClockArrowDownIcon:GV,ClockArrowUp:WV,ClockArrowUpIcon:WV,ClockIcon:un,Cloud:lH,CloudAlert:KV,CloudAlertIcon:KV,CloudCog:ZV,CloudCogIcon:ZV,CloudDownload:Jj,CloudDownloadIcon:Jj,CloudDrizzle:YV,CloudDrizzleIcon:YV,CloudFog:QV,CloudFogIcon:QV,CloudHail:XV,CloudHailIcon:XV,CloudIcon:lH,CloudLightning:JV,CloudLightningIcon:JV,CloudMoon:tH,CloudMoonIcon:tH,CloudMoonRain:eH,CloudMoonRainIcon:eH,CloudOff:sH,CloudOffIcon:sH,CloudRain:nH,CloudRainIcon:nH,CloudRainWind:rH,CloudRainWindIcon:rH,CloudSnow:aH,CloudSnowIcon:aH,CloudSun:oH,CloudSunIcon:oH,CloudSunRain:iH,CloudSunRainIcon:iH,CloudUpload:eN,CloudUploadIcon:eN,Cloudy:cH,CloudyIcon:cH,Clover:Jv,CloverIcon:Jv,Club:dH,ClubIcon:dH,Code:rS,Code2:tN,Code2Icon:tN,CodeIcon:rS,CodeSquare:fk,CodeSquareIcon:fk,CodeXml:tN,CodeXmlIcon:tN,Codepen:uH,CodepenIcon:uH,Codesandbox:hH,CodesandboxIcon:hH,Coffee:nS,CoffeeIcon:nS,Cog:mH,CogIcon:mH,Coins:pL,CoinsIcon:pL,Columns:sN,Columns2:sN,Columns2Icon:sN,Columns3:rN,Columns3Icon:rN,Columns4:pH,Columns4Icon:pH,ColumnsIcon:sN,Combine:fH,CombineIcon:fH,Command:xH,CommandIcon:xH,Compass:o1,CompassIcon:o1,Component:gH,ComponentIcon:gH,Computer:yH,ComputerIcon:yH,ConciergeBell:vH,ConciergeBellIcon:vH,Cone:bH,ConeIcon:bH,Construction:_H,ConstructionIcon:_H,Contact:aS,Contact2:nN,Contact2Icon:nN,ContactIcon:aS,ContactRound:nN,ContactRoundIcon:nN,Container:wH,ContainerIcon:wH,Contrast:jH,ContrastIcon:jH,Cookie:NH,CookieIcon:NH,CookingPot:kH,CookingPotIcon:kH,Copy:yi,CopyCheck:SH,CopyCheckIcon:SH,CopyIcon:yi,CopyMinus:CH,CopyMinusIcon:CH,CopyPlus:MH,CopyPlusIcon:MH,CopySlash:TH,CopySlashIcon:TH,CopyX:AH,CopyXIcon:AH,Copyleft:EH,CopyleftIcon:EH,Copyright:PH,CopyrightIcon:PH,CornerDownLeft:IH,CornerDownLeftIcon:IH,CornerDownRight:LH,CornerDownRightIcon:LH,CornerLeftDown:DH,CornerLeftDownIcon:DH,CornerLeftUp:OH,CornerLeftUpIcon:OH,CornerRightDown:RH,CornerRightDownIcon:RH,CornerRightUp:FH,CornerRightUpIcon:FH,CornerUpLeft:zH,CornerUpLeftIcon:zH,CornerUpRight:BH,CornerUpRightIcon:BH,Cpu:$H,CpuIcon:$H,CreativeCommons:qH,CreativeCommonsIcon:qH,CreditCard:Mx,CreditCardIcon:Mx,Croissant:UH,CroissantIcon:UH,Crop:VH,CropIcon:VH,Cross:HH,CrossIcon:HH,Crosshair:GH,CrosshairIcon:GH,Crown:Dm,CrownIcon:Dm,Cuboid:WH,CuboidIcon:WH,CupSoda:KH,CupSodaIcon:KH,CurlyBraces:hj,CurlyBracesIcon:hj,Currency:ZH,CurrencyIcon:ZH,Cylinder:YH,CylinderIcon:YH,Dam:QH,DamIcon:QH,Database:fL,DatabaseBackup:XH,DatabaseBackupIcon:XH,DatabaseIcon:fL,DatabaseZap:JH,DatabaseZapIcon:JH,Delete:eG,DeleteIcon:eG,Dessert:tG,DessertIcon:tG,Diameter:sG,DiameterIcon:sG,Diamond:aG,DiamondIcon:aG,DiamondMinus:rG,DiamondMinusIcon:rG,DiamondPercent:aN,DiamondPercentIcon:aN,DiamondPlus:nG,DiamondPlusIcon:nG,Dice1:iG,Dice1Icon:iG,Dice2:oG,Dice2Icon:oG,Dice3:lG,Dice3Icon:lG,Dice4:cG,Dice4Icon:cG,Dice5:dG,Dice5Icon:dG,Dice6:uG,Dice6Icon:uG,Dices:hG,DicesIcon:hG,Diff:mG,DiffIcon:mG,Disc:gG,Disc2:pG,Disc2Icon:pG,Disc3:fG,Disc3Icon:fG,DiscAlbum:xG,DiscAlbumIcon:xG,DiscIcon:gG,Divide:yG,DivideCircle:Fj,DivideCircleIcon:Fj,DivideIcon:yG,DivideSquare:vk,DivideSquareIcon:vk,Dna:bG,DnaIcon:bG,DnaOff:vG,DnaOffIcon:vG,Dock:_G,DockIcon:_G,Dog:wG,DogIcon:wG,DollarSign:hl,DollarSignIcon:hl,Donut:jG,DonutIcon:jG,DoorClosed:NG,DoorClosedIcon:NG,DoorOpen:l1,DoorOpenIcon:l1,Dot:kG,DotIcon:kG,DotSquare:bk,DotSquareIcon:bk,Download:vi,DownloadCloud:Jj,DownloadCloudIcon:Jj,DownloadIcon:vi,DraftingCompass:SG,DraftingCompassIcon:SG,Drama:CG,DramaIcon:CG,Dribbble:MG,DribbbleIcon:MG,Drill:TG,DrillIcon:TG,Droplet:AG,DropletIcon:AG,Droplets:Jg,DropletsIcon:Jg,Drum:EG,DrumIcon:EG,Drumstick:PG,DrumstickIcon:PG,Dumbbell:IG,DumbbellIcon:IG,Ear:DG,EarIcon:DG,EarOff:LG,EarOffIcon:LG,Earth:iN,EarthIcon:iN,EarthLock:OG,EarthLockIcon:OG,Eclipse:RG,EclipseIcon:RG,Edit:md,Edit2:s0,Edit2Icon:s0,Edit3:Uv,Edit3Icon:Uv,EditIcon:md,Egg:RM,EggFried:FG,EggFriedIcon:FG,EggIcon:RM,EggOff:zG,EggOffIcon:zG,Ellipsis:xx,EllipsisIcon:xx,EllipsisVertical:fx,EllipsisVerticalIcon:fx,Equal:qG,EqualApproximately:BG,EqualApproximatelyIcon:BG,EqualIcon:qG,EqualNot:$G,EqualNotIcon:$G,EqualSquare:_k,EqualSquareIcon:_k,Eraser:UG,EraserIcon:UG,EthernetPort:VG,EthernetPortIcon:VG,Euro:HG,EuroIcon:HG,Expand:xL,ExpandIcon:xL,ExternalLink:en,ExternalLinkIcon:en,Eye:Dn,EyeClosed:GG,EyeClosedIcon:GG,EyeIcon:Dn,EyeOff:kp,EyeOffIcon:kp,Facebook:Cu,FacebookIcon:Cu,Factory:WG,FactoryIcon:WG,Fan:KG,FanIcon:KG,FastForward:ZG,FastForwardIcon:ZG,Feather:YG,FeatherIcon:YG,Fence:QG,FenceIcon:QG,FerrisWheel:XG,FerrisWheelIcon:XG,Figma:JG,FigmaIcon:JG,File:FM,FileArchive:eW,FileArchiveIcon:eW,FileAudio:sW,FileAudio2:tW,FileAudio2Icon:tW,FileAudioIcon:sW,FileAxis3D:oN,FileAxis3DIcon:oN,FileAxis3d:oN,FileAxis3dIcon:oN,FileBadge:nW,FileBadge2:rW,FileBadge2Icon:rW,FileBadgeIcon:nW,FileBarChart:lN,FileBarChart2:cN,FileBarChart2Icon:cN,FileBarChartIcon:lN,FileBox:aW,FileBoxIcon:aW,FileChartColumn:cN,FileChartColumnIcon:cN,FileChartColumnIncreasing:lN,FileChartColumnIncreasingIcon:lN,FileChartLine:dN,FileChartLineIcon:dN,FileChartPie:uN,FileChartPieIcon:uN,FileCheck:oW,FileCheck2:iW,FileCheck2Icon:iW,FileCheckIcon:oW,FileClock:lW,FileClockIcon:lW,FileCode:dW,FileCode2:cW,FileCode2Icon:cW,FileCodeIcon:dW,FileCog:hN,FileCog2:hN,FileCog2Icon:hN,FileCogIcon:hN,FileDiff:uW,FileDiffIcon:uW,FileDigit:hW,FileDigitIcon:hW,FileDown:mW,FileDownIcon:mW,FileEdit:pN,FileEditIcon:pN,FileHeart:pW,FileHeartIcon:pW,FileIcon:FM,FileImage:G_,FileImageIcon:G_,FileInput:fW,FileInputIcon:fW,FileJson:gW,FileJson2:xW,FileJson2Icon:xW,FileJsonIcon:gW,FileKey:vW,FileKey2:yW,FileKey2Icon:yW,FileKeyIcon:vW,FileLineChart:dN,FileLineChartIcon:dN,FileLock:_W,FileLock2:bW,FileLock2Icon:bW,FileLockIcon:_W,FileMinus:jW,FileMinus2:wW,FileMinus2Icon:wW,FileMinusIcon:jW,FileMusic:NW,FileMusicIcon:NW,FileOutput:kW,FileOutputIcon:kW,FilePen:pN,FilePenIcon:pN,FilePenLine:mN,FilePenLineIcon:mN,FilePieChart:uN,FilePieChartIcon:uN,FilePlus:CW,FilePlus2:SW,FilePlus2Icon:SW,FilePlusIcon:CW,FileQuestion:MW,FileQuestionIcon:MW,FileScan:TW,FileScanIcon:TW,FileSearch:EW,FileSearch2:AW,FileSearch2Icon:AW,FileSearchIcon:EW,FileSignature:mN,FileSignatureIcon:mN,FileSliders:PW,FileSlidersIcon:PW,FileSpreadsheet:c1,FileSpreadsheetIcon:c1,FileStack:gL,FileStackIcon:gL,FileSymlink:IW,FileSymlinkIcon:IW,FileTerminal:LW,FileTerminalIcon:LW,FileText:wn,FileTextIcon:wn,FileType:OW,FileType2:DW,FileType2Icon:DW,FileTypeIcon:OW,FileUp:RW,FileUpIcon:RW,FileUser:FW,FileUserIcon:FW,FileVideo:BW,FileVideo2:zW,FileVideo2Icon:zW,FileVideoIcon:BW,FileVolume:qW,FileVolume2:$W,FileVolume2Icon:$W,FileVolumeIcon:qW,FileWarning:UW,FileWarningIcon:UW,FileX:HW,FileX2:VW,FileX2Icon:VW,FileXIcon:HW,Files:GW,FilesIcon:GW,Film:yu,FilmIcon:yu,Filter:ey,FilterIcon:ey,FilterX:WW,FilterXIcon:WW,Fingerprint:KW,FingerprintIcon:KW,FireExtinguisher:ZW,FireExtinguisherIcon:ZW,Fish:XW,FishIcon:XW,FishOff:YW,FishOffIcon:YW,FishSymbol:QW,FishSymbolIcon:QW,Flag:d1,FlagIcon:d1,FlagOff:JW,FlagOffIcon:JW,FlagTriangleLeft:eK,FlagTriangleLeftIcon:eK,FlagTriangleRight:tK,FlagTriangleRightIcon:tK,Flame:sh,FlameIcon:sh,FlameKindling:sK,FlameKindlingIcon:sK,Flashlight:nK,FlashlightIcon:nK,FlashlightOff:rK,FlashlightOffIcon:rK,FlaskConical:W_,FlaskConicalIcon:W_,FlaskConicalOff:aK,FlaskConicalOffIcon:aK,FlaskRound:iK,FlaskRoundIcon:iK,FlipHorizontal:yL,FlipHorizontal2:oK,FlipHorizontal2Icon:oK,FlipHorizontalIcon:yL,FlipVertical:cK,FlipVertical2:lK,FlipVertical2Icon:lK,FlipVerticalIcon:cK,Flower:dK,Flower2:Kg,Flower2Icon:Kg,FlowerIcon:dK,Focus:uK,FocusIcon:uK,FoldHorizontal:hK,FoldHorizontalIcon:hK,FoldVertical:mK,FoldVerticalIcon:mK,Folder:BK,FolderArchive:pK,FolderArchiveIcon:pK,FolderCheck:fK,FolderCheckIcon:fK,FolderClock:xK,FolderClockIcon:xK,FolderClosed:gK,FolderClosedIcon:gK,FolderCode:yK,FolderCodeIcon:yK,FolderCog:fN,FolderCog2:fN,FolderCog2Icon:fN,FolderCogIcon:fN,FolderDot:vK,FolderDotIcon:vK,FolderDown:bK,FolderDownIcon:bK,FolderEdit:xN,FolderEditIcon:xN,FolderGit:wK,FolderGit2:_K,FolderGit2Icon:_K,FolderGitIcon:wK,FolderHeart:jK,FolderHeartIcon:jK,FolderIcon:BK,FolderInput:NK,FolderInputIcon:NK,FolderKanban:kK,FolderKanbanIcon:kK,FolderKey:SK,FolderKeyIcon:SK,FolderLock:CK,FolderLockIcon:CK,FolderMinus:MK,FolderMinusIcon:MK,FolderOpen:Om,FolderOpenDot:TK,FolderOpenDotIcon:TK,FolderOpenIcon:Om,FolderOutput:AK,FolderOutputIcon:AK,FolderPen:xN,FolderPenIcon:xN,FolderPlus:EK,FolderPlusIcon:EK,FolderRoot:PK,FolderRootIcon:PK,FolderSearch:LK,FolderSearch2:IK,FolderSearch2Icon:IK,FolderSearchIcon:LK,FolderSymlink:DK,FolderSymlinkIcon:DK,FolderSync:OK,FolderSyncIcon:OK,FolderTree:RK,FolderTreeIcon:RK,FolderUp:FK,FolderUpIcon:FK,FolderX:zK,FolderXIcon:zK,Folders:$K,FoldersIcon:$K,Footprints:qK,FootprintsIcon:qK,ForkKnife:i4,ForkKnifeCrossed:a4,ForkKnifeCrossedIcon:a4,ForkKnifeIcon:i4,Forklift:UK,ForkliftIcon:UK,FormInput:$N,FormInputIcon:$N,Forward:VK,ForwardIcon:VK,Frame:HK,FrameIcon:HK,Framer:GK,FramerIcon:GK,Frown:WK,FrownIcon:WK,Fuel:KK,FuelIcon:KK,Fullscreen:ZK,FullscreenIcon:ZK,FunctionSquare:wk,FunctionSquareIcon:wk,GalleryHorizontal:QK,GalleryHorizontalEnd:YK,GalleryHorizontalEndIcon:YK,GalleryHorizontalIcon:QK,GalleryThumbnails:XK,GalleryThumbnailsIcon:XK,GalleryVertical:eZ,GalleryVerticalEnd:JK,GalleryVerticalEndIcon:JK,GalleryVerticalIcon:eZ,Gamepad:sZ,Gamepad2:tZ,Gamepad2Icon:tZ,GamepadIcon:sZ,GanttChart:jj,GanttChartIcon:jj,GanttChartSquare:Gy,GanttChartSquareIcon:Gy,Gauge:rZ,GaugeCircle:zj,GaugeCircleIcon:zj,GaugeIcon:rZ,Gavel:nZ,GavelIcon:nZ,Gem:aZ,GemIcon:aZ,Ghost:iS,GhostIcon:iS,Gift:So,GiftIcon:So,GitBranch:oZ,GitBranchIcon:oZ,GitBranchPlus:iZ,GitBranchPlusIcon:iZ,GitCommit:gN,GitCommitHorizontal:gN,GitCommitHorizontalIcon:gN,GitCommitIcon:gN,GitCommitVertical:lZ,GitCommitVerticalIcon:lZ,GitCompare:dZ,GitCompareArrows:cZ,GitCompareArrowsIcon:cZ,GitCompareIcon:dZ,GitFork:uZ,GitForkIcon:uZ,GitGraph:hZ,GitGraphIcon:hZ,GitMerge:mZ,GitMergeIcon:mZ,GitPullRequest:vZ,GitPullRequestArrow:pZ,GitPullRequestArrowIcon:pZ,GitPullRequestClosed:fZ,GitPullRequestClosedIcon:fZ,GitPullRequestCreate:gZ,GitPullRequestCreateArrow:xZ,GitPullRequestCreateArrowIcon:xZ,GitPullRequestCreateIcon:gZ,GitPullRequestDraft:yZ,GitPullRequestDraftIcon:yZ,GitPullRequestIcon:vZ,Github:bZ,GithubIcon:bZ,Gitlab:_Z,GitlabIcon:_Z,GlassWater:wZ,GlassWaterIcon:wZ,Glasses:jZ,GlassesIcon:jZ,Globe:ru,Globe2:iN,Globe2Icon:iN,GlobeIcon:ru,GlobeLock:NZ,GlobeLockIcon:NZ,Goal:kZ,GoalIcon:kZ,Grab:SZ,GrabIcon:SZ,GraduationCap:Zh,GraduationCapIcon:Zh,Grape:CZ,GrapeIcon:CZ,Grid:ix,Grid2X2:vN,Grid2X2Icon:vN,Grid2X2Plus:yN,Grid2X2PlusIcon:yN,Grid2x2:vN,Grid2x2Check:MZ,Grid2x2CheckIcon:MZ,Grid2x2Icon:vN,Grid2x2Plus:yN,Grid2x2PlusIcon:yN,Grid2x2X:TZ,Grid2x2XIcon:TZ,Grid3X3:ix,Grid3X3Icon:ix,Grid3x3:ix,Grid3x3Icon:ix,GridIcon:ix,Grip:EZ,GripHorizontal:AZ,GripHorizontalIcon:AZ,GripIcon:EZ,GripVertical:Mu,GripVerticalIcon:Mu,Group:PZ,GroupIcon:PZ,Guitar:IZ,GuitarIcon:IZ,Ham:LZ,HamIcon:LZ,Hammer:DZ,HammerIcon:DZ,Hand:vL,HandCoins:OZ,HandCoinsIcon:OZ,HandHeart:RZ,HandHeartIcon:RZ,HandHelping:bN,HandHelpingIcon:bN,HandIcon:vL,HandMetal:FZ,HandMetalIcon:FZ,HandPlatter:zZ,HandPlatterIcon:zZ,Handshake:bL,HandshakeIcon:bL,HardDrive:_L,HardDriveDownload:BZ,HardDriveDownloadIcon:BZ,HardDriveIcon:_L,HardDriveUpload:$Z,HardDriveUploadIcon:$Z,HardHat:qZ,HardHatIcon:qZ,Hash:K_,HashIcon:K_,Haze:UZ,HazeIcon:UZ,HdmiPort:VZ,HdmiPortIcon:VZ,Heading:KZ,Heading1:zM,Heading1Icon:zM,Heading2:BM,Heading2Icon:BM,Heading3:wL,Heading3Icon:wL,Heading4:HZ,Heading4Icon:HZ,Heading5:GZ,Heading5Icon:GZ,Heading6:WZ,Heading6Icon:WZ,HeadingIcon:KZ,HeadphoneOff:ZZ,HeadphoneOffIcon:ZZ,Headphones:YZ,HeadphonesIcon:YZ,Headset:QZ,HeadsetIcon:QZ,Heart:Ya,HeartCrack:XZ,HeartCrackIcon:XZ,HeartHandshake:JZ,HeartHandshakeIcon:JZ,HeartIcon:Ya,HeartOff:eY,HeartOffIcon:eY,HeartPulse:tY,HeartPulseIcon:tY,Heater:sY,HeaterIcon:sY,HelpCircle:Bv,HelpCircleIcon:Bv,HelpingHand:bN,HelpingHandIcon:bN,Hexagon:rY,HexagonIcon:rY,Highlighter:nY,HighlighterIcon:nY,History:$M,HistoryIcon:$M,Home:dn,HomeIcon:dn,Hop:iY,HopIcon:iY,HopOff:aY,HopOffIcon:aY,Hospital:oY,HospitalIcon:oY,Hotel:lY,HotelIcon:lY,Hourglass:cY,HourglassIcon:cY,House:dn,HouseIcon:dn,HousePlug:dY,HousePlugIcon:dY,HousePlus:uY,HousePlusIcon:uY,IceCream:wN,IceCream2:_N,IceCream2Icon:_N,IceCreamBowl:_N,IceCreamBowlIcon:_N,IceCreamCone:wN,IceCreamConeIcon:wN,IceCreamIcon:wN,Icon:jqe,IdCard:hY,IdCardIcon:hY,Image:vl,ImageDown:mY,ImageDownIcon:mY,ImageIcon:vl,ImageMinus:pY,ImageMinusIcon:pY,ImageOff:fY,ImageOffIcon:fY,ImagePlay:xY,ImagePlayIcon:xY,ImagePlus:u1,ImagePlusIcon:u1,ImageUp:gY,ImageUpIcon:gY,ImageUpscale:yY,ImageUpscaleIcon:yY,Images:vY,ImagesIcon:vY,Import:bY,ImportIcon:bY,Inbox:_Y,InboxIcon:_Y,Indent:NN,IndentDecrease:jN,IndentDecreaseIcon:jN,IndentIcon:NN,IndentIncrease:NN,IndentIncreaseIcon:NN,IndianRupee:wY,IndianRupeeIcon:wY,Infinity:jY,InfinityIcon:jY,Info:jL,InfoIcon:jL,Inspect:Mk,InspectIcon:Mk,InspectionPanel:NY,InspectionPanelIcon:NY,Instagram:Tu,InstagramIcon:Tu,Italic:oS,ItalicIcon:oS,IterationCcw:kY,IterationCcwIcon:kY,IterationCw:SY,IterationCwIcon:SY,JapaneseYen:CY,JapaneseYenIcon:CY,Joystick:MY,JoystickIcon:MY,Kanban:f0,KanbanIcon:f0,KanbanSquare:jk,KanbanSquareDashed:xk,KanbanSquareDashedIcon:xk,KanbanSquareIcon:jk,Key:Sp,KeyIcon:Sp,KeyRound:lS,KeyRoundIcon:lS,KeySquare:TY,KeySquareIcon:TY,Keyboard:PY,KeyboardIcon:PY,KeyboardMusic:AY,KeyboardMusicIcon:AY,KeyboardOff:EY,KeyboardOffIcon:EY,Lamp:FY,LampCeiling:IY,LampCeilingIcon:IY,LampDesk:LY,LampDeskIcon:LY,LampFloor:DY,LampFloorIcon:DY,LampIcon:FY,LampWallDown:OY,LampWallDownIcon:OY,LampWallUp:RY,LampWallUpIcon:RY,LandPlot:zY,LandPlotIcon:zY,Landmark:BY,LandmarkIcon:BY,Languages:$Y,LanguagesIcon:$Y,Laptop:UY,Laptop2:kN,Laptop2Icon:kN,LaptopIcon:UY,LaptopMinimal:kN,LaptopMinimalCheck:qY,LaptopMinimalCheckIcon:qY,LaptopMinimalIcon:kN,Lasso:HY,LassoIcon:HY,LassoSelect:VY,LassoSelectIcon:VY,Laugh:GY,LaughIcon:GY,Layers:qM,Layers2:WY,Layers2Icon:WY,Layers3:KY,Layers3Icon:KY,LayersIcon:qM,Layout:qv,LayoutDashboard:cS,LayoutDashboardIcon:cS,LayoutGrid:Cp,LayoutGridIcon:Cp,LayoutIcon:qv,LayoutList:ZY,LayoutListIcon:ZY,LayoutPanelLeft:YY,LayoutPanelLeftIcon:YY,LayoutPanelTop:QY,LayoutPanelTopIcon:QY,LayoutTemplate:dS,LayoutTemplateIcon:dS,Leaf:XY,LeafIcon:XY,LeafyGreen:JY,LeafyGreenIcon:JY,Lectern:eQ,LecternIcon:eQ,LetterText:tQ,LetterTextIcon:tQ,Library:UM,LibraryBig:sQ,LibraryBigIcon:sQ,LibraryIcon:UM,LibrarySquare:Nk,LibrarySquareIcon:Nk,LifeBuoy:VM,LifeBuoyIcon:VM,Ligature:rQ,LigatureIcon:rQ,Lightbulb:Z_,LightbulbIcon:Z_,LightbulbOff:nQ,LightbulbOffIcon:nQ,LineChart:bj,LineChartIcon:bj,Link:Bo,Link2:ml,Link2Icon:ml,Link2Off:aQ,Link2OffIcon:aQ,LinkIcon:Bo,Linkedin:Mp,LinkedinIcon:Mp,List:rh,ListCheck:iQ,ListCheckIcon:iQ,ListChecks:oQ,ListChecksIcon:oQ,ListCollapse:lQ,ListCollapseIcon:lQ,ListEnd:cQ,ListEndIcon:cQ,ListFilter:dQ,ListFilterIcon:dQ,ListIcon:rh,ListMinus:uQ,ListMinusIcon:uQ,ListMusic:hQ,ListMusicIcon:hQ,ListOrdered:x0,ListOrderedIcon:x0,ListPlus:mQ,ListPlusIcon:mQ,ListRestart:pQ,ListRestartIcon:pQ,ListStart:fQ,ListStartIcon:fQ,ListTodo:xQ,ListTodoIcon:xQ,ListTree:gQ,ListTreeIcon:gQ,ListVideo:yQ,ListVideoIcon:yQ,ListX:vQ,ListXIcon:vQ,Loader:_Q,Loader2:bs,Loader2Icon:bs,LoaderCircle:bs,LoaderCircleIcon:bs,LoaderIcon:_Q,LoaderPinwheel:bQ,LoaderPinwheelIcon:bQ,Locate:NQ,LocateFixed:wQ,LocateFixedIcon:wQ,LocateIcon:NQ,LocateOff:jQ,LocateOffIcon:jQ,Lock:Eh,LockIcon:Eh,LockKeyhole:kQ,LockKeyholeIcon:kQ,LockKeyholeOpen:SN,LockKeyholeOpenIcon:SN,LockOpen:CN,LockOpenIcon:CN,LogIn:uS,LogInIcon:uS,LogOut:hS,LogOutIcon:hS,Logs:SQ,LogsIcon:SQ,Lollipop:CQ,LollipopIcon:CQ,LucideAArrowDown:L9,LucideAArrowUp:D9,LucideALargeSmall:O9,LucideAccessibility:R9,LucideActivity:Ch,LucideActivitySquare:ZN,LucideAirVent:F9,LucideAirplay:z9,LucideAlarmCheck:X2,LucideAlarmClock:$9,LucideAlarmClockCheck:X2,LucideAlarmClockMinus:J2,LucideAlarmClockOff:B9,LucideAlarmClockPlus:ej,LucideAlarmMinus:J2,LucideAlarmPlus:ej,LucideAlarmSmoke:q9,LucideAlbum:U9,LucideAlertCircle:Cl,LucideAlertOctagon:$v,LucideAlertTriangle:Yu,LucideAlignCenter:Q4,LucideAlignCenterHorizontal:V9,LucideAlignCenterVertical:H9,LucideAlignEndHorizontal:G9,LucideAlignEndVertical:W9,LucideAlignHorizontalDistributeCenter:K9,LucideAlignHorizontalDistributeEnd:Z9,LucideAlignHorizontalDistributeStart:Y9,LucideAlignHorizontalJustifyCenter:Q9,LucideAlignHorizontalJustifyEnd:X9,LucideAlignHorizontalJustifyStart:J9,LucideAlignHorizontalSpaceAround:eB,LucideAlignHorizontalSpaceBetween:tB,LucideAlignJustify:sB,LucideAlignLeft:X4,LucideAlignRight:J4,LucideAlignStartHorizontal:rB,LucideAlignStartVertical:nB,LucideAlignVerticalDistributeCenter:aB,LucideAlignVerticalDistributeEnd:iB,LucideAlignVerticalDistributeStart:oB,LucideAlignVerticalJustifyCenter:lB,LucideAlignVerticalJustifyEnd:cB,LucideAlignVerticalJustifyStart:dB,LucideAlignVerticalSpaceAround:uB,LucideAlignVerticalSpaceBetween:hB,LucideAmbulance:mB,LucideAmpersand:pB,LucideAmpersands:fB,LucideAmphora:xB,LucideAnchor:gB,LucideAngry:yB,LucideAnnoyed:vB,LucideAntenna:bB,LucideAnvil:_B,LucideAperture:wB,LucideAppWindow:sL,LucideAppWindowMac:jB,LucideApple:NB,LucideArchive:IM,LucideArchiveRestore:rL,LucideArchiveX:kB,LucideAreaChart:pj,LucideArmchair:SB,LucideArrowBigDown:MB,LucideArrowBigDownDash:CB,LucideArrowBigLeft:AB,LucideArrowBigLeftDash:TB,LucideArrowBigRight:PB,LucideArrowBigRightDash:EB,LucideArrowBigUp:LB,LucideArrowBigUpDash:IB,LucideArrowDown:Kh,LucideArrowDown01:DB,LucideArrowDown10:OB,LucideArrowDownAZ:tj,LucideArrowDownAz:tj,LucideArrowDownCircle:Sj,LucideArrowDownFromLine:RB,LucideArrowDownLeft:FB,LucideArrowDownLeftFromCircle:Mj,LucideArrowDownLeftFromSquare:ek,LucideArrowDownLeftSquare:YN,LucideArrowDownNarrowWide:zB,LucideArrowDownRight:nL,LucideArrowDownRightFromCircle:Tj,LucideArrowDownRightFromSquare:tk,LucideArrowDownRightSquare:QN,LucideArrowDownSquare:XN,LucideArrowDownToDot:BB,LucideArrowDownToLine:$B,LucideArrowDownUp:qB,LucideArrowDownWideNarrow:sj,LucideArrowDownZA:rj,LucideArrowDownZa:rj,LucideArrowLeft:Qa,LucideArrowLeftCircle:Cj,LucideArrowLeftFromLine:UB,LucideArrowLeftRight:VB,LucideArrowLeftSquare:JN,LucideArrowLeftToLine:HB,LucideArrowRight:Sa,LucideArrowRightCircle:Pj,LucideArrowRightFromLine:GB,LucideArrowRightLeft:a1,LucideArrowRightSquare:nk,LucideArrowRightToLine:WB,LucideArrowUp:Su,LucideArrowUp01:KB,LucideArrowUp10:ZB,LucideArrowUpAZ:nj,LucideArrowUpAz:nj,LucideArrowUpCircle:Ij,LucideArrowUpDown:_d,LucideArrowUpFromDot:YB,LucideArrowUpFromLine:QB,LucideArrowUpLeft:XB,LucideArrowUpLeftFromCircle:Aj,LucideArrowUpLeftFromSquare:sk,LucideArrowUpLeftSquare:ak,LucideArrowUpNarrowWide:aj,LucideArrowUpRight:aL,LucideArrowUpRightFromCircle:Ej,LucideArrowUpRightFromSquare:rk,LucideArrowUpRightSquare:ik,LucideArrowUpSquare:ok,LucideArrowUpToLine:JB,LucideArrowUpWideNarrow:e$,LucideArrowUpZA:ij,LucideArrowUpZa:ij,LucideArrowsUpFromLine:t$,LucideAsterisk:s$,LucideAsteriskSquare:lk,LucideAtSign:r$,LucideAtom:n$,LucideAudioLines:a$,LucideAudioWaveform:i$,LucideAward:tc,LucideAxe:o$,LucideAxis3D:oj,LucideAxis3d:oj,LucideBaby:l$,LucideBackpack:c$,LucideBadge:k$,LucideBadgeAlert:d$,LucideBadgeCent:u$,LucideBadgeCheck:lj,LucideBadgeDollarSign:h$,LucideBadgeEuro:m$,LucideBadgeHelp:p$,LucideBadgeIndianRupee:f$,LucideBadgeInfo:x$,LucideBadgeJapaneseYen:g$,LucideBadgeMinus:y$,LucideBadgePercent:v$,LucideBadgePlus:b$,LucideBadgePoundSterling:_$,LucideBadgeRussianRuble:w$,LucideBadgeSwissFranc:j$,LucideBadgeX:N$,LucideBaggageClaim:S$,LucideBan:iL,LucideBanana:C$,LucideBandage:M$,LucideBanknote:T$,LucideBarChart:_j,LucideBarChart2:wj,LucideBarChart3:yo,LucideBarChart4:vj,LucideBarChartBig:yj,LucideBarChartHorizontal:xj,LucideBarChartHorizontalBig:fj,LucideBarcode:A$,LucideBaseline:E$,LucideBath:su,LucideBattery:R$,LucideBatteryCharging:P$,LucideBatteryFull:I$,LucideBatteryLow:L$,LucideBatteryMedium:D$,LucideBatteryWarning:O$,LucideBeaker:F$,LucideBean:B$,LucideBeanOff:z$,LucideBed:Mh,LucideBedDouble:eS,LucideBedSingle:$$,LucideBeef:q$,LucideBeer:V$,LucideBeerOff:U$,LucideBell:Lm,LucideBellDot:H$,LucideBellElectric:G$,LucideBellMinus:W$,LucideBellOff:i1,LucideBellPlus:K$,LucideBellRing:Z$,LucideBetweenHorizonalEnd:cj,LucideBetweenHorizonalStart:dj,LucideBetweenHorizontalEnd:cj,LucideBetweenHorizontalStart:dj,LucideBetweenVerticalEnd:Y$,LucideBetweenVerticalStart:Q$,LucideBicepsFlexed:X$,LucideBike:J$,LucideBinary:eq,LucideBinoculars:tq,LucideBiohazard:sq,LucideBird:rq,LucideBitcoin:nq,LucideBlend:aq,LucideBlinds:iq,LucideBlocks:oq,LucideBluetooth:uq,LucideBluetoothConnected:lq,LucideBluetoothOff:cq,LucideBluetoothSearching:dq,LucideBold:tS,LucideBolt:hq,LucideBomb:mq,LucideBone:pq,LucideBook:Oq,LucideBookA:fq,LucideBookAudio:xq,LucideBookCheck:gq,LucideBookCopy:yq,LucideBookDashed:uj,LucideBookDown:vq,LucideBookHeadphones:bq,LucideBookHeart:_q,LucideBookImage:wq,LucideBookKey:jq,LucideBookLock:Nq,LucideBookMarked:kq,LucideBookMinus:Sq,LucideBookOpen:Th,LucideBookOpenCheck:Cq,LucideBookOpenText:Mq,LucideBookPlus:Tq,LucideBookTemplate:uj,LucideBookText:Aq,LucideBookType:Eq,LucideBookUp:Iq,LucideBookUp2:Pq,LucideBookUser:Lq,LucideBookX:Dq,LucideBookmark:Sx,LucideBookmarkCheck:Rq,LucideBookmarkMinus:Fq,LucideBookmarkPlus:oL,LucideBookmarkX:zq,LucideBoomBox:Bq,LucideBot:LM,LucideBotMessageSquare:$q,LucideBotOff:qq,LucideBox:Uq,LucideBoxSelect:yk,LucideBoxes:Vq,LucideBraces:hj,LucideBrackets:Hq,LucideBrain:lL,LucideBrainCircuit:Gq,LucideBrainCog:Wq,LucideBrickWall:Kq,LucideBriefcase:th,LucideBriefcaseBusiness:Zq,LucideBriefcaseConveyorBelt:Yq,LucideBriefcaseMedical:Qq,LucideBringToFront:Xq,LucideBrush:Jq,LucideBug:sU,LucideBugOff:eU,LucideBugPlay:tU,LucideBuilding:sS,LucideBuilding2:Ca,LucideBus:nU,LucideBusFront:rU,LucideCable:iU,LucideCableCar:aU,LucideCake:Ah,LucideCakeSlice:oU,LucideCalculator:cL,LucideCalendar:hn,LucideCalendar1:lU,LucideCalendarArrowDown:cU,LucideCalendarArrowUp:dU,LucideCalendarCheck:dL,LucideCalendarCheck2:uU,LucideCalendarClock:uL,LucideCalendarCog:hU,LucideCalendarDays:Od,LucideCalendarFold:mU,LucideCalendarHeart:pU,LucideCalendarMinus:xU,LucideCalendarMinus2:fU,LucideCalendarOff:hL,LucideCalendarPlus:V_,LucideCalendarPlus2:gU,LucideCalendarRange:yU,LucideCalendarSearch:vU,LucideCalendarSync:bU,LucideCalendarX:wU,LucideCalendarX2:_U,LucideCamera:ff,LucideCameraOff:jU,LucideCandlestickChart:gj,LucideCandy:SU,LucideCandyCane:NU,LucideCandyOff:kU,LucideCannabis:CU,LucideCaptions:mj,LucideCaptionsOff:MU,LucideCar:DM,LucideCarFront:TU,LucideCarTaxiFront:AU,LucideCaravan:EU,LucideCarrot:PU,LucideCaseLower:IU,LucideCaseSensitive:LU,LucideCaseUpper:DU,LucideCassetteTape:OU,LucideCast:RU,LucideCastle:FU,LucideCat:zU,LucideCctv:BU,LucideChartArea:pj,LucideChartBar:xj,LucideChartBarBig:fj,LucideChartBarDecreasing:$U,LucideChartBarIncreasing:qU,LucideChartBarStacked:UU,LucideChartCandlestick:gj,LucideChartColumn:yo,LucideChartColumnBig:yj,LucideChartColumnDecreasing:VU,LucideChartColumnIncreasing:vj,LucideChartColumnStacked:HU,LucideChartGantt:GU,LucideChartLine:bj,LucideChartNetwork:WU,LucideChartNoAxesColumn:wj,LucideChartNoAxesColumnDecreasing:KU,LucideChartNoAxesColumnIncreasing:_j,LucideChartNoAxesCombined:ZU,LucideChartNoAxesGantt:jj,LucideChartPie:Nj,LucideChartScatter:kj,LucideChartSpline:YU,LucideCheck:ba,LucideCheckCheck:mL,LucideCheckCircle:gi,LucideCheckCircle2:sa,LucideCheckSquare:Vv,LucideCheckSquare2:dk,LucideChefHat:QU,LucideCherry:XU,LucideChevronDown:oo,LucideChevronDownCircle:Lj,LucideChevronDownSquare:uk,LucideChevronFirst:JU,LucideChevronLast:eV,LucideChevronLeft:Xo,LucideChevronLeftCircle:Dj,LucideChevronLeftSquare:hk,LucideChevronRight:oa,LucideChevronRightCircle:Oj,LucideChevronRightSquare:mk,LucideChevronUp:xf,LucideChevronUpCircle:Rj,LucideChevronUpSquare:pk,LucideChevronsDown:sV,LucideChevronsDownUp:tV,LucideChevronsLeft:aV,LucideChevronsLeftRight:nV,LucideChevronsLeftRightEllipsis:rV,LucideChevronsRight:oV,LucideChevronsRightLeft:iV,LucideChevronsUp:lV,LucideChevronsUpDown:Cx,LucideChrome:cV,LucideChurch:dV,LucideCigarette:hV,LucideCigaretteOff:uV,LucideCircle:wd,LucideCircleAlert:Cl,LucideCircleArrowDown:Sj,LucideCircleArrowLeft:Cj,LucideCircleArrowOutDownLeft:Mj,LucideCircleArrowOutDownRight:Tj,LucideCircleArrowOutUpLeft:Aj,LucideCircleArrowOutUpRight:Ej,LucideCircleArrowRight:Pj,LucideCircleArrowUp:Ij,LucideCircleCheck:sa,LucideCircleCheckBig:gi,LucideCircleChevronDown:Lj,LucideCircleChevronLeft:Dj,LucideCircleChevronRight:Oj,LucideCircleChevronUp:Rj,LucideCircleDashed:mV,LucideCircleDivide:Fj,LucideCircleDollarSign:pV,LucideCircleDot:xV,LucideCircleDotDashed:fV,LucideCircleEllipsis:gV,LucideCircleEqual:yV,LucideCircleFadingArrowUp:vV,LucideCircleFadingPlus:bV,LucideCircleGauge:zj,LucideCircleHelp:Bv,LucideCircleMinus:Bj,LucideCircleOff:_V,LucideCircleParking:qj,LucideCircleParkingOff:$j,LucideCirclePause:Uj,LucideCirclePercent:Vj,LucideCirclePlay:pp,LucideCirclePlus:Hj,LucideCirclePower:Gj,LucideCircleSlash:wV,LucideCircleSlash2:Wj,LucideCircleSlashed:Wj,LucideCircleStop:Kj,LucideCircleUser:Yj,LucideCircleUserRound:Zj,LucideCircleX:jc,LucideCircuitBoard:jV,LucideCitrus:NV,LucideClapperboard:kV,LucideClipboard:PV,LucideClipboardCheck:OM,LucideClipboardCopy:SV,LucideClipboardEdit:Xj,LucideClipboardList:H_,LucideClipboardMinus:CV,LucideClipboardPaste:MV,LucideClipboardPen:Xj,LucideClipboardPenLine:Qj,LucideClipboardPlus:TV,LucideClipboardSignature:Qj,LucideClipboardType:AV,LucideClipboardX:EV,LucideClock:un,LucideClock1:IV,LucideClock10:LV,LucideClock11:DV,LucideClock12:OV,LucideClock2:RV,LucideClock3:FV,LucideClock4:zV,LucideClock5:BV,LucideClock6:$V,LucideClock7:qV,LucideClock8:UV,LucideClock9:VV,LucideClockAlert:HV,LucideClockArrowDown:GV,LucideClockArrowUp:WV,LucideCloud:lH,LucideCloudAlert:KV,LucideCloudCog:ZV,LucideCloudDownload:Jj,LucideCloudDrizzle:YV,LucideCloudFog:QV,LucideCloudHail:XV,LucideCloudLightning:JV,LucideCloudMoon:tH,LucideCloudMoonRain:eH,LucideCloudOff:sH,LucideCloudRain:nH,LucideCloudRainWind:rH,LucideCloudSnow:aH,LucideCloudSun:oH,LucideCloudSunRain:iH,LucideCloudUpload:eN,LucideCloudy:cH,LucideClover:Jv,LucideClub:dH,LucideCode:rS,LucideCode2:tN,LucideCodeSquare:fk,LucideCodeXml:tN,LucideCodepen:uH,LucideCodesandbox:hH,LucideCoffee:nS,LucideCog:mH,LucideCoins:pL,LucideColumns:sN,LucideColumns2:sN,LucideColumns3:rN,LucideColumns4:pH,LucideCombine:fH,LucideCommand:xH,LucideCompass:o1,LucideComponent:gH,LucideComputer:yH,LucideConciergeBell:vH,LucideCone:bH,LucideConstruction:_H,LucideContact:aS,LucideContact2:nN,LucideContactRound:nN,LucideContainer:wH,LucideContrast:jH,LucideCookie:NH,LucideCookingPot:kH,LucideCopy:yi,LucideCopyCheck:SH,LucideCopyMinus:CH,LucideCopyPlus:MH,LucideCopySlash:TH,LucideCopyX:AH,LucideCopyleft:EH,LucideCopyright:PH,LucideCornerDownLeft:IH,LucideCornerDownRight:LH,LucideCornerLeftDown:DH,LucideCornerLeftUp:OH,LucideCornerRightDown:RH,LucideCornerRightUp:FH,LucideCornerUpLeft:zH,LucideCornerUpRight:BH,LucideCpu:$H,LucideCreativeCommons:qH,LucideCreditCard:Mx,LucideCroissant:UH,LucideCrop:VH,LucideCross:HH,LucideCrosshair:GH,LucideCrown:Dm,LucideCuboid:WH,LucideCupSoda:KH,LucideCurlyBraces:hj,LucideCurrency:ZH,LucideCylinder:YH,LucideDam:QH,LucideDatabase:fL,LucideDatabaseBackup:XH,LucideDatabaseZap:JH,LucideDelete:eG,LucideDessert:tG,LucideDiameter:sG,LucideDiamond:aG,LucideDiamondMinus:rG,LucideDiamondPercent:aN,LucideDiamondPlus:nG,LucideDice1:iG,LucideDice2:oG,LucideDice3:lG,LucideDice4:cG,LucideDice5:dG,LucideDice6:uG,LucideDices:hG,LucideDiff:mG,LucideDisc:gG,LucideDisc2:pG,LucideDisc3:fG,LucideDiscAlbum:xG,LucideDivide:yG,LucideDivideCircle:Fj,LucideDivideSquare:vk,LucideDna:bG,LucideDnaOff:vG,LucideDock:_G,LucideDog:wG,LucideDollarSign:hl,LucideDonut:jG,LucideDoorClosed:NG,LucideDoorOpen:l1,LucideDot:kG,LucideDotSquare:bk,LucideDownload:vi,LucideDownloadCloud:Jj,LucideDraftingCompass:SG,LucideDrama:CG,LucideDribbble:MG,LucideDrill:TG,LucideDroplet:AG,LucideDroplets:Jg,LucideDrum:EG,LucideDrumstick:PG,LucideDumbbell:IG,LucideEar:DG,LucideEarOff:LG,LucideEarth:iN,LucideEarthLock:OG,LucideEclipse:RG,LucideEdit:md,LucideEdit2:s0,LucideEdit3:Uv,LucideEgg:RM,LucideEggFried:FG,LucideEggOff:zG,LucideEllipsis:xx,LucideEllipsisVertical:fx,LucideEqual:qG,LucideEqualApproximately:BG,LucideEqualNot:$G,LucideEqualSquare:_k,LucideEraser:UG,LucideEthernetPort:VG,LucideEuro:HG,LucideExpand:xL,LucideExternalLink:en,LucideEye:Dn,LucideEyeClosed:GG,LucideEyeOff:kp,LucideFacebook:Cu,LucideFactory:WG,LucideFan:KG,LucideFastForward:ZG,LucideFeather:YG,LucideFence:QG,LucideFerrisWheel:XG,LucideFigma:JG,LucideFile:FM,LucideFileArchive:eW,LucideFileAudio:sW,LucideFileAudio2:tW,LucideFileAxis3D:oN,LucideFileAxis3d:oN,LucideFileBadge:nW,LucideFileBadge2:rW,LucideFileBarChart:lN,LucideFileBarChart2:cN,LucideFileBox:aW,LucideFileChartColumn:cN,LucideFileChartColumnIncreasing:lN,LucideFileChartLine:dN,LucideFileChartPie:uN,LucideFileCheck:oW,LucideFileCheck2:iW,LucideFileClock:lW,LucideFileCode:dW,LucideFileCode2:cW,LucideFileCog:hN,LucideFileCog2:hN,LucideFileDiff:uW,LucideFileDigit:hW,LucideFileDown:mW,LucideFileEdit:pN,LucideFileHeart:pW,LucideFileImage:G_,LucideFileInput:fW,LucideFileJson:gW,LucideFileJson2:xW,LucideFileKey:vW,LucideFileKey2:yW,LucideFileLineChart:dN,LucideFileLock:_W,LucideFileLock2:bW,LucideFileMinus:jW,LucideFileMinus2:wW,LucideFileMusic:NW,LucideFileOutput:kW,LucideFilePen:pN,LucideFilePenLine:mN,LucideFilePieChart:uN,LucideFilePlus:CW,LucideFilePlus2:SW,LucideFileQuestion:MW,LucideFileScan:TW,LucideFileSearch:EW,LucideFileSearch2:AW,LucideFileSignature:mN,LucideFileSliders:PW,LucideFileSpreadsheet:c1,LucideFileStack:gL,LucideFileSymlink:IW,LucideFileTerminal:LW,LucideFileText:wn,LucideFileType:OW,LucideFileType2:DW,LucideFileUp:RW,LucideFileUser:FW,LucideFileVideo:BW,LucideFileVideo2:zW,LucideFileVolume:qW,LucideFileVolume2:$W,LucideFileWarning:UW,LucideFileX:HW,LucideFileX2:VW,LucideFiles:GW,LucideFilm:yu,LucideFilter:ey,LucideFilterX:WW,LucideFingerprint:KW,LucideFireExtinguisher:ZW,LucideFish:XW,LucideFishOff:YW,LucideFishSymbol:QW,LucideFlag:d1,LucideFlagOff:JW,LucideFlagTriangleLeft:eK,LucideFlagTriangleRight:tK,LucideFlame:sh,LucideFlameKindling:sK,LucideFlashlight:nK,LucideFlashlightOff:rK,LucideFlaskConical:W_,LucideFlaskConicalOff:aK,LucideFlaskRound:iK,LucideFlipHorizontal:yL,LucideFlipHorizontal2:oK,LucideFlipVertical:cK,LucideFlipVertical2:lK,LucideFlower:dK,LucideFlower2:Kg,LucideFocus:uK,LucideFoldHorizontal:hK,LucideFoldVertical:mK,LucideFolder:BK,LucideFolderArchive:pK,LucideFolderCheck:fK,LucideFolderClock:xK,LucideFolderClosed:gK,LucideFolderCode:yK,LucideFolderCog:fN,LucideFolderCog2:fN,LucideFolderDot:vK,LucideFolderDown:bK,LucideFolderEdit:xN,LucideFolderGit:wK,LucideFolderGit2:_K,LucideFolderHeart:jK,LucideFolderInput:NK,LucideFolderKanban:kK,LucideFolderKey:SK,LucideFolderLock:CK,LucideFolderMinus:MK,LucideFolderOpen:Om,LucideFolderOpenDot:TK,LucideFolderOutput:AK,LucideFolderPen:xN,LucideFolderPlus:EK,LucideFolderRoot:PK,LucideFolderSearch:LK,LucideFolderSearch2:IK,LucideFolderSymlink:DK,LucideFolderSync:OK,LucideFolderTree:RK,LucideFolderUp:FK,LucideFolderX:zK,LucideFolders:$K,LucideFootprints:qK,LucideForkKnife:i4,LucideForkKnifeCrossed:a4,LucideForklift:UK,LucideFormInput:$N,LucideForward:VK,LucideFrame:HK,LucideFramer:GK,LucideFrown:WK,LucideFuel:KK,LucideFullscreen:ZK,LucideFunctionSquare:wk,LucideGalleryHorizontal:QK,LucideGalleryHorizontalEnd:YK,LucideGalleryThumbnails:XK,LucideGalleryVertical:eZ,LucideGalleryVerticalEnd:JK,LucideGamepad:sZ,LucideGamepad2:tZ,LucideGanttChart:jj,LucideGanttChartSquare:Gy,LucideGauge:rZ,LucideGaugeCircle:zj,LucideGavel:nZ,LucideGem:aZ,LucideGhost:iS,LucideGift:So,LucideGitBranch:oZ,LucideGitBranchPlus:iZ,LucideGitCommit:gN,LucideGitCommitHorizontal:gN,LucideGitCommitVertical:lZ,LucideGitCompare:dZ,LucideGitCompareArrows:cZ,LucideGitFork:uZ,LucideGitGraph:hZ,LucideGitMerge:mZ,LucideGitPullRequest:vZ,LucideGitPullRequestArrow:pZ,LucideGitPullRequestClosed:fZ,LucideGitPullRequestCreate:gZ,LucideGitPullRequestCreateArrow:xZ,LucideGitPullRequestDraft:yZ,LucideGithub:bZ,LucideGitlab:_Z,LucideGlassWater:wZ,LucideGlasses:jZ,LucideGlobe:ru,LucideGlobe2:iN,LucideGlobeLock:NZ,LucideGoal:kZ,LucideGrab:SZ,LucideGraduationCap:Zh,LucideGrape:CZ,LucideGrid:ix,LucideGrid2X2:vN,LucideGrid2X2Plus:yN,LucideGrid2x2:vN,LucideGrid2x2Check:MZ,LucideGrid2x2Plus:yN,LucideGrid2x2X:TZ,LucideGrid3X3:ix,LucideGrid3x3:ix,LucideGrip:EZ,LucideGripHorizontal:AZ,LucideGripVertical:Mu,LucideGroup:PZ,LucideGuitar:IZ,LucideHam:LZ,LucideHammer:DZ,LucideHand:vL,LucideHandCoins:OZ,LucideHandHeart:RZ,LucideHandHelping:bN,LucideHandMetal:FZ,LucideHandPlatter:zZ,LucideHandshake:bL,LucideHardDrive:_L,LucideHardDriveDownload:BZ,LucideHardDriveUpload:$Z,LucideHardHat:qZ,LucideHash:K_,LucideHaze:UZ,LucideHdmiPort:VZ,LucideHeading:KZ,LucideHeading1:zM,LucideHeading2:BM,LucideHeading3:wL,LucideHeading4:HZ,LucideHeading5:GZ,LucideHeading6:WZ,LucideHeadphoneOff:ZZ,LucideHeadphones:YZ,LucideHeadset:QZ,LucideHeart:Ya,LucideHeartCrack:XZ,LucideHeartHandshake:JZ,LucideHeartOff:eY,LucideHeartPulse:tY,LucideHeater:sY,LucideHelpCircle:Bv,LucideHelpingHand:bN,LucideHexagon:rY,LucideHighlighter:nY,LucideHistory:$M,LucideHome:dn,LucideHop:iY,LucideHopOff:aY,LucideHospital:oY,LucideHotel:lY,LucideHourglass:cY,LucideHouse:dn,LucideHousePlug:dY,LucideHousePlus:uY,LucideIceCream:wN,LucideIceCream2:_N,LucideIceCreamBowl:_N,LucideIceCreamCone:wN,LucideIdCard:hY,LucideImage:vl,LucideImageDown:mY,LucideImageMinus:pY,LucideImageOff:fY,LucideImagePlay:xY,LucideImagePlus:u1,LucideImageUp:gY,LucideImageUpscale:yY,LucideImages:vY,LucideImport:bY,LucideInbox:_Y,LucideIndent:NN,LucideIndentDecrease:jN,LucideIndentIncrease:NN,LucideIndianRupee:wY,LucideInfinity:jY,LucideInfo:jL,LucideInspect:Mk,LucideInspectionPanel:NY,LucideInstagram:Tu,LucideItalic:oS,LucideIterationCcw:kY,LucideIterationCw:SY,LucideJapaneseYen:CY,LucideJoystick:MY,LucideKanban:f0,LucideKanbanSquare:jk,LucideKanbanSquareDashed:xk,LucideKey:Sp,LucideKeyRound:lS,LucideKeySquare:TY,LucideKeyboard:PY,LucideKeyboardMusic:AY,LucideKeyboardOff:EY,LucideLamp:FY,LucideLampCeiling:IY,LucideLampDesk:LY,LucideLampFloor:DY,LucideLampWallDown:OY,LucideLampWallUp:RY,LucideLandPlot:zY,LucideLandmark:BY,LucideLanguages:$Y,LucideLaptop:UY,LucideLaptop2:kN,LucideLaptopMinimal:kN,LucideLaptopMinimalCheck:qY,LucideLasso:HY,LucideLassoSelect:VY,LucideLaugh:GY,LucideLayers:qM,LucideLayers2:WY,LucideLayers3:KY,LucideLayout:qv,LucideLayoutDashboard:cS,LucideLayoutGrid:Cp,LucideLayoutList:ZY,LucideLayoutPanelLeft:YY,LucideLayoutPanelTop:QY,LucideLayoutTemplate:dS,LucideLeaf:XY,LucideLeafyGreen:JY,LucideLectern:eQ,LucideLetterText:tQ,LucideLibrary:UM,LucideLibraryBig:sQ,LucideLibrarySquare:Nk,LucideLifeBuoy:VM,LucideLigature:rQ,LucideLightbulb:Z_,LucideLightbulbOff:nQ,LucideLineChart:bj,LucideLink:Bo,LucideLink2:ml,LucideLink2Off:aQ,LucideLinkedin:Mp,LucideList:rh,LucideListCheck:iQ,LucideListChecks:oQ,LucideListCollapse:lQ,LucideListEnd:cQ,LucideListFilter:dQ,LucideListMinus:uQ,LucideListMusic:hQ,LucideListOrdered:x0,LucideListPlus:mQ,LucideListRestart:pQ,LucideListStart:fQ,LucideListTodo:xQ,LucideListTree:gQ,LucideListVideo:yQ,LucideListX:vQ,LucideLoader:_Q,LucideLoader2:bs,LucideLoaderCircle:bs,LucideLoaderPinwheel:bQ,LucideLocate:NQ,LucideLocateFixed:wQ,LucideLocateOff:jQ,LucideLock:Eh,LucideLockKeyhole:kQ,LucideLockKeyholeOpen:SN,LucideLockOpen:CN,LucideLogIn:uS,LucideLogOut:hS,LucideLogs:SQ,LucideLollipop:CQ,LucideLuggage:MQ,LucideMSquare:kk,LucideMagnet:TQ,LucideMail:lr,LucideMailCheck:AQ,LucideMailMinus:EQ,LucideMailOpen:PQ,LucideMailPlus:NL,LucideMailQuestion:IQ,LucideMailSearch:LQ,LucideMailWarning:DQ,LucideMailX:kL,LucideMailbox:OQ,LucideMails:RQ,LucideMap:g0,LucideMapPin:ia,LucideMapPinCheck:zQ,LucideMapPinCheckInside:FQ,LucideMapPinHouse:BQ,LucideMapPinMinus:qQ,LucideMapPinMinusInside:$Q,LucideMapPinOff:UQ,LucideMapPinPlus:HQ,LucideMapPinPlusInside:VQ,LucideMapPinX:WQ,LucideMapPinXInside:GQ,LucideMapPinned:KQ,LucideMartini:ZQ,LucideMaximize:mS,LucideMaximize2:YQ,LucideMedal:h1,LucideMegaphone:Ph,LucideMegaphoneOff:QQ,LucideMeh:XQ,LucideMemoryStick:JQ,LucideMenu:pS,LucideMenuSquare:Sk,LucideMerge:eX,LucideMessageCircle:qc,LucideMessageCircleCode:tX,LucideMessageCircleDashed:sX,LucideMessageCircleHeart:HM,LucideMessageCircleMore:rX,LucideMessageCircleOff:nX,LucideMessageCirclePlus:aX,LucideMessageCircleQuestion:SL,LucideMessageCircleReply:iX,LucideMessageCircleWarning:oX,LucideMessageCircleX:lX,LucideMessageSquare:so,LucideMessageSquareCode:cX,LucideMessageSquareDashed:dX,LucideMessageSquareDiff:uX,LucideMessageSquareDot:hX,LucideMessageSquareHeart:mX,LucideMessageSquareLock:pX,LucideMessageSquareMore:CL,LucideMessageSquareOff:fX,LucideMessageSquarePlus:GM,LucideMessageSquareQuote:ML,LucideMessageSquareReply:xX,LucideMessageSquareShare:gX,LucideMessageSquareText:yX,LucideMessageSquareWarning:vX,LucideMessageSquareX:bX,LucideMessagesSquare:_X,LucideMic:TL,LucideMic2:MN,LucideMicOff:wX,LucideMicVocal:MN,LucideMicrochip:jX,LucideMicroscope:NX,LucideMicrowave:kX,LucideMilestone:SX,LucideMilk:MX,LucideMilkOff:CX,LucideMinimize:AX,LucideMinimize2:TX,LucideMinus:y0,LucideMinusCircle:Bj,LucideMinusSquare:Ck,LucideMonitor:xS,LucideMonitorCheck:EX,LucideMonitorCog:PX,LucideMonitorDot:IX,LucideMonitorDown:LX,LucideMonitorOff:DX,LucideMonitorPause:OX,LucideMonitorPlay:RX,LucideMonitorSmartphone:FX,LucideMonitorSpeaker:zX,LucideMonitorStop:BX,LucideMonitorUp:fS,LucideMonitorX:$X,LucideMoon:UX,LucideMoonStar:qX,LucideMoreHorizontal:xx,LucideMoreVertical:fx,LucideMountain:AL,LucideMountainSnow:VX,LucideMouse:KX,LucideMouseOff:HX,LucideMousePointer:Nh,LucideMousePointer2:GX,LucideMousePointerBan:WX,LucideMousePointerClick:Tx,LucideMousePointerSquareDashed:gk,LucideMove:oJ,LucideMove3D:TN,LucideMove3d:TN,LucideMoveDiagonal:YX,LucideMoveDiagonal2:ZX,LucideMoveDown:JX,LucideMoveDownLeft:QX,LucideMoveDownRight:XX,LucideMoveHorizontal:eJ,LucideMoveLeft:tJ,LucideMoveRight:sJ,LucideMoveUp:aJ,LucideMoveUpLeft:rJ,LucideMoveUpRight:nJ,LucideMoveVertical:iJ,LucideMusic:uJ,LucideMusic2:lJ,LucideMusic3:cJ,LucideMusic4:dJ,LucideNavigation:fJ,LucideNavigation2:mJ,LucideNavigation2Off:hJ,LucideNavigationOff:pJ,LucideNetwork:xJ,LucideNewspaper:m1,LucideNfc:gJ,LucideNotebook:_J,LucideNotebookPen:yJ,LucideNotebookTabs:vJ,LucideNotebookText:bJ,LucideNotepadText:jJ,LucideNotepadTextDashed:wJ,LucideNut:kJ,LucideNutOff:NJ,LucideOctagon:CJ,LucideOctagonAlert:$v,LucideOctagonMinus:SJ,LucideOctagonPause:AN,LucideOctagonX:EN,LucideOmega:MJ,LucideOption:TJ,LucideOrbit:AJ,LucideOrigami:EJ,LucideOutdent:jN,LucidePackage:Al,LucidePackage2:PJ,LucidePackageCheck:IJ,LucidePackageMinus:LJ,LucidePackageOpen:DJ,LucidePackagePlus:OJ,LucidePackageSearch:RJ,LucidePackageX:FJ,LucidePaintBucket:zJ,LucidePaintRoller:BJ,LucidePaintbrush:$J,LucidePaintbrush2:PN,LucidePaintbrushVertical:PN,LucidePalette:Bl,LucidePalmtree:Zk,LucidePanelBottom:VJ,LucidePanelBottomClose:qJ,LucidePanelBottomDashed:IN,LucidePanelBottomInactive:IN,LucidePanelBottomOpen:UJ,LucidePanelLeft:RN,LucidePanelLeftClose:LN,LucidePanelLeftDashed:DN,LucidePanelLeftInactive:DN,LucidePanelLeftOpen:ON,LucidePanelRight:WJ,LucidePanelRightClose:HJ,LucidePanelRightDashed:FN,LucidePanelRightInactive:FN,LucidePanelRightOpen:GJ,LucidePanelTop:YJ,LucidePanelTopClose:KJ,LucidePanelTopDashed:zN,LucidePanelTopInactive:zN,LucidePanelTopOpen:ZJ,LucidePanelsLeftBottom:QJ,LucidePanelsLeftRight:rN,LucidePanelsRightBottom:XJ,LucidePanelsTopBottom:VN,LucidePanelsTopLeft:qv,LucidePaperclip:gS,LucideParentheses:JJ,LucideParkingCircle:qj,LucideParkingCircleOff:$j,LucideParkingMeter:eee,LucideParkingSquare:Ak,LucideParkingSquareOff:Tk,LucidePartyPopper:nu,LucidePause:Rm,LucidePauseCircle:Uj,LucidePauseOctagon:AN,LucidePawPrint:tee,LucidePcCase:see,LucidePen:s0,LucidePenBox:md,LucidePenLine:Uv,LucidePenOff:ree,LucidePenSquare:md,LucidePenTool:Y_,LucidePencil:za,LucidePencilLine:nee,LucidePencilOff:aee,LucidePencilRuler:iee,LucidePentagon:oee,LucidePercent:yS,LucidePercentCircle:Vj,LucidePercentDiamond:aN,LucidePercentSquare:Ek,LucidePersonStanding:lee,LucidePhilippinePeso:cee,LucidePhone:Mn,LucidePhoneCall:dee,LucidePhoneForwarded:uee,LucidePhoneIncoming:hee,LucidePhoneMissed:mee,LucidePhoneOff:pee,LucidePhoneOutgoing:fee,LucidePi:xee,LucidePiSquare:Pk,LucidePiano:gee,LucidePickaxe:yee,LucidePictureInPicture:bee,LucidePictureInPicture2:vee,LucidePieChart:Nj,LucidePiggyBank:_ee,LucidePilcrow:Nee,LucidePilcrowLeft:wee,LucidePilcrowRight:jee,LucidePilcrowSquare:Ik,LucidePill:See,LucidePillBottle:kee,LucidePin:Q_,LucidePinOff:EL,LucidePipette:Cee,LucidePizza:Mee,LucidePlane:Eee,LucidePlaneLanding:Tee,LucidePlaneTakeoff:Aee,LucidePlay:il,LucidePlayCircle:pp,LucidePlaySquare:Lk,LucidePlug:PL,LucidePlug2:Pee,LucidePlugZap:BN,LucidePlugZap2:BN,LucidePlus:qs,LucidePlusCircle:Hj,LucidePlusSquare:Dk,LucidePocket:Lee,LucidePocketKnife:Iee,LucidePodcast:Dee,LucidePointer:Ree,LucidePointerOff:Oee,LucidePopcorn:Fee,LucidePopsicle:zee,LucidePoundSterling:Bee,LucidePower:IL,LucidePowerCircle:Gj,LucidePowerOff:$ee,LucidePowerSquare:Ok,LucidePresentation:ty,LucidePrinter:LL,LucidePrinterCheck:qee,LucideProjector:Uee,LucideProportions:Vee,LucidePuzzle:Hee,LucidePyramid:Gee,LucideQrCode:p1,LucideQuote:f1,LucideRabbit:Wee,LucideRadar:Kee,LucideRadiation:Zee,LucideRadical:Yee,LucideRadio:x1,LucideRadioReceiver:Qee,LucideRadioTower:Xee,LucideRadius:Jee,LucideRailSymbol:ete,LucideRainbow:tte,LucideRat:ste,LucideRatio:rte,LucideReceipt:hte,LucideReceiptCent:nte,LucideReceiptEuro:ate,LucideReceiptIndianRupee:ite,LucideReceiptJapaneseYen:ote,LucideReceiptPoundSterling:lte,LucideReceiptRussianRuble:cte,LucideReceiptSwissFranc:dte,LucideReceiptText:ute,LucideRectangleEllipsis:$N,LucideRectangleHorizontal:mte,LucideRectangleVertical:pte,LucideRecycle:fte,LucideRedo:vS,LucideRedo2:xte,LucideRedoDot:gte,LucideRefreshCcw:WM,LucideRefreshCcwDot:yte,LucideRefreshCw:Wo,LucideRefreshCwOff:vte,LucideRefrigerator:bte,LucideRegex:_te,LucideRemoveFormatting:wte,LucideRepeat:DL,LucideRepeat1:jte,LucideRepeat2:Nte,LucideReplace:Ste,LucideReplaceAll:kte,LucideReply:OL,LucideReplyAll:Cte,LucideRewind:Mte,LucideRibbon:Tte,LucideRocket:v0,LucideRockingChair:Ate,LucideRollerCoaster:Ete,LucideRotate3D:qN,LucideRotate3d:qN,LucideRotateCcw:g1,LucideRotateCcwSquare:Pte,LucideRotateCw:RL,LucideRotateCwSquare:Ite,LucideRoute:Dte,LucideRouteOff:Lte,LucideRouter:Ote,LucideRows:UN,LucideRows2:UN,LucideRows3:VN,LucideRows4:Rte,LucideRss:Fte,LucideRuler:Ax,LucideRussianRuble:zte,LucideSailboat:Bte,LucideSalad:$te,LucideSandwich:qte,LucideSatellite:Vte,LucideSatelliteDish:Ute,LucideSave:Uc,LucideSaveAll:Hte,LucideSaveOff:Gte,LucideScale:FL,LucideScale3D:HN,LucideScale3d:HN,LucideScaling:Wte,LucideScan:tse,LucideScanBarcode:Kte,LucideScanEye:Zte,LucideScanFace:Yte,LucideScanLine:Qte,LucideScanQrCode:Xte,LucideScanSearch:Jte,LucideScanText:ese,LucideScatterChart:kj,LucideSchool:sse,LucideSchool2:Qk,LucideScissors:nse,LucideScissorsLineDashed:rse,LucideScissorsSquare:Rk,LucideScissorsSquareDashedBottom:ck,LucideScreenShare:ise,LucideScreenShareOff:ase,LucideScroll:lse,LucideScrollText:ose,LucideSearch:sn,LucideSearchCheck:cse,LucideSearchCode:dse,LucideSearchSlash:use,LucideSearchX:zL,LucideSection:hse,LucideSend:$n,LucideSendHorizonal:GN,LucideSendHorizontal:GN,LucideSendToBack:mse,LucideSeparatorHorizontal:pse,LucideSeparatorVertical:fse,LucideServer:vse,LucideServerCog:xse,LucideServerCrash:gse,LucideServerOff:yse,LucideSettings:Qo,LucideSettings2:BL,LucideShapes:bse,LucideShare:$L,LucideShare2:nd,LucideSheet:_se,LucideShell:wse,LucideShield:Au,LucideShieldAlert:jse,LucideShieldBan:Nse,LucideShieldCheck:qL,LucideShieldClose:WN,LucideShieldEllipsis:kse,LucideShieldHalf:Sse,LucideShieldMinus:Cse,LucideShieldOff:Mse,LucideShieldPlus:Tse,LucideShieldQuestion:Ase,LucideShieldX:WN,LucideShip:Pse,LucideShipWheel:Ese,LucideShirt:Ise,LucideShoppingBag:b0,LucideShoppingBasket:Lse,LucideShoppingCart:vp,LucideShovel:Dse,LucideShowerHead:Ose,LucideShrink:Rse,LucideShrub:Fse,LucideShuffle:bS,LucideSidebar:RN,LucideSidebarClose:LN,LucideSidebarOpen:ON,LucideSigma:zse,LucideSigmaSquare:Fk,LucideSignal:Vse,LucideSignalHigh:Bse,LucideSignalLow:$se,LucideSignalMedium:qse,LucideSignalZero:Use,LucideSignature:Hse,LucideSignpost:Wse,LucideSignpostBig:Gse,LucideSiren:Kse,LucideSkipBack:Zse,LucideSkipForward:Yse,LucideSkull:Qse,LucideSlack:Xse,LucideSlash:Jse,LucideSlashSquare:zk,LucideSlice:ere,LucideSliders:KN,LucideSlidersHorizontal:y1,LucideSlidersVertical:KN,LucideSmartphone:_0,LucideSmartphoneCharging:tre,LucideSmartphoneNfc:sre,LucideSmile:nre,LucideSmilePlus:rre,LucideSnail:are,LucideSnowflake:o0,LucideSofa:ire,LucideSortAsc:aj,LucideSortDesc:sj,LucideSoup:ore,LucideSpace:lre,LucideSpade:cre,LucideSparkle:dre,LucideSparkles:fn,LucideSpeaker:ure,LucideSpeech:hre,LucideSpellCheck:pre,LucideSpellCheck2:mre,LucideSpline:fre,LucideSplit:xre,LucideSplitSquareHorizontal:Bk,LucideSplitSquareVertical:$k,LucideSprayCan:gre,LucideSprout:yre,LucideSquare:w0,LucideSquareActivity:ZN,LucideSquareArrowDown:XN,LucideSquareArrowDownLeft:YN,LucideSquareArrowDownRight:QN,LucideSquareArrowLeft:JN,LucideSquareArrowOutDownLeft:ek,LucideSquareArrowOutDownRight:tk,LucideSquareArrowOutUpLeft:sk,LucideSquareArrowOutUpRight:rk,LucideSquareArrowRight:nk,LucideSquareArrowUp:ok,LucideSquareArrowUpLeft:ak,LucideSquareArrowUpRight:ik,LucideSquareAsterisk:lk,LucideSquareBottomDashedScissors:ck,LucideSquareChartGantt:Gy,LucideSquareCheck:dk,LucideSquareCheckBig:Vv,LucideSquareChevronDown:uk,LucideSquareChevronLeft:hk,LucideSquareChevronRight:mk,LucideSquareChevronUp:pk,LucideSquareCode:fk,LucideSquareDashed:yk,LucideSquareDashedBottom:bre,LucideSquareDashedBottomCode:vre,LucideSquareDashedKanban:xk,LucideSquareDashedMousePointer:gk,LucideSquareDivide:vk,LucideSquareDot:bk,LucideSquareEqual:_k,LucideSquareFunction:wk,LucideSquareGanttChart:Gy,LucideSquareKanban:jk,LucideSquareLibrary:Nk,LucideSquareM:kk,LucideSquareMenu:Sk,LucideSquareMinus:Ck,LucideSquareMousePointer:Mk,LucideSquareParking:Ak,LucideSquareParkingOff:Tk,LucideSquarePen:md,LucideSquarePercent:Ek,LucideSquarePi:Pk,LucideSquarePilcrow:Ik,LucideSquarePlay:Lk,LucideSquarePlus:Dk,LucideSquarePower:Ok,LucideSquareRadical:_re,LucideSquareScissors:Rk,LucideSquareSigma:Fk,LucideSquareSlash:zk,LucideSquareSplitHorizontal:Bk,LucideSquareSplitVertical:$k,LucideSquareSquare:wre,LucideSquareStack:jre,LucideSquareTerminal:qk,LucideSquareUser:Vk,LucideSquareUserRound:Uk,LucideSquareX:Hk,LucideSquircle:Nre,LucideSquirrel:kre,LucideStamp:Sre,LucideStar:Jn,LucideStarHalf:Cre,LucideStarOff:Mre,LucideStars:fn,LucideStepBack:Tre,LucideStepForward:Are,LucideStethoscope:Ere,LucideSticker:Pre,LucideStickyNote:Ire,LucideStopCircle:Kj,LucideStore:KM,LucideStretchHorizontal:Lre,LucideStretchVertical:Dre,LucideStrikethrough:UL,LucideSubscript:Ore,LucideSubtitles:mj,LucideSun:v1,LucideSunDim:Rre,LucideSunMedium:Fre,LucideSunMoon:zre,LucideSunSnow:Bre,LucideSunrise:$re,LucideSunset:qre,LucideSuperscript:Ure,LucideSwatchBook:Vre,LucideSwissFranc:Hre,LucideSwitchCamera:Gre,LucideSword:Wre,LucideSwords:Kre,LucideSyringe:Zre,LucideTable:YM,LucideTable2:ZM,LucideTableCellsMerge:Yre,LucideTableCellsSplit:Qre,LucideTableColumnsSplit:Xre,LucideTableOfContents:Jre,LucideTableProperties:ene,LucideTableRowsSplit:tne,LucideTablet:rne,LucideTabletSmartphone:sne,LucideTablets:nne,LucideTag:Fm,LucideTags:ane,LucideTally1:ine,LucideTally2:one,LucideTally3:lne,LucideTally4:cne,LucideTally5:dne,LucideTangent:une,LucideTarget:zm,LucideTelescope:hne,LucideTent:pne,LucideTentTree:mne,LucideTerminal:fne,LucideTerminalSquare:qk,LucideTestTube:xne,LucideTestTube2:Gk,LucideTestTubeDiagonal:Gk,LucideTestTubes:gne,LucideText:wne,LucideTextCursor:vne,LucideTextCursorInput:yne,LucideTextQuote:bne,LucideTextSearch:_ne,LucideTextSelect:Wk,LucideTextSelection:Wk,LucideTheater:jne,LucideThermometer:VL,LucideThermometerSnowflake:Nne,LucideThermometerSun:kne,LucideThumbsDown:HL,LucideThumbsUp:nh,LucideTicket:GL,LucideTicketCheck:Sne,LucideTicketMinus:Cne,LucideTicketPercent:Mne,LucideTicketPlus:Tne,LucideTicketSlash:Ane,LucideTicketX:Ene,LucideTickets:Ine,LucideTicketsPlane:Pne,LucideTimer:One,LucideTimerOff:Lne,LucideTimerReset:Dne,LucideToggleLeft:Rne,LucideToggleRight:Fne,LucideToilet:zne,LucideTornado:Bne,LucideTorus:$ne,LucideTouchpad:Une,LucideTouchpadOff:qne,LucideTowerControl:Vne,LucideToyBrick:Hne,LucideTractor:Gne,LucideTrafficCone:Wne,LucideTrain:Kk,LucideTrainFront:Zne,LucideTrainFrontTunnel:Kne,LucideTrainTrack:Yne,LucideTramFront:Kk,LucideTrash:Qne,LucideTrash2:Nr,LucideTreeDeciduous:Xne,LucideTreePalm:Zk,LucideTreePine:j0,LucideTrees:Jne,LucideTrello:eae,LucideTrendingDown:_S,LucideTrendingUp:Jo,LucideTrendingUpDown:tae,LucideTriangle:rae,LucideTriangleAlert:Yu,LucideTriangleRight:sae,LucideTrophy:vo,LucideTruck:QM,LucideTurtle:nae,LucideTv:iae,LucideTv2:Yk,LucideTvMinimal:Yk,LucideTvMinimalPlay:aae,LucideTwitch:oae,LucideTwitter:lae,LucideType:dae,LucideTypeOutline:cae,LucideUmbrella:hae,LucideUmbrellaOff:uae,LucideUnderline:WL,LucideUndo:wS,LucideUndo2:mae,LucideUndoDot:pae,LucideUnfoldHorizontal:fae,LucideUnfoldVertical:xae,LucideUngroup:gae,LucideUniversity:Qk,LucideUnlink:jS,LucideUnlink2:yae,LucideUnlock:CN,LucideUnlockKeyhole:SN,LucideUnplug:vae,LucideUpload:di,LucideUploadCloud:eN,LucideUsb:bae,LucideUser:Wi,LucideUser2:r4,LucideUserCheck:X_,LucideUserCheck2:Xk,LucideUserCircle:Yj,LucideUserCircle2:Zj,LucideUserCog:KL,LucideUserCog2:Jk,LucideUserMinus:ZL,LucideUserMinus2:e4,LucideUserPen:_ae,LucideUserPlus:El,LucideUserPlus2:t4,LucideUserRound:r4,LucideUserRoundCheck:Xk,LucideUserRoundCog:Jk,LucideUserRoundMinus:e4,LucideUserRoundPen:wae,LucideUserRoundPlus:t4,LucideUserRoundSearch:jae,LucideUserRoundX:s4,LucideUserSearch:Nae,LucideUserSquare:Vk,LucideUserSquare2:Uk,LucideUserX:kae,LucideUserX2:s4,LucideUsers:hr,LucideUsers2:n4,LucideUsersRound:n4,LucideUtensils:i4,LucideUtensilsCrossed:a4,LucideUtilityPole:Sae,LucideVariable:XM,LucideVault:Cae,LucideVegan:Mae,LucideVenetianMask:Tae,LucideVerified:lj,LucideVibrate:Eae,LucideVibrateOff:Aae,LucideVideo:Cn,LucideVideoOff:Pae,LucideVideotape:Iae,LucideView:Lae,LucideVoicemail:Dae,LucideVolleyball:Oae,LucideVolume:$ae,LucideVolume1:Rae,LucideVolume2:Fae,LucideVolumeOff:zae,LucideVolumeX:Bae,LucideVote:qae,LucideWallet:YL,LucideWallet2:o4,LucideWalletCards:Uae,LucideWalletMinimal:o4,LucideWallpaper:Vae,LucideWand:Hae,LucideWand2:Hv,LucideWandSparkles:Hv,LucideWarehouse:Gae,LucideWashingMachine:Wae,LucideWatch:Kae,LucideWaves:QL,LucideWaypoints:Zae,LucideWebcam:Yae,LucideWebhook:Xae,LucideWebhookOff:Qae,LucideWeight:Jae,LucideWheat:tie,LucideWheatOff:eie,LucideWholeWord:sie,LucideWifi:oie,LucideWifiHigh:rie,LucideWifiLow:nie,LucideWifiOff:aie,LucideWifiZero:iie,LucideWind:cie,LucideWindArrowDown:lie,LucideWine:uie,LucideWineOff:die,LucideWorkflow:hie,LucideWorm:mie,LucideWrapText:pie,LucideWrench:sy,LucideX:Mr,LucideXCircle:jc,LucideXOctagon:EN,LucideXSquare:Hk,LucideYoutube:fie,LucideZap:Yh,LucideZapOff:xie,LucideZoomIn:J_,LucideZoomOut:JM,Luggage:MQ,LuggageIcon:MQ,MSquare:kk,MSquareIcon:kk,Magnet:TQ,MagnetIcon:TQ,Mail:lr,MailCheck:AQ,MailCheckIcon:AQ,MailIcon:lr,MailMinus:EQ,MailMinusIcon:EQ,MailOpen:PQ,MailOpenIcon:PQ,MailPlus:NL,MailPlusIcon:NL,MailQuestion:IQ,MailQuestionIcon:IQ,MailSearch:LQ,MailSearchIcon:LQ,MailWarning:DQ,MailWarningIcon:DQ,MailX:kL,MailXIcon:kL,Mailbox:OQ,MailboxIcon:OQ,Mails:RQ,MailsIcon:RQ,Map:g0,MapIcon:g0,MapPin:ia,MapPinCheck:zQ,MapPinCheckIcon:zQ,MapPinCheckInside:FQ,MapPinCheckInsideIcon:FQ,MapPinHouse:BQ,MapPinHouseIcon:BQ,MapPinIcon:ia,MapPinMinus:qQ,MapPinMinusIcon:qQ,MapPinMinusInside:$Q,MapPinMinusInsideIcon:$Q,MapPinOff:UQ,MapPinOffIcon:UQ,MapPinPlus:HQ,MapPinPlusIcon:HQ,MapPinPlusInside:VQ,MapPinPlusInsideIcon:VQ,MapPinX:WQ,MapPinXIcon:WQ,MapPinXInside:GQ,MapPinXInsideIcon:GQ,MapPinned:KQ,MapPinnedIcon:KQ,Martini:ZQ,MartiniIcon:ZQ,Maximize:mS,Maximize2:YQ,Maximize2Icon:YQ,MaximizeIcon:mS,Medal:h1,MedalIcon:h1,Megaphone:Ph,MegaphoneIcon:Ph,MegaphoneOff:QQ,MegaphoneOffIcon:QQ,Meh:XQ,MehIcon:XQ,MemoryStick:JQ,MemoryStickIcon:JQ,Menu:pS,MenuIcon:pS,MenuSquare:Sk,MenuSquareIcon:Sk,Merge:eX,MergeIcon:eX,MessageCircle:qc,MessageCircleCode:tX,MessageCircleCodeIcon:tX,MessageCircleDashed:sX,MessageCircleDashedIcon:sX,MessageCircleHeart:HM,MessageCircleHeartIcon:HM,MessageCircleIcon:qc,MessageCircleMore:rX,MessageCircleMoreIcon:rX,MessageCircleOff:nX,MessageCircleOffIcon:nX,MessageCirclePlus:aX,MessageCirclePlusIcon:aX,MessageCircleQuestion:SL,MessageCircleQuestionIcon:SL,MessageCircleReply:iX,MessageCircleReplyIcon:iX,MessageCircleWarning:oX,MessageCircleWarningIcon:oX,MessageCircleX:lX,MessageCircleXIcon:lX,MessageSquare:so,MessageSquareCode:cX,MessageSquareCodeIcon:cX,MessageSquareDashed:dX,MessageSquareDashedIcon:dX,MessageSquareDiff:uX,MessageSquareDiffIcon:uX,MessageSquareDot:hX,MessageSquareDotIcon:hX,MessageSquareHeart:mX,MessageSquareHeartIcon:mX,MessageSquareIcon:so,MessageSquareLock:pX,MessageSquareLockIcon:pX,MessageSquareMore:CL,MessageSquareMoreIcon:CL,MessageSquareOff:fX,MessageSquareOffIcon:fX,MessageSquarePlus:GM,MessageSquarePlusIcon:GM,MessageSquareQuote:ML,MessageSquareQuoteIcon:ML,MessageSquareReply:xX,MessageSquareReplyIcon:xX,MessageSquareShare:gX,MessageSquareShareIcon:gX,MessageSquareText:yX,MessageSquareTextIcon:yX,MessageSquareWarning:vX,MessageSquareWarningIcon:vX,MessageSquareX:bX,MessageSquareXIcon:bX,MessagesSquare:_X,MessagesSquareIcon:_X,Mic:TL,Mic2:MN,Mic2Icon:MN,MicIcon:TL,MicOff:wX,MicOffIcon:wX,MicVocal:MN,MicVocalIcon:MN,Microchip:jX,MicrochipIcon:jX,Microscope:NX,MicroscopeIcon:NX,Microwave:kX,MicrowaveIcon:kX,Milestone:SX,MilestoneIcon:SX,Milk:MX,MilkIcon:MX,MilkOff:CX,MilkOffIcon:CX,Minimize:AX,Minimize2:TX,Minimize2Icon:TX,MinimizeIcon:AX,Minus:y0,MinusCircle:Bj,MinusCircleIcon:Bj,MinusIcon:y0,MinusSquare:Ck,MinusSquareIcon:Ck,Monitor:xS,MonitorCheck:EX,MonitorCheckIcon:EX,MonitorCog:PX,MonitorCogIcon:PX,MonitorDot:IX,MonitorDotIcon:IX,MonitorDown:LX,MonitorDownIcon:LX,MonitorIcon:xS,MonitorOff:DX,MonitorOffIcon:DX,MonitorPause:OX,MonitorPauseIcon:OX,MonitorPlay:RX,MonitorPlayIcon:RX,MonitorSmartphone:FX,MonitorSmartphoneIcon:FX,MonitorSpeaker:zX,MonitorSpeakerIcon:zX,MonitorStop:BX,MonitorStopIcon:BX,MonitorUp:fS,MonitorUpIcon:fS,MonitorX:$X,MonitorXIcon:$X,Moon:UX,MoonIcon:UX,MoonStar:qX,MoonStarIcon:qX,MoreHorizontal:xx,MoreHorizontalIcon:xx,MoreVertical:fx,MoreVerticalIcon:fx,Mountain:AL,MountainIcon:AL,MountainSnow:VX,MountainSnowIcon:VX,Mouse:KX,MouseIcon:KX,MouseOff:HX,MouseOffIcon:HX,MousePointer:Nh,MousePointer2:GX,MousePointer2Icon:GX,MousePointerBan:WX,MousePointerBanIcon:WX,MousePointerClick:Tx,MousePointerClickIcon:Tx,MousePointerIcon:Nh,MousePointerSquareDashed:gk,MousePointerSquareDashedIcon:gk,Move:oJ,Move3D:TN,Move3DIcon:TN,Move3d:TN,Move3dIcon:TN,MoveDiagonal:YX,MoveDiagonal2:ZX,MoveDiagonal2Icon:ZX,MoveDiagonalIcon:YX,MoveDown:JX,MoveDownIcon:JX,MoveDownLeft:QX,MoveDownLeftIcon:QX,MoveDownRight:XX,MoveDownRightIcon:XX,MoveHorizontal:eJ,MoveHorizontalIcon:eJ,MoveIcon:oJ,MoveLeft:tJ,MoveLeftIcon:tJ,MoveRight:sJ,MoveRightIcon:sJ,MoveUp:aJ,MoveUpIcon:aJ,MoveUpLeft:rJ,MoveUpLeftIcon:rJ,MoveUpRight:nJ,MoveUpRightIcon:nJ,MoveVertical:iJ,MoveVerticalIcon:iJ,Music:uJ,Music2:lJ,Music2Icon:lJ,Music3:cJ,Music3Icon:cJ,Music4:dJ,Music4Icon:dJ,MusicIcon:uJ,Navigation:fJ,Navigation2:mJ,Navigation2Icon:mJ,Navigation2Off:hJ,Navigation2OffIcon:hJ,NavigationIcon:fJ,NavigationOff:pJ,NavigationOffIcon:pJ,Network:xJ,NetworkIcon:xJ,Newspaper:m1,NewspaperIcon:m1,Nfc:gJ,NfcIcon:gJ,Notebook:_J,NotebookIcon:_J,NotebookPen:yJ,NotebookPenIcon:yJ,NotebookTabs:vJ,NotebookTabsIcon:vJ,NotebookText:bJ,NotebookTextIcon:bJ,NotepadText:jJ,NotepadTextDashed:wJ,NotepadTextDashedIcon:wJ,NotepadTextIcon:jJ,Nut:kJ,NutIcon:kJ,NutOff:NJ,NutOffIcon:NJ,Octagon:CJ,OctagonAlert:$v,OctagonAlertIcon:$v,OctagonIcon:CJ,OctagonMinus:SJ,OctagonMinusIcon:SJ,OctagonPause:AN,OctagonPauseIcon:AN,OctagonX:EN,OctagonXIcon:EN,Omega:MJ,OmegaIcon:MJ,Option:TJ,OptionIcon:TJ,Orbit:AJ,OrbitIcon:AJ,Origami:EJ,OrigamiIcon:EJ,Outdent:jN,OutdentIcon:jN,Package:Al,Package2:PJ,Package2Icon:PJ,PackageCheck:IJ,PackageCheckIcon:IJ,PackageIcon:Al,PackageMinus:LJ,PackageMinusIcon:LJ,PackageOpen:DJ,PackageOpenIcon:DJ,PackagePlus:OJ,PackagePlusIcon:OJ,PackageSearch:RJ,PackageSearchIcon:RJ,PackageX:FJ,PackageXIcon:FJ,PaintBucket:zJ,PaintBucketIcon:zJ,PaintRoller:BJ,PaintRollerIcon:BJ,Paintbrush:$J,Paintbrush2:PN,Paintbrush2Icon:PN,PaintbrushIcon:$J,PaintbrushVertical:PN,PaintbrushVerticalIcon:PN,Palette:Bl,PaletteIcon:Bl,Palmtree:Zk,PalmtreeIcon:Zk,PanelBottom:VJ,PanelBottomClose:qJ,PanelBottomCloseIcon:qJ,PanelBottomDashed:IN,PanelBottomDashedIcon:IN,PanelBottomIcon:VJ,PanelBottomInactive:IN,PanelBottomInactiveIcon:IN,PanelBottomOpen:UJ,PanelBottomOpenIcon:UJ,PanelLeft:RN,PanelLeftClose:LN,PanelLeftCloseIcon:LN,PanelLeftDashed:DN,PanelLeftDashedIcon:DN,PanelLeftIcon:RN,PanelLeftInactive:DN,PanelLeftInactiveIcon:DN,PanelLeftOpen:ON,PanelLeftOpenIcon:ON,PanelRight:WJ,PanelRightClose:HJ,PanelRightCloseIcon:HJ,PanelRightDashed:FN,PanelRightDashedIcon:FN,PanelRightIcon:WJ,PanelRightInactive:FN,PanelRightInactiveIcon:FN,PanelRightOpen:GJ,PanelRightOpenIcon:GJ,PanelTop:YJ,PanelTopClose:KJ,PanelTopCloseIcon:KJ,PanelTopDashed:zN,PanelTopDashedIcon:zN,PanelTopIcon:YJ,PanelTopInactive:zN,PanelTopInactiveIcon:zN,PanelTopOpen:ZJ,PanelTopOpenIcon:ZJ,PanelsLeftBottom:QJ,PanelsLeftBottomIcon:QJ,PanelsLeftRight:rN,PanelsLeftRightIcon:rN,PanelsRightBottom:XJ,PanelsRightBottomIcon:XJ,PanelsTopBottom:VN,PanelsTopBottomIcon:VN,PanelsTopLeft:qv,PanelsTopLeftIcon:qv,Paperclip:gS,PaperclipIcon:gS,Parentheses:JJ,ParenthesesIcon:JJ,ParkingCircle:qj,ParkingCircleIcon:qj,ParkingCircleOff:$j,ParkingCircleOffIcon:$j,ParkingMeter:eee,ParkingMeterIcon:eee,ParkingSquare:Ak,ParkingSquareIcon:Ak,ParkingSquareOff:Tk,ParkingSquareOffIcon:Tk,PartyPopper:nu,PartyPopperIcon:nu,Pause:Rm,PauseCircle:Uj,PauseCircleIcon:Uj,PauseIcon:Rm,PauseOctagon:AN,PauseOctagonIcon:AN,PawPrint:tee,PawPrintIcon:tee,PcCase:see,PcCaseIcon:see,Pen:s0,PenBox:md,PenBoxIcon:md,PenIcon:s0,PenLine:Uv,PenLineIcon:Uv,PenOff:ree,PenOffIcon:ree,PenSquare:md,PenSquareIcon:md,PenTool:Y_,PenToolIcon:Y_,Pencil:za,PencilIcon:za,PencilLine:nee,PencilLineIcon:nee,PencilOff:aee,PencilOffIcon:aee,PencilRuler:iee,PencilRulerIcon:iee,Pentagon:oee,PentagonIcon:oee,Percent:yS,PercentCircle:Vj,PercentCircleIcon:Vj,PercentDiamond:aN,PercentDiamondIcon:aN,PercentIcon:yS,PercentSquare:Ek,PercentSquareIcon:Ek,PersonStanding:lee,PersonStandingIcon:lee,PhilippinePeso:cee,PhilippinePesoIcon:cee,Phone:Mn,PhoneCall:dee,PhoneCallIcon:dee,PhoneForwarded:uee,PhoneForwardedIcon:uee,PhoneIcon:Mn,PhoneIncoming:hee,PhoneIncomingIcon:hee,PhoneMissed:mee,PhoneMissedIcon:mee,PhoneOff:pee,PhoneOffIcon:pee,PhoneOutgoing:fee,PhoneOutgoingIcon:fee,Pi:xee,PiIcon:xee,PiSquare:Pk,PiSquareIcon:Pk,Piano:gee,PianoIcon:gee,Pickaxe:yee,PickaxeIcon:yee,PictureInPicture:bee,PictureInPicture2:vee,PictureInPicture2Icon:vee,PictureInPictureIcon:bee,PieChart:Nj,PieChartIcon:Nj,PiggyBank:_ee,PiggyBankIcon:_ee,Pilcrow:Nee,PilcrowIcon:Nee,PilcrowLeft:wee,PilcrowLeftIcon:wee,PilcrowRight:jee,PilcrowRightIcon:jee,PilcrowSquare:Ik,PilcrowSquareIcon:Ik,Pill:See,PillBottle:kee,PillBottleIcon:kee,PillIcon:See,Pin:Q_,PinIcon:Q_,PinOff:EL,PinOffIcon:EL,Pipette:Cee,PipetteIcon:Cee,Pizza:Mee,PizzaIcon:Mee,Plane:Eee,PlaneIcon:Eee,PlaneLanding:Tee,PlaneLandingIcon:Tee,PlaneTakeoff:Aee,PlaneTakeoffIcon:Aee,Play:il,PlayCircle:pp,PlayCircleIcon:pp,PlayIcon:il,PlaySquare:Lk,PlaySquareIcon:Lk,Plug:PL,Plug2:Pee,Plug2Icon:Pee,PlugIcon:PL,PlugZap:BN,PlugZap2:BN,PlugZap2Icon:BN,PlugZapIcon:BN,Plus:qs,PlusCircle:Hj,PlusCircleIcon:Hj,PlusIcon:qs,PlusSquare:Dk,PlusSquareIcon:Dk,Pocket:Lee,PocketIcon:Lee,PocketKnife:Iee,PocketKnifeIcon:Iee,Podcast:Dee,PodcastIcon:Dee,Pointer:Ree,PointerIcon:Ree,PointerOff:Oee,PointerOffIcon:Oee,Popcorn:Fee,PopcornIcon:Fee,Popsicle:zee,PopsicleIcon:zee,PoundSterling:Bee,PoundSterlingIcon:Bee,Power:IL,PowerCircle:Gj,PowerCircleIcon:Gj,PowerIcon:IL,PowerOff:$ee,PowerOffIcon:$ee,PowerSquare:Ok,PowerSquareIcon:Ok,Presentation:ty,PresentationIcon:ty,Printer:LL,PrinterCheck:qee,PrinterCheckIcon:qee,PrinterIcon:LL,Projector:Uee,ProjectorIcon:Uee,Proportions:Vee,ProportionsIcon:Vee,Puzzle:Hee,PuzzleIcon:Hee,Pyramid:Gee,PyramidIcon:Gee,QrCode:p1,QrCodeIcon:p1,Quote:f1,QuoteIcon:f1,Rabbit:Wee,RabbitIcon:Wee,Radar:Kee,RadarIcon:Kee,Radiation:Zee,RadiationIcon:Zee,Radical:Yee,RadicalIcon:Yee,Radio:x1,RadioIcon:x1,RadioReceiver:Qee,RadioReceiverIcon:Qee,RadioTower:Xee,RadioTowerIcon:Xee,Radius:Jee,RadiusIcon:Jee,RailSymbol:ete,RailSymbolIcon:ete,Rainbow:tte,RainbowIcon:tte,Rat:ste,RatIcon:ste,Ratio:rte,RatioIcon:rte,Receipt:hte,ReceiptCent:nte,ReceiptCentIcon:nte,ReceiptEuro:ate,ReceiptEuroIcon:ate,ReceiptIcon:hte,ReceiptIndianRupee:ite,ReceiptIndianRupeeIcon:ite,ReceiptJapaneseYen:ote,ReceiptJapaneseYenIcon:ote,ReceiptPoundSterling:lte,ReceiptPoundSterlingIcon:lte,ReceiptRussianRuble:cte,ReceiptRussianRubleIcon:cte,ReceiptSwissFranc:dte,ReceiptSwissFrancIcon:dte,ReceiptText:ute,ReceiptTextIcon:ute,RectangleEllipsis:$N,RectangleEllipsisIcon:$N,RectangleHorizontal:mte,RectangleHorizontalIcon:mte,RectangleVertical:pte,RectangleVerticalIcon:pte,Recycle:fte,RecycleIcon:fte,Redo:vS,Redo2:xte,Redo2Icon:xte,RedoDot:gte,RedoDotIcon:gte,RedoIcon:vS,RefreshCcw:WM,RefreshCcwDot:yte,RefreshCcwDotIcon:yte,RefreshCcwIcon:WM,RefreshCw:Wo,RefreshCwIcon:Wo,RefreshCwOff:vte,RefreshCwOffIcon:vte,Refrigerator:bte,RefrigeratorIcon:bte,Regex:_te,RegexIcon:_te,RemoveFormatting:wte,RemoveFormattingIcon:wte,Repeat:DL,Repeat1:jte,Repeat1Icon:jte,Repeat2:Nte,Repeat2Icon:Nte,RepeatIcon:DL,Replace:Ste,ReplaceAll:kte,ReplaceAllIcon:kte,ReplaceIcon:Ste,Reply:OL,ReplyAll:Cte,ReplyAllIcon:Cte,ReplyIcon:OL,Rewind:Mte,RewindIcon:Mte,Ribbon:Tte,RibbonIcon:Tte,Rocket:v0,RocketIcon:v0,RockingChair:Ate,RockingChairIcon:Ate,RollerCoaster:Ete,RollerCoasterIcon:Ete,Rotate3D:qN,Rotate3DIcon:qN,Rotate3d:qN,Rotate3dIcon:qN,RotateCcw:g1,RotateCcwIcon:g1,RotateCcwSquare:Pte,RotateCcwSquareIcon:Pte,RotateCw:RL,RotateCwIcon:RL,RotateCwSquare:Ite,RotateCwSquareIcon:Ite,Route:Dte,RouteIcon:Dte,RouteOff:Lte,RouteOffIcon:Lte,Router:Ote,RouterIcon:Ote,Rows:UN,Rows2:UN,Rows2Icon:UN,Rows3:VN,Rows3Icon:VN,Rows4:Rte,Rows4Icon:Rte,RowsIcon:UN,Rss:Fte,RssIcon:Fte,Ruler:Ax,RulerIcon:Ax,RussianRuble:zte,RussianRubleIcon:zte,Sailboat:Bte,SailboatIcon:Bte,Salad:$te,SaladIcon:$te,Sandwich:qte,SandwichIcon:qte,Satellite:Vte,SatelliteDish:Ute,SatelliteDishIcon:Ute,SatelliteIcon:Vte,Save:Uc,SaveAll:Hte,SaveAllIcon:Hte,SaveIcon:Uc,SaveOff:Gte,SaveOffIcon:Gte,Scale:FL,Scale3D:HN,Scale3DIcon:HN,Scale3d:HN,Scale3dIcon:HN,ScaleIcon:FL,Scaling:Wte,ScalingIcon:Wte,Scan:tse,ScanBarcode:Kte,ScanBarcodeIcon:Kte,ScanEye:Zte,ScanEyeIcon:Zte,ScanFace:Yte,ScanFaceIcon:Yte,ScanIcon:tse,ScanLine:Qte,ScanLineIcon:Qte,ScanQrCode:Xte,ScanQrCodeIcon:Xte,ScanSearch:Jte,ScanSearchIcon:Jte,ScanText:ese,ScanTextIcon:ese,ScatterChart:kj,ScatterChartIcon:kj,School:sse,School2:Qk,School2Icon:Qk,SchoolIcon:sse,Scissors:nse,ScissorsIcon:nse,ScissorsLineDashed:rse,ScissorsLineDashedIcon:rse,ScissorsSquare:Rk,ScissorsSquareDashedBottom:ck,ScissorsSquareDashedBottomIcon:ck,ScissorsSquareIcon:Rk,ScreenShare:ise,ScreenShareIcon:ise,ScreenShareOff:ase,ScreenShareOffIcon:ase,Scroll:lse,ScrollIcon:lse,ScrollText:ose,ScrollTextIcon:ose,Search:sn,SearchCheck:cse,SearchCheckIcon:cse,SearchCode:dse,SearchCodeIcon:dse,SearchIcon:sn,SearchSlash:use,SearchSlashIcon:use,SearchX:zL,SearchXIcon:zL,Section:hse,SectionIcon:hse,Send:$n,SendHorizonal:GN,SendHorizonalIcon:GN,SendHorizontal:GN,SendHorizontalIcon:GN,SendIcon:$n,SendToBack:mse,SendToBackIcon:mse,SeparatorHorizontal:pse,SeparatorHorizontalIcon:pse,SeparatorVertical:fse,SeparatorVerticalIcon:fse,Server:vse,ServerCog:xse,ServerCogIcon:xse,ServerCrash:gse,ServerCrashIcon:gse,ServerIcon:vse,ServerOff:yse,ServerOffIcon:yse,Settings:Qo,Settings2:BL,Settings2Icon:BL,SettingsIcon:Qo,Shapes:bse,ShapesIcon:bse,Share:$L,Share2:nd,Share2Icon:nd,ShareIcon:$L,Sheet:_se,SheetIcon:_se,Shell:wse,ShellIcon:wse,Shield:Au,ShieldAlert:jse,ShieldAlertIcon:jse,ShieldBan:Nse,ShieldBanIcon:Nse,ShieldCheck:qL,ShieldCheckIcon:qL,ShieldClose:WN,ShieldCloseIcon:WN,ShieldEllipsis:kse,ShieldEllipsisIcon:kse,ShieldHalf:Sse,ShieldHalfIcon:Sse,ShieldIcon:Au,ShieldMinus:Cse,ShieldMinusIcon:Cse,ShieldOff:Mse,ShieldOffIcon:Mse,ShieldPlus:Tse,ShieldPlusIcon:Tse,ShieldQuestion:Ase,ShieldQuestionIcon:Ase,ShieldX:WN,ShieldXIcon:WN,Ship:Pse,ShipIcon:Pse,ShipWheel:Ese,ShipWheelIcon:Ese,Shirt:Ise,ShirtIcon:Ise,ShoppingBag:b0,ShoppingBagIcon:b0,ShoppingBasket:Lse,ShoppingBasketIcon:Lse,ShoppingCart:vp,ShoppingCartIcon:vp,Shovel:Dse,ShovelIcon:Dse,ShowerHead:Ose,ShowerHeadIcon:Ose,Shrink:Rse,ShrinkIcon:Rse,Shrub:Fse,ShrubIcon:Fse,Shuffle:bS,ShuffleIcon:bS,Sidebar:RN,SidebarClose:LN,SidebarCloseIcon:LN,SidebarIcon:RN,SidebarOpen:ON,SidebarOpenIcon:ON,Sigma:zse,SigmaIcon:zse,SigmaSquare:Fk,SigmaSquareIcon:Fk,Signal:Vse,SignalHigh:Bse,SignalHighIcon:Bse,SignalIcon:Vse,SignalLow:$se,SignalLowIcon:$se,SignalMedium:qse,SignalMediumIcon:qse,SignalZero:Use,SignalZeroIcon:Use,Signature:Hse,SignatureIcon:Hse,Signpost:Wse,SignpostBig:Gse,SignpostBigIcon:Gse,SignpostIcon:Wse,Siren:Kse,SirenIcon:Kse,SkipBack:Zse,SkipBackIcon:Zse,SkipForward:Yse,SkipForwardIcon:Yse,Skull:Qse,SkullIcon:Qse,Slack:Xse,SlackIcon:Xse,Slash:Jse,SlashIcon:Jse,SlashSquare:zk,SlashSquareIcon:zk,Slice:ere,SliceIcon:ere,Sliders:KN,SlidersHorizontal:y1,SlidersHorizontalIcon:y1,SlidersIcon:KN,SlidersVertical:KN,SlidersVerticalIcon:KN,Smartphone:_0,SmartphoneCharging:tre,SmartphoneChargingIcon:tre,SmartphoneIcon:_0,SmartphoneNfc:sre,SmartphoneNfcIcon:sre,Smile:nre,SmileIcon:nre,SmilePlus:rre,SmilePlusIcon:rre,Snail:are,SnailIcon:are,Snowflake:o0,SnowflakeIcon:o0,Sofa:ire,SofaIcon:ire,SortAsc:aj,SortAscIcon:aj,SortDesc:sj,SortDescIcon:sj,Soup:ore,SoupIcon:ore,Space:lre,SpaceIcon:lre,Spade:cre,SpadeIcon:cre,Sparkle:dre,SparkleIcon:dre,Sparkles:fn,SparklesIcon:fn,Speaker:ure,SpeakerIcon:ure,Speech:hre,SpeechIcon:hre,SpellCheck:pre,SpellCheck2:mre,SpellCheck2Icon:mre,SpellCheckIcon:pre,Spline:fre,SplineIcon:fre,Split:xre,SplitIcon:xre,SplitSquareHorizontal:Bk,SplitSquareHorizontalIcon:Bk,SplitSquareVertical:$k,SplitSquareVerticalIcon:$k,SprayCan:gre,SprayCanIcon:gre,Sprout:yre,SproutIcon:yre,Square:w0,SquareActivity:ZN,SquareActivityIcon:ZN,SquareArrowDown:XN,SquareArrowDownIcon:XN,SquareArrowDownLeft:YN,SquareArrowDownLeftIcon:YN,SquareArrowDownRight:QN,SquareArrowDownRightIcon:QN,SquareArrowLeft:JN,SquareArrowLeftIcon:JN,SquareArrowOutDownLeft:ek,SquareArrowOutDownLeftIcon:ek,SquareArrowOutDownRight:tk,SquareArrowOutDownRightIcon:tk,SquareArrowOutUpLeft:sk,SquareArrowOutUpLeftIcon:sk,SquareArrowOutUpRight:rk,SquareArrowOutUpRightIcon:rk,SquareArrowRight:nk,SquareArrowRightIcon:nk,SquareArrowUp:ok,SquareArrowUpIcon:ok,SquareArrowUpLeft:ak,SquareArrowUpLeftIcon:ak,SquareArrowUpRight:ik,SquareArrowUpRightIcon:ik,SquareAsterisk:lk,SquareAsteriskIcon:lk,SquareBottomDashedScissors:ck,SquareBottomDashedScissorsIcon:ck,SquareChartGantt:Gy,SquareChartGanttIcon:Gy,SquareCheck:dk,SquareCheckBig:Vv,SquareCheckBigIcon:Vv,SquareCheckIcon:dk,SquareChevronDown:uk,SquareChevronDownIcon:uk,SquareChevronLeft:hk,SquareChevronLeftIcon:hk,SquareChevronRight:mk,SquareChevronRightIcon:mk,SquareChevronUp:pk,SquareChevronUpIcon:pk,SquareCode:fk,SquareCodeIcon:fk,SquareDashed:yk,SquareDashedBottom:bre,SquareDashedBottomCode:vre,SquareDashedBottomCodeIcon:vre,SquareDashedBottomIcon:bre,SquareDashedIcon:yk,SquareDashedKanban:xk,SquareDashedKanbanIcon:xk,SquareDashedMousePointer:gk,SquareDashedMousePointerIcon:gk,SquareDivide:vk,SquareDivideIcon:vk,SquareDot:bk,SquareDotIcon:bk,SquareEqual:_k,SquareEqualIcon:_k,SquareFunction:wk,SquareFunctionIcon:wk,SquareGanttChart:Gy,SquareGanttChartIcon:Gy,SquareIcon:w0,SquareKanban:jk,SquareKanbanIcon:jk,SquareLibrary:Nk,SquareLibraryIcon:Nk,SquareM:kk,SquareMIcon:kk,SquareMenu:Sk,SquareMenuIcon:Sk,SquareMinus:Ck,SquareMinusIcon:Ck,SquareMousePointer:Mk,SquareMousePointerIcon:Mk,SquareParking:Ak,SquareParkingIcon:Ak,SquareParkingOff:Tk,SquareParkingOffIcon:Tk,SquarePen:md,SquarePenIcon:md,SquarePercent:Ek,SquarePercentIcon:Ek,SquarePi:Pk,SquarePiIcon:Pk,SquarePilcrow:Ik,SquarePilcrowIcon:Ik,SquarePlay:Lk,SquarePlayIcon:Lk,SquarePlus:Dk,SquarePlusIcon:Dk,SquarePower:Ok,SquarePowerIcon:Ok,SquareRadical:_re,SquareRadicalIcon:_re,SquareScissors:Rk,SquareScissorsIcon:Rk,SquareSigma:Fk,SquareSigmaIcon:Fk,SquareSlash:zk,SquareSlashIcon:zk,SquareSplitHorizontal:Bk,SquareSplitHorizontalIcon:Bk,SquareSplitVertical:$k,SquareSplitVerticalIcon:$k,SquareSquare:wre,SquareSquareIcon:wre,SquareStack:jre,SquareStackIcon:jre,SquareTerminal:qk,SquareTerminalIcon:qk,SquareUser:Vk,SquareUserIcon:Vk,SquareUserRound:Uk,SquareUserRoundIcon:Uk,SquareX:Hk,SquareXIcon:Hk,Squircle:Nre,SquircleIcon:Nre,Squirrel:kre,SquirrelIcon:kre,Stamp:Sre,StampIcon:Sre,Star:Jn,StarHalf:Cre,StarHalfIcon:Cre,StarIcon:Jn,StarOff:Mre,StarOffIcon:Mre,Stars:fn,StarsIcon:fn,StepBack:Tre,StepBackIcon:Tre,StepForward:Are,StepForwardIcon:Are,Stethoscope:Ere,StethoscopeIcon:Ere,Sticker:Pre,StickerIcon:Pre,StickyNote:Ire,StickyNoteIcon:Ire,StopCircle:Kj,StopCircleIcon:Kj,Store:KM,StoreIcon:KM,StretchHorizontal:Lre,StretchHorizontalIcon:Lre,StretchVertical:Dre,StretchVerticalIcon:Dre,Strikethrough:UL,StrikethroughIcon:UL,Subscript:Ore,SubscriptIcon:Ore,Subtitles:mj,SubtitlesIcon:mj,Sun:v1,SunDim:Rre,SunDimIcon:Rre,SunIcon:v1,SunMedium:Fre,SunMediumIcon:Fre,SunMoon:zre,SunMoonIcon:zre,SunSnow:Bre,SunSnowIcon:Bre,Sunrise:$re,SunriseIcon:$re,Sunset:qre,SunsetIcon:qre,Superscript:Ure,SuperscriptIcon:Ure,SwatchBook:Vre,SwatchBookIcon:Vre,SwissFranc:Hre,SwissFrancIcon:Hre,SwitchCamera:Gre,SwitchCameraIcon:Gre,Sword:Wre,SwordIcon:Wre,Swords:Kre,SwordsIcon:Kre,Syringe:Zre,SyringeIcon:Zre,Table:YM,Table2:ZM,Table2Icon:ZM,TableCellsMerge:Yre,TableCellsMergeIcon:Yre,TableCellsSplit:Qre,TableCellsSplitIcon:Qre,TableColumnsSplit:Xre,TableColumnsSplitIcon:Xre,TableIcon:YM,TableOfContents:Jre,TableOfContentsIcon:Jre,TableProperties:ene,TablePropertiesIcon:ene,TableRowsSplit:tne,TableRowsSplitIcon:tne,Tablet:rne,TabletIcon:rne,TabletSmartphone:sne,TabletSmartphoneIcon:sne,Tablets:nne,TabletsIcon:nne,Tag:Fm,TagIcon:Fm,Tags:ane,TagsIcon:ane,Tally1:ine,Tally1Icon:ine,Tally2:one,Tally2Icon:one,Tally3:lne,Tally3Icon:lne,Tally4:cne,Tally4Icon:cne,Tally5:dne,Tally5Icon:dne,Tangent:une,TangentIcon:une,Target:zm,TargetIcon:zm,Telescope:hne,TelescopeIcon:hne,Tent:pne,TentIcon:pne,TentTree:mne,TentTreeIcon:mne,Terminal:fne,TerminalIcon:fne,TerminalSquare:qk,TerminalSquareIcon:qk,TestTube:xne,TestTube2:Gk,TestTube2Icon:Gk,TestTubeDiagonal:Gk,TestTubeDiagonalIcon:Gk,TestTubeIcon:xne,TestTubes:gne,TestTubesIcon:gne,Text:wne,TextCursor:vne,TextCursorIcon:vne,TextCursorInput:yne,TextCursorInputIcon:yne,TextIcon:wne,TextQuote:bne,TextQuoteIcon:bne,TextSearch:_ne,TextSearchIcon:_ne,TextSelect:Wk,TextSelectIcon:Wk,TextSelection:Wk,TextSelectionIcon:Wk,Theater:jne,TheaterIcon:jne,Thermometer:VL,ThermometerIcon:VL,ThermometerSnowflake:Nne,ThermometerSnowflakeIcon:Nne,ThermometerSun:kne,ThermometerSunIcon:kne,ThumbsDown:HL,ThumbsDownIcon:HL,ThumbsUp:nh,ThumbsUpIcon:nh,Ticket:GL,TicketCheck:Sne,TicketCheckIcon:Sne,TicketIcon:GL,TicketMinus:Cne,TicketMinusIcon:Cne,TicketPercent:Mne,TicketPercentIcon:Mne,TicketPlus:Tne,TicketPlusIcon:Tne,TicketSlash:Ane,TicketSlashIcon:Ane,TicketX:Ene,TicketXIcon:Ene,Tickets:Ine,TicketsIcon:Ine,TicketsPlane:Pne,TicketsPlaneIcon:Pne,Timer:One,TimerIcon:One,TimerOff:Lne,TimerOffIcon:Lne,TimerReset:Dne,TimerResetIcon:Dne,ToggleLeft:Rne,ToggleLeftIcon:Rne,ToggleRight:Fne,ToggleRightIcon:Fne,Toilet:zne,ToiletIcon:zne,Tornado:Bne,TornadoIcon:Bne,Torus:$ne,TorusIcon:$ne,Touchpad:Une,TouchpadIcon:Une,TouchpadOff:qne,TouchpadOffIcon:qne,TowerControl:Vne,TowerControlIcon:Vne,ToyBrick:Hne,ToyBrickIcon:Hne,Tractor:Gne,TractorIcon:Gne,TrafficCone:Wne,TrafficConeIcon:Wne,Train:Kk,TrainFront:Zne,TrainFrontIcon:Zne,TrainFrontTunnel:Kne,TrainFrontTunnelIcon:Kne,TrainIcon:Kk,TrainTrack:Yne,TrainTrackIcon:Yne,TramFront:Kk,TramFrontIcon:Kk,Trash:Qne,Trash2:Nr,Trash2Icon:Nr,TrashIcon:Qne,TreeDeciduous:Xne,TreeDeciduousIcon:Xne,TreePalm:Zk,TreePalmIcon:Zk,TreePine:j0,TreePineIcon:j0,Trees:Jne,TreesIcon:Jne,Trello:eae,TrelloIcon:eae,TrendingDown:_S,TrendingDownIcon:_S,TrendingUp:Jo,TrendingUpDown:tae,TrendingUpDownIcon:tae,TrendingUpIcon:Jo,Triangle:rae,TriangleAlert:Yu,TriangleAlertIcon:Yu,TriangleIcon:rae,TriangleRight:sae,TriangleRightIcon:sae,Trophy:vo,TrophyIcon:vo,Truck:QM,TruckIcon:QM,Turtle:nae,TurtleIcon:nae,Tv:iae,Tv2:Yk,Tv2Icon:Yk,TvIcon:iae,TvMinimal:Yk,TvMinimalIcon:Yk,TvMinimalPlay:aae,TvMinimalPlayIcon:aae,Twitch:oae,TwitchIcon:oae,Twitter:lae,TwitterIcon:lae,Type:dae,TypeIcon:dae,TypeOutline:cae,TypeOutlineIcon:cae,Umbrella:hae,UmbrellaIcon:hae,UmbrellaOff:uae,UmbrellaOffIcon:uae,Underline:WL,UnderlineIcon:WL,Undo:wS,Undo2:mae,Undo2Icon:mae,UndoDot:pae,UndoDotIcon:pae,UndoIcon:wS,UnfoldHorizontal:fae,UnfoldHorizontalIcon:fae,UnfoldVertical:xae,UnfoldVerticalIcon:xae,Ungroup:gae,UngroupIcon:gae,University:Qk,UniversityIcon:Qk,Unlink:jS,Unlink2:yae,Unlink2Icon:yae,UnlinkIcon:jS,Unlock:CN,UnlockIcon:CN,UnlockKeyhole:SN,UnlockKeyholeIcon:SN,Unplug:vae,UnplugIcon:vae,Upload:di,UploadCloud:eN,UploadCloudIcon:eN,UploadIcon:di,Usb:bae,UsbIcon:bae,User:Wi,User2:r4,User2Icon:r4,UserCheck:X_,UserCheck2:Xk,UserCheck2Icon:Xk,UserCheckIcon:X_,UserCircle:Yj,UserCircle2:Zj,UserCircle2Icon:Zj,UserCircleIcon:Yj,UserCog:KL,UserCog2:Jk,UserCog2Icon:Jk,UserCogIcon:KL,UserIcon:Wi,UserMinus:ZL,UserMinus2:e4,UserMinus2Icon:e4,UserMinusIcon:ZL,UserPen:_ae,UserPenIcon:_ae,UserPlus:El,UserPlus2:t4,UserPlus2Icon:t4,UserPlusIcon:El,UserRound:r4,UserRoundCheck:Xk,UserRoundCheckIcon:Xk,UserRoundCog:Jk,UserRoundCogIcon:Jk,UserRoundIcon:r4,UserRoundMinus:e4,UserRoundMinusIcon:e4,UserRoundPen:wae,UserRoundPenIcon:wae,UserRoundPlus:t4,UserRoundPlusIcon:t4,UserRoundSearch:jae,UserRoundSearchIcon:jae,UserRoundX:s4,UserRoundXIcon:s4,UserSearch:Nae,UserSearchIcon:Nae,UserSquare:Vk,UserSquare2:Uk,UserSquare2Icon:Uk,UserSquareIcon:Vk,UserX:kae,UserX2:s4,UserX2Icon:s4,UserXIcon:kae,Users:hr,Users2:n4,Users2Icon:n4,UsersIcon:hr,UsersRound:n4,UsersRoundIcon:n4,Utensils:i4,UtensilsCrossed:a4,UtensilsCrossedIcon:a4,UtensilsIcon:i4,UtilityPole:Sae,UtilityPoleIcon:Sae,Variable:XM,VariableIcon:XM,Vault:Cae,VaultIcon:Cae,Vegan:Mae,VeganIcon:Mae,VenetianMask:Tae,VenetianMaskIcon:Tae,Verified:lj,VerifiedIcon:lj,Vibrate:Eae,VibrateIcon:Eae,VibrateOff:Aae,VibrateOffIcon:Aae,Video:Cn,VideoIcon:Cn,VideoOff:Pae,VideoOffIcon:Pae,Videotape:Iae,VideotapeIcon:Iae,View:Lae,ViewIcon:Lae,Voicemail:Dae,VoicemailIcon:Dae,Volleyball:Oae,VolleyballIcon:Oae,Volume:$ae,Volume1:Rae,Volume1Icon:Rae,Volume2:Fae,Volume2Icon:Fae,VolumeIcon:$ae,VolumeOff:zae,VolumeOffIcon:zae,VolumeX:Bae,VolumeXIcon:Bae,Vote:qae,VoteIcon:qae,Wallet:YL,Wallet2:o4,Wallet2Icon:o4,WalletCards:Uae,WalletCardsIcon:Uae,WalletIcon:YL,WalletMinimal:o4,WalletMinimalIcon:o4,Wallpaper:Vae,WallpaperIcon:Vae,Wand:Hae,Wand2:Hv,Wand2Icon:Hv,WandIcon:Hae,WandSparkles:Hv,WandSparklesIcon:Hv,Warehouse:Gae,WarehouseIcon:Gae,WashingMachine:Wae,WashingMachineIcon:Wae,Watch:Kae,WatchIcon:Kae,Waves:QL,WavesIcon:QL,Waypoints:Zae,WaypointsIcon:Zae,Webcam:Yae,WebcamIcon:Yae,Webhook:Xae,WebhookIcon:Xae,WebhookOff:Qae,WebhookOffIcon:Qae,Weight:Jae,WeightIcon:Jae,Wheat:tie,WheatIcon:tie,WheatOff:eie,WheatOffIcon:eie,WholeWord:sie,WholeWordIcon:sie,Wifi:oie,WifiHigh:rie,WifiHighIcon:rie,WifiIcon:oie,WifiLow:nie,WifiLowIcon:nie,WifiOff:aie,WifiOffIcon:aie,WifiZero:iie,WifiZeroIcon:iie,Wind:cie,WindArrowDown:lie,WindArrowDownIcon:lie,WindIcon:cie,Wine:uie,WineIcon:uie,WineOff:die,WineOffIcon:die,Workflow:hie,WorkflowIcon:hie,Worm:mie,WormIcon:mie,WrapText:pie,WrapTextIcon:pie,Wrench:sy,WrenchIcon:sy,X:Mr,XCircle:jc,XCircleIcon:jc,XIcon:Mr,XOctagon:EN,XOctagonIcon:EN,XSquare:Hk,XSquareIcon:Hk,Youtube:fie,YoutubeIcon:fie,Zap:Yh,ZapIcon:Yh,ZapOff:xie,ZapOffIcon:xie,ZoomIn:J_,ZoomInIcon:J_,ZoomOut:JM,ZoomOutIcon:JM,createLucideIcon:Z,icons:ogt},Symbol.toStringTag,{value:"Module"})),T2e="-",lgt=t=>{const s=dgt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(T2e);return i[0]===""&&i.length!==1&&i.shift(),Nqe(i,s)||cgt(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},Nqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?Nqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(T2e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},WAe=/^\[(.+)\]$/,cgt=t=>{if(WAe.test(t)){const s=WAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},dgt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return hgt(Object.entries(t.classGroups),r).forEach(([o,l])=>{G0e(l,n,o,s)}),n},G0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:KAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(ugt(a)){G0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{G0e(l,KAe(s,o),r,n)})})},KAe=(t,s)=>{let r=t;return s.split(T2e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},ugt=t=>t.isThemeGetter,hgt=(t,s)=>s?t.map(([r,n])=>{const a=n.map(o=>typeof o=="string"?s+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([l,i])=>[s+l,i])):o);return[r,a]}):t,mgt=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(o,l)=>{r.set(o,l),s++,s>t&&(s=0,n=r,r=new Map)};return{get(o){let l=r.get(o);if(l!==void 0)return l;if((l=n.get(o))!==void 0)return a(o,l),l},set(o,l){r.has(o)?r.set(o,l):a(o,l)}}},kqe="!",pgt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const c=[];let u=0,p=0,f;for(let j=0;jp?f-p:void 0;return{modifiers:c,hasImportantModifier:v,baseClassName:_,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},fgt=t=>{if(t.length<=1)return t;const s=[];let r=[];return t.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},xgt=t=>({cache:mgt(t.cacheSize),parseClassName:pgt(t),...lgt(t)}),ggt=/\s+/,ygt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(ggt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:v}=r(u);let _=!!v,w=n(_?g.substring(0,v):g);if(!w){if(!_){i=u+(i.length>0?" "+i:i);continue}if(w=n(g),!w){i=u+(i.length>0?" "+i:i);continue}_=!1}const j=fgt(p).join(":"),k=f?j+kqe:j,S=k+w;if(o.includes(S))continue;o.push(S);const M=a(w,_);for(let L=0;L0?" "+i:i)}return i};function vgt(){let t=0,s,r,n="";for(;t{if(typeof t=="string")return t;let s,r="";for(let n=0;nf(p),t());return r=xgt(u),n=r.cache.get,a=r.cache.set,o=i,i(c)}function i(c){const u=n(c);if(u)return u;const p=ygt(c,r);return a(c,p),p}return function(){return o(vgt.apply(null,arguments))}}const xc=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},Cqe=/^\[(?:([a-z-]+):)?(.+)\]$/i,_gt=/^\d+\/\d+$/,wgt=new Set(["px","full","screen"]),jgt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ngt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,kgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Sgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Cgt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Nv=t=>eT(t)||wgt.has(t)||_gt.test(t),Ob=t=>WA(t,"length",Dgt),eT=t=>!!t&&!Number.isNaN(Number(t)),dxe=t=>WA(t,"number",eT),KP=t=>!!t&&Number.isInteger(Number(t)),Mgt=t=>t.endsWith("%")&&eT(t.slice(0,-1)),Qi=t=>Cqe.test(t),Rb=t=>jgt.test(t),Tgt=new Set(["length","size","percentage"]),Agt=t=>WA(t,Tgt,Mqe),Egt=t=>WA(t,"position",Mqe),Pgt=new Set(["image","url"]),Igt=t=>WA(t,Pgt,Rgt),Lgt=t=>WA(t,"",Ogt),ZP=()=>!0,WA=(t,s,r)=>{const n=Cqe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},Dgt=t=>Ngt.test(t)&&!kgt.test(t),Mqe=()=>!1,Ogt=t=>Sgt.test(t),Rgt=t=>Cgt.test(t),Fgt=()=>{const t=xc("colors"),s=xc("spacing"),r=xc("blur"),n=xc("brightness"),a=xc("borderColor"),o=xc("borderRadius"),l=xc("borderSpacing"),i=xc("borderWidth"),c=xc("contrast"),u=xc("grayscale"),p=xc("hueRotate"),f=xc("invert"),g=xc("gap"),v=xc("gradientColorStops"),_=xc("gradientColorStopPositions"),w=xc("inset"),j=xc("margin"),k=xc("opacity"),S=xc("padding"),M=xc("saturate"),L=xc("scale"),P=xc("sepia"),O=xc("skew"),$=xc("space"),U=xc("translate"),B=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",Qi,s],Y=()=>[Qi,s],ee=()=>["",Nv,Ob],Q=()=>["auto",eT,Qi],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],oe=()=>["start","end","center","between","around","evenly","stretch"],fe=()=>["","0",Qi],ge=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ue=()=>[eT,Qi];return{cacheSize:500,separator:":",theme:{colors:[ZP],spacing:[Nv,Ob],blur:["none","",Rb,Qi],brightness:ue(),borderColor:[t],borderRadius:["none","","full",Rb,Qi],borderSpacing:Y(),borderWidth:ee(),contrast:ue(),grayscale:fe(),hueRotate:ue(),invert:fe(),gap:Y(),gradientColorStops:[t],gradientColorStopPositions:[Mgt,Ob],inset:X(),margin:X(),opacity:ue(),padding:Y(),saturate:ue(),scale:ue(),sepia:fe(),skew:ue(),space:Y(),translate:Y()},classGroups:{aspect:[{aspect:["auto","square","video",Qi]}],container:["container"],columns:[{columns:[Rb]}],"break-after":[{"break-after":ge()}],"break-before":[{"break-before":ge()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ce(),Qi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",KP,Qi]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Qi]}],grow:[{grow:fe()}],shrink:[{shrink:fe()}],order:[{order:["first","last","none",KP,Qi]}],"grid-cols":[{"grid-cols":[ZP]}],"col-start-end":[{col:["auto",{span:["full",KP,Qi]},Qi]}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":[ZP]}],"row-start-end":[{row:["auto",{span:[KP,Qi]},Qi]}],"row-start":[{"row-start":Q()}],"row-end":[{"row-end":Q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Qi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Qi]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...oe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...oe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...oe(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Qi,s]}],"min-w":[{"min-w":[Qi,s,"min","max","fit"]}],"max-w":[{"max-w":[Qi,s,"none","full","min","max","fit","prose",{screen:[Rb]},Rb]}],h:[{h:[Qi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Qi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Qi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Qi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Rb,Ob]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",dxe]}],"font-family":[{font:[ZP]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Qi]}],"line-clamp":[{"line-clamp":["none",eT,dxe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Nv,Qi]}],"list-image":[{"list-image":["none",Qi]}],"list-style-type":[{list:["none","disc","decimal",Qi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Nv,Ob]}],"underline-offset":[{"underline-offset":["auto",Nv,Qi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Y()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Qi]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Qi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),Egt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Agt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Igt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:ne()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[Nv,Qi]}],"outline-w":[{outline:[Nv,Ob]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Nv,Ob]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Rb,Lgt]}],"shadow-color":[{shadow:[ZP]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Rb,Qi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[P]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[P]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Qi]}],duration:[{duration:ue()}],ease:[{ease:["linear","in","out","in-out",Qi]}],delay:[{delay:ue()}],animate:[{animate:["none","spin","ping","pulse","bounce",Qi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[KP,Qi]}],"translate-x":[{"translate-x":[U]}],"translate-y":[{"translate-y":[U]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Qi]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Qi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Y()}],"scroll-mx":[{"scroll-mx":Y()}],"scroll-my":[{"scroll-my":Y()}],"scroll-ms":[{"scroll-ms":Y()}],"scroll-me":[{"scroll-me":Y()}],"scroll-mt":[{"scroll-mt":Y()}],"scroll-mr":[{"scroll-mr":Y()}],"scroll-mb":[{"scroll-mb":Y()}],"scroll-ml":[{"scroll-ml":Y()}],"scroll-p":[{"scroll-p":Y()}],"scroll-px":[{"scroll-px":Y()}],"scroll-py":[{"scroll-py":Y()}],"scroll-ps":[{"scroll-ps":Y()}],"scroll-pe":[{"scroll-pe":Y()}],"scroll-pt":[{"scroll-pt":Y()}],"scroll-pr":[{"scroll-pr":Y()}],"scroll-pb":[{"scroll-pb":Y()}],"scroll-pl":[{"scroll-pl":Y()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Qi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Nv,Ob,dxe]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},zgt=bgt(Fgt);function It(...t){return zgt(Vi(t))}function Xl(t,s=!1){return s&&t>=1e6?`$${(t/1e6).toFixed(1)}M`:s&&t>=1e3?`$${(t/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function ZAe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function Lde(t){return t?t.replace(/<[^>]*>/g,""):""}const Bgt=ngt,Tqe=N.forwardRef(({className:t,...s},r)=>e.jsx(fqe,{ref:r,className:It("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));Tqe.displayName=fqe.displayName;const $gt=b3("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Aqe=N.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(xqe,{ref:n,className:It($gt({variant:s}),t),...r}));Aqe.displayName=xqe.displayName;const qgt=N.forwardRef(({className:t,...s},r)=>e.jsx(vqe,{ref:r,className:It("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...s}));qgt.displayName=vqe.displayName;const Eqe=N.forwardRef(({className:t,...s},r)=>e.jsx(bqe,{ref:r,className:It("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Mr,{className:"h-4 w-4"})}));Eqe.displayName=bqe.displayName;const Pqe=N.forwardRef(({className:t,...s},r)=>e.jsx(gqe,{ref:r,className:It("text-sm font-semibold",t),...s}));Pqe.displayName=gqe.displayName;const Iqe=N.forwardRef(({className:t,...s},r)=>e.jsx(yqe,{ref:r,className:It("text-sm opacity-90",t),...s}));Iqe.displayName=yqe.displayName;function Ugt(){const{toasts:t}=Ha();return e.jsxs(Bgt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(Aqe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(Pqe,{children:r}),n&&e.jsx(Iqe,{children:n})]}),a,e.jsx(Eqe,{})]},s)}),e.jsx(Tqe,{})]})}var YAe=["light","dark"],Vgt="(prefers-color-scheme: dark)",Hgt=N.createContext(void 0),Ggt={setTheme:t=>{},themes:[]},Wgt=()=>{var t;return(t=N.useContext(Hgt))!=null?t:Ggt};N.memo(({forcedTheme:t,storageKey:s,attribute:r,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:c})=>{let u=o==="system",p=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(_=>`'${_}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?YAe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(_,w=!1,j=!0)=>{let k=l?l[_]:_,S=w?_+"|| ''":`'${k}'`,M="";return a&&j&&!w&&YAe.includes(_)&&(M+=`d.style.colorScheme = '${_}';`),r==="class"?w||k?M+=`c.add(${S})`:M+="null":k&&(M+=`d[s](n,${S})`),M},v=t?`!function(){${p}${g(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${Vgt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${g("dark")}}else{${g("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}${u?"":"else{"+g(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${g(l?"x[e]":"e",!0)}}else{${g(o,!1,!1)};}${f}}catch(t){}}();`;return N.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:v}})});var Kgt=t=>{switch(t){case"success":return Qgt;case"info":return Jgt;case"warning":return Xgt;case"error":return eyt;default:return null}},Zgt=Array(12).fill(0),Ygt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},Zgt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Qgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Xgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Jgt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),eyt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ht.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),tyt=ht.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ht.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ht.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),syt=()=>{let[t,s]=ht.useState(document.hidden);return ht.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},W0e=1,ryt=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let r=this.subscribers.indexOf(s);this.subscribers.splice(r,1)}),this.publish=s=>{this.subscribers.forEach(r=>r(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var r;let{message:n,...a}=s,o=typeof(s==null?void 0:s.id)=="number"||((r=s.id)==null?void 0:r.length)>0?s.id:W0e++,l=this.toasts.find(c=>c.id===o),i=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(c=>c.id===o?(this.publish({...c,...s,id:o,title:n}),{...c,...s,id:o,dismissible:i,title:n}):c):this.addToast({title:n,...a,dismissible:i,id:o}),o},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:s,dismiss:!0})),s),this.message=(s,r)=>this.create({...r,message:s}),this.error=(s,r)=>this.create({...r,message:s,type:"error"}),this.success=(s,r)=>this.create({...r,type:"success",message:s}),this.info=(s,r)=>this.create({...r,type:"info",message:s}),this.warning=(s,r)=>this.create({...r,type:"warning",message:s}),this.loading=(s,r)=>this.create({...r,type:"loading",message:s}),this.promise=(s,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:s,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let a=s instanceof Promise?s:s(),o=n!==void 0,l,i=a.then(async u=>{if(l=["resolve",u],ht.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(ayt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:f})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let p=typeof r.error=="function"?await r.error(u):r.error,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),c=()=>new Promise((u,p)=>i.then(()=>l[0]==="reject"?p(l[1]):u(l[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||W0e++;return this.create({jsx:s(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},up=new ryt,nyt=(t,s)=>{let r=(s==null?void 0:s.id)||W0e++;return up.addToast({title:t,...s,id:r}),r},ayt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",iyt=nyt,oyt=()=>up.toasts,lyt=()=>up.getActiveToasts(),me=Object.assign(iyt,{success:up.success,info:up.info,warning:up.warning,error:up.error,custom:up.custom,message:up.message,promise:up.promise,dismiss:up.dismiss,loading:up.loading},{getHistory:oyt,getToasts:lyt});function cyt(t,{insertAt:s}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",s==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}cyt(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function Y7(t){return t.label!==void 0}var dyt=3,uyt="32px",hyt="16px",QAe=4e3,myt=356,pyt=14,fyt=20,xyt=200;function Sg(...t){return t.filter(Boolean).join(" ")}function gyt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var yyt=t=>{var s,r,n,a,o,l,i,c,u,p,f;let{invert:g,toast:v,unstyled:_,interacting:w,setHeights:j,visibleToasts:k,heights:S,index:M,toasts:L,expanded:P,removeToast:O,defaultRichColors:$,closeButton:U,style:B,cancelButtonStyle:V,actionButtonStyle:X,className:Y="",descriptionClassName:ee="",duration:Q,position:ce,gap:ne,loadingIcon:re,expandByDefault:oe,classNames:fe,icons:ge,closeButtonAriaLabel:ue="Close toast",pauseWhenPageIsHidden:xe}=t,[_e,$e]=ht.useState(null),[Me,Ie]=ht.useState(null),[ke,pe]=ht.useState(!1),[we,Le]=ht.useState(!1),[Qe,Te]=ht.useState(!1),[pt,ye]=ht.useState(!1),[qe,at]=ht.useState(!1),[tt,Ae]=ht.useState(0),[rt,He]=ht.useState(0),ct=ht.useRef(v.duration||Q||QAe),Ue=ht.useRef(null),Ze=ht.useRef(null),Je=M===0,Ge=M+1<=k,et=v.type,it=v.dismissible!==!1,Dt=v.className||"",Vt=v.descriptionClassName||"",hs=ht.useMemo(()=>S.findIndex(Gr=>Gr.toastId===v.id)||0,[S,v.id]),As=ht.useMemo(()=>{var Gr;return(Gr=v.closeButton)!=null?Gr:U},[v.closeButton,U]),Ms=ht.useMemo(()=>v.duration||Q||QAe,[v.duration,Q]),cs=ht.useRef(0),er=ht.useRef(0),xt=ht.useRef(0),Ps=ht.useRef(null),[mr,Tr]=ce.split("-"),Dr=ht.useMemo(()=>S.reduce((Gr,mn,Yr)=>Yr>=hs?Gr:Gr+mn.height,0),[S,hs]),xn=syt(),Si=v.invert||g,Ia=et==="loading";er.current=ht.useMemo(()=>hs*ne+Dr,[hs,Dr]),ht.useEffect(()=>{ct.current=Ms},[Ms]),ht.useEffect(()=>{pe(!0)},[]),ht.useEffect(()=>{let Gr=Ze.current;if(Gr){let mn=Gr.getBoundingClientRect().height;return He(mn),j(Yr=>[{toastId:v.id,height:mn,position:v.position},...Yr]),()=>j(Yr=>Yr.filter(bi=>bi.toastId!==v.id))}},[j,v.id]),ht.useLayoutEffect(()=>{if(!ke)return;let Gr=Ze.current,mn=Gr.style.height;Gr.style.height="auto";let Yr=Gr.getBoundingClientRect().height;Gr.style.height=mn,He(Yr),j(bi=>bi.find(ft=>ft.toastId===v.id)?bi.map(ft=>ft.toastId===v.id?{...ft,height:Yr}:ft):[{toastId:v.id,height:Yr,position:v.position},...bi])},[ke,v.title,v.description,j,v.id]);let ur=ht.useCallback(()=>{Le(!0),Ae(er.current),j(Gr=>Gr.filter(mn=>mn.toastId!==v.id)),setTimeout(()=>{O(v)},xyt)},[v,O,j,er]);ht.useEffect(()=>{if(v.promise&&et==="loading"||v.duration===1/0||v.type==="loading")return;let Gr;return P||w||xe&&xn?(()=>{if(xt.current{var mn;(mn=v.onAutoClose)==null||mn.call(v,v),ur()},ct.current)),()=>clearTimeout(Gr)},[P,w,v,et,xe,xn,ur]),ht.useEffect(()=>{v.delete&&ur()},[ur,v.delete]);function Jr(){var Gr,mn,Yr;return ge!=null&&ge.loading?ht.createElement("div",{className:Sg(fe==null?void 0:fe.loader,(Gr=v==null?void 0:v.classNames)==null?void 0:Gr.loader,"sonner-loader"),"data-visible":et==="loading"},ge.loading):re?ht.createElement("div",{className:Sg(fe==null?void 0:fe.loader,(mn=v==null?void 0:v.classNames)==null?void 0:mn.loader,"sonner-loader"),"data-visible":et==="loading"},re):ht.createElement(Ygt,{className:Sg(fe==null?void 0:fe.loader,(Yr=v==null?void 0:v.classNames)==null?void 0:Yr.loader),visible:et==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ze,className:Sg(Y,Dt,fe==null?void 0:fe.toast,(s=v==null?void 0:v.classNames)==null?void 0:s.toast,fe==null?void 0:fe.default,fe==null?void 0:fe[et],(r=v==null?void 0:v.classNames)==null?void 0:r[et]),"data-sonner-toast":"","data-rich-colors":(n=v.richColors)!=null?n:$,"data-styled":!(v.jsx||v.unstyled||_),"data-mounted":ke,"data-promise":!!v.promise,"data-swiped":qe,"data-removed":we,"data-visible":Ge,"data-y-position":mr,"data-x-position":Tr,"data-index":M,"data-front":Je,"data-swiping":Qe,"data-dismissible":it,"data-type":et,"data-invert":Si,"data-swipe-out":pt,"data-swipe-direction":Me,"data-expanded":!!(P||oe&&ke),style:{"--index":M,"--toasts-before":M,"--z-index":L.length-M,"--offset":`${we?tt:er.current}px`,"--initial-height":oe?"auto":`${rt}px`,...B,...v.style},onDragEnd:()=>{Te(!1),$e(null),Ps.current=null},onPointerDown:Gr=>{Ia||!it||(Ue.current=new Date,Ae(er.current),Gr.target.setPointerCapture(Gr.pointerId),Gr.target.tagName!=="BUTTON"&&(Te(!0),Ps.current={x:Gr.clientX,y:Gr.clientY}))},onPointerUp:()=>{var Gr,mn,Yr,bi;if(pt||!it)return;Ps.current=null;let ft=Number(((Gr=Ze.current)==null?void 0:Gr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),or=Number(((mn=Ze.current)==null?void 0:mn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Vn=new Date().getTime()-((Yr=Ue.current)==null?void 0:Yr.getTime()),Sr=_e==="x"?ft:or,jr=Math.abs(Sr)/Vn;if(Math.abs(Sr)>=fyt||jr>.11){Ae(er.current),(bi=v.onDismiss)==null||bi.call(v,v),Ie(_e==="x"?ft>0?"right":"left":or>0?"down":"up"),ur(),ye(!0),at(!1);return}Te(!1),$e(null)},onPointerMove:Gr=>{var mn,Yr,bi,ft;if(!Ps.current||!it||((mn=window.getSelection())==null?void 0:mn.toString().length)>0)return;let or=Gr.clientY-Ps.current.y,Vn=Gr.clientX-Ps.current.x,Sr=(Yr=t.swipeDirections)!=null?Yr:gyt(ce);!_e&&(Math.abs(Vn)>1||Math.abs(or)>1)&&$e(Math.abs(Vn)>Math.abs(or)?"x":"y");let jr={x:0,y:0};_e==="y"?(Sr.includes("top")||Sr.includes("bottom"))&&(Sr.includes("top")&&or<0||Sr.includes("bottom")&&or>0)&&(jr.y=or):_e==="x"&&(Sr.includes("left")||Sr.includes("right"))&&(Sr.includes("left")&&Vn<0||Sr.includes("right")&&Vn>0)&&(jr.x=Vn),(Math.abs(jr.x)>0||Math.abs(jr.y)>0)&&at(!0),(bi=Ze.current)==null||bi.style.setProperty("--swipe-amount-x",`${jr.x}px`),(ft=Ze.current)==null||ft.style.setProperty("--swipe-amount-y",`${jr.y}px`)}},As&&!v.jsx?ht.createElement("button",{"aria-label":ue,"data-disabled":Ia,"data-close-button":!0,onClick:Ia||!it?()=>{}:()=>{var Gr;ur(),(Gr=v.onDismiss)==null||Gr.call(v,v)},className:Sg(fe==null?void 0:fe.closeButton,(a=v==null?void 0:v.classNames)==null?void 0:a.closeButton)},(o=ge==null?void 0:ge.close)!=null?o:tyt):null,v.jsx||N.isValidElement(v.title)?v.jsx?v.jsx:typeof v.title=="function"?v.title():v.title:ht.createElement(ht.Fragment,null,et||v.icon||v.promise?ht.createElement("div",{"data-icon":"",className:Sg(fe==null?void 0:fe.icon,(l=v==null?void 0:v.classNames)==null?void 0:l.icon)},v.promise||v.type==="loading"&&!v.icon?v.icon||Jr():null,v.type!=="loading"?v.icon||(ge==null?void 0:ge[et])||Kgt(et):null):null,ht.createElement("div",{"data-content":"",className:Sg(fe==null?void 0:fe.content,(i=v==null?void 0:v.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:Sg(fe==null?void 0:fe.title,(c=v==null?void 0:v.classNames)==null?void 0:c.title)},typeof v.title=="function"?v.title():v.title),v.description?ht.createElement("div",{"data-description":"",className:Sg(ee,Vt,fe==null?void 0:fe.description,(u=v==null?void 0:v.classNames)==null?void 0:u.description)},typeof v.description=="function"?v.description():v.description):null),N.isValidElement(v.cancel)?v.cancel:v.cancel&&Y7(v.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:v.cancelButtonStyle||V,onClick:Gr=>{var mn,Yr;Y7(v.cancel)&&it&&((Yr=(mn=v.cancel).onClick)==null||Yr.call(mn,Gr),ur())},className:Sg(fe==null?void 0:fe.cancelButton,(p=v==null?void 0:v.classNames)==null?void 0:p.cancelButton)},v.cancel.label):null,N.isValidElement(v.action)?v.action:v.action&&Y7(v.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:v.actionButtonStyle||X,onClick:Gr=>{var mn,Yr;Y7(v.action)&&((Yr=(mn=v.action).onClick)==null||Yr.call(mn,Gr),!Gr.defaultPrevented&&ur())},className:Sg(fe==null?void 0:fe.actionButton,(f=v==null?void 0:v.classNames)==null?void 0:f.actionButton)},v.action.label):null))};function XAe(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function vyt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?hyt:uyt;function c(u){["top","right","bottom","left"].forEach(p=>{r[`${l}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?c(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${l}-${u}`]=i:r[`${l}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):c(i)}),r}var byt=N.forwardRef(function(t,s){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:c,mobileOffset:u,theme:p="light",richColors:f,duration:g,style:v,visibleToasts:_=dyt,toastOptions:w,dir:j=XAe(),gap:k=pyt,loadingIcon:S,icons:M,containerAriaLabel:L="Notifications",pauseWhenPageIsHidden:P}=t,[O,$]=ht.useState([]),U=ht.useMemo(()=>Array.from(new Set([n].concat(O.filter(xe=>xe.position).map(xe=>xe.position)))),[O,n]),[B,V]=ht.useState([]),[X,Y]=ht.useState(!1),[ee,Q]=ht.useState(!1),[ce,ne]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),re=ht.useRef(null),oe=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),fe=ht.useRef(null),ge=ht.useRef(!1),ue=ht.useCallback(xe=>{$(_e=>{var $e;return($e=_e.find(Me=>Me.id===xe.id))!=null&&$e.delete||up.dismiss(xe.id),_e.filter(({id:Me})=>Me!==xe.id)})},[]);return ht.useEffect(()=>up.subscribe(xe=>{if(xe.dismiss){$(_e=>_e.map($e=>$e.id===xe.id?{...$e,delete:!0}:$e));return}setTimeout(()=>{w2e.flushSync(()=>{$(_e=>{let $e=_e.findIndex(Me=>Me.id===xe.id);return $e!==-1?[..._e.slice(0,$e),{..._e[$e],...xe},..._e.slice($e+1)]:[xe,..._e]})})})}),[]),ht.useEffect(()=>{if(p!=="system"){ne(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ne("dark"):ne("light")),typeof window>"u")return;let xe=window.matchMedia("(prefers-color-scheme: dark)");try{xe.addEventListener("change",({matches:_e})=>{ne(_e?"dark":"light")})}catch{xe.addListener(({matches:$e})=>{try{ne($e?"dark":"light")}catch(Me){console.error(Me)}})}},[p]),ht.useEffect(()=>{O.length<=1&&Y(!1)},[O]),ht.useEffect(()=>{let xe=_e=>{var $e,Me;a.every(Ie=>_e[Ie]||_e.code===Ie)&&(Y(!0),($e=re.current)==null||$e.focus()),_e.code==="Escape"&&(document.activeElement===re.current||(Me=re.current)!=null&&Me.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[a]),ht.useEffect(()=>{if(re.current)return()=>{fe.current&&(fe.current.focus({preventScroll:!0}),fe.current=null,ge.current=!1)}},[re.current]),ht.createElement("section",{ref:s,"aria-label":`${L} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((xe,_e)=>{var $e;let[Me,Ie]=xe.split("-");return O.length?ht.createElement("ol",{key:xe,dir:j==="auto"?XAe():j,tabIndex:-1,ref:re,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Me,"data-lifted":X&&O.length>1&&!o,"data-x-position":Ie,style:{"--front-toast-height":`${(($e=B[0])==null?void 0:$e.height)||0}px`,"--width":`${myt}px`,"--gap":`${k}px`,...v,...vyt(c,u)},onBlur:ke=>{ge.current&&!ke.currentTarget.contains(ke.relatedTarget)&&(ge.current=!1,fe.current&&(fe.current.focus({preventScroll:!0}),fe.current=null))},onFocus:ke=>{ke.target instanceof HTMLElement&&ke.target.dataset.dismissible==="false"||ge.current||(ge.current=!0,fe.current=ke.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{ee||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:ke=>{ke.target instanceof HTMLElement&&ke.target.dataset.dismissible==="false"||Q(!0)},onPointerUp:()=>Q(!1)},O.filter(ke=>!ke.position&&_e===0||ke.position===xe).map((ke,pe)=>{var we,Le;return ht.createElement(yyt,{key:ke.id,icons:M,index:pe,toast:ke,defaultRichColors:f,duration:(we=w==null?void 0:w.duration)!=null?we:g,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:_,closeButton:(Le=w==null?void 0:w.closeButton)!=null?Le:l,interacting:ee,position:xe,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ue,toasts:O.filter(Qe=>Qe.position==ke.position),heights:B.filter(Qe=>Qe.position==ke.position),setHeights:V,expandByDefault:o,gap:k,loadingIcon:S,expanded:X,pauseWhenPageIsHidden:P,swipeDirections:t.swipeDirections})})):null}))});const _yt=({...t})=>{const{theme:s="system"}=Wgt();return e.jsx(byt,{theme:s,position:"top-center",className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var wyt=Ewe[" useId ".trim().toString()]||(()=>{}),jyt=0;function Eu(t){const[s,r]=N.useState(wyt());return jd(()=>{r(n=>n??String(jyt++))},[t]),s?`radix-${s}`:""}const Nyt=["top","right","bottom","left"],pw=Math.min,nf=Math.max,yoe=Math.round,Q7=Math.floor,N0=t=>({x:t,y:t}),kyt={left:"right",right:"left",bottom:"top",top:"bottom"},Syt={start:"end",end:"start"};function K0e(t,s,r){return nf(t,pw(s,r))}function I1(t,s){return typeof t=="function"?t(s):t}function L1(t){return t.split("-")[0]}function KA(t){return t.split("-")[1]}function A2e(t){return t==="x"?"y":"x"}function E2e(t){return t==="y"?"height":"width"}const Cyt=new Set(["top","bottom"]);function l0(t){return Cyt.has(L1(t))?"y":"x"}function P2e(t){return A2e(l0(t))}function Myt(t,s,r){r===void 0&&(r=!1);const n=KA(t),a=P2e(t),o=E2e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=voe(l)),[l,voe(l)]}function Tyt(t){const s=voe(t);return[Z0e(t),s,Z0e(s)]}function Z0e(t){return t.replace(/start|end/g,s=>Syt[s])}const JAe=["left","right"],eEe=["right","left"],Ayt=["top","bottom"],Eyt=["bottom","top"];function Pyt(t,s,r){switch(t){case"top":case"bottom":return r?s?eEe:JAe:s?JAe:eEe;case"left":case"right":return s?Ayt:Eyt;default:return[]}}function Iyt(t,s,r,n){const a=KA(t);let o=Pyt(L1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(Z0e)))),o}function voe(t){return t.replace(/left|right|bottom|top/g,s=>kyt[s])}function Lyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function Lqe(t){return typeof t!="number"?Lyt(t):{top:t,right:t,bottom:t,left:t}}function boe(t){const{x:s,y:r,width:n,height:a}=t;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function tEe(t,s,r){let{reference:n,floating:a}=t;const o=l0(s),l=P2e(s),i=E2e(l),c=L1(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,g=n[i]/2-a[i]/2;let v;switch(c){case"top":v={x:p,y:n.y-a.height};break;case"bottom":v={x:p,y:n.y+n.height};break;case"right":v={x:n.x+n.width,y:f};break;case"left":v={x:n.x-a.width,y:f};break;default:v={x:n.x,y:n.y}}switch(KA(s)){case"start":v[l]-=g*(r&&u?-1:1);break;case"end":v[l]+=g*(r&&u?-1:1);break}return v}const Dyt=async(t,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=r,i=o.filter(Boolean),c=await(l.isRTL==null?void 0:l.isRTL(s));let u=await l.getElementRects({reference:t,floating:s,strategy:a}),{x:p,y:f}=tEe(u,n,c),g=n,v={},_=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:c}=s,{element:u,padding:p=0}=I1(t,s)||{};if(u==null)return{};const f=Lqe(p),g={x:r,y:n},v=P2e(a),_=E2e(v),w=await l.getDimensions(u),j=v==="y",k=j?"top":"left",S=j?"bottom":"right",M=j?"clientHeight":"clientWidth",L=o.reference[_]+o.reference[v]-g[v]-o.floating[_],P=g[v]-o.reference[v],O=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=O?O[M]:0;(!$||!await(l.isElement==null?void 0:l.isElement(O)))&&($=i.floating[M]||o.floating[_]);const U=L/2-P/2,B=$/2-w[_]/2-1,V=pw(f[k],B),X=pw(f[S],B),Y=V,ee=$-w[_]-X,Q=$/2-w[_]/2+U,ce=K0e(Y,Q,ee),ne=!c.arrow&&KA(a)!=null&&Q!==ce&&o.reference[_]/2-(QQ<=0)){var X,Y;const Q=(((X=o.flip)==null?void 0:X.index)||0)+1,ce=$[Q];if(ce&&(!(f==="alignment"?S!==l0(ce):!1)||V.every(oe=>oe.overflows[0]>0&&l0(oe.placement)===S)))return{data:{index:Q,overflows:V},reset:{placement:ce}};let ne=(Y=V.filter(re=>re.overflows[0]<=0).sort((re,oe)=>re.overflows[1]-oe.overflows[1])[0])==null?void 0:Y.placement;if(!ne)switch(v){case"bestFit":{var ee;const re=(ee=V.filter(oe=>{if(O){const fe=l0(oe.placement);return fe===S||fe==="y"}return!0}).map(oe=>[oe.placement,oe.overflows.filter(fe=>fe>0).reduce((fe,ge)=>fe+ge,0)]).sort((oe,fe)=>oe[1]-fe[1])[0])==null?void 0:ee[0];re&&(ne=re);break}case"initialPlacement":ne=i;break}if(a!==ne)return{reset:{placement:ne}}}return{}}}};function sEe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function rEe(t){return Nyt.some(s=>t[s]>=0)}const Fyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=I1(t,s);switch(n){case"referenceHidden":{const o=await J8(s,{...a,elementContext:"reference"}),l=sEe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:rEe(l)}}}case"escaped":{const o=await J8(s,{...a,altBoundary:!0}),l=sEe(o,r.floating);return{data:{escapedOffsets:l,escaped:rEe(l)}}}default:return{}}}}},Dqe=new Set(["left","top"]);async function zyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=L1(r),i=KA(r),c=l0(r)==="y",u=Dqe.has(l)?-1:1,p=o&&c?-1:1,f=I1(s,t);let{mainAxis:g,crossAxis:v,alignmentAxis:_}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof _=="number"&&(v=i==="end"?_*-1:_),c?{x:v*p,y:g*u}:{x:g*u,y:v*p}}const Byt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var r,n;const{x:a,y:o,placement:l,middlewareData:i}=s,c=await zyt(s,t);return l===((r=i.offset)==null?void 0:r.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:o+c.y,data:{...c,placement:l}}}}},$yt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:j=>{let{x:k,y:S}=j;return{x:k,y:S}}},...c}=I1(t,s),u={x:r,y:n},p=await J8(s,c),f=l0(L1(a)),g=A2e(f);let v=u[g],_=u[f];if(o){const j=g==="y"?"top":"left",k=g==="y"?"bottom":"right",S=v+p[j],M=v-p[k];v=K0e(S,v,M)}if(l){const j=f==="y"?"top":"left",k=f==="y"?"bottom":"right",S=_+p[j],M=_-p[k];_=K0e(S,_,M)}const w=i.fn({...s,[g]:v,[f]:_});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[g]:o,[f]:l}}}}}},qyt=function(t){return t===void 0&&(t={}),{options:t,fn(s){const{x:r,y:n,placement:a,rects:o,middlewareData:l}=s,{offset:i=0,mainAxis:c=!0,crossAxis:u=!0}=I1(t,s),p={x:r,y:n},f=l0(a),g=A2e(f);let v=p[g],_=p[f];const w=I1(i,s),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const M=g==="y"?"height":"width",L=o.reference[g]-o.floating[M]+j.mainAxis,P=o.reference[g]+o.reference[M]-j.mainAxis;vP&&(v=P)}if(u){var k,S;const M=g==="y"?"width":"height",L=Dqe.has(L1(a)),P=o.reference[f]-o.floating[M]+(L&&((k=l.offset)==null?void 0:k[f])||0)+(L?0:j.crossAxis),O=o.reference[f]+o.reference[M]+(L?0:((S=l.offset)==null?void 0:S[f])||0)-(L?j.crossAxis:0);_O&&(_=O)}return{[g]:v,[f]:_}}}},Uyt=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){var r,n;const{placement:a,rects:o,platform:l,elements:i}=s,{apply:c=()=>{},...u}=I1(t,s),p=await J8(s,u),f=L1(a),g=KA(a),v=l0(a)==="y",{width:_,height:w}=o.floating;let j,k;f==="top"||f==="bottom"?(j=f,k=g===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(k=f,j=g==="end"?"top":"bottom");const S=w-p.top-p.bottom,M=_-p.left-p.right,L=pw(w-p[j],S),P=pw(_-p[k],M),O=!s.middlewareData.shift;let $=L,U=P;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(U=M),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=S),O&&!g){const V=nf(p.left,0),X=nf(p.right,0),Y=nf(p.top,0),ee=nf(p.bottom,0);v?U=_-2*(V!==0||X!==0?V+X:nf(p.left,p.right)):$=w-2*(Y!==0||ee!==0?Y+ee:nf(p.top,p.bottom))}await c({...s,availableWidth:U,availableHeight:$});const B=await l.getDimensions(i.floating);return _!==B.width||w!==B.height?{reset:{rects:!0}}:{}}}};function Dde(){return typeof window<"u"}function ZA(t){return Oqe(t)?(t.nodeName||"").toLowerCase():"#document"}function gf(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function B0(t){var s;return(s=(Oqe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function Oqe(t){return Dde()?t instanceof Node||t instanceof gf(t).Node:!1}function oy(t){return Dde()?t instanceof Element||t instanceof gf(t).Element:!1}function E0(t){return Dde()?t instanceof HTMLElement||t instanceof gf(t).HTMLElement:!1}function nEe(t){return!Dde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof gf(t).ShadowRoot}const Vyt=new Set(["inline","contents"]);function EO(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=ly(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!Vyt.has(a)}const Hyt=new Set(["table","td","th"]);function Gyt(t){return Hyt.has(ZA(t))}const Wyt=[":popover-open",":modal"];function Ode(t){return Wyt.some(s=>{try{return t.matches(s)}catch{return!1}})}const Kyt=["transform","translate","scale","rotate","perspective"],Zyt=["transform","translate","scale","rotate","perspective","filter"],Yyt=["paint","layout","strict","content"];function I2e(t){const s=L2e(),r=oy(t)?ly(t):t;return Kyt.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||Zyt.some(n=>(r.willChange||"").includes(n))||Yyt.some(n=>(r.contain||"").includes(n))}function Qyt(t){let s=fw(t);for(;E0(s)&&!zT(s);){if(I2e(s))return s;if(Ode(s))return null;s=fw(s)}return null}function L2e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Xyt=new Set(["html","body","#document"]);function zT(t){return Xyt.has(ZA(t))}function ly(t){return gf(t).getComputedStyle(t)}function Rde(t){return oy(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function fw(t){if(ZA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||nEe(t)&&t.host||B0(t);return nEe(s)?s.host:s}function Rqe(t){const s=fw(t);return zT(s)?t.ownerDocument?t.ownerDocument.body:t.body:E0(s)&&EO(s)?s:Rqe(s)}function eD(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=Rqe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=gf(a);if(o){const i=Y0e(l);return s.concat(l,l.visualViewport||[],EO(a)?a:[],i&&r?eD(i):[])}return s.concat(a,eD(a,[],r))}function Y0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Fqe(t){const s=ly(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=E0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=yoe(r)!==o||yoe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function D2e(t){return oy(t)?t:t.contextElement}function tT(t){const s=D2e(t);if(!E0(s))return N0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=Fqe(s);let l=(o?yoe(r.width):r.width)/n,i=(o?yoe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Jyt=N0(0);function zqe(t){const s=gf(t);return!L2e()||!s.visualViewport?Jyt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function e0t(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==gf(t)?!1:s}function US(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=D2e(t);let l=N0(1);s&&(n?oy(n)&&(l=tT(n)):l=tT(t));const i=e0t(o,r,n)?zqe(o):N0(0);let c=(a.left+i.x)/l.x,u=(a.top+i.y)/l.y,p=a.width/l.x,f=a.height/l.y;if(o){const g=gf(o),v=n&&oy(n)?gf(n):n;let _=g,w=Y0e(_);for(;w&&n&&v!==_;){const j=tT(w),k=w.getBoundingClientRect(),S=ly(w),M=k.left+(w.clientLeft+parseFloat(S.paddingLeft))*j.x,L=k.top+(w.clientTop+parseFloat(S.paddingTop))*j.y;c*=j.x,u*=j.y,p*=j.x,f*=j.y,c+=M,u+=L,_=gf(w),w=Y0e(_)}}return boe({width:p,height:f,x:c,y:u})}function O2e(t,s){const r=Rde(t).scrollLeft;return s?s.left+r:US(B0(t)).left+r}function Bqe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:O2e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function t0t(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=B0(n),i=s?Ode(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=N0(1);const p=N0(0),f=E0(n);if((f||!f&&!o)&&((ZA(n)!=="body"||EO(l))&&(c=Rde(n)),E0(n))){const v=US(n);u=tT(n),p.x=v.x+n.clientLeft,p.y=v.y+n.clientTop}const g=l&&!f&&!o?Bqe(l,c,!0):N0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+p.x+g.x,y:r.y*u.y-c.scrollTop*u.y+p.y+g.y}}function s0t(t){return Array.from(t.getClientRects())}function r0t(t){const s=B0(t),r=Rde(t),n=t.ownerDocument.body,a=nf(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=nf(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+O2e(t);const i=-r.scrollTop;return ly(n).direction==="rtl"&&(l+=nf(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function n0t(t,s){const r=gf(t),n=B0(t),a=r.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,c=0;if(a){o=a.width,l=a.height;const u=L2e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const a0t=new Set(["absolute","fixed"]);function i0t(t,s){const r=US(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=E0(t)?tT(t):N0(1),l=t.clientWidth*o.x,i=t.clientHeight*o.y,c=a*o.x,u=n*o.y;return{width:l,height:i,x:c,y:u}}function aEe(t,s,r){let n;if(s==="viewport")n=n0t(t,r);else if(s==="document")n=r0t(B0(t));else if(oy(s))n=i0t(s,r);else{const a=zqe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return boe(n)}function $qe(t,s){const r=fw(t);return r===s||!oy(r)||zT(r)?!1:ly(r).position==="fixed"||$qe(r,s)}function o0t(t,s){const r=s.get(t);if(r)return r;let n=eD(t,[],!1).filter(i=>oy(i)&&ZA(i)!=="body"),a=null;const o=ly(t).position==="fixed";let l=o?fw(t):t;for(;oy(l)&&!zT(l);){const i=ly(l),c=I2e(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&a0t.has(a.position)||EO(l)&&!c&&$qe(t,l))?n=n.filter(p=>p!==l):a=i,l=fw(l)}return s.set(t,n),n}function l0t(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?Ode(s)?[]:o0t(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,p)=>{const f=aEe(s,p,a);return u.top=nf(f.top,u.top),u.right=pw(f.right,u.right),u.bottom=pw(f.bottom,u.bottom),u.left=nf(f.left,u.left),u},aEe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function c0t(t){const{width:s,height:r}=Fqe(t);return{width:s,height:r}}function d0t(t,s,r){const n=E0(s),a=B0(s),o=r==="fixed",l=US(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=N0(0);function u(){c.x=O2e(a)}if(n||!n&&!o)if((ZA(s)!=="body"||EO(a))&&(i=Rde(s)),n){const v=US(s,!0,o,s);c.x=v.x+s.clientLeft,c.y=v.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?Bqe(a,i):N0(0),f=l.left+i.scrollLeft-c.x-p.x,g=l.top+i.scrollTop-c.y-p.y;return{x:f,y:g,width:l.width,height:l.height}}function uxe(t){return ly(t).position==="static"}function iEe(t,s){if(!E0(t)||ly(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return B0(t)===r&&(r=r.ownerDocument.body),r}function qqe(t,s){const r=gf(t);if(Ode(t))return r;if(!E0(t)){let a=fw(t);for(;a&&!zT(a);){if(oy(a)&&!uxe(a))return a;a=fw(a)}return r}let n=iEe(t,s);for(;n&&Gyt(n)&&uxe(n);)n=iEe(n,s);return n&&zT(n)&&uxe(n)&&!I2e(n)?r:n||Qyt(t)||r}const u0t=async function(t){const s=this.getOffsetParent||qqe,r=this.getDimensions,n=await r(t.floating);return{reference:d0t(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function h0t(t){return ly(t).direction==="rtl"}const m0t={convertOffsetParentRelativeRectToViewportRelativeRect:t0t,getDocumentElement:B0,getClippingRect:l0t,getOffsetParent:qqe,getElementRects:u0t,getClientRects:s0t,getDimensions:c0t,getScale:tT,isElement:oy,isRTL:h0t};function Uqe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function p0t(t,s){let r=null,n;const a=B0(t);function o(){var i;clearTimeout(n),(i=r)==null||i.disconnect(),r=null}function l(i,c){i===void 0&&(i=!1),c===void 0&&(c=1),o();const u=t.getBoundingClientRect(),{left:p,top:f,width:g,height:v}=u;if(i||s(),!g||!v)return;const _=Q7(f),w=Q7(a.clientWidth-(p+g)),j=Q7(a.clientHeight-(f+v)),k=Q7(p),M={rootMargin:-_+"px "+-w+"px "+-j+"px "+-k+"px",threshold:nf(0,pw(1,c))||1};let L=!0;function P(O){const $=O[0].intersectionRatio;if($!==c){if(!L)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!Uqe(u,t.getBoundingClientRect())&&l(),L=!1}try{r=new IntersectionObserver(P,{...M,root:a.ownerDocument})}catch{r=new IntersectionObserver(P,M)}r.observe(t)}return l(!0),o}function f0t(t,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=D2e(t),p=a||o?[...u?eD(u):[],...eD(s)]:[];p.forEach(k=>{a&&k.addEventListener("scroll",r,{passive:!0}),o&&k.addEventListener("resize",r)});const f=u&&i?p0t(u,r):null;let g=-1,v=null;l&&(v=new ResizeObserver(k=>{let[S]=k;S&&S.target===u&&v&&(v.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=v)==null||M.observe(s)})),r()}),u&&!c&&v.observe(u),v.observe(s));let _,w=c?US(t):null;c&&j();function j(){const k=US(t);w&&!Uqe(w,k)&&r(),w=k,_=requestAnimationFrame(j)}return r(),()=>{var k;p.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(k=v)==null||k.disconnect(),v=null,c&&cancelAnimationFrame(_)}}const x0t=Byt,g0t=$yt,y0t=Ryt,v0t=Uyt,b0t=Fyt,oEe=Oyt,_0t=qyt,w0t=(t,s,r)=>{const n=new Map,a={platform:m0t,...r},o={...a.platform,_c:n};return Dyt(t,s,{...a,platform:o})};var j0t=typeof document<"u",N0t=function(){},gie=j0t?N.useLayoutEffect:N0t;function _oe(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let r,n,a;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==s.length)return!1;for(n=r;n--!==0;)if(!_oe(t[n],s[n]))return!1;return!0}if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(s,a[n]))return!1;for(n=r;n--!==0;){const o=a[n];if(!(o==="_owner"&&t.$$typeof)&&!_oe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function Vqe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function lEe(t,s){const r=Vqe(t);return Math.round(s*r)/r}function hxe(t){const s=N.useRef(t);return gie(()=>{s.current=t}),s}function k0t(t){t===void 0&&(t={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:c,open:u}=t,[p,f]=N.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,v]=N.useState(n);_oe(g,n)||v(n);const[_,w]=N.useState(null),[j,k]=N.useState(null),S=N.useCallback(oe=>{oe!==O.current&&(O.current=oe,w(oe))},[]),M=N.useCallback(oe=>{oe!==$.current&&($.current=oe,k(oe))},[]),L=o||_,P=l||j,O=N.useRef(null),$=N.useRef(null),U=N.useRef(p),B=c!=null,V=hxe(c),X=hxe(a),Y=hxe(u),ee=N.useCallback(()=>{if(!O.current||!$.current)return;const oe={placement:s,strategy:r,middleware:g};X.current&&(oe.platform=X.current),w0t(O.current,$.current,oe).then(fe=>{const ge={...fe,isPositioned:Y.current!==!1};Q.current&&!_oe(U.current,ge)&&(U.current=ge,yp.flushSync(()=>{f(ge)}))})},[g,s,r,X,Y]);gie(()=>{u===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,f(oe=>({...oe,isPositioned:!1})))},[u]);const Q=N.useRef(!1);gie(()=>(Q.current=!0,()=>{Q.current=!1}),[]),gie(()=>{if(L&&(O.current=L),P&&($.current=P),L&&P){if(V.current)return V.current(L,P,ee);ee()}},[L,P,ee,V,B]);const ce=N.useMemo(()=>({reference:O,floating:$,setReference:S,setFloating:M}),[S,M]),ne=N.useMemo(()=>({reference:L,floating:P}),[L,P]),re=N.useMemo(()=>{const oe={position:r,left:0,top:0};if(!ne.floating)return oe;const fe=lEe(ne.floating,p.x),ge=lEe(ne.floating,p.y);return i?{...oe,transform:"translate("+fe+"px, "+ge+"px)",...Vqe(ne.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:ge}},[r,i,ne.floating,p.x,p.y]);return N.useMemo(()=>({...p,update:ee,refs:ce,elements:ne,floatingStyles:re}),[p,ee,ce,ne,re])}const S0t=t=>{function s(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:a}=typeof t=="function"?t(r):t;return n&&s(n)?n.current!=null?oEe({element:n.current,padding:a}).fn(r):{}:n?oEe({element:n,padding:a}).fn(r):{}}}},C0t=(t,s)=>({...x0t(t),options:[t,s]}),M0t=(t,s)=>({...g0t(t),options:[t,s]}),T0t=(t,s)=>({..._0t(t),options:[t,s]}),A0t=(t,s)=>({...y0t(t),options:[t,s]}),E0t=(t,s)=>({...v0t(t),options:[t,s]}),P0t=(t,s)=>({...b0t(t),options:[t,s]}),I0t=(t,s)=>({...S0t(t),options:[t,s]});var L0t="Arrow",Hqe=N.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(an.svg,{...o,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:e.jsx("polygon",{points:"0,0 30,0 15,10"})})});Hqe.displayName=L0t;var D0t=Hqe;function PO(t){const[s,r]=N.useState(void 0);return jd(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let l,i;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,i=u.blockSize}else l=t.offsetWidth,i=t.offsetHeight;r({width:l,height:i})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),s}var R2e="Popper",[Gqe,$0]=od(R2e),[O0t,Wqe]=Gqe(R2e),Kqe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=N.useState(null);return e.jsx(O0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};Kqe.displayName=R2e;var Zqe="PopperAnchor",Yqe=N.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=Wqe(Zqe,r),l=N.useRef(null),i=Va(s,l);return N.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(an.div,{...a,ref:i})});Yqe.displayName=Zqe;var F2e="PopperContent",[R0t,F0t]=Gqe(F2e),Qqe=N.forwardRef((t,s)=>{var ke,pe,we,Le,Qe,Te;const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:f="partial",hideWhenDetached:g=!1,updatePositionStrategy:v="optimized",onPlaced:_,...w}=t,j=Wqe(F2e,r),[k,S]=N.useState(null),M=Va(s,pt=>S(pt)),[L,P]=N.useState(null),O=PO(L),$=(O==null?void 0:O.width)??0,U=(O==null?void 0:O.height)??0,B=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},X=Array.isArray(u)?u:[u],Y=X.length>0,ee={padding:V,boundary:X.filter(B0t),altBoundary:Y},{refs:Q,floatingStyles:ce,placement:ne,isPositioned:re,middlewareData:oe}=k0t({strategy:"fixed",placement:B,whileElementsMounted:(...pt)=>f0t(...pt,{animationFrame:v==="always"}),elements:{reference:j.anchor},middleware:[C0t({mainAxis:a+U,alignmentAxis:l}),c&&M0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T0t():void 0,...ee}),c&&A0t({...ee}),E0t({...ee,apply:({elements:pt,rects:ye,availableWidth:qe,availableHeight:at})=>{const{width:tt,height:Ae}=ye.reference,rt=pt.floating.style;rt.setProperty("--radix-popper-available-width",`${qe}px`),rt.setProperty("--radix-popper-available-height",`${at}px`),rt.setProperty("--radix-popper-anchor-width",`${tt}px`),rt.setProperty("--radix-popper-anchor-height",`${Ae}px`)}}),L&&I0t({element:L,padding:i}),$0t({arrowWidth:$,arrowHeight:U}),g&&P0t({strategy:"referenceHidden",...ee})]}),[fe,ge]=eUe(ne),ue=bd(_);jd(()=>{re&&(ue==null||ue())},[re,ue]);const xe=(ke=oe.arrow)==null?void 0:ke.x,_e=(pe=oe.arrow)==null?void 0:pe.y,$e=((we=oe.arrow)==null?void 0:we.centerOffset)!==0,[Me,Ie]=N.useState();return jd(()=>{k&&Ie(window.getComputedStyle(k).zIndex)},[k]),e.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:re?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Me,"--radix-popper-transform-origin":[(Le=oe.transformOrigin)==null?void 0:Le.x,(Qe=oe.transformOrigin)==null?void 0:Qe.y].join(" "),...((Te=oe.hide)==null?void 0:Te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(R0t,{scope:r,placedSide:fe,onArrowChange:P,arrowX:xe,arrowY:_e,shouldHideArrow:$e,children:e.jsx(an.div,{"data-side":fe,"data-align":ge,...w,ref:M,style:{...w.style,animation:re?void 0:"none"}})})})});Qqe.displayName=F2e;var Xqe="PopperArrow",z0t={top:"bottom",right:"left",bottom:"top",left:"right"},Jqe=N.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=F0t(Xqe,n),l=z0t[o.placedSide];return e.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:e.jsx(D0t,{...a,ref:r,style:{...a.style,display:"block"}})})});Jqe.displayName=Xqe;function B0t(t){return t!==null}var $0t=t=>({name:"transformOrigin",options:t,fn(s){var j,k,S;const{placement:r,rects:n,middlewareData:a}=s,l=((j=a.arrow)==null?void 0:j.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,p]=eUe(r),f={start:"0%",center:"50%",end:"100%"}[p],g=(((k=a.arrow)==null?void 0:k.x)??0)+i/2,v=(((S=a.arrow)==null?void 0:S.y)??0)+c/2;let _="",w="";return u==="bottom"?(_=l?f:`${g}px`,w=`${-c}px`):u==="top"?(_=l?f:`${g}px`,w=`${n.floating.height+c}px`):u==="right"?(_=`${-c}px`,w=l?f:`${v}px`):u==="left"&&(_=`${n.floating.width+c}px`,w=l?f:`${v}px`),{data:{x:_,y:w}}}});function eUe(t){const[s,r="center"]=t.split("-");return[s,r]}var IO=Kqe,YA=Yqe,LO=Qqe,DO=Jqe,[Fde]=od("Tooltip",[$0]),zde=$0(),tUe="TooltipProvider",q0t=700,Q0e="tooltip.open",[U0t,z2e]=Fde(tUe),sUe=t=>{const{__scopeTooltip:s,delayDuration:r=q0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=N.useRef(!0),i=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(U0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:N.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:N.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};sUe.displayName=tUe;var tD="Tooltip",[V0t,Bde]=Fde(tD),rUe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=z2e(tD,t.__scopeTooltip),u=zde(s),[p,f]=N.useState(null),g=Eu(),v=N.useRef(0),_=l??c.disableHoverableContent,w=i??c.delayDuration,j=N.useRef(!1),[k,S]=oh({prop:n,defaultProp:a??!1,onChange:$=>{$?(c.onOpen(),document.dispatchEvent(new CustomEvent(Q0e))):c.onClose(),o==null||o($)},caller:tD}),M=N.useMemo(()=>k?j.current?"delayed-open":"instant-open":"closed",[k]),L=N.useCallback(()=>{window.clearTimeout(v.current),v.current=0,j.current=!1,S(!0)},[S]),P=N.useCallback(()=>{window.clearTimeout(v.current),v.current=0,S(!1)},[S]),O=N.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{j.current=!0,S(!0),v.current=0},w)},[w,S]);return N.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),e.jsx(IO,{...u,children:e.jsx(V0t,{scope:s,contentId:g,open:k,stateAttribute:M,trigger:p,onTriggerChange:f,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?O():L()},[c.isOpenDelayedRef,O,L]),onTriggerLeave:N.useCallback(()=>{_?P():(window.clearTimeout(v.current),v.current=0)},[P,_]),onOpen:L,onClose:P,disableHoverableContent:_,children:r})})};rUe.displayName=tD;var X0e="TooltipTrigger",nUe=N.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Bde(X0e,r),o=z2e(X0e,r),l=zde(r),i=N.useRef(null),c=Va(s,i,a.onTriggerChange),u=N.useRef(!1),p=N.useRef(!1),f=N.useCallback(()=>u.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(YA,{asChild:!0,...l,children:e.jsx(an.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Lr(t.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Lr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Lr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Lr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Lr(t.onBlur,a.onClose),onClick:Lr(t.onClick,a.onClose)})})});nUe.displayName=X0e;var H0t="TooltipPortal",[DTs,G0t]=Fde(H0t,{forceMount:void 0}),BT="TooltipContent",aUe=N.forwardRef((t,s)=>{const r=G0t(BT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=Bde(BT,t.__scopeTooltip);return e.jsx(zd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(iUe,{side:a,...o,ref:s}):e.jsx(W0t,{side:a,...o,ref:s})})}),W0t=N.forwardRef((t,s)=>{const r=Bde(BT,t.__scopeTooltip),n=z2e(BT,t.__scopeTooltip),a=N.useRef(null),o=Va(s,a),[l,i]=N.useState(null),{trigger:c,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,g=N.useCallback(()=>{i(null),f(!1)},[f]),v=N.useCallback((_,w)=>{const j=_.currentTarget,k={x:_.clientX,y:_.clientY},S=X0t(k,j.getBoundingClientRect()),M=J0t(k,S),L=evt(w.getBoundingClientRect()),P=svt([...M,...L]);i(P),f(!0)},[f]);return N.useEffect(()=>()=>g(),[g]),N.useEffect(()=>{if(c&&p){const _=j=>v(j,p),w=j=>v(j,c);return c.addEventListener("pointerleave",_),p.addEventListener("pointerleave",w),()=>{c.removeEventListener("pointerleave",_),p.removeEventListener("pointerleave",w)}}},[c,p,v,g]),N.useEffect(()=>{if(l){const _=w=>{const j=w.target,k={x:w.clientX,y:w.clientY},S=(c==null?void 0:c.contains(j))||(p==null?void 0:p.contains(j)),M=!tvt(k,l);S?g():M&&(g(),u())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[c,p,l,u,g]),e.jsx(iUe,{...t,ref:o})}),[K0t,Z0t]=Fde(tD,{isInside:!1}),Y0t=Q$e("TooltipContent"),iUe=N.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=Bde(BT,r),u=zde(r),{onClose:p}=c;return N.useEffect(()=>(document.addEventListener(Q0e,p),()=>document.removeEventListener(Q0e,p)),[p]),N.useEffect(()=>{if(c.trigger){const f=g=>{const v=g.target;v!=null&&v.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),e.jsx(Aw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(LO,{"data-state":c.stateAttribute,...u,...i,ref:s,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(Y0t,{children:n}),e.jsx(K0t,{scope:r,isInside:!0,children:e.jsx(Bxt,{id:c.contentId,role:"tooltip",children:a||n})})]})})});aUe.displayName=BT;var oUe="TooltipArrow",Q0t=N.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=zde(r);return Z0t(oUe,r).isInside?null:e.jsx(DO,{...a,...n,ref:s})});Q0t.displayName=oUe;function X0t(t,s){const r=Math.abs(s.top-t.y),n=Math.abs(s.bottom-t.y),a=Math.abs(s.right-t.x),o=Math.abs(s.left-t.x);switch(Math.min(r,n,a,o)){case o:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function J0t(t,s,r=5){const n=[];switch(s){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function evt(t){const{top:s,right:r,bottom:n,left:a}=t;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function tvt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function svt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),rvt(s)}function rvt(t){if(t.length<=1)return t.slice();const s=[];for(let n=0;n=2;){const o=s[s.length-1],l=s[s.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=t.length-1;n>=0;n--){const a=t[n];for(;r.length>=2;){const o=r[r.length-1],l=r[r.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))r.pop();else break}r.push(a)}return r.pop(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var nvt=sUe,avt=rUe,ivt=nUe,lUe=aUe;const G1=nvt,Nc=avt,kc=ivt,ec=N.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(lUe,{ref:n,sideOffset:s,className:It("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));ec.displayName=lUe.displayName;var QA=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},VS=typeof window>"u"||"Deno"in globalThis;function wm(){}function ovt(t,s){return typeof t=="function"?t(s):t}function J0e(t){return typeof t=="number"&&t>=0&&t!==1/0}function cUe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function ew(t,s){return typeof t=="function"?t(s):t}function cx(t,s){return typeof t=="function"?t(s):t}function cEe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==B2e(l,s.options))return!1}else if(!sD(s.queryKey,l))return!1}if(r!=="all"){const c=s.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&s.isStale()!==i||a&&a!==s.state.fetchStatus||o&&!o(s))}function dEe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(HS(s.options.mutationKey)!==HS(o))return!1}else if(!sD(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function B2e(t,s){return((s==null?void 0:s.queryKeyHashFn)||HS)(t)}function HS(t){return JSON.stringify(t,(s,r)=>eve(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function sD(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>sD(t[r],s[r])):!1}function dUe(t,s){if(t===s)return t;const r=uEe(t)&&uEe(s);if(r||eve(t)&&eve(s)){const n=r?t:Object.keys(t),a=n.length,o=r?s:Object.keys(s),l=o.length,i=r?[]:{},c=new Set(n);let u=0;for(let p=0;p{setTimeout(s,t)})}function tve(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?dUe(t,s):s}function cvt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function dvt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var $2e=Symbol();function uUe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===$2e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function hUe(t,s){return typeof t=="function"?t(...s):!!t}var z4,g_,bT,k9e,uvt=(k9e=class extends QA{constructor(){super();ti(this,z4);ti(this,g_);ti(this,bT);Yn(this,bT,s=>{if(!VS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){is(this,g_)||this.setEventListener(is(this,bT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,g_))==null||s.call(this),Yn(this,g_,void 0))}setEventListener(s){var r;Yn(this,bT,s),(r=is(this,g_))==null||r.call(this),Yn(this,g_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){is(this,z4)!==s&&(Yn(this,z4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof is(this,z4)=="boolean"?is(this,z4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},z4=new WeakMap,g_=new WeakMap,bT=new WeakMap,k9e),q2e=new uvt,_T,y_,wT,S9e,hvt=(S9e=class extends QA{constructor(){super();ti(this,_T,!0);ti(this,y_);ti(this,wT);Yn(this,wT,s=>{if(!VS&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){is(this,y_)||this.setEventListener(is(this,wT))}onUnsubscribe(){var s;this.hasListeners()||((s=is(this,y_))==null||s.call(this),Yn(this,y_,void 0))}setEventListener(s){var r;Yn(this,wT,s),(r=is(this,y_))==null||r.call(this),Yn(this,y_,s(this.setOnline.bind(this)))}setOnline(s){is(this,_T)!==s&&(Yn(this,_T,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return is(this,_T)}},_T=new WeakMap,y_=new WeakMap,wT=new WeakMap,S9e),joe=new hvt;function sve(){let t,s;const r=new Promise((a,o)=>{t=a,s=o});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),t(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function mvt(t){return Math.min(1e3*2**t,3e4)}function mUe(t){return(t??"online")==="online"?joe.isOnline():!0}var pUe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function mxe(t){return t instanceof pUe}function fUe(t){let s=!1,r=0,n=!1,a;const o=sve(),l=w=>{var j;n||(g(new pUe(w)),(j=t.abort)==null||j.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>q2e.isFocused()&&(t.networkMode==="always"||joe.isOnline())&&t.canRun(),p=()=>mUe(t.networkMode)&&t.canRun(),f=w=>{var j;n||(n=!0,(j=t.onSuccess)==null||j.call(t,w),a==null||a(),o.resolve(w))},g=w=>{var j;n||(n=!0,(j=t.onError)==null||j.call(t,w),a==null||a(),o.reject(w))},v=()=>new Promise(w=>{var j;a=k=>{(n||u())&&w(k)},(j=t.onPause)==null||j.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),_=()=>{if(n)return;let w;const j=r===0?t.initialPromise:void 0;try{w=j??t.fn()}catch(k){w=Promise.reject(k)}Promise.resolve(w).then(f).catch(k=>{var O;if(n)return;const S=t.retry??(VS?0:3),M=t.retryDelay??mvt,L=typeof M=="function"?M(r,k):M,P=S===!0||typeof S=="number"&&ru()?void 0:v()).then(()=>{s?g(k):_()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:p,start:()=>(p()?_():v().then(_),o)}}var pvt=t=>setTimeout(t,0);function fvt(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=pvt;const o=i=>{s?t.push(i):a(()=>{r(i)})},l=()=>{const i=t;t=[],i.length&&a(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;s++;try{c=i()}finally{s--,s||l()}return c},batchCalls:i=>(...c)=>{o(()=>{i(...c)})},schedule:o,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var bu=fvt(),B4,C9e,xUe=(C9e=class{constructor(){ti(this,B4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),J0e(this.gcTime)&&Yn(this,B4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(VS?1/0:5*60*1e3))}clearGcTimeout(){is(this,B4)&&(clearTimeout(is(this,B4)),Yn(this,B4,void 0))}},B4=new WeakMap,C9e),jT,$4,lx,q4,$h,bO,U4,Og,Pv,M9e,xvt=(M9e=class extends xUe{constructor(s){super();ti(this,Og);ti(this,jT);ti(this,$4);ti(this,lx);ti(this,q4);ti(this,$h);ti(this,bO);ti(this,U4);Yn(this,U4,!1),Yn(this,bO,s.defaultOptions),this.setOptions(s.options),this.observers=[],Yn(this,q4,s.client),Yn(this,lx,is(this,q4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Yn(this,jT,gvt(this.options)),this.state=s.state??is(this,jT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=is(this,$h))==null?void 0:s.promise}setOptions(s){this.options={...is(this,bO),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&is(this,lx).remove(this)}setData(s,r){const n=tve(this.state.data,s,this.options);return Ji(this,Og,Pv).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Ji(this,Og,Pv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=is(this,$h))==null?void 0:n.promise;return(a=is(this,$h))==null||a.cancel(s),r?r.then(wm).catch(wm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(is(this,jT))}isActive(){return this.observers.some(s=>cx(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$2e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>ew(s.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(s=>s.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(s=0){return this.state.data===void 0?!0:s==="static"?!1:this.state.isInvalidated?!0:!cUe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,$h))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=is(this,$h))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),is(this,lx).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(is(this,$h)&&(is(this,U4)?is(this,$h).cancel({revert:!0}):is(this,$h).cancelRetry()),this.scheduleGc()),is(this,lx).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ji(this,Og,Pv).call(this,{type:"invalidate"})}fetch(s,r){var u,p,f;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(is(this,$h))return is(this,$h).continueRetry(),is(this,$h).promise}if(s&&this.setOptions(s),!this.options.queryFn){const g=this.observers.find(v=>v.options.queryFn);g&&this.setOptions(g.options)}const n=new AbortController,a=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Yn(this,U4,!0),n.signal)})},o=()=>{const g=uUe(this.options,r),_=(()=>{const w={client:is(this,q4),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return Yn(this,U4,!1),this.options.persister?this.options.persister(g,_,this):g(_)},i=(()=>{const g={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:is(this,q4),state:this.state,fetchFn:o};return a(g),g})();(u=this.options.behavior)==null||u.onFetch(i,this),Yn(this,$4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Ji(this,Og,Pv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=g=>{var v,_,w,j;mxe(g)&&g.silent||Ji(this,Og,Pv).call(this,{type:"error",error:g}),mxe(g)||((_=(v=is(this,lx).config).onError)==null||_.call(v,g,this),(j=(w=is(this,lx).config).onSettled)==null||j.call(w,this.state.data,g,this)),this.scheduleGc()};return Yn(this,$h,fUe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:g=>{var v,_,w,j;if(g===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(k){c(k);return}(_=(v=is(this,lx).config).onSuccess)==null||_.call(v,g,this),(j=(w=is(this,lx).config).onSettled)==null||j.call(w,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,v)=>{Ji(this,Og,Pv).call(this,{type:"failed",failureCount:g,error:v})},onPause:()=>{Ji(this,Og,Pv).call(this,{type:"pause"})},onContinue:()=>{Ji(this,Og,Pv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),is(this,$h).start()}},jT=new WeakMap,$4=new WeakMap,lx=new WeakMap,q4=new WeakMap,$h=new WeakMap,bO=new WeakMap,U4=new WeakMap,Og=new WeakSet,Pv=function(s){const r=n=>{switch(s.type){case"failed":return{...n,fetchFailureCount:s.failureCount,fetchFailureReason:s.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...gUe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Yn(this,$4,void 0),{...n,data:s.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:s.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=s.error;return mxe(a)&&a.revert&&is(this,$4)?{...is(this,$4),fetchStatus:"idle"}:{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...s.state}}};this.state=r(this.state),bu.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),is(this,lx).notify({query:this,type:"updated",action:s})})},M9e);function gUe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mUe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function gvt(t){const s=typeof t.initialData=="function"?t.initialData():t.initialData,r=s!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Jy,T9e,yvt=(T9e=class extends QA{constructor(s={}){super();ti(this,Jy);this.config=s,Yn(this,Jy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??B2e(a,r);let l=this.get(o);return l||(l=new xvt({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){is(this,Jy).has(s.queryHash)||(is(this,Jy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=is(this,Jy).get(s.queryHash);r&&(s.destroy(),r===s&&is(this,Jy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){bu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return is(this,Jy).get(s)}getAll(){return[...is(this,Jy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>cEe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>cEe(s,n)):r}notify(s){bu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){bu.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){bu.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Jy=new WeakMap,T9e),e0,vm,V4,t0,Hb,A9e,vvt=(A9e=class extends xUe{constructor(s){super();ti(this,t0);ti(this,e0);ti(this,vm);ti(this,V4);this.mutationId=s.mutationId,Yn(this,vm,s.mutationCache),Yn(this,e0,[]),this.state=s.state||yUe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){is(this,e0).includes(s)||(is(this,e0).push(s),this.clearGcTimeout(),is(this,vm).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Yn(this,e0,is(this,e0).filter(r=>r!==s)),this.scheduleGc(),is(this,vm).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){is(this,e0).length||(this.state.status==="pending"?this.scheduleGc():is(this,vm).remove(this))}continue(){var s;return((s=is(this,V4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,p,f,g,v,_,w,j,k,S,M,L,P,O,$,U;const r=()=>{Ji(this,t0,Hb).call(this,{type:"continue"})};Yn(this,V4,fUe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(B,V)=>{Ji(this,t0,Hb).call(this,{type:"failed",failureCount:B,error:V})},onPause:()=>{Ji(this,t0,Hb).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>is(this,vm).canRun(this)}));const n=this.state.status==="pending",a=!is(this,V4).canStart();try{if(n)r();else{Ji(this,t0,Hb).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=is(this,vm).config).onMutate)==null?void 0:l.call(o,s,this));const V=await((c=(i=this.options).onMutate)==null?void 0:c.call(i,s));V!==this.state.context&&Ji(this,t0,Hb).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const B=await is(this,V4).start();return await((p=(u=is(this,vm).config).onSuccess)==null?void 0:p.call(u,B,s,this.state.context,this)),await((g=(f=this.options).onSuccess)==null?void 0:g.call(f,B,s,this.state.context)),await((_=(v=is(this,vm).config).onSettled)==null?void 0:_.call(v,B,null,this.state.variables,this.state.context,this)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,B,null,s,this.state.context)),Ji(this,t0,Hb).call(this,{type:"success",data:B}),B}catch(B){try{throw await((S=(k=is(this,vm).config).onError)==null?void 0:S.call(k,B,s,this.state.context,this)),await((L=(M=this.options).onError)==null?void 0:L.call(M,B,s,this.state.context)),await((O=(P=is(this,vm).config).onSettled)==null?void 0:O.call(P,void 0,B,this.state.variables,this.state.context,this)),await((U=($=this.options).onSettled)==null?void 0:U.call($,void 0,B,s,this.state.context)),B}finally{Ji(this,t0,Hb).call(this,{type:"error",error:B})}}finally{is(this,vm).runNext(this)}}},e0=new WeakMap,vm=new WeakMap,V4=new WeakMap,t0=new WeakSet,Hb=function(s){const r=n=>{switch(s.type){case"failed":return{...n,failureCount:s.failureCount,failureReason:s.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:s.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:s.isPaused,status:"pending",variables:s.variables,submittedAt:Date.now()};case"success":return{...n,data:s.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:s.error,failureCount:n.failureCount+1,failureReason:s.error,isPaused:!1,status:"error"}}};this.state=r(this.state),bu.batch(()=>{is(this,e0).forEach(n=>{n.onMutationUpdate(s)}),is(this,vm).notify({mutation:this,type:"updated",action:s})})},A9e);function yUe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Gv,Rg,_O,E9e,bvt=(E9e=class extends QA{constructor(s={}){super();ti(this,Gv);ti(this,Rg);ti(this,_O);this.config=s,Yn(this,Gv,new Set),Yn(this,Rg,new Map),Yn(this,_O,0)}build(s,r,n){const a=new vvt({mutationCache:this,mutationId:++A7(this,_O)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){is(this,Gv).add(s);const r=X7(s);if(typeof r=="string"){const n=is(this,Rg).get(r);n?n.push(s):is(this,Rg).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(is(this,Gv).delete(s)){const r=X7(s);if(typeof r=="string"){const n=is(this,Rg).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&is(this,Rg).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=X7(s);if(typeof r=="string"){const n=is(this,Rg).get(r),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=X7(s);if(typeof r=="string"){const a=(n=is(this,Rg).get(r))==null?void 0:n.find(o=>o!==s&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){bu.batch(()=>{is(this,Gv).forEach(s=>{this.notify({type:"removed",mutation:s})}),is(this,Gv).clear(),is(this,Rg).clear()})}getAll(){return Array.from(is(this,Gv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>dEe(r,n))}findAll(s={}){return this.getAll().filter(r=>dEe(s,r))}notify(s){bu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return bu.batch(()=>Promise.all(s.map(r=>r.continue().catch(wm))))}},Gv=new WeakMap,Rg=new WeakMap,_O=new WeakMap,E9e);function X7(t){var s;return(s=t.options.scope)==null?void 0:s.id}function Noe(t){return{onFetch:(s,r)=>{var p,f,g,v,_;const n=s.options,a=(g=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:g.direction,o=((v=s.state.data)==null?void 0:v.pages)||[],l=((_=s.state.data)==null?void 0:_.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const j=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},k=uUe(s.options,s.fetchOptions),S=async(M,L,P)=>{if(w)return Promise.reject();if(L==null&&M.pages.length)return Promise.resolve(M);const $=(()=>{const X={client:s.client,queryKey:s.queryKey,pageParam:L,direction:P?"backward":"forward",meta:s.options.meta};return j(X),X})(),U=await k($),{maxPages:B}=s.options,V=P?dvt:cvt;return{pages:V(M.pages,U,B),pageParams:V(M.pageParams,L,B)}};if(a&&o.length){const M=a==="backward",L=M?vUe:rve,P={pages:o,pageParams:l},O=L(n,P);i=await S(P,O,M)}else{const M=t??o.length;do{const L=c===0?l[0]??n.initialPageParam:rve(n,i);if(c>0&&L==null)break;i=await S(i,L),c++}while(c{var w,j;return(j=(w=s.options).persister)==null?void 0:j.call(w,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function rve(t,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?t.getNextPageParam(s[n],s,r[n],r):void 0}function vUe(t,{pages:s,pageParams:r}){var n;return s.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,s[0],s,r[0],r):void 0}function _vt(t,s){return s?rve(t,s)!=null:!1}function wvt(t,s){return!s||!t.getPreviousPageParam?!1:vUe(t,s)!=null}var hd,v_,b_,NT,kT,__,ST,CT,P9e,jvt=(P9e=class{constructor(t={}){ti(this,hd);ti(this,v_);ti(this,b_);ti(this,NT);ti(this,kT);ti(this,__);ti(this,ST);ti(this,CT);Yn(this,hd,t.queryCache||new yvt),Yn(this,v_,t.mutationCache||new bvt),Yn(this,b_,t.defaultOptions||{}),Yn(this,NT,new Map),Yn(this,kT,new Map),Yn(this,__,0)}mount(){A7(this,__)._++,is(this,__)===1&&(Yn(this,ST,q2e.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,hd).onFocus())})),Yn(this,CT,joe.subscribe(async t=>{t&&(await this.resumePausedMutations(),is(this,hd).onOnline())})))}unmount(){var t,s;A7(this,__)._--,is(this,__)===0&&((t=is(this,ST))==null||t.call(this),Yn(this,ST,void 0),(s=is(this,CT))==null||s.call(this),Yn(this,CT,void 0))}isFetching(t){return is(this,hd).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return is(this,v_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,hd).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=is(this,hd).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(ew(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return is(this,hd).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=is(this,hd).get(n.queryHash),o=a==null?void 0:a.state.data,l=ovt(s,o);if(l!==void 0)return is(this,hd).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return bu.batch(()=>is(this,hd).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=is(this,hd).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=is(this,hd);bu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=is(this,hd);return bu.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=bu.batch(()=>is(this,hd).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(wm).catch(wm)}invalidateQueries(t,s={}){return bu.batch(()=>(is(this,hd).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},s)))}refetchQueries(t,s={}){const r={...s,cancelRefetch:s.cancelRefetch??!0},n=bu.batch(()=>is(this,hd).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(wm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(wm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=is(this,hd).build(this,s);return r.isStaleByTime(ew(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(wm).catch(wm)}fetchInfiniteQuery(t){return t.behavior=Noe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(wm).catch(wm)}ensureInfiniteQueryData(t){return t.behavior=Noe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return joe.isOnline()?is(this,v_).resumePausedMutations():Promise.resolve()}getQueryCache(){return is(this,hd)}getMutationCache(){return is(this,v_)}getDefaultOptions(){return is(this,b_)}setDefaultOptions(t){Yn(this,b_,t)}setQueryDefaults(t,s){is(this,NT).set(HS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...is(this,NT).values()],r={};return s.forEach(n=>{sD(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){is(this,kT).set(HS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...is(this,kT).values()],r={};return s.forEach(n=>{sD(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...is(this,b_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=B2e(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===$2e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...is(this,b_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){is(this,hd).clear(),is(this,v_).clear()}},hd=new WeakMap,v_=new WeakMap,b_=new WeakMap,NT=new WeakMap,kT=new WeakMap,__=new WeakMap,ST=new WeakMap,CT=new WeakMap,P9e),lp,To,wO,bm,H4,MT,w_,j_,jO,TT,AT,G4,W4,N_,ET,ul,AI,nve,ave,ive,ove,lve,cve,dve,_Ue,I9e,bUe=(I9e=class extends QA{constructor(s,r){super();ti(this,ul);ti(this,lp);ti(this,To);ti(this,wO);ti(this,bm);ti(this,H4);ti(this,MT);ti(this,w_);ti(this,j_);ti(this,jO);ti(this,TT);ti(this,AT);ti(this,G4);ti(this,W4);ti(this,N_);ti(this,ET,new Set);this.options=r,Yn(this,lp,s),Yn(this,j_,null),Yn(this,w_,sve()),this.options.experimental_prefetchInRender||is(this,w_).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(is(this,To).addObserver(this),mEe(is(this,To),this.options)?Ji(this,ul,AI).call(this):this.updateResult(),Ji(this,ul,ove).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return uve(is(this,To),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return uve(is(this,To),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ji(this,ul,lve).call(this),Ji(this,ul,cve).call(this),is(this,To).removeObserver(this)}setOptions(s){const r=this.options,n=is(this,To);if(this.options=is(this,lp).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof cx(this.options.enabled,is(this,To))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ji(this,ul,dve).call(this),is(this,To).setOptions(this.options),r._defaulted&&!woe(this.options,r)&&is(this,lp).getQueryCache().notify({type:"observerOptionsUpdated",query:is(this,To),observer:this});const a=this.hasListeners();a&&pEe(is(this,To),n,this.options,r)&&Ji(this,ul,AI).call(this),this.updateResult(),a&&(is(this,To)!==n||cx(this.options.enabled,is(this,To))!==cx(r.enabled,is(this,To))||ew(this.options.staleTime,is(this,To))!==ew(r.staleTime,is(this,To)))&&Ji(this,ul,nve).call(this);const o=Ji(this,ul,ave).call(this);a&&(is(this,To)!==n||cx(this.options.enabled,is(this,To))!==cx(r.enabled,is(this,To))||o!==is(this,N_))&&Ji(this,ul,ive).call(this,o)}getOptimisticResult(s){const r=is(this,lp).getQueryCache().build(is(this,lp),s),n=this.createResult(r,s);return kvt(this,n)&&(Yn(this,bm,n),Yn(this,MT,this.options),Yn(this,H4,is(this,To).state)),n}getCurrentResult(){return is(this,bm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){is(this,ET).add(s)}getCurrentQuery(){return is(this,To)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=is(this,lp).defaultQueryOptions(s),n=is(this,lp).getQueryCache().build(is(this,lp),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Ji(this,ul,AI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),is(this,bm)))}createResult(s,r){var B;const n=is(this,To),a=this.options,o=is(this,bm),l=is(this,H4),i=is(this,MT),u=s!==n?s.state:is(this,wO),{state:p}=s;let f={...p},g=!1,v;if(r._optimisticResults){const V=this.hasListeners(),X=!V&&mEe(s,r),Y=V&&pEe(s,n,r,a);(X||Y)&&(f={...f,...gUe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:_,errorUpdatedAt:w,status:j}=f;v=f.data;let k=!1;if(r.placeholderData!==void 0&&v===void 0&&j==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,k=!0):V=typeof r.placeholderData=="function"?r.placeholderData((B=is(this,AT))==null?void 0:B.state.data,is(this,AT)):r.placeholderData,V!==void 0&&(j="success",v=tve(o==null?void 0:o.data,V,r),g=!0)}if(r.select&&v!==void 0&&!k)if(o&&v===(l==null?void 0:l.data)&&r.select===is(this,jO))v=is(this,TT);else try{Yn(this,jO,r.select),v=r.select(v),v=tve(o==null?void 0:o.data,v,r),Yn(this,TT,v),Yn(this,j_,null)}catch(V){Yn(this,j_,V)}is(this,j_)&&(_=is(this,j_),v=is(this,TT),w=Date.now(),j="error");const S=f.fetchStatus==="fetching",M=j==="pending",L=j==="error",P=M&&S,O=v!==void 0,U={status:j,fetchStatus:f.fetchStatus,isPending:M,isSuccess:j==="success",isError:L,isInitialLoading:P,isLoading:P,data:v,dataUpdatedAt:f.dataUpdatedAt,error:_,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!M,isLoadingError:L&&!O,isPaused:f.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:L&&O,isStale:U2e(s,r),refetch:this.refetch,promise:is(this,w_),isEnabled:cx(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=ee=>{U.status==="error"?ee.reject(U.error):U.data!==void 0&&ee.resolve(U.data)},X=()=>{const ee=Yn(this,w_,U.promise=sve());V(ee)},Y=is(this,w_);switch(Y.status){case"pending":s.queryHash===n.queryHash&&V(Y);break;case"fulfilled":(U.status==="error"||U.data!==Y.value)&&X();break;case"rejected":(U.status!=="error"||U.error!==Y.reason)&&X();break}}return U}updateResult(){const s=is(this,bm),r=this.createResult(is(this,To),this.options);if(Yn(this,H4,is(this,To).state),Yn(this,MT,this.options),is(this,H4).data!==void 0&&Yn(this,AT,is(this,To)),woe(r,s))return;Yn(this,bm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!is(this,ET).size)return!0;const l=new Set(o??is(this,ET));return this.options.throwOnError&&l.add("error"),Object.keys(is(this,bm)).some(i=>{const c=i;return is(this,bm)[c]!==s[c]&&l.has(c)})};Ji(this,ul,_Ue).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ji(this,ul,ove).call(this)}},lp=new WeakMap,To=new WeakMap,wO=new WeakMap,bm=new WeakMap,H4=new WeakMap,MT=new WeakMap,w_=new WeakMap,j_=new WeakMap,jO=new WeakMap,TT=new WeakMap,AT=new WeakMap,G4=new WeakMap,W4=new WeakMap,N_=new WeakMap,ET=new WeakMap,ul=new WeakSet,AI=function(s){Ji(this,ul,dve).call(this);let r=is(this,To).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(wm)),r},nve=function(){Ji(this,ul,lve).call(this);const s=ew(this.options.staleTime,is(this,To));if(VS||is(this,bm).isStale||!J0e(s))return;const n=cUe(is(this,bm).dataUpdatedAt,s)+1;Yn(this,G4,setTimeout(()=>{is(this,bm).isStale||this.updateResult()},n))},ave=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(is(this,To)):this.options.refetchInterval)??!1},ive=function(s){Ji(this,ul,cve).call(this),Yn(this,N_,s),!(VS||cx(this.options.enabled,is(this,To))===!1||!J0e(is(this,N_))||is(this,N_)===0)&&Yn(this,W4,setInterval(()=>{(this.options.refetchIntervalInBackground||q2e.isFocused())&&Ji(this,ul,AI).call(this)},is(this,N_)))},ove=function(){Ji(this,ul,nve).call(this),Ji(this,ul,ive).call(this,Ji(this,ul,ave).call(this))},lve=function(){is(this,G4)&&(clearTimeout(is(this,G4)),Yn(this,G4,void 0))},cve=function(){is(this,W4)&&(clearInterval(is(this,W4)),Yn(this,W4,void 0))},dve=function(){const s=is(this,lp).getQueryCache().build(is(this,lp),this.options);if(s===is(this,To))return;const r=is(this,To);Yn(this,To,s),Yn(this,wO,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},_Ue=function(s){bu.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(is(this,bm))}),is(this,lp).getQueryCache().notify({query:is(this,To),type:"observerResultsUpdated"})})},I9e);function Nvt(t,s){return cx(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function mEe(t,s){return Nvt(t,s)||t.state.data!==void 0&&uve(t,s,s.refetchOnMount)}function uve(t,s,r){if(cx(s.enabled,t)!==!1&&ew(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&U2e(t,s)}return!1}function pEe(t,s,r,n){return(t!==s||cx(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&U2e(t,r)}function U2e(t,s){return cx(s.enabled,t)!==!1&&t.isStaleByTime(ew(s.staleTime,t))}function kvt(t,s){return!woe(t.getCurrentResult(),s)}var Svt=class extends bUe{constructor(t,s){super(t,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Noe()})}getOptimisticResult(t){return t.behavior=Noe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var _,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(w=(_=r.fetchMeta)==null?void 0:_.fetchMore)==null?void 0:w.direction,u=l&&c==="forward",p=a&&c==="forward",f=l&&c==="backward",g=a&&c==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:_vt(s,r.data),hasPreviousPage:wvt(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!g}}},k_,S_,cp,Wv,C1,yie,hve,L9e,Cvt=(L9e=class extends QA{constructor(r,n){super();ti(this,C1);ti(this,k_);ti(this,S_);ti(this,cp);ti(this,Wv);Yn(this,k_,r),this.setOptions(n),this.bindMethods(),Ji(this,C1,yie).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=is(this,k_).defaultMutationOptions(r),woe(this.options,n)||is(this,k_).getMutationCache().notify({type:"observerOptionsUpdated",mutation:is(this,cp),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&HS(n.mutationKey)!==HS(this.options.mutationKey)?this.reset():((a=is(this,cp))==null?void 0:a.state.status)==="pending"&&is(this,cp).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=is(this,cp))==null||r.removeObserver(this)}onMutationUpdate(r){Ji(this,C1,yie).call(this),Ji(this,C1,hve).call(this,r)}getCurrentResult(){return is(this,S_)}reset(){var r;(r=is(this,cp))==null||r.removeObserver(this),Yn(this,cp,void 0),Ji(this,C1,yie).call(this),Ji(this,C1,hve).call(this)}mutate(r,n){var a;return Yn(this,Wv,n),(a=is(this,cp))==null||a.removeObserver(this),Yn(this,cp,is(this,k_).getMutationCache().build(is(this,k_),this.options)),is(this,cp).addObserver(this),is(this,cp).execute(r)}},k_=new WeakMap,S_=new WeakMap,cp=new WeakMap,Wv=new WeakMap,C1=new WeakSet,yie=function(){var n;const r=((n=is(this,cp))==null?void 0:n.state)??yUe();Yn(this,S_,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},hve=function(r){bu.batch(()=>{var n,a,o,l,i,c,u,p;if(is(this,Wv)&&this.hasListeners()){const f=is(this,S_).variables,g=is(this,S_).context;(r==null?void 0:r.type)==="success"?((a=(n=is(this,Wv)).onSuccess)==null||a.call(n,r.data,f,g),(l=(o=is(this,Wv)).onSettled)==null||l.call(o,r.data,null,f,g)):(r==null?void 0:r.type)==="error"&&((c=(i=is(this,Wv)).onError)==null||c.call(i,r.error,f,g),(p=(u=is(this,Wv)).onSettled)==null||p.call(u,void 0,r.error,f,g))}this.listeners.forEach(f=>{f(is(this,S_))})})},L9e),wUe=N.createContext(void 0),Xt=t=>{const s=N.useContext(wUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Mvt=({client:t,children:s})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(wUe.Provider,{value:t,children:s})),jUe=N.createContext(!1),Tvt=()=>N.useContext(jUe);jUe.Provider;function Avt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Evt=N.createContext(Avt()),Pvt=()=>N.useContext(Evt),Ivt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},Lvt=t=>{N.useEffect(()=>{t.clearReset()},[t])},Dvt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||hUe(r,[t.error,n])),Ovt=t=>{if(t.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Rvt=(t,s)=>t.isLoading&&t.isFetching&&!s,Fvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,fEe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function NUe(t,s,r){var f,g,v,_,w;const n=Tvt(),a=Pvt(),o=Xt(),l=o.defaultQueryOptions(t);(g=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||g.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",Ovt(l),Ivt(l,a),Lvt(a);const i=!o.getQueryCache().get(l.queryHash),[c]=N.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(j=>{const k=p?c.subscribe(bu.batchCalls(j)):wm;return c.updateResult(),k},[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(l)},[l,c]),Fvt(l,u))throw fEe(l,c,a);if(Dvt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((_=(v=o.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||_.call(v,l,u),l.experimental_prefetchInRender&&!VS&&Rvt(u,n)){const j=i?fEe(l,c,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;j==null||j.catch(wm).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function mt(t,s){return NUe(t,bUe)}function Lt(t,s){const r=Xt(),[n]=N.useState(()=>new Cvt(r,t));N.useEffect(()=>{n.setOptions(t)},[n,t]);const a=N.useSyncExternalStore(N.useCallback(l=>n.subscribe(bu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=N.useCallback((l,i)=>{n.mutate(l,i).catch(wm)},[n]);if(a.error&&hUe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function V2e(t,s){return NUe(t,Svt)}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function rD(){return rD=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function kUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Bvt(){return Math.random().toString(36).substr(2,8)}function gEe(t,s){return{usr:t.state,key:t.key,idx:s}}function mve(t,s,r,n){return r===void 0&&(r=null),rD({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?XA(s):s,{state:r,key:s&&s.key||n||Bvt()})}function koe(t){let{pathname:s="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(s+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(s+=n.charAt(0)==="#"?n:"#"+n),s}function XA(t){let s={};if(t){let r=t.indexOf("#");r>=0&&(s.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(s.search=t.substr(n),t=t.substr(0,n)),t&&(s.pathname=t)}return s}function $vt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=T_.Pop,c=null,u=p();u==null&&(u=0,l.replaceState(rD({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=T_.Pop;let j=p(),k=j==null?null:j-u;u=j,c&&c({action:i,location:w.location,delta:k})}function g(j,k){i=T_.Push;let S=mve(w.location,j,k);u=p()+1;let M=gEe(S,u),L=w.createHref(S);try{l.pushState(M,"",L)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;a.location.assign(L)}o&&c&&c({action:i,location:w.location,delta:1})}function v(j,k){i=T_.Replace;let S=mve(w.location,j,k);u=p();let M=gEe(S,u),L=w.createHref(S);l.replaceState(M,"",L),o&&c&&c({action:i,location:w.location,delta:0})}function _(j){let k=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof j=="string"?j:koe(j);return S=S.replace(/ $/,"%20"),Rd(k,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,k)}let w={get action(){return i},get location(){return t(a,l)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(xEe,f),c=j,()=>{a.removeEventListener(xEe,f),c=null}},createHref(j){return s(a,j)},createURL:_,encodeLocation(j){let k=_(j);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:v,go(j){return l.go(j)}};return w}var yEe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(yEe||(yEe={}));function qvt(t,s,r){return r===void 0&&(r="/"),Uvt(t,s,r)}function Uvt(t,s,r,n){let a=typeof s=="string"?XA(s):s,o=H2e(a.pathname||"/",r);if(o==null)return null;let l=SUe(t);Vvt(l);let i=null;for(let c=0;i==null&&c{let c={relativePath:i===void 0?o.path||"":i,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};c.relativePath.startsWith("/")&&(Rd(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let u=tw([n,c.relativePath]),p=r.concat(c);o.children&&o.children.length>0&&(Rd(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),SUe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:Qvt(u,o.index),routesMeta:p})};return t.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let c of CUe(o.path))a(o,l,c)}),s}function CUe(t){let s=t.split("/");if(s.length===0)return[];let[r,...n]=s,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let l=CUe(n.join("/")),i=[];return i.push(...l.map(c=>c===""?o:[o,c].join("/"))),a&&i.push(...l),i.map(c=>t.startsWith("/")&&c===""?"/":c)}function Vvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Xvt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Hvt=/^:[\w-]+$/,Gvt=3,Wvt=2,Kvt=1,Zvt=10,Yvt=-2,vEe=t=>t==="*";function Qvt(t,s){let r=t.split("/"),n=r.length;return r.some(vEe)&&(n+=Yvt),s&&(n+=Wvt),r.filter(a=>!vEe(a)).reduce((a,o)=>a+(Hvt.test(o)?Gvt:o===""?Kvt:Zvt),n)}function Xvt(t,s){return t.length===s.length&&t.slice(0,-1).every((n,a)=>n===s[a])?t[t.length-1]-s[s.length-1]:0}function Jvt(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:g,isOptional:v}=p;if(g==="*"){let w=i[f]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const _=i[f];return v&&!_?u[g]=void 0:u[g]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function t1t(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),kUe(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],a="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,c)=>(n.push({paramName:i,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),a+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":t!==""&&t!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,s?void 0:"i"),n]}function s1t(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return kUe(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function H2e(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let r=s.endsWith("/")?s.length-1:s.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function r1t(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?XA(t):t;return{pathname:r?r.startsWith("/")?r:n1t(r,s):s,search:o1t(n),hash:l1t(a)}}function n1t(t,s){let r=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function pxe(t,s,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function a1t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function G2e(t,s){let r=a1t(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function W2e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=XA(t):(a=rD({},t),Rd(!a.pathname||!a.pathname.includes("?"),pxe("?","pathname","search",a)),Rd(!a.pathname||!a.pathname.includes("#"),pxe("#","pathname","hash",a)),Rd(!a.search||!a.search.includes("#"),pxe("#","search","hash",a)));let o=t===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=r;else{let f=s.length-1;if(!n&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),f-=1;a.pathname=g.join("/")}i=f>=0?s[f]:"/"}let c=r1t(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const tw=t=>t.join("/").replace(/\/\/+/g,"/"),i1t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),o1t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,l1t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function c1t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const MUe=["post","put","patch","delete"];new Set(MUe);const d1t=["get",...MUe];new Set(d1t);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function nD(){return nD=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),N.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=W2e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:tw([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const p1t=N.createContext(null);function f1t(t){let s=N.useContext(q0).outlet;return s&&N.createElement(p1t.Provider,{value:t},s)}function lo(){let{matches:t}=N.useContext(q0),s=t[t.length-1];return s?s.params:{}}function EUe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=N.useContext(Ew),{matches:a}=N.useContext(q0),{pathname:o}=dc(),l=JSON.stringify(G2e(a,n.v7_relativeSplatPath));return N.useMemo(()=>W2e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function x1t(t,s){return g1t(t,s)}function g1t(t,s,r,n){JA()||Rd(!1);let{navigator:a}=N.useContext(Ew),{matches:o}=N.useContext(q0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=dc(),p;if(s){var f;let j=typeof s=="string"?XA(s):s;c==="/"||(f=j.pathname)!=null&&f.startsWith(c)||Rd(!1),p=j}else p=u;let g=p.pathname||"/",v=g;if(c!=="/"){let j=c.replace(/^\//,"").split("/");v="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let _=qvt(t,{pathname:v}),w=w1t(_&&_.map(j=>Object.assign({},j,{params:Object.assign({},i,j.params),pathname:tw([c,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?c:tw([c,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),o,r,n);return s&&w?N.createElement($de.Provider,{value:{location:nD({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:T_.Pop}},w):w}function y1t(){let t=S1t(),s=c1t(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return N.createElement(N.Fragment,null,N.createElement("h2",null,"Unexpected Application Error!"),N.createElement("h3",{style:{fontStyle:"italic"}},s),r?N.createElement("pre",{style:a},r):null,null)}const v1t=N.createElement(y1t,null);class b1t extends N.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,r){return r.location!==s.location||r.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:r.error,location:r.location,revalidation:s.revalidation||r.revalidation}}componentDidCatch(s,r){console.error("React Router caught the following error during render",s,r)}render(){return this.state.error!==void 0?N.createElement(q0.Provider,{value:this.props.routeContext},N.createElement(TUe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function _1t(t){let{routeContext:s,match:r,children:n}=t,a=N.useContext(K2e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),N.createElement(q0.Provider,{value:s},n)}function w1t(t,s,r,n){var a;if(s===void 0&&(s=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let l=t,i=(a=r)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(f=>f.route.id&&(i==null?void 0:i[f.route.id])!==void 0);p>=0||Rd(!1),l=l.slice(0,Math.min(l.length,p+1))}let c=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((p,f,g)=>{let v,_=!1,w=null,j=null;r&&(v=i&&f.route.id?i[f.route.id]:void 0,w=f.route.errorElement||v1t,c&&(u<0&&g===0?(M1t("route-fallback"),_=!0,j=null):u===g&&(_=!0,j=f.route.hydrateFallbackElement||null)));let k=s.concat(l.slice(0,g+1)),S=()=>{let M;return v?M=w:_?M=j:f.route.Component?M=N.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=p,N.createElement(_1t,{match:f,routeContext:{outlet:p,matches:k,isDataRoute:r!=null},children:M})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?N.createElement(b1t,{location:r.location,revalidation:r.revalidation,component:w,error:v,children:S(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):S()},null)}var PUe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(PUe||{}),IUe=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(IUe||{});function j1t(t){let s=N.useContext(K2e);return s||Rd(!1),s}function N1t(t){let s=N.useContext(u1t);return s||Rd(!1),s}function k1t(t){let s=N.useContext(q0);return s||Rd(!1),s}function LUe(t){let s=k1t(),r=s.matches[s.matches.length-1];return r.route.id||Rd(!1),r.route.id}function S1t(){var t;let s=N.useContext(TUe),r=N1t(),n=LUe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function C1t(){let{router:t}=j1t(PUe.UseNavigateStable),s=LUe(IUe.UseNavigateStable),r=N.useRef(!1);return AUe(()=>{r.current=!0}),N.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,nD({fromRouteId:s},o)))},[t,s])}const bEe={};function M1t(t,s,r){bEe[t]||(bEe[t]=!0)}function T1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function fxe(t){let{to:s,replace:r,state:n,relative:a}=t;JA()||Rd(!1);let{future:o,static:l}=N.useContext(Ew),{matches:i}=N.useContext(q0),{pathname:c}=dc(),u=nr(),p=W2e(s,G2e(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(p);return N.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function A1t(t){return f1t(t.context)}function Ns(t){Rd(!1)}function E1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=T_.Pop,navigator:o,static:l=!1,future:i}=t;JA()&&Rd(!1);let c=s.replace(/^\/*/,"/"),u=N.useMemo(()=>({basename:c,navigator:o,static:l,future:nD({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=XA(n));let{pathname:p="/",search:f="",hash:g="",state:v=null,key:_="default"}=n,w=N.useMemo(()=>{let j=H2e(p,c);return j==null?null:{location:{pathname:j,search:f,hash:g,state:v,key:_},navigationType:a}},[c,p,f,g,v,_,a]);return w==null?null:N.createElement(Ew.Provider,{value:u},N.createElement($de.Provider,{children:r,value:w}))}function Z2e(t){let{children:s,location:r}=t;return x1t(pve(s),r)}new Promise(()=>{});function pve(t,s){s===void 0&&(s=[]);let r=[];return N.Children.forEach(t,(n,a)=>{if(!N.isValidElement(n))return;let o=[...s,a];if(n.type===N.Fragment){r.push.apply(r,pve(n.props.children,o));return}n.type!==Ns&&Rd(!1),!n.props.index||!n.props.children||Rd(!1);let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=pve(n.props.children,o)),r.push(l)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function fve(){return fve=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function I1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function L1t(t,s){return t.button===0&&(!s||s==="_self")&&!I1t(t)}function xve(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,r)=>{let n=t[r];return s.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function D1t(t,s){let r=xve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const O1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],R1t="6";try{window.__reactRouterVersion=R1t}catch{}const F1t="startTransition",_Ee=Ewe[F1t];function z1t(t){let{basename:s,children:r,future:n,window:a}=t,o=N.useRef();o.current==null&&(o.current=zvt({window:a,v5Compat:!0}));let l=o.current,[i,c]=N.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=N.useCallback(f=>{u&&_Ee?_Ee(()=>c(f)):c(f)},[c,u]);return N.useLayoutEffect(()=>l.listen(p),[l,p]),N.useEffect(()=>T1t(n),[n]),N.createElement(E1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const B1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",$1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,pa=N.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:c,to:u,preventScrollReset:p,viewTransition:f}=s,g=P1t(s,O1t),{basename:v}=N.useContext(Ew),_,w=!1;if(typeof u=="string"&&$1t.test(u)&&(_=u,B1t))try{let M=new URL(window.location.href),L=u.startsWith("//")?new URL(M.protocol+u):new URL(u),P=H2e(L.pathname,v);L.origin===M.origin&&P!=null?u=P+L.search+L.hash:w=!0}catch{}let j=h1t(u,{relative:a}),k=q1t(u,{replace:l,state:i,target:c,preventScrollReset:p,relative:a,viewTransition:f});function S(M){n&&n(M),M.defaultPrevented||k(M)}return N.createElement("a",fve({},g,{href:_||j,onClick:w||o?n:S,ref:r,target:c}))});var wEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(wEe||(wEe={}));var jEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(jEe||(jEe={}));function q1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=nr(),u=dc(),p=EUe(t,{relative:l});return N.useCallback(f=>{if(L1t(f,r)){f.preventDefault();let g=n!==void 0?n:koe(u)===koe(p);c(t,{replace:g,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,p,n,a,r,t,o,l,i])}function uc(t){let s=N.useRef(xve(t)),r=N.useRef(!1),n=dc(),a=N.useMemo(()=>D1t(n.search,r.current?null:s.current),[n.search]),o=nr(),l=N.useCallback((i,c)=>{const u=xve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var U1t=typeof Element<"u",V1t=typeof Map=="function",H1t=typeof Set=="function",G1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function vie(t,s){if(t===s)return!0;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(t.constructor!==s.constructor)return!1;var r,n,a;if(Array.isArray(t)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(!vie(t[n],s[n]))return!1;return!0}var o;if(V1t&&t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;for(o=t.entries();!(n=o.next()).done;)if(!vie(n.value[1],s.get(n.value[0])))return!1;return!0}if(H1t&&t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(o=t.entries();!(n=o.next()).done;)if(!s.has(n.value[0]))return!1;return!0}if(G1t&&ArrayBuffer.isView(t)&&ArrayBuffer.isView(s)){if(r=t.length,r!=s.length)return!1;for(n=r;n--!==0;)if(t[n]!==s[n])return!1;return!0}if(t.constructor===RegExp)return t.source===s.source&&t.flags===s.flags;if(t.valueOf!==Object.prototype.valueOf&&typeof t.valueOf=="function"&&typeof s.valueOf=="function")return t.valueOf()===s.valueOf();if(t.toString!==Object.prototype.toString&&typeof t.toString=="function"&&typeof s.toString=="function")return t.toString()===s.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(s,a[n]))return!1;if(U1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!vie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var W1t=function(s,r){try{return vie(s,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const K1t=Po(W1t);var Z1t=function(t,s,r,n,a,o,l,i){if(!t){var c;if(s===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,a,o,l,i],p=0;c=new Error(s.replace(/%s/g,function(){return u[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},Y1t=Z1t;const NEe=Po(Y1t);var Q1t=function(s,r,n,a){var o=n?n.call(a,s,r):void 0;if(o!==void 0)return!!o;if(s===r)return!0;if(typeof s!="object"||!s||typeof r!="object"||!r)return!1;var l=Object.keys(s),i=Object.keys(r);if(l.length!==i.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(r),u=0;u(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(DUe||{}),xxe={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}},kEe=Object.values(DUe),Y2e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},J1t=Object.entries(Y2e).reduce((t,[s,r])=>(t[r]=s,t),{}),Zg="data-rh",sT={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},rT=(t,s)=>{for(let r=t.length-1;r>=0;r-=1){const n=t[r];if(Object.prototype.hasOwnProperty.call(n,s))return n[s]}return null},ebt=t=>{let s=rT(t,"title");const r=rT(t,sT.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=rT(t,sT.DEFAULT_TITLE);return s||n||void 0},tbt=t=>rT(t,sT.ON_CHANGE_CLIENT_STATE)||(()=>{}),gxe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),sbt=(t,s)=>s.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const a=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(t),YP=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&rbt(`Helmet: ${t} should be of type "Array". Instead found type "${typeof a[t]}"`),!1)).map(a=>a[t]).reverse().reduce((a,o)=>{const l={};o.filter(c=>{let u;const p=Object.keys(c);for(let g=0;ga.push(c));const i=Object.keys(l);for(let c=0;c{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:sbt(["href"],t),bodyAttributes:gxe("bodyAttributes",t),defer:rT(t,sT.DEFER),encode:rT(t,sT.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:gxe("htmlAttributes",t),linkTags:YP("link",["rel","href"],t),metaTags:YP("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:YP("noscript",["innerHTML"],t),onChangeClientState:tbt(t),scriptTags:YP("script",["src","innerHTML"],t),styleTags:YP("style",["cssText"],t),title:ebt(t),titleAttributes:gxe("titleAttributes",t),prioritizeSeoTags:nbt(t,sT.PRIORITIZE_SEO_TAGS)}),OUe=t=>Array.isArray(t)?t.join(""):t,ibt=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(ibt(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},SEe=(t,s)=>({...t,[s]:void 0}),obt=["noscript","script","style"],gve=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),RUe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),lbt=(t,s,r,n)=>{const a=RUe(r),o=OUe(s);return a?`<${t} ${Zg}="true" ${a}>${gve(o,n)}`:`<${t} ${Zg}="true">${gve(o,n)}`},cbt=(t,s,r=!0)=>s.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,p)=>{const f=typeof o[p]>"u"?p:`${p}="${gve(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=obt.indexOf(t)===-1;return`${n}<${t} ${Zg}="true" ${l}${c?"/>":`>${i}`}`},""),FUe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=Y2e[n];return r[a||n]=t[n],r},s),dbt=(t,s,r)=>{const n={key:s,[Zg]:!0},a=FUe(r,n);return[ht.createElement("title",a,s)]},bie=(t,s)=>s.map((r,n)=>{const a={key:n,[Zg]:!0};return Object.keys(r).forEach(o=>{const i=Y2e[o]||o;if(i==="innerHTML"||i==="cssText"){const c=r.innerHTML||r.cssText;a.dangerouslySetInnerHTML={__html:c}}else a[i]=r[o]}),ht.createElement(t,a)}),ox=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>dbt(t,s.title,s.titleAttributes),toString:()=>lbt(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>FUe(s),toString:()=>RUe(s)};default:return{toComponent:()=>bie(t,s),toString:()=>cbt(t,s,r)}}},ubt=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=yxe(t,xxe.meta),o=yxe(s,xxe.link),l=yxe(r,xxe.script);return{priorityMethods:{toComponent:()=>[...bie("meta",a.priority),...bie("link",o.priority),...bie("script",l.priority)],toString:()=>`${ox("meta",a.priority,n)} ${ox("link",o.priority,n)} ${ox("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},hbt=t=>{const{baseTag:s,bodyAttributes:r,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:c,prioritizeSeoTags:u}=t;let{linkTags:p,metaTags:f,scriptTags:g}=t,v={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:v,linkTags:p,metaTags:f,scriptTags:g}=ubt(t)),{priority:v,base:ox("base",s,n),bodyAttributes:ox("bodyAttributes",r,n),htmlAttributes:ox("htmlAttributes",a,n),link:ox("link",p,n),meta:ox("meta",f,n),noscript:ox("noscript",o,n),script:ox("script",g,n),style:ox("style",l,n),title:ox("title",{title:i,titleAttributes:c},n)}},yve=hbt,J7=[],zUe=!!(typeof window<"u"&&window.document&&window.document.createElement),vve=class{constructor(t,s){An(this,"instances",[]);An(this,"canUseDOM",zUe);An(this,"context");An(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?J7:this.instances,add:t=>{(this.canUseDOM?J7:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?J7:this.instances).indexOf(t);(this.canUseDOM?J7:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=yve({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},mbt={},BUe=ht.createContext(mbt),K4,$Ue=(K4=class extends N.Component{constructor(r){super(r);An(this,"helmetData");this.helmetData=new vve(this.props.context||{},K4.canUseDOM)}render(){return ht.createElement(BUe.Provider,{value:this.helmetData.value},this.props.children)}},An(K4,"canUseDOM",zUe),K4),v5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Zg}]`),a=[].slice.call(n),o=[];let l;return s&&s.length&&s.forEach(i=>{const c=document.createElement(t);for(const u in i)if(Object.prototype.hasOwnProperty.call(i,u))if(u==="innerHTML")c.innerHTML=i.innerHTML;else if(u==="cssText")c.styleSheet?c.styleSheet.cssText=i.cssText:c.appendChild(document.createTextNode(i.cssText));else{const p=u,f=typeof i[p]>"u"?"":i[p];c.setAttribute(u,f)}c.setAttribute(Zg,"true"),a.some((u,p)=>(l=p,c.isEqualNode(u)))?a.splice(l,1):o.push(c)}),a.forEach(i=>{var c;return(c=i.parentNode)==null?void 0:c.removeChild(i)}),o.forEach(i=>r.appendChild(i)),{oldTags:a,newTags:o}},bve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Zg),a=n?n.split(","):[],o=[...a],l=Object.keys(s);for(const i of l){const c=s[i]||"";r.getAttribute(i)!==c&&r.setAttribute(i,c),a.indexOf(i)===-1&&a.push(i);const u=o.indexOf(i);u!==-1&&o.splice(u,1)}for(let i=o.length-1;i>=0;i-=1)r.removeAttribute(o[i]);a.length===o.length?r.removeAttribute(Zg):r.getAttribute(Zg)!==l.join(",")&&r.setAttribute(Zg,l.join(","))},pbt=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=OUe(t)),bve("title",s)},CEe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:c,scriptTags:u,styleTags:p,title:f,titleAttributes:g}=t;bve("body",n),bve("html",a),pbt(f,g);const v={baseTag:v5("base",r),linkTags:v5("link",o),metaTags:v5("meta",l),noscriptTags:v5("noscript",i),scriptTags:v5("script",u),styleTags:v5("style",p)},_={},w={};Object.keys(v).forEach(j=>{const{newTags:k,oldTags:S}=v[j];k.length&&(_[j]=k),S.length&&(w[j]=v[j].oldTags)}),s&&s(),c(t,_,w)},QP=null,fbt=t=>{QP&&cancelAnimationFrame(QP),t.defer?QP=requestAnimationFrame(()=>{CEe(t,()=>{QP=null})}):(CEe(t),QP=null)},xbt=fbt,MEe=class extends N.Component{constructor(){super(...arguments);An(this,"rendered",!1)}shouldComponentUpdate(s){return!X1t(s,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:s}=this.props.context;s.remove(this),this.emitChange()}emitChange(){const{helmetInstances:s,setHelmet:r}=this.props.context;let n=null;const a=abt(s.get().map(o=>{const l={...o.props};return delete l.context,l}));$Ue.canUseDOM?xbt(a):yve&&(n=yve(a)),r(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:s}=this.props.context;s.add(this),this.emitChange()}render(){return this.init(),null}},Zye,$l=(Zye=class extends N.Component{shouldComponentUpdate(t){return!K1t(SEe(this.props,"helmetData"),SEe(t,"helmetData"))}mapNestedChildrenToProps(t,s){if(!s)return null;switch(t.type){case"script":case"noscript":return{innerHTML:s};case"style":return{cssText:s};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,s,r,n){return{...s,[t.type]:[...s[t.type]||[],{...r,...this.mapNestedChildrenToProps(t,n)}]}}mapObjectTypeChildren(t,s,r,n){switch(t.type){case"title":return{...s,[t.type]:n,titleAttributes:{...r}};case"body":return{...s,bodyAttributes:{...r}};case"html":return{...s,htmlAttributes:{...r}};default:return{...s,[t.type]:{...r}}}}mapArrayTypeChildrenToProps(t,s){let r={...s};return Object.keys(t).forEach(n=>{r={...r,[n]:t[n]}}),r}warnOnInvalidChildren(t,s){return NEe(kEe.some(r=>t.type===r),typeof t.type=="function"?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${kEe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),NEe(!s||typeof s=="string"||Array.isArray(s)&&!s.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(t,s){let r={};return ht.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((c,u)=>(c[J1t[u]||u]=o[u],c),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":s=this.mapChildrenToProps(a,s);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,l,a);break;default:s=this.mapObjectTypeChildren(n,s,l,a);break}}),this.mapArrayTypeChildrenToProps(r,s)}render(){const{children:t,...s}=this.props;let r={...s},{helmetData:n}=s;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof vve)){const a=n;n=new vve(a.context,!0),delete r.helmetData}return n?ht.createElement(MEe,{...r,context:n.value}):ht.createElement(BUe.Consumer,null,a=>ht.createElement(MEe,{...r,context:a}))}},An(Zye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Zye),_ve=function(t,s){return _ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])},_ve(t,s)};function qUe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");_ve(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var gx=function(){return gx=Object.assign||function(s){for(var r,n=1,a=arguments.length;n=0;i--)(l=t[i])&&(o=(a<3?l(o):a>3?l(s,r,o):l(s,r))||o);return a>3&&o&&Object.defineProperty(s,r,o),o}function VUe(t,s){return function(r,n){s(r,n,t)}}function HUe(t,s,r,n,a,o){function l(k){if(k!==void 0&&typeof k!="function")throw new TypeError("Function expected");return k}for(var i=n.kind,c=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,g=!1,v=r.length-1;v>=0;v--){var _={};for(var w in n)_[w]=w==="access"?{}:n[w];for(var w in n.access)_.access[w]=n.access[w];_.addInitializer=function(k){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(k||null))};var j=(0,r[v])(i==="accessor"?{get:p.get,set:p.set}:p[c],_);if(i==="accessor"){if(j===void 0)continue;if(j===null||typeof j!="object")throw new TypeError("Object expected");(f=l(j.get))&&(p.get=f),(f=l(j.set))&&(p.set=f),(f=l(j.init))&&a.unshift(f)}else(f=l(j))&&(i==="field"?a.unshift(f):p[c]=f)}u&&Object.defineProperty(u,n.name,p),g=!0}function GUe(t,s,r){for(var n=arguments.length>2,a=0;a0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q2e(t,s){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,o=[],l;try{for(;(s===void 0||s-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){l={error:i}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(l)throw l.error}}return o}function XUe(){for(var t=[],s=0;s1||c(v,w)})},_&&(a[v]=_(a[v])))}function c(v,_){try{u(n[v](_))}catch(w){g(o[0][3],w)}}function u(v){v.value instanceof $T?Promise.resolve(v.value.v).then(p,f):g(o[0][2],v)}function p(v){c("next",v)}function f(v){c("throw",v)}function g(v,_){v(_),o.shift(),o.length&&c(o[0][0],o[0][1])}}function tVe(t){var s,r;return s={},n("next"),n("throw",function(a){throw a}),n("return"),s[Symbol.iterator]=function(){return this},s;function n(a,o){s[a]=t[a]?function(l){return(r=!r)?{value:$T(t[a](l)),done:!1}:o?o(l):l}:o}}function sVe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=t[Symbol.asyncIterator],r;return s?s.call(t):(t=typeof Soe=="function"?Soe(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(l){return new Promise(function(i,c){l=t[o](l),a(i,c,l.done,l.value)})}}function a(o,l,i,c){Promise.resolve(c).then(function(u){o({value:u,done:i})},l)}}function rVe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var gbt=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},wve=function(t){return wve=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},wve(t)};function nVe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=wve(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ol(async()=>{const{default:n}=await Promise.resolve().then(()=>_3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class J2e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class TEe extends J2e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class AEe extends J2e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class EEe extends J2e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var jve;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(jve||(jve={}));class wbt{constructor(s,{headers:r={},customFetch:n,region:a=jve.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=_bt(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return va(this,arguments,void 0,function*(r,n={}){var a;try{const{headers:o,method:l,body:i,signal:c}=n;let u={},{region:p}=n;p||(p=this.region);const f=new URL(`${this.url}/${r}`);p&&p!=="any"&&(u["x-region"]=p,f.searchParams.set("forceFunctionRegion",p));let g;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",g=i):typeof i=="string"?(u["Content-Type"]="text/plain",g=i):typeof FormData<"u"&&i instanceof FormData?g=i:(u["Content-Type"]="application/json",g=JSON.stringify(i)):g=i;const v=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:g,signal:c}).catch(k=>{throw k.name==="AbortError"?k:new TEe(k)}),_=v.headers.get("x-relay-error");if(_&&_==="true")throw new AEe(v);if(!v.ok)throw new EEe(v);let w=((a=v.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),j;return w==="application/json"?j=yield v.json():w==="application/octet-stream"||w==="application/pdf"?j=yield v.blob():w==="text/event-stream"?j=v:w==="multipart/form-data"?j=yield v.formData():j=yield v.text(),{data:j,error:null,response:v}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new TEe(o)}:{data:null,error:o,response:o instanceof EEe||o instanceof AEe?o.context:void 0}}})}}var fp={};const eE=O9e(bbt);var ez={},tz={},sz={},rz={},nz={},jbt=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},qT=jbt();const Nbt=qT.fetch,hVe=qT.fetch.bind(qT),mVe=qT.Headers,kbt=qT.Request,Sbt=qT.Response,_3=Object.freeze(Object.defineProperty({__proto__:null,Headers:mVe,Request:kbt,Response:Sbt,default:hVe,fetch:Nbt},Symbol.toStringTag,{value:"Module"})),Cbt=O9e(_3);var az={},PEe;function pVe(){if(PEe)return az;PEe=1,Object.defineProperty(az,"__esModule",{value:!0});class t extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}}return az.default=t,az}var IEe;function fVe(){if(IEe)return nz;IEe=1,Object.defineProperty(nz,"__esModule",{value:!0});const t=eE,s=t.__importDefault(Cbt),r=t.__importDefault(pVe());class n{constructor(o){var l,i;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(l=o.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=o.signal,this.isMaybeSingle=(i=o.isMaybeSingle)!==null&&i!==void 0?i:!1,o.fetch?this.fetch=o.fetch:typeof fetch>"u"?this.fetch=s.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,l){return this.headers=new Headers(this.headers),this.headers.set(o,l),this}then(o,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let c=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var p,f,g,v;let _=null,w=null,j=null,k=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const O=await u.text();O===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?w=O:w=JSON.parse(O))}const L=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),P=(g=u.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");L&&P&&P.length>1&&(j=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(_={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,j=null,k=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const L=await u.text();try{_=JSON.parse(L),Array.isArray(_)&&u.status===404&&(w=[],_=null,k=200,S="OK")}catch{u.status===404&&L===""?(k=204,S="No Content"):_={message:L}}if(_&&this.isMaybeSingle&&(!((v=_==null?void 0:_.details)===null||v===void 0)&&v.includes("0 rows"))&&(_=null,k=200,S="OK"),_&&this.shouldThrowOnError)throw new r.default(_)}return{error:_,data:w,count:j,status:k,statusText:S}});return this.shouldThrowOnError||(c=c.catch(u=>{var p,f,g;return{error:{message:`${(p=u==null?void 0:u.name)!==null&&p!==void 0?p:"FetchError"}: ${u==null?void 0:u.message}`,details:`${(f=u==null?void 0:u.stack)!==null&&f!==void 0?f:""}`,hint:"",code:`${(g=u==null?void 0:u.code)!==null&&g!==void 0?g:""}`},data:null,count:null,status:0,statusText:""}})),c.then(o,l)}returns(){return this}overrideTypes(){return this}}return nz.default=n,nz}var LEe;function xVe(){if(LEe)return rz;LEe=1,Object.defineProperty(rz,"__esModule",{value:!0});const s=eE.__importDefault(fVe());class r extends s.default{select(a){let o=!1;const l=(a??"*").split("").map(i=>/\s/.test(i)&&!o?"":(i==='"'&&(o=!o),i)).join("");return this.url.searchParams.set("select",l),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:o=!0,nullsFirst:l,foreignTable:i,referencedTable:c=i}={}){const u=c?`${c}.order`:"order",p=this.url.searchParams.get(u);return this.url.searchParams.set(u,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const c=typeof i>"u"?"offset":`${i}.offset`,u=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(u,`${o-a+1}`),this}abortSignal(a){return this.signal=a,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:a=!1,verbose:o=!1,settings:l=!1,buffers:i=!1,wal:c=!1,format:u="text"}={}){var p;const f=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),g=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${g}"; options=${f};`),u==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}}return rz.default=r,rz}var DEe;function eje(){if(DEe)return sz;DEe=1,Object.defineProperty(sz,"__esModule",{value:!0});const s=eE.__importDefault(xVe()),r=new RegExp("[,()]");class n extends s.default{eq(o,l){return this.url.searchParams.append(o,`eq.${l}`),this}neq(o,l){return this.url.searchParams.append(o,`neq.${l}`),this}gt(o,l){return this.url.searchParams.append(o,`gt.${l}`),this}gte(o,l){return this.url.searchParams.append(o,`gte.${l}`),this}lt(o,l){return this.url.searchParams.append(o,`lt.${l}`),this}lte(o,l){return this.url.searchParams.append(o,`lte.${l}`),this}like(o,l){return this.url.searchParams.append(o,`like.${l}`),this}likeAllOf(o,l){return this.url.searchParams.append(o,`like(all).{${l.join(",")}}`),this}likeAnyOf(o,l){return this.url.searchParams.append(o,`like(any).{${l.join(",")}}`),this}ilike(o,l){return this.url.searchParams.append(o,`ilike.${l}`),this}ilikeAllOf(o,l){return this.url.searchParams.append(o,`ilike(all).{${l.join(",")}}`),this}ilikeAnyOf(o,l){return this.url.searchParams.append(o,`ilike(any).{${l.join(",")}}`),this}is(o,l){return this.url.searchParams.append(o,`is.${l}`),this}in(o,l){const i=Array.from(new Set(l)).map(c=>typeof c=="string"&&r.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(o,`in.(${i})`),this}contains(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cs.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cs.{${l.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(l)}`),this}containedBy(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cd.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cd.{${l.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(l)}`),this}rangeGt(o,l){return this.url.searchParams.append(o,`sr.${l}`),this}rangeGte(o,l){return this.url.searchParams.append(o,`nxl.${l}`),this}rangeLt(o,l){return this.url.searchParams.append(o,`sl.${l}`),this}rangeLte(o,l){return this.url.searchParams.append(o,`nxr.${l}`),this}rangeAdjacent(o,l){return this.url.searchParams.append(o,`adj.${l}`),this}overlaps(o,l){return typeof l=="string"?this.url.searchParams.append(o,`ov.${l}`):this.url.searchParams.append(o,`ov.{${l.join(",")}}`),this}textSearch(o,l,{config:i,type:c}={}){let u="";c==="plain"?u="pl":c==="phrase"?u="ph":c==="websearch"&&(u="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return sz.default=n,sz}var OEe;function gVe(){if(OEe)return tz;OEe=1,Object.defineProperty(tz,"__esModule",{value:!0});const s=eE.__importDefault(eje());class r{constructor(a,{headers:o={},schema:l,fetch:i}){this.url=a,this.headers=new Headers(o),this.schema=l,this.fetch=i}select(a,o){const{head:l=!1,count:i}=o??{},c=l?"HEAD":"GET";let u=!1;const p=(a??"*").split("").map(f=>/\s/.test(f)&&!u?"":(f==='"'&&(u=!u),f)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new s.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:o,defaultToNull:l=!0}={}){var i;const c="POST";if(o&&this.headers.append("Prefer",`count=${o}`),l||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const u=a.reduce((p,f)=>p.concat(Object.keys(f)),[]);if(u.length>0){const p=[...new Set(u)].map(f=>`"${f}"`);this.url.searchParams.set("columns",p.join(","))}}return new s.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:o,ignoreDuplicates:l=!1,count:i,defaultToNull:c=!0}={}){var u;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const f=a.reduce((g,v)=>g.concat(Object.keys(v)),[]);if(f.length>0){const g=[...new Set(f)].map(v=>`"${v}"`);this.url.searchParams.set("columns",g.join(","))}}return new s.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new s.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}delete({count:a}={}){var o;const l="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new s.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return tz.default=r,tz}var REe;function Mbt(){if(REe)return ez;REe=1,Object.defineProperty(ez,"__esModule",{value:!0});const t=eE,s=t.__importDefault(gVe()),r=t.__importDefault(eje());class n{constructor(o,{headers:l={},schema:i,fetch:c}={}){this.url=o,this.headers=new Headers(l),this.schemaName=i,this.fetch=c}from(o){const l=new URL(`${this.url}/${o}`);return new s.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new n(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:i=!1,get:c=!1,count:u}={}){var p;let f;const g=new URL(`${this.url}/rpc/${o}`);let v;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([w,j])=>j!==void 0).map(([w,j])=>[w,Array.isArray(j)?`{${j.join(",")}}`:`${j}`]).forEach(([w,j])=>{g.searchParams.append(w,j)})):(f="POST",v=l);const _=new Headers(this.headers);return u&&_.set("Prefer",`count=${u}`),new r.default({method:f,url:g,headers:_,schema:this.schemaName,body:v,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return ez.default=n,ez}Object.defineProperty(fp,"__esModule",{value:!0});var yVe=fp.PostgrestError=MVe=fp.PostgrestBuilder=SVe=fp.PostgrestTransformBuilder=NVe=fp.PostgrestFilterBuilder=wVe=fp.PostgrestQueryBuilder=bVe=fp.PostgrestClient=void 0;const tE=eE,vVe=tE.__importDefault(Mbt());var bVe=fp.PostgrestClient=vVe.default;const _Ve=tE.__importDefault(gVe());var wVe=fp.PostgrestQueryBuilder=_Ve.default;const jVe=tE.__importDefault(eje());var NVe=fp.PostgrestFilterBuilder=jVe.default;const kVe=tE.__importDefault(xVe());var SVe=fp.PostgrestTransformBuilder=kVe.default;const CVe=tE.__importDefault(fVe());var MVe=fp.PostgrestBuilder=CVe.default;const TVe=tE.__importDefault(pVe());yVe=fp.PostgrestError=TVe.default;var AVe=fp.default={PostgrestClient:vVe.default,PostgrestQueryBuilder:_Ve.default,PostgrestFilterBuilder:jVe.default,PostgrestTransformBuilder:kVe.default,PostgrestBuilder:CVe.default,PostgrestError:TVe.default};const Tbt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return MVe},get PostgrestClient(){return bVe},get PostgrestError(){return yVe},get PostgrestFilterBuilder(){return NVe},get PostgrestQueryBuilder(){return wVe},get PostgrestTransformBuilder(){return SVe},default:AVe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:Abt,PostgrestQueryBuilder:RTs,PostgrestFilterBuilder:FTs,PostgrestTransformBuilder:zTs,PostgrestBuilder:BTs,PostgrestError:$Ts}=AVe||Tbt;class Ebt{static detectEnvironment(){var s;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((s=navigator.userAgent)===null||s===void 0)&&s.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const n=r.node,a=parseInt(n.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const s=this.detectEnvironment();if(s.constructor)return s.constructor;let r=s.error||"WebSocket not supported in this environment.";throw s.workaround&&(r+=` Suggested solution: ${s.workaround}`),new Error(r)}static createWebSocket(s,r){const n=this.getWebSocketConstructor();return new n(s,r)}static isWebSocketSupported(){try{const s=this.detectEnvironment();return s.type==="native"||s.type==="ws"}catch{return!1}}}const Pbt="2.78.0",Ibt=`realtime-js/${Pbt}`,Lbt="1.0.0",Nve=1e4,Dbt=1e3,Obt=100;var XL;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(XL||(XL={}));var pu;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(pu||(pu={}));var zg;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(zg||(zg={}));var kve;(function(t){t.websocket="websocket"})(kve||(kve={}));var p4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(p4||(p4={}));class Rbt{constructor(){this.HEADER_LENGTH=1}decode(s,r){return s.constructor===ArrayBuffer?r(this._binaryDecode(s)):r(typeof s=="string"?JSON.parse(s):{})}_binaryDecode(s){const r=new DataView(s),n=new TextDecoder;return this._decodeBroadcast(s,r,n)}_decodeBroadcast(s,r,n){const a=r.getUint8(1),o=r.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(s.slice(l,l+a));l=l+a;const c=n.decode(s.slice(l,l+o));l=l+o;const u=JSON.parse(n.decode(s.slice(l,s.byteLength)));return{ref:null,topic:i,event:c,payload:u}}}class EVe{constructor(s,r){this.callback=s,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=s,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Zl;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Zl||(Zl={}));const FEe=(t,s,r={})=>{var n;const a=(n=r.skipTypes)!==null&&n!==void 0?n:[];return s?Object.keys(s).reduce((o,l)=>(o[l]=Fbt(l,t,s,a),o),{}):{}},Fbt=(t,s,r,n)=>{const a=s.find(i=>i.name===t),o=a==null?void 0:a.type,l=r[t];return o&&!n.includes(o)?PVe(o,l):Sve(l)},PVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return qbt(s,r)}switch(t){case Zl.bool:return zbt(s);case Zl.float4:case Zl.float8:case Zl.int2:case Zl.int4:case Zl.int8:case Zl.numeric:case Zl.oid:return Bbt(s);case Zl.json:case Zl.jsonb:return $bt(s);case Zl.timestamp:return Ubt(s);case Zl.abstime:case Zl.date:case Zl.daterange:case Zl.int4range:case Zl.int8range:case Zl.money:case Zl.reltime:case Zl.text:case Zl.time:case Zl.timestamptz:case Zl.timetz:case Zl.tsrange:case Zl.tstzrange:return Sve(s);default:return Sve(s)}},Sve=t=>t,zbt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Bbt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},$bt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},qbt=(t,s)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let o;const l=t.slice(1,r);try{o=JSON.parse("["+l+"]")}catch{o=l?l.split(","):[]}return o.map(i=>PVe(s,i))}return t},Ubt=t=>typeof t=="string"?t.replace(" ","T"):t,IVe=t=>{const s=new URL(t);return s.protocol=s.protocol.replace(/^ws/i,"http"),s.pathname=s.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),s.pathname===""||s.pathname==="/"?s.pathname="/api/broadcast":s.pathname=s.pathname+"/api/broadcast",s.href};class vxe{constructor(s,r,n={},a=Nve){this.channel=s,this.event=r,this.payload=n,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(s){this.timeout=s,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(s){this.payload=Object.assign(Object.assign({},this.payload),s)}receive(s,r){var n;return this._hasReceived(s)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:s,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const s=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},s),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(s,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:s,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:s,response:r}){this.recHooks.filter(n=>n.status===s).forEach(n=>n.callback(r))}_hasReceived(s){return this.receivedResp&&this.receivedResp.status===s}}var zEe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(zEe||(zEe={}));class JL{constructor(s,r){this.channel=s,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.joinRef=this.channel._joinRef(),this.state=JL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=JL.syncDiff(this.state,c,o,l)}),this.pendingDiffs=[],i()}),this.channel._on(n.diff,{},a=>{const{onJoin:o,onLeave:l,onSync:i}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=JL.syncDiff(this.state,a,o,l),i())}),this.onJoin((a,o,l)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:o,newPresences:l})}),this.onLeave((a,o,l)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:o,leftPresences:l})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(s,r,n,a){const o=this.cloneDeep(s),l=this.transformState(r),i={},c={};return this.map(o,(u,p)=>{l[u]||(c[u]=p)}),this.map(l,(u,p)=>{const f=o[u];if(f){const g=p.map(j=>j.presence_ref),v=f.map(j=>j.presence_ref),_=p.filter(j=>v.indexOf(j.presence_ref)<0),w=f.filter(j=>g.indexOf(j.presence_ref)<0);_.length>0&&(i[u]=_),w.length>0&&(c[u]=w)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:c},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,c)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(c),p.length>0){const f=s[i].map(v=>v.presence_ref),g=p.filter(v=>f.indexOf(v.presence_ref)<0);s[i].unshift(...g)}n(i,p,c)}),this.map(l,(i,c)=>{let u=s[i];if(!u)return;const p=c.map(f=>f.presence_ref);u=u.filter(f=>p.indexOf(f.presence_ref)<0),s[i]=u,a(i,u,c),u.length===0&&delete s[i]}),s}static map(s,r){return Object.getOwnPropertyNames(s).map(n=>r(n,s[n]))}static transformState(s){return s=this.cloneDeep(s),Object.getOwnPropertyNames(s).reduce((r,n)=>{const a=s[n];return"metas"in a?r[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=a,r},{})}static cloneDeep(s){return JSON.parse(JSON.stringify(s))}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var BEe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(BEe||(BEe={}));var e8;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(e8||(e8={}));var Ov;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Ov||(Ov={}));class tje{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=pu.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new vxe(this,zg.join,this.params,this.timeout),this.rejoinTimer=new EVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=pu.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(l=>l.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=pu.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=pu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=pu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=pu.errored,this.rejoinTimer.scheduleTimeout())}),this._on(zg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new JL(this),this.broadcastEndpointURL=IVe(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((o=(a=this.params.config)===null||a===void 0?void 0:a.broadcast)===null||o===void 0)&&o.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(s,r=this.timeout){var n,a,o;if(this.socket.isConnected()||this.socket.connect(),this.state==pu.closed){const{config:{broadcast:l,presence:i,private:c}}=this.params,u=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(v=>v.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[e8.PRESENCE]&&this.bindings[e8.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},g={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(v=>s==null?void 0:s(Ov.CHANNEL_ERROR,v)),this._onClose(()=>s==null?void 0:s(Ov.CLOSED)),this.updateJoinPayload(Object.assign({config:g},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:v})=>{var _;if(this.socket.setAuth(),v===void 0){s==null||s(Ov.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,j=(_=w==null?void 0:w.length)!==null&&_!==void 0?_:0,k=[];for(let S=0;S{this.state=pu.errored,s==null||s(Ov.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(v).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Ov.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(s,r={}){return await this.send({type:"presence",event:"track",payload:s},r.timeout||this.timeout)}async untrack(s={}){return await this.send({type:"presence",event:"untrack"},s)}on(s,r,n){return this.state===pu.joined&&s===e8.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(s,r,n)}async httpSend(s,r,n={}){var a;const o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(r==null)return Promise.reject("Payload is required for httpSend()");const l={method:"POST",headers:{Authorization:o,apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:r,private:this.private}]})},i=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);if(i.status===202)return{success:!0};let c=i.statusText;try{const u=await i.json();c=u.error||u.message||c}catch{}return Promise.reject(new Error(c))}async send(s,r={}){var n,a;if(!this._canPush()&&s.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:o,payload:l}=s,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:l,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,c;const u=this._push(s.type,s,r.timeout||this.timeout);s.type==="broadcast"&&!(!((c=(i=(l=this.params)===null||l===void 0?void 0:l.config)===null||i===void 0?void 0:i.broadcast)===null||c===void 0)&&c.ack)&&o("ok"),u.receive("ok",()=>o("ok")),u.receive("error",()=>o("error")),u.receive("timeout",()=>o("timed out"))})}updateJoinPayload(s){this.joinPush.updatePayload(s)}unsubscribe(s=this.timeout){this.state=pu.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(zg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new vxe(this,zg.leave,{},s),n.receive("ok",()=>{r(),a("ok")}).receive("timeout",()=>{r(),a("timed out")}).receive("error",()=>{a("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(s=>s.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=pu.closed,this.bindings={}}async _fetchWithTimeout(s,r,n){const a=new AbortController,o=setTimeout(()=>a.abort(),n),l=await this.socket.fetch(s,Object.assign(Object.assign({},r),{signal:a.signal}));return clearTimeout(o),l}_push(s,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${s}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new vxe(this,s,r,n);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(s){if(s.startTimeout(),this.pushBuffer.push(s),this.pushBuffer.length>Obt){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(s,r,n){return r}_isMember(s){return this.topic===s}_joinRef(){return this.joinPush.ref}_trigger(s,r,n){var a,o;const l=s.toLocaleLowerCase(),{close:i,error:c,leave:u,join:p}=zg;if(n&&[i,c,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let g=this._onMessage(l,r,n);if(r&&!g)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(v=>{var _,w,j;return((_=v.filter)===null||_===void 0?void 0:_.event)==="*"||((j=(w=v.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===l}).map(v=>v.callback(g,n)):(o=this.bindings[l])===null||o===void 0||o.filter(v=>{var _,w,j,k,S,M;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in v){const L=v.id,P=(_=v.filter)===null||_===void 0?void 0:_.event;return L&&((w=r.ids)===null||w===void 0?void 0:w.includes(L))&&(P==="*"||(P==null?void 0:P.toLocaleLowerCase())===((j=r.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{const L=(S=(k=v==null?void 0:v.filter)===null||k===void 0?void 0:k.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return L==="*"||L===((M=r==null?void 0:r.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return v.type.toLocaleLowerCase()===l}).map(v=>{if(typeof g=="object"&&"ids"in g){const _=g.data,{schema:w,table:j,commit_timestamp:k,type:S,errors:M}=_;g=Object.assign(Object.assign({},{schema:w,table:j,commit_timestamp:k,eventType:S,new:{},old:{},errors:M}),this._getPayloadRecords(_))}v.callback(g,n)})}_isClosed(){return this.state===pu.closed}_isJoined(){return this.state===pu.joined}_isJoining(){return this.state===pu.joining}_isLeaving(){return this.state===pu.leaving}_replyEventName(s){return`chan_reply_${s}`}_on(s,r,n){const a=s.toLocaleLowerCase(),o={type:a,filter:r,callback:n};return this.bindings[a]?this.bindings[a].push(o):this.bindings[a]=[o],this}_off(s,r){const n=s.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(a=>{var o;return!(((o=a.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&tje.isEqual(a.filter,r))})),this}static isEqual(s,r){if(Object.keys(s).length!==Object.keys(r).length)return!1;for(const n in s)if(s[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(s){this._on(zg.close,{},s)}_onError(s){this._on(zg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=pu.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=FEe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=FEe(s.columns,s.old_record)),r}}const bxe=()=>{},iz={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},Vbt=[1e3,2e3,5e3,1e4],Hbt=1e4,Gbt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class Wbt{constructor(s,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Nve,this.transport=null,this.heartbeatIntervalMs=iz.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=bxe,this.ref=0,this.reconnectTimer=null,this.logger=bxe,this.conn=null,this.sendBuffer=[],this.serializer=new Rbt,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=a=>{let o;return a?o=a:typeof fetch>"u"?o=(...l)=>ol(async()=>{const{default:i}=await Promise.resolve().then(()=>_3);return{default:i}},void 0).then(({default:i})=>i(...l)).catch(i=>{throw new Error(`Failed to load @supabase/node-fetch: ${i.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):o=fetch,(...l)=>o(...l)},!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${s}/${kve.websocket}`,this.httpEndpoint=IVe(s),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Ebt.createWebSocket(this.endpointURL())}catch(s){this._setConnectionState("disconnected");const r=s.message;throw r.includes("Node.js")?new Error(`${r} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:Lbt}))}disconnect(s,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},s?this.conn.close(s,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(s){const r=await s.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const s=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),s}log(s,r,n){this.logger(s,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case XL.connecting:return p4.Connecting;case XL.open:return p4.Open;case XL.closing:return p4.Closing;default:return p4.Closed}}isConnected(){return this.connectionState()===p4.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(s,r={config:{}}){const n=`realtime:${s}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new tje(`realtime:${s}`,r,this);return this.channels.push(o),o}}push(s){const{topic:r,event:n,payload:a,ref:o}=s,l=()=>{this.encode(s,i=>{var c;(c=this.conn)===null||c===void 0||c.send(i)})};this.log("push",`${r} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(s=null){this._authPromise=this._performAuth(s);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var s;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(s=this.conn)===null||s===void 0||s.close(Dbt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},iz.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(s){this.heartbeatCallback=s}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(s=>s()),this.sendBuffer=[])}_makeRef(){let s=this.ref+1;return s===this.ref?this.ref=0:this.ref=s,this.ref.toString()}_leaveOpenTopic(s){let r=this.channels.find(n=>n.topic===s&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${s}"`),r.unsubscribe())}_remove(s){this.channels=this.channels.filter(r=>r.topic!==s.topic)}_onConnMessage(s){this.decode(s.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(u){this.log("error","error in heartbeat callback",u)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:a,payload:o,ref:l}=r,i=l?`(${l})`:"",c=o.status||"";this.log("receive",`${c} ${n} ${a} ${i}`.trim(),o),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(a,o,l)),this._triggerStateCallbacks("message",r)})}_clearTimer(s){var r;s==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):s==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=s=>this._onConnError(s),this.conn.onmessage=s=>this._onConnMessage(s),this.conn.onclose=s=>this._onConnClose(s))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(s=>s.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(s){var r;this._setConnectionState("disconnected"),this.log("transport","close",s),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",s)}_onConnError(s){this._setConnectionState("disconnected"),this.log("transport",`${s}`),this._triggerChanError(),this._triggerStateCallbacks("error",s)}_triggerChanError(){this.channels.forEach(s=>s._trigger(zg.error))}_appendParams(s,r){if(Object.keys(r).length===0)return s;const n=s.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${s}${n}${a}`}_workerObjectUrl(s){let r;if(s)r=s;else{const n=new Blob([Gbt],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(s,r=!1){this._connectionState=s,s==="connecting"?this._wasManualDisconnect=!1:s==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(s=null){let r;s?r=s:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const a={access_token:r,version:Ibt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(zg.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(s="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${s}`,r)})}_triggerStateCallbacks(s,r){try{this.stateChangeCallbacks[s].forEach(n=>{try{n(r)}catch(a){this.log("error",`error in ${s} callback`,a)}})}catch(n){this.log("error",`error triggering ${s} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new EVe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},iz.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(s){var r,n,a,o,l,i,c,u,p;if(this.transport=(r=s==null?void 0:s.transport)!==null&&r!==void 0?r:null,this.timeout=(n=s==null?void 0:s.timeout)!==null&&n!==void 0?n:Nve,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:iz.HEARTBEAT_INTERVAL,this.worker=(o=s==null?void 0:s.worker)!==null&&o!==void 0?o:!1,this.accessToken=(l=s==null?void 0:s.accessToken)!==null&&l!==void 0?l:null,this.heartbeatCallback=(i=s==null?void 0:s.heartbeatCallback)!==null&&i!==void 0?i:bxe,s!=null&&s.params&&(this.params=s.params),s!=null&&s.logger&&(this.logger=s.logger),(s!=null&&s.logLevel||s!=null&&s.log_level)&&(this.logLevel=s.logLevel||s.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=s==null?void 0:s.reconnectAfterMs)!==null&&c!==void 0?c:f=>Vbt[f-1]||Hbt,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,g)=>g(JSON.stringify(f)),this.decode=(p=s==null?void 0:s.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl}}}class sje extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Qc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class Kbt extends sje{constructor(s,r,n){super(s),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Cve extends sje{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const rje=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ol(async()=>{const{default:n}=await Promise.resolve().then(()=>_3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Zbt=()=>va(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield ol(()=>Promise.resolve().then(()=>_3),void 0)).Response:Response}),Mve=t=>{if(Array.isArray(t))return t.map(r=>Mve(r));if(typeof t=="function"||t!==Object(t))return t;const s={};return Object.entries(t).forEach(([r,n])=>{const a=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));s[a]=Mve(n)}),s},Ybt=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},_xe=t=>{var s;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(s=t.error)===null||s===void 0?void 0:s.message)||JSON.stringify(t)},Qbt=(t,s,r)=>va(void 0,void 0,void 0,function*(){const n=yield Zbt();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(a=>{const o=t.status||500,l=(a==null?void 0:a.statusCode)||o+"";s(new Kbt(_xe(a),o,l))}).catch(a=>{s(new Cve(_xe(a),a))}):s(new Cve(_xe(t),t))}),Xbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(Ybt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,s!=null&&s.duplex&&(a.duplex=s.duplex),Object.assign(Object.assign({},a),r))};function OO(t,s,r,n,a,o){return va(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Xbt(s,n,a,o)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>l(c)).catch(c=>Qbt(c,i,n))})})}function aD(t,s,r,n){return va(this,void 0,void 0,function*(){return OO(t,"GET",s,r,n)})}function Dg(t,s,r,n,a){return va(this,void 0,void 0,function*(){return OO(t,"POST",s,n,a,r)})}function Tve(t,s,r,n,a){return va(this,void 0,void 0,function*(){return OO(t,"PUT",s,n,a,r)})}function Jbt(t,s,r,n){return va(this,void 0,void 0,function*(){return OO(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function nje(t,s,r,n,a){return va(this,void 0,void 0,function*(){return OO(t,"DELETE",s,n,a,r)})}class e_t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return va(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Qc(s))return{data:null,error:s};throw s}})}}var LVe;class t_t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[LVe]="BlobDownloadBuilder",this.promise=null}asStream(){return new e_t(this.downloadFn,this.shouldThrowOnError)}then(s,r){return this.getPromise().then(s,r)}catch(s){return this.getPromise().catch(s)}finally(s){return this.getPromise().finally(s)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return va(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Qc(s))return{data:null,error:s};throw s}})}}LVe=Symbol.toStringTag;const s_t={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},$Ee={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class r_t{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=rje(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return va(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},$Ee),a);let i=Object.assign(Object.assign({},this.headers),s==="POST"&&{"x-upsert":String(l.upsert)});const c=l.metadata;typeof Blob<"u"&&n instanceof Blob?(o=new FormData,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c)),o.append("",n)):typeof FormData<"u"&&n instanceof FormData?(o=n,o.append("cacheControl",l.cacheControl),c&&o.append("metadata",this.encodeMetadata(c))):(o=n,i["cache-control"]=`max-age=${l.cacheControl}`,i["content-type"]=l.contentType,c&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),a!=null&&a.headers&&(i=Object.assign(Object.assign({},i),a.headers));const u=this._removeEmptyFolders(r),p=this._getFinalPath(u),f=yield(s=="PUT"?Tve:Dg)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:u,id:f.Id,fullPath:f.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(Qc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return va(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return va(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(s),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",r);try{let c;const u=Object.assign({upsert:$Ee.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",u.cacheControl)):(c=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType);const f=yield Tve(this.fetch,i.toString(),c,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Qc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return va(this,void 0,void 0,function*(){try{let n=this._getFinalPath(s);const a=Object.assign({},this.headers);r!=null&&r.upsert&&(a["x-upsert"]="true");const o=yield Dg(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:a}),l=new URL(this.url+o.url),i=l.searchParams.get("token");if(!i)throw new sje("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}update(s,r,n){return va(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return va(this,void 0,void 0,function*(){try{return{data:yield Dg(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return va(this,void 0,void 0,function*(){try{return{data:{path:(yield Dg(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:s,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return va(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Dg(this.fetch,`${this.url}/object/sign/${a}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const l=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return o={signedUrl:encodeURI(`${this.url}${o.signedURL}${l}`)},{data:o,error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return va(this,void 0,void 0,function*(){try{const a=yield Dg(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:s},{headers:this.headers}),o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:a.map(l=>Object.assign(Object.assign({},l),{signedUrl:l.signedURL?encodeURI(`${this.url}${l.signedURL}${o}`):null})),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}download(s,r){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),l=o?`?${o}`:"",i=this._getFinalPath(s),c=()=>aD(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new t_t(c,this.shouldThrowOnError)}info(s){return va(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield aD(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:Mve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}exists(s){return va(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield Jbt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n)&&n instanceof Cve){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(s,r){const n=this._getFinalPath(s),a=[],o=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";o!==""&&a.push(o);const i=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&a.push(c);let u=a.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${u}`)}}}remove(s){return va(this,void 0,void 0,function*(){try{return{data:yield nje(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}list(s,r,n){return va(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},s_t),r),{prefix:s||""});return{data:yield Dg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}listV2(s,r){return va(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Dg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}encodeMetadata(s){return JSON.stringify(s)}toBase64(s){return typeof Buffer<"u"?Buffer.from(s).toString("base64"):btoa(s)}_getFinalPath(s){return`${this.bucketId}/${s.replace(/^\/+/,"")}`}_removeEmptyFolders(s){return s.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(s){const r=[];return s.width&&r.push(`width=${s.width}`),s.height&&r.push(`height=${s.height}`),s.resize&&r.push(`resize=${s.resize}`),s.format&&r.push(`format=${s.format}`),s.quality&&r.push(`quality=${s.quality}`),r.join("&")}}const DVe="2.78.0",OVe={"X-Client-Info":`storage-js/${DVe}`};class n_t{constructor(s,r={},n,a){this.shouldThrowOnError=!1;const o=new URL(s);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(o.hostname)&&!o.hostname.includes("storage.supabase.")&&(o.hostname=o.hostname.replace("supabase.","storage.supabase.")),this.url=o.href.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},OVe),r),this.fetch=rje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return va(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield aD(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}getBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield aD(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}createBucket(s){return va(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Dg(this.fetch,`${this.url}/bucket`,{id:r,name:r,type:n.type,public:n.public,file_size_limit:n.fileSizeLimit,allowed_mime_types:n.allowedMimeTypes},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Qc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return va(this,void 0,void 0,function*(){try{return{data:yield Tve(this.fetch,`${this.url}/bucket/${s}`,{id:s,name:s,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Qc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield Dg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield nje(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}listBucketOptionsToQueryString(s){const r={};return s&&("limit"in s&&(r.limit=String(s.limit)),"offset"in s&&(r.offset=String(s.offset)),s.search&&(r.search=s.search),s.sortColumn&&(r.sortColumn=s.sortColumn),s.sortOrder&&(r.sortOrder=s.sortOrder)),Object.keys(r).length>0?"?"+new URLSearchParams(r).toString():""}}class a_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},OVe),r),this.fetch=rje(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield Dg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}listBuckets(s){return va(this,void 0,void 0,function*(){try{const r=new URLSearchParams;(s==null?void 0:s.limit)!==void 0&&r.set("limit",s.limit.toString()),(s==null?void 0:s.offset)!==void 0&&r.set("offset",s.offset.toString()),s!=null&&s.sortColumn&&r.set("sortColumn",s.sortColumn),s!=null&&s.sortOrder&&r.set("sortOrder",s.sortOrder),s!=null&&s.search&&r.set("search",s.search);const n=r.toString(),a=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return{data:yield aD(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield nje(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Qc(r))return{data:null,error:r};throw r}})}}const aje={"X-Client-Info":`storage-js/${DVe}`,"Content-Type":"application/json"};class RVe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function of(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class wxe extends RVe{constructor(s,r,n){super(s),this.name="StorageVectorsApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class i_t extends RVe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var qEe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(qEe||(qEe={}));const ije=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ol(async()=>{const{default:n}=await Promise.resolve().then(()=>_3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},o_t=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},UEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),l_t=(t,s,r)=>va(void 0,void 0,void 0,function*(){if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(r!=null&&r.noResolveJson)){const a=t.status||500,o=t;if(typeof o.json=="function")o.json().then(l=>{const i=(l==null?void 0:l.statusCode)||(l==null?void 0:l.code)||a+"";s(new wxe(UEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new wxe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new wxe(i,a,l))}}else s(new i_t(UEe(t),t))}),c_t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(o_t(n)?(a.headers=Object.assign({"Content-Type":"application/json"},s==null?void 0:s.headers),a.body=JSON.stringify(n)):a.body=n,Object.assign(Object.assign({},a),r)):a};function d_t(t,s,r,n,a,o){return va(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,c_t(s,n,a,o)).then(c=>{if(!c.ok)throw c;if(n!=null&&n.noResolveJson)return c;const u=c.headers.get("content-type");return!u||!u.includes("application/json")?{}:c.json()}).then(c=>l(c)).catch(c=>l_t(c,i,n))})})}function lf(t,s,r,n,a){return va(this,void 0,void 0,function*(){return d_t(t,"POST",s,n,a,r)})}class u_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},aje),r),this.fetch=ije(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return va(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getIndex(s,r){return va(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(of(n))return{data:null,error:n};throw n}})}listIndexes(s){return va(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return va(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(of(n))return{data:null,error:n};throw n}})}}class h_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},aje),r),this.fetch=ije(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return va(this,void 0,void 0,function*(){try{if(s.vectors.length<1||s.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield lf(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getVectors(s){return va(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}listVectors(s){return va(this,void 0,void 0,function*(){try{if(s.segmentCount!==void 0){if(s.segmentCount<1||s.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(s.segmentIndex!==void 0&&(s.segmentIndex<0||s.segmentIndex>=s.segmentCount))throw new Error(`segmentIndex must be between 0 and ${s.segmentCount-1}`)}return{data:yield lf(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}queryVectors(s){return va(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteVectors(s){return va(this,void 0,void 0,function*(){try{if(s.keys.length<1||s.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield lf(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}}class m_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},aje),r),this.fetch=ije(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return va(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}getBucket(s){return va(this,void 0,void 0,function*(){try{return{data:yield lf(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}listBuckets(){return va(this,arguments,void 0,function*(s={}){try{return{data:yield lf(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}deleteBucket(s){return va(this,void 0,void 0,function*(){try{return{data:(yield lf(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(of(r))return{data:null,error:r};throw r}})}}class p_t extends m_t{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new f_t(this.url,this.headers,s,this.fetch)}}class f_t extends u_t{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return va(this,void 0,void 0,function*(){return r.createIndex.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const s=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return va(this,arguments,void 0,function*(r={}){return s.listIndexes.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName}))})}getIndex(s){const r=Object.create(null,{getIndex:{get:()=>super.getIndex}});return va(this,void 0,void 0,function*(){return r.getIndex.call(this,this.vectorBucketName,s)})}deleteIndex(s){const r=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return va(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new x_t(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class x_t extends h_t{constructor(s,r,n,a,o){super(s,r,o),this.vectorBucketName=n,this.indexName=a}putVectors(s){const r=Object.create(null,{putVectors:{get:()=>super.putVectors}});return va(this,void 0,void 0,function*(){return r.putVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(s){const r=Object.create(null,{getVectors:{get:()=>super.getVectors}});return va(this,void 0,void 0,function*(){return r.getVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const s=Object.create(null,{listVectors:{get:()=>super.listVectors}});return va(this,arguments,void 0,function*(r={}){return s.listVectors.call(this,Object.assign(Object.assign({},r),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(s){const r=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return va(this,void 0,void 0,function*(){return r.queryVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(s){const r=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return va(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class g_t extends n_t{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new r_t(this.url,this.headers,s,this.fetch)}get vectors(){return new p_t(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new a_t(this.url+"/iceberg",this.headers,this.fetch)}}const y_t="2.78.0";let EI="";typeof Deno<"u"?EI="deno":typeof document<"u"?EI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?EI="react-native":EI="node";const v_t={"X-Client-Info":`supabase-js-${EI}/${y_t}`},b_t={headers:v_t},__t={schema:"public"},w_t={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},j_t={},N_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=hVe:s=fetch,(...r)=>s(...r)},k_t=()=>typeof Headers>"u"?mVe:Headers,S_t=(t,s,r)=>{const n=N_t(r),a=k_t();return async(o,l)=>{var i;const c=(i=await s())!==null&&i!==void 0?i:t;let u=new a(l==null?void 0:l.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),n(o,Object.assign(Object.assign({},l),{headers:u}))}};function C_t(t){return t.endsWith("/")?t:t+"/"}function M_t(t,s){var r,n;const{db:a,auth:o,realtime:l,global:i}=t,{db:c,auth:u,realtime:p,global:f}=s,g={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},f),i),{headers:Object.assign(Object.assign({},(r=f==null?void 0:f.headers)!==null&&r!==void 0?r:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?g.accessToken=t.accessToken:delete g.accessToken,g}function T_t(t){const s=t==null?void 0:t.trim();if(!s)throw new Error("supabaseUrl is required.");if(!s.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(C_t(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const FVe="2.78.0",H5=30*1e3,Ave=3,jxe=Ave*H5,A_t="http://localhost:9999",E_t="supabase.auth.token",P_t={"X-Client-Info":`gotrue-js/${FVe}`},Eve="X-Supabase-Api-Version",zVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},I_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,L_t=10*60*1e3;class iD extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function qa(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class D_t extends iD{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function O_t(t){return qa(t)&&t.name==="AuthApiError"}class f4 extends iD{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class Iw extends iD{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class Tg extends Iw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function R_t(t){return qa(t)&&t.name==="AuthSessionMissingError"}class b5 extends Iw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class oz extends Iw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class lz extends Iw{constructor(s,r=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function F_t(t){return qa(t)&&t.name==="AuthImplicitGrantRedirectError"}class VEe extends Iw{constructor(s,r=null){super(s,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Pve extends Iw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function Nxe(t){return qa(t)&&t.name==="AuthRetryableFetchError"}class HEe extends Iw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class Ive extends Iw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const Coe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),GEe=` \r=`.split(""),z_t=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(Coe[n]),s.queuedBits-=6}else if(s.queuedBits>0)for(s.queue=s.queue<<6-s.queuedBits,s.queuedBits=6;s.queuedBits>=6;){const n=s.queue>>s.queuedBits-6&63;r(Coe[n]),s.queuedBits-=6}}function BVe(t,s,r){const n=z_t[t];if(n>-1)for(s.queue=s.queue<<6|n,s.queuedBits+=6;s.queuedBits>=8;)r(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function KEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{q_t(l,n,r)};for(let l=0;l>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function $_t(t,s){for(let r=0;r55295&&n<=56319){const a=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}B_t(n,s)}}function q_t(t,s,r){if(s.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){s.utf8seq=n;break}if(s.utf8seq===2)s.codepoint=t&31;else if(s.utf8seq===3)s.codepoint=t&15;else if(s.utf8seq===4)s.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|t&63,s.utf8seq-=1,s.utf8seq===0&&r(s.codepoint)}}function nT(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function w4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>WEe(a,r,n)),WEe(null,r,n),s.join("")}function V_t(t){return Math.round(Date.now()/1e3)+t}function H_t(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t=="x"?s:s&3|8).toString(16)})}const ym=()=>typeof window<"u"&&typeof document<"u",$2={tested:!1,writable:!1},$Ve=()=>{if(!ym())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if($2.tested)return $2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),$2.tested=!0,$2.writable=!0}catch{$2.tested=!0,$2.writable=!1}return $2.writable};function G_t(t){const s={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((a,o)=>{s[o]=a})}catch{}return r.searchParams.forEach((n,a)=>{s[a]=n}),s}const qVe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>ol(async()=>{const{default:n}=await Promise.resolve().then(()=>_3);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},W_t=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",G5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},q2=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Fb=async(t,s)=>{await t.removeItem(s)};class Ude{constructor(){this.promise=new Ude.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Ude.promiseConstructor=Promise;function kxe(t){const s=t.split(".");if(s.length!==3)throw new Ive("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function Z_t(t,s){return new Promise((n,a)=>{(async()=>{for(let o=0;o<1/0;o++)try{const l=await t(o);if(!s(o,null,l)){n(l);return}}catch(l){if(!s(o,l)){a(l);return}}})()})}function Y_t(t){return("0"+t.toString(16)).substr(-2)}function Q_t(){const s=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let a="";for(let o=0;o<56;o++)a+=r.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(s),Array.from(s,Y_t).join("")}async function X_t(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(n);return Array.from(a).map(o=>String.fromCharCode(o)).join("")}async function J_t(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await X_t(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function _5(t,s,r=!1){const n=Q_t();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await G5(t,`${s}-code-verifier`,a);const o=await J_t(n);return[o,n===o?"plain":"s256"]}const ewt=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function twt(t){const s=t.headers.get(Eve);if(!s||!s.match(ewt))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function swt(t){if(!t)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(t<=s)throw new Error("JWT has expired")}function rwt(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const nwt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function w5(t){if(!nwt.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Sxe(){const t={};return new Proxy(t,{get:(s,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(s,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function awt(t,s){return new Proxy(t,{get:(r,n,a)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const o=n.toString();if(o==="Symbol(Symbol.toPrimitive)"||o==="Symbol(Symbol.toStringTag)"||o==="Symbol(util.inspect.custom)"||o==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,a)}return!s.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s.value=!0),Reflect.get(r,n,a)}})}function ZEe(t){return JSON.parse(JSON.stringify(t))}const l4=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),iwt=[502,503,504];async function YEe(t){var s;if(!W_t(t))throw new Pve(l4(t),0);if(iwt.includes(t.status))throw new Pve(l4(t),t.status);let r;try{r=await t.json()}catch(o){throw new f4(l4(o),o)}let n;const a=twt(t);if(a&&a.getTime()>=zVe["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new HEe(l4(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new Tg}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,l)=>o&&typeof l=="string",!0))throw new HEe(l4(r),t.status,r.weak_password.reasons);throw new D_t(l4(r),t.status||500,n)}const owt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),r))};async function Ni(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[Eve]||(o[Eve]=zVe["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const l=(a=n==null?void 0:n.query)!==null&&a!==void 0?a:{};n!=null&&n.redirectTo&&(l.redirect_to=n.redirectTo);const i=Object.keys(l).length?"?"+new URLSearchParams(l).toString():"",c=await lwt(t,s,r+i,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function lwt(t,s,r,n,a,o){const l=owt(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new Pve(l4(c),0)}if(i.ok||await YEe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await YEe(c)}}function Ag(t){var s;let r=null;uwt(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=V_t(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function QEe(t){const s=Ag(t);return!s.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(s.data.weak_password=t.weak_password),s}function u_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function cwt(t){return{data:t,error:null}}function dwt(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Pw(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o},c=Object.assign({},l);return{data:{properties:i,user:c},error:null}}function XEe(t){return t}function uwt(t){return t.access_token&&t.refresh_token&&t.expires_in}const Cxe=["global","local","others"];class hwt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=qVe(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(s,r=Cxe[0]){if(Cxe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Cxe.join(", ")}`);try{return await Ni(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(qa(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await Ni(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:u_})}catch(n){if(qa(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=Pw(s,["options"]),a=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await Ni(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:dwt,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(qa(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await Ni(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:u_})}catch(r){if(qa(r))return{data:{user:null},error:r};throw r}}async listUsers(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await Ni(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:XEe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,v=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return v.length>0&&(v.forEach(_=>{const w=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(_.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(qa(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){w5(s);try{return await Ni(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:u_})}catch(r){if(qa(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){w5(s);try{return await Ni(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:u_})}catch(n){if(qa(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){w5(s);try{return await Ni(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:u_})}catch(n){if(qa(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){w5(s.userId);try{const{data:r,error:n}=await Ni(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:n}}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _deleteFactor(s){w5(s.userId),w5(s.id);try{return{data:await Ni(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _listOAuthClients(s){var r,n,a,o,l,i,c;try{const u={nextPage:null,lastPage:0,total:0},p=await Ni(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=s==null?void 0:s.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=s==null?void 0:s.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:XEe});if(p.error)throw p.error;const f=await p.json(),g=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,v=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return v.length>0&&(v.forEach(_=>{const w=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(_.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(qa(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await Ni(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await Ni(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await Ni(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(qa(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await Ni(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await Ni(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}}function JEe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const j5={debug:!!(globalThis&&$Ve()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class UVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class mwt extends UVe{}async function pwt(t,s,r){j5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),j5.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},s),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,s===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async a=>{if(a){j5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{j5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw j5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new mwt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(j5.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}function fwt(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function VVe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function xwt(t){return parseInt(t,16)}function gwt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function ywt(t){var s;const{chainId:r,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:c,resources:u,scheme:p,uri:f,version:g}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(l&&l.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${l}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(g!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${g}`);if(!((s=t.statement)===null||s===void 0)&&s.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const v=VVe(t.address),_=p?`${p}://${n}`:n,w=t.statement?`${t.statement} `:"",j=`${_} wants you to sign in with your Ethereum account: ${v} ${w}`;let k=`URI: ${f} Version: ${g} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(k+=` Expiration Time: ${a.toISOString()}`),i&&(k+=` Not Before: ${i.toISOString()}`),c&&(k+=` Request ID: ${c}`),u){let S=` Resources:`;for(const M of u){if(!M||typeof M!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${M}`);S+=` - ${M}`}k+=S}return`${j} ${k}`}class Zd extends Error{constructor({message:s,code:r,cause:n,name:a}){var o;super(s,{cause:n}),this.__isWebAuthnError=!0,this.name=(o=a??(n instanceof Error?n.name:void 0))!==null&&o!==void 0?o:"Unknown Error",this.code=r}}class Moe extends Zd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function vwt({error:t,options:s}){var r,n,a;const{publicKey:o}=s;if(!o)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=o.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new Zd({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(s.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Zd({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((a=o.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new Zd({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Zd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return o.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new Zd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Zd({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const l=window.location.hostname;if(HVe(l)){if(o.rp.id!==l)return new Zd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new Zd({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function bwt({error:t,options:s}){const{publicKey:r}=s;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Zd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Zd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(HVe(n)){if(r.rpId!==n)return new Zd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Zd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Zd({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Zd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class _wt{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const s=new AbortController;return this.controller=s,s.signal}cancelCeremony(){if(this.controller){const s=new Error("Manually cancelling existing WebAuthn API call");s.name="AbortError",this.controller.abort(s),this.controller=void 0}}}const wwt=new _wt;function jwt(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:s,user:r,excludeCredentials:n}=t,a=Pw(t,["challenge","user","excludeCredentials"]),o=nT(s).buffer,l=Object.assign(Object.assign({},r),{id:nT(r.id).buffer}),i=Object.assign(Object.assign({},a),{challenge:o,user:l});if(n&&n.length>0){i.excludeCredentials=new Array(n.length);for(let c=0;c0){o.allowCredentials=new Array(r.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),r=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),n={};for(const a of t)if(a)for(const o in a){const l=a[o];if(l!==void 0)if(Array.isArray(l))n[o]=l;else if(r(l))n[o]=l;else if(s(l)){const i=n[o];s(i)?n[o]=Toe(i,l):n[o]=Toe(l)}else n[o]=l}return n}function Ewt(t,s){return Toe(Twt,t,s||{})}function Pwt(t,s){return Toe(Awt,t,s||{})}class Iwt{constructor(s){this.client=s,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(s){return this.client.mfa.enroll(Object.assign(Object.assign({},s),{factorType:"webauthn"}))}async _challenge({factorId:s,webauthn:r,friendlyName:n,signal:a},o){try{const{data:l,error:i}=await this.client.mfa.challenge({factorId:s,webauthn:r});if(!l)return{data:null,error:i};const c=a??wwt.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:u}=l.webauthn.credential_options.publicKey;u.name||(u.name=`${u.id}:${n}`),u.displayName||(u.displayName=u.name)}switch(l.webauthn.type){case"create":{const u=Ewt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await Cwt({publicKey:u,signal:c});return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=Pwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await Mwt(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:u,signal:c}));return p?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(l){return qa(l)?{data:null,error:l}:{data:null,error:new f4("Unexpected error in challenge",l)}}}async _verify({challengeId:s,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:s,webauthn:n})}async _authenticate({factorId:s,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a}},o){if(!r)return{data:null,error:new iD("rpId is required for WebAuthn authentication")};try{if(!e6e())return{data:null,error:new f4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this.challenge({factorId:s,webauthn:{rpId:r,rpOrigins:n},signal:a},{request:o});if(!l)return{data:null,error:i};const{webauthn:c}=l;return this._verify({factorId:s,challengeId:l.challengeId,webauthn:{type:c.type,rpId:r,rpOrigins:n,credential_response:c.credential_response}})}catch(l){return qa(l)?{data:null,error:l}:{data:null,error:new f4("Unexpected error in authenticate",l)}}}async _register({friendlyName:s,rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a},o){if(!r)return{data:null,error:new iD("rpId is required for WebAuthn registration")};try{if(!e6e())return{data:null,error:new f4("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:s});if(!l)return await this.client.mfa.listFactors().then(p=>{var f;return(f=p.data)===null||f===void 0?void 0:f.all.find(g=>g.factor_type==="webauthn"&&g.friendly_name===s&&g.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:i};const{data:c,error:u}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:a},{create:o});return c?this._verify({factorId:l.id,challengeId:c.challengeId,webauthn:{rpId:r,rpOrigins:n,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}catch(l){return qa(l)?{data:null,error:l}:{data:null,error:new f4("Unexpected error in register",l)}}}}fwt();const Lwt={url:A_t,storageKey:E_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:P_t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function t6e(t,s,r){return await r()}const N5={};class oD{get jwks(){var s,r;return(r=(s=N5[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){N5[this.storageKey]=Object.assign(Object.assign({},N5[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=N5[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){N5[this.storageKey]=Object.assign(Object.assign({},N5[this.storageKey]),{cachedAt:s})}constructor(s){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=oD.nextInstanceID,oD.nextInstanceID+=1,this.instanceID>0&&ym()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const a=Object.assign(Object.assign({},Lwt),s);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new hwt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=qVe(a.fetch),this.lock=a.lock||t6e,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:ym()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=pwt:this.lock=t6e,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new Iwt(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:$Ve()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=JEe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=JEe(this.memoryStorage)),ym()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),await this._notifyAllSubscribers(o.data.event,o.data.session,!1)})}this.initialize()}_debug(...s){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${FVe}) ${new Date().toISOString()}`,...s),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var s;try{const r=G_t(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),ym()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),F_t(o)){const c=(s=o.details)===null||s===void 0?void 0:s.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:l,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",l,"redirect type",i),await this._saveSession(l),setTimeout(async()=>{i==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",l):await this._notifyAllSubscribers("SIGNED_IN",l)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return qa(r)?{error:r}:{error:new f4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await Ni(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.captchaToken}},xform:Ag}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(qa(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(s){var r,n,a;try{let o;if("email"in s){const{email:p,password:f,options:g}=s;let v=null,_=null;this.flowType==="pkce"&&([v,_]=await _5(this.storage,this.storageKey)),o=await Ni(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:g==null?void 0:g.emailRedirectTo,body:{email:p,password:f,data:(r=g==null?void 0:g.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken},code_challenge:v,code_challenge_method:_},xform:Ag})}else if("phone"in s){const{phone:p,password:f,options:g}=s;o=await Ni(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=g==null?void 0:g.data)!==null&&n!==void 0?n:{},channel:(a=g==null?void 0:g.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:g==null?void 0:g.captchaToken}},xform:Ag})}else throw new oz("You must provide either an email or phone number and a password");const{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const c=l.session,u=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(o){if(qa(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(s){try{let r;if("email"in s){const{email:o,password:l,options:i}=s;r=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:QEe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:l,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:QEe})}else throw new oz("You must provide either an email or phone number and a password");const{data:n,error:a}=r;return a?{data:{user:null,session:null},error:a}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new b5}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(r){if(qa(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(s){var r,n,a,o;return await this._handleProviderSignIn(s.provider,{redirectTo:(r=s.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=s.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=s.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(o=s.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(s){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(s))}async signInWithWeb3(s){const{chain:r}=s;switch(r){case"ethereum":return await this.signInWithEthereum(s);case"solana":return await this.signInWithSolana(s);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(s){var r,n,a,o,l,i,c,u,p,f,g;let v,_;if("message"in s)v=s.message,_=s.signature;else{const{chain:w,wallet:j,statement:k,options:S}=s;let M;if(ym())if(typeof j=="object")M=j;else{const B=window;if("ethereum"in B&&typeof B.ethereum=="object"&&"request"in B.ethereum&&typeof B.ethereum.request=="function")M=B.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof j!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=j}const L=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),P=await M.request({method:"eth_requestAccounts"}).then(B=>B).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!P||P.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const O=VVe(P[0]);let $=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const B=await M.request({method:"eth_chainId"});$=xwt(B)}const U={domain:L.host,address:O,statement:k,uri:L.href,version:"1",chainId:$,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(c=S==null?void 0:S.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=S==null?void 0:S.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=S==null?void 0:S.signInWithEthereum)===null||p===void 0?void 0:p.resources};v=ywt(U),_=await M.request({method:"personal_sign",params:[gwt(v),O]})}try{const{data:w,error:j}=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:v,signature:_},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(g=s.options)===null||g===void 0?void 0:g.captchaToken}}:null),xform:Ag});if(j)throw j;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new b5}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:j})}catch(w){if(qa(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,p,f,g,v;let _,w;if("message"in s)_=s.message,w=s.signature;else{const{chain:j,wallet:k,statement:S,options:M}=s;let L;if(ym())if(typeof k=="object")L=k;else{const O=window;if("solana"in O&&typeof O.solana=="object"&&("signIn"in O.solana&&typeof O.solana.signIn=="function"||"signMessage"in O.solana&&typeof O.solana.signMessage=="function"))L=O.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof k!="object"||!(M!=null&&M.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");L=k}const P=new URL((r=M==null?void 0:M.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in L&&L.signIn){const O=await L.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},M==null?void 0:M.signInWithSolana),{version:"1",domain:P.host,uri:P.href}),S?{statement:S}:null));let $;if(Array.isArray(O)&&O[0]&&typeof O[0]=="object")$=O[0];else if(O&&typeof O=="object"&&"signedMessage"in O&&"signature"in O)$=O;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in $&&"signature"in $&&(typeof $.signedMessage=="string"||$.signedMessage instanceof Uint8Array)&&$.signature instanceof Uint8Array)_=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),w=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in L)||typeof L.signMessage!="function"||!("publicKey"in L)||typeof L!="object"||!L.publicKey||!("toBase58"in L.publicKey)||typeof L.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${P.host} wants you to sign in with your Solana account:`,L.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${P.href}`,`Issued At: ${(a=(n=M==null?void 0:M.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=M==null?void 0:M.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${M.signInWithSolana.notBefore}`]:[],...!((l=M==null?void 0:M.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${M.signInWithSolana.expirationTime}`]:[],...!((i=M==null?void 0:M.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${M.signInWithSolana.chainId}`]:[],...!((c=M==null?void 0:M.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${M.signInWithSolana.nonce}`]:[],...!((u=M==null?void 0:M.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${M.signInWithSolana.requestId}`]:[],...!((f=(p=M==null?void 0:M.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...M.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const O=await L.signMessage(new TextEncoder().encode(_),"utf8");if(!O||!(O instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=O}}try{const{data:j,error:k}=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:w4(w)},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(v=s.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:Ag});if(k)throw k;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new b5}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:k})}catch(j){if(qa(j))return{data:{user:null,session:null},error:j};throw j}}async _exchangeCodeForSession(s){const r=await q2(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:Ag});if(await Fb(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new b5}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:a??null}),error:l})}catch(o){if(qa(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(s){try{const{options:r,provider:n,token:a,access_token:o,nonce:l}=s,i=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:a,access_token:o,nonce:l,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Ag}),{data:c,error:u}=i;return u?{data:{user:null,session:null},error:u}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new b5}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(qa(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(s){var r,n,a,o,l;try{if("email"in s){const{email:i,options:c}=s;let u=null,p=null;this.flowType==="pkce"&&([u,p]=await _5(this.storage,this.storageKey));const{error:f}=await Ni(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:f}}if("phone"in s){const{phone:i,options:c}=s,{data:u,error:p}=await Ni(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:i,data:(a=c==null?void 0:c.data)!==null&&a!==void 0?a:{},create_user:(o=c==null?void 0:c.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(l=c==null?void 0:c.channel)!==null&&l!==void 0?l:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:p}}throw new oz("You must provide either an email or phone number.")}catch(i){if(qa(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(s){var r,n;try{let a,o;"options"in s&&(a=(r=s.options)===null||r===void 0?void 0:r.redirectTo,o=(n=s.options)===null||n===void 0?void 0:n.captchaToken);const{data:l,error:i}=await Ni(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Ag});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const c=l.session,u=l.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(a){if(qa(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(s){var r,n,a;try{let o=null,l=null;return this.flowType==="pkce"&&([o,l]=await _5(this.storage,this.storageKey)),await Ni(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:(n=(r=s.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:cwt})}catch(o){if(qa(o))return{data:null,error:o};throw o}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async s=>{const{data:{session:r},error:n}=s;if(n)throw n;if(!r)throw new Tg;const{error:a}=await Ni(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(qa(s))return{data:{user:null,session:null},error:s};throw s}}async resend(s){try{const r=`${this.url}/resend`;if("email"in s){const{email:n,type:a,options:o}=s,{error:l}=await Ni(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return{data:{user:null,session:null},error:l}}else if("phone"in s){const{phone:n,type:a,options:o}=s,{data:l,error:i}=await Ni(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return{data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:i}}throw new oz("You must provide either an email or phone number and a type")}catch(r){if(qa(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(s,r){this._debug("#_acquireLock","begin",s);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,s,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(s){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await s(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let s=null;const r=await q2(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?s=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const n=s.expires_at?s.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(s){try{return s?await Ni(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:u_}):await this._useSession(async r=>{var n,a,o;const{data:l,error:i}=r;if(i)throw i;return!(!((n=l.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Tg}:await Ni(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(a=l.session)===null||a===void 0?void 0:a.access_token)!==null&&o!==void 0?o:void 0,xform:u_})})}catch(r){if(qa(r))return R_t(r)&&(await this._removeSession(),await Fb(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(s,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(s,r))}async _updateUser(s,r={}){try{return await this._useSession(async n=>{const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new Tg;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await _5(this.storage,this.storageKey));const{data:u,error:p}=await Ni(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},s),{code_challenge:i,code_challenge_method:c}),jwt:l.access_token,xform:u_});if(p)throw p;return l.user=u.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(qa(n))return{data:{user:null},error:n};throw n}}async setSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(s))}async _setSession(s){try{if(!s.access_token||!s.refresh_token)throw new Tg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=kxe(s.access_token);if(l.exp&&(n=l.exp,a=n<=r),a){const{data:i,error:c}=await this._callRefreshToken(s.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!i)return{data:{user:null,session:null},error:null};o=i}else{const{data:i,error:c}=await this._getUser(s.access_token);if(c)throw c;o={access_token:s.access_token,refresh_token:s.refresh_token,user:i.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(r){if(qa(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(s){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(s))}async _refreshSession(s){try{return await this._useSession(async r=>{var n;if(!s){const{data:l,error:i}=r;if(i)throw i;s=(n=l.session)!==null&&n!==void 0?n:void 0}if(!(s!=null&&s.refresh_token))throw new Tg;const{data:a,error:o}=await this._callRefreshToken(s.refresh_token);return o?{data:{user:null,session:null},error:o}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(qa(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!ym())throw new lz("No browser detected.");if(s.error||s.error_description||s.error_code)throw new lz(s.error_description||"Error in URL with unspecified error_description",{error:s.error||"unspecified_error",code:s.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new VEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new lz("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!s.code)throw new VEe("No code detected.");const{data:S,error:M}=await this._exchangeCodeForSession(s.code);if(M)throw M;const L=new URL(window.location.href);return L.searchParams.delete("code"),window.history.replaceState(window.history.state,"",L.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:c,token_type:u}=s;if(!o||!i||!l||!u)throw new lz("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let g=p+f;c&&(g=parseInt(c));const v=g-p;v*1e3<=H5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${v}s, should have been closer to ${f}s`);const _=g-f;p-_>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",_,g,p):p-_<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",_,g,p);const{data:w,error:j}=await this._getUser(o);if(j)throw j;const k={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:g,refresh_token:l,token_type:u,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:k,redirectType:s.type},error:null}}catch(n){if(qa(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(s){return!!(s.access_token||s.error_description)}async _isPKCECallback(s){const r=await q2(this.storage,`${this.storageKey}-code-verifier`);return!!(s.code&&r)}async signOut(s={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(s))}async _signOut({scope:s}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{error:o};const l=(n=a.session)===null||n===void 0?void 0:n.access_token;if(l){const{error:i}=await this.admin.signOut(l,s);if(i&&!(O_t(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Fb(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=H_t(),n={id:r,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(s){return await this._useSession(async r=>{var n,a;try{const{data:{session:o},error:l}=r;if(l)throw l;await((n=this.stateChangeEmitters.get(s))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",s,"session",o)}catch(o){await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",o),console.error(o)}})}async resetPasswordForEmail(s,r={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await _5(this.storage,this.storageKey,!0));try{return await Ni(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(qa(o))return{data:null,error:o};throw o}}async getUserIdentities(){var s;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(s=r.user.identities)!==null&&s!==void 0?s:[]},error:null}}catch(r){if(qa(r))return{data:null,error:r};throw r}}async linkIdentity(s){return"token"in s?this.linkIdentityIdToken(s):this.linkIdentityOAuth(s)}async linkIdentityOAuth(s){var r;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,c,u,p;const{data:f,error:g}=o;if(g)throw g;const v=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(c=s.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await Ni(this.fetch,"GET",v,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return ym()&&!(!((r=s.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:s.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(qa(n))return{data:{provider:s.provider,url:null},error:n};throw n}}async linkIdentityIdToken(s){return await this._useSession(async r=>{var n;try{const{error:a,data:{session:o}}=r;if(a)throw a;const{options:l,provider:i,token:c,access_token:u,nonce:p}=s,f=await Ni(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=o==null?void 0:o.access_token)!==null&&n!==void 0?n:void 0,body:{provider:i,id_token:c,access_token:u,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:Ag}),{data:g,error:v}=f;return v?{data:{user:null,session:null},error:v}:!g||!g.session||!g.user?{data:{user:null,session:null},error:new b5}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("USER_UPDATED",g.session)),{data:g,error:v})}catch(a){if(qa(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)throw l;return await Ni(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(a=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _refreshAccessToken(s){const r=`#_refreshAccessToken(${s.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await Z_t(async a=>(a>0&&await K_t(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await Ni(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:Ag})),(a,o)=>{const l=200*Math.pow(2,a);return o&&Nxe(o)&&Date.now()+l-n{try{await i.callback(s,r)}catch(c){o.push(c)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),H5);this.autoRefreshTicker=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const s=this.autoRefreshTicker;this.autoRefreshTicker=null,s&&clearInterval(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const s=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((n.expires_at*1e3-s)/H5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${H5}ms, refresh threshold is ${Ave} ticks`),a<=Ave&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s.isAcquireTimeout||s instanceof UVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ym()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(s){console.error("_handleVisibilityChange",s)}}async _onVisibilityChanged(s){const r=`#_onVisibilityChanged(${s})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),s||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(s,r,n){const a=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&a.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&a.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[o,l]=await _5(this.storage,this.storageKey),i=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(l)}`});a.push(i.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);a.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&a.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${s}?${a.join("&")}`}async _unenroll(s){try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;return o?{data:null,error:o}:await Ni(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _enroll(s){try{return await this._useSession(async r=>{var n,a;const{data:o,error:l}=r;if(l)return{data:null,error:l};const i=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:s.factorType==="totp"?{issuer:s.issuer}:{}),{data:c,error:u}=await Ni(this.fetch,"POST",`${this.url}/factors`,{body:i,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(s.factorType==="totp"&&c.type==="totp"&&(!((a=c==null?void 0:c.totp)===null||a===void 0)&&a.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _verify(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=Object.assign({challenge_id:s.challengeId},"webauthn"in s?{webauthn:Object.assign(Object.assign({},s.webauthn),{credential_response:s.webauthn.type==="create"?kwt(s.webauthn.credential_response):Swt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await Ni(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return c?{data:null,error:c}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:c})})}catch(r){if(qa(r))return{data:null,error:r};throw r}})}async _challenge(s){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:a,error:o}=r;if(o)return{data:null,error:o};const l=await Ni(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:s,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});if(l.error)return l;const{data:i}=l;if(i.type!=="webauthn")return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:jwt(i.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:Nwt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(qa(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(s){const{data:r,error:n}=await this._challenge({factorId:s.factorId});return n?{data:null,error:n}:await this._verify({factorId:s.factorId,challengeId:r.id,code:s.code})}async _listFactors(){var s;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const a={all:[],phone:[],totp:[],webauthn:[]};for(const o of(s=r==null?void 0:r.factors)!==null&&s!==void 0?s:[])a.all.push(o),o.status==="verified"&&a[o.factor_type].push(o);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(){var s,r;const{data:{session:n},error:a}=await this.getSession();if(a)return{data:null,error:a};if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=kxe(n.access_token);let l=null;o.aal&&(l=o.aal);let i=l;((r=(s=n.user.factors)===null||s===void 0?void 0:s.filter(p=>p.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(i="aal2");const u=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:u},error:null}}async _getAuthorizationDetails(s){try{return await this._useSession(async r=>{const{data:{session:n},error:a}=r;return a?{data:null,error:a}:n?await Ni(this.fetch,"GET",`${this.url}/oauth/authorizations/${s}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):{data:null,error:new Tg}})}catch(r){if(qa(r))return{data:null,error:r};throw r}}async _approveAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new Tg};const l=await Ni(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&ym()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(qa(n))return{data:null,error:n};throw n}}async _denyAuthorization(s,r){try{return await this._useSession(async n=>{const{data:{session:a},error:o}=n;if(o)return{data:null,error:o};if(!a)return{data:null,error:new Tg};const l=await Ni(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&ym()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(qa(n))return{data:null,error:n};throw n}}async fetchJwk(s,r={keys:[]}){let n=r.keys.find(i=>i.kid===s);if(n)return n;const a=Date.now();if(n=this.jwks.keys.find(i=>i.kid===s),n&&this.jwks_cached_at+L_t>a)return n;const{data:o,error:l}=await Ni(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:v,error:_}=await this.getSession();if(_||!v.session)return{data:null,error:_};n=v.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=kxe(n);r!=null&&r.allowExpired||swt(o.exp);const u=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:v}=await this.getUser(n);if(v)throw v;return{data:{claims:o,header:a,signature:l},error:null}}const p=rwt(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,U_t(`${i}.${c}`)))throw new Ive("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(qa(n))return{data:null,error:n};throw n}}}oD.nextInstanceID=0;const Dwt=oD;class Owt extends Dwt{constructor(s){super(s)}}class Rwt{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=T_t(s);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const c=`sb-${i.hostname.split(".")[0]}-auth-token`,u={db:__t,realtime:j_t,auth:Object.assign(Object.assign({},w_t),{storageKey:c}),global:b_t},p=M_t(n??{},u);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(f,g)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(g)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=S_t(r,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new Abt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new g_t(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new wbt(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(s){return this.rest.from(s)}schema(s){return this.rest.schema(s)}rpc(s,r={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(s,r,n)}channel(s,r={config:{}}){return this.realtime.channel(s,r)}getChannels(){return this.realtime.getChannels()}removeChannel(s){return this.realtime.removeChannel(s)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var s,r;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(r=(s=n.session)===null||s===void 0?void 0:s.access_token)!==null&&r!==void 0?r:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:i,lock:c,debug:u},p,f){const g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Owt({url:this.authUrl.href,headers:Object.assign(Object.assign({},g),p),storageKey:l,autoRefreshToken:s,persistSession:r,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:c,debug:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(v=>v.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new Wbt(this.realtimeUrl.href,Object.assign(Object.assign({},s),{params:Object.assign({apikey:this.supabaseKey},s==null?void 0:s.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(s,r,n){(s==="TOKEN_REFRESHED"||s==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):s==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const Fwt=(t,s,r)=>new Rwt(t,s,r);function zwt(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const s=t.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}zwt()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Bwt="https://relzejiswnotikjgvjhz.supabase.co",$wt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",H=Fwt(Bwt,$wt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),GVe=N.createContext(void 0),qwt=({children:t})=>{const[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState(!0),[i,c]=N.useState(!0),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState(null),[w,j]=N.useState([]),[k,S]=N.useState(null),M=N.useRef(null),L=N.useRef(!1),P=N.useRef(!1),O=nr(),$=()=>{p(!1),g(!1),_(null),j([]),S(null),M.current=null,L.current=!1},U=async Y=>{if(!(L.current&&M.current===Y)&&!P.current){P.current=!0,c(!0);try{console.log("Checking roles via RPC for user:",Y);const[{data:ee,error:Q},{data:ce,error:ne}]=await Promise.all([H.rpc("has_role",{_user_id:Y,_role:"admin"}),H.rpc("has_role",{_user_id:Y,_role:"brokerage_manager"})]);if(Q||ne)console.error("Role RPC errors:",{isAdminError:Q,isBrokerError:ne}),p(!1),g(!1);else{const fe=!!ee,ge=!!ce;console.log("RPC roles result:",{adminValue:fe,brokerValue:ge}),p(fe),g(ge)}const{data:re,error:oe}=await H.from("profiles").select("brokerage_id").eq("id",Y).single();if(_(!oe&&re?re.brokerage_id:null),ce){console.log("Fetching managed brokerages for user:",Y);const{data:fe,error:ge}=await H.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",Y);if(console.log("Managed brokerage assignments result:",{assignments:fe,assignmentsError:ge}),ge||!fe){console.error("Error fetching managed brokerage assignments:",ge),j([]);return}const ue=Array.from(new Set(fe.map(Me=>Me.brokerage_id).filter(Boolean)));if(ue.length===0){j([]);return}const{data:xe,error:_e}=await H.from("brokerages").select("id, name").in("id",ue);if(console.log("Managed brokerages details result:",{brokeragesData:xe,brokeragesError:_e}),_e||!xe){console.error("Error fetching managed brokerages details:",_e),j([]);return}const $e=xe.map(Me=>({id:Me.id,name:Me.name})).sort((Me,Ie)=>ue.indexOf(Me.id)-ue.indexOf(Ie.id));console.log("Parsed managed brokerages:",$e),j($e),$e.length>0&&S(Me=>Me??$e[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),j([]);M.current=Y,L.current=!0}catch(ee){console.error("Unexpected error in checkRoles:",ee),$()}finally{P.current=!1,c(!1)}}};N.useEffect(()=>{let Y=!0,ee=!1;const Q=()=>{!Y||ee||(ee=!0,l(!1))},{data:{subscription:ce}}=H.auth.onAuthStateChange((oe,fe)=>{console.log("Auth event:",oe),Y&&(a(fe),r((fe==null?void 0:fe.user)??null),Q(),oe==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{O("/profile?reset=true")},100)),fe!=null&&fe.user?(!L.current||M.current!==fe.user.id)&&setTimeout(()=>{U(fe.user.id)},0):($(),c(!1)))}),ne=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),Q()},4e3);return(async()=>{try{const{data:{session:oe}}=await H.auth.getSession();if(!Y)return;a(oe),r((oe==null?void 0:oe.user)??null),oe!=null&&oe.user?await U(oe.user.id):$()}catch(oe){console.error("Error restoring auth session:",oe),Y&&(a(null),r(null),$())}finally{Q()}})(),()=>{Y=!1,window.clearTimeout(ne),ce.unsubscribe()}},[]);const B=async(Y,ee)=>{const{error:Q}=await H.auth.signInWithPassword({email:Y,password:ee});if(Q)throw me.error(Q.message),Q;me.success("Welcome back!");const ce=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),O(ce)},V=async(Y,ee,Q)=>{const ce=`${window.location.origin}/dashboard`,{error:ne}=await H.auth.signUp({email:Y,password:ee,options:{emailRedirectTo:ce,data:{name:Q}}});if(ne)throw me.error(ne.message),ne;me.success("Account created! Welcome to LevelUp."),O("/dashboard")},X=async()=>{try{const{data:{session:Y}}=await H.auth.getSession();if(Y){const{error:ee}=await H.auth.signOut();ee?ee.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",ee.message):(console.error("Sign out error:",ee),me.error(ee.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),g(!1),_(null),j([]),S(null),O("/auth")}catch(Y){console.error("Unexpected sign out error:",Y),O("/auth")}};return e.jsx(GVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:B,signUp:V,signOut:X,isAdmin:u,isBrokerageManager:f,brokerageId:v,managedBrokerages:w,selectedBrokerageId:k,setSelectedBrokerageId:S},children:t})},Os=()=>{const t=N.useContext(GVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},WVe=N.createContext(void 0),U2="levelup_admin_session",zb="levelup_impersonation",Mxe="levelup_impersonation_return",Uwt=({children:t})=>{const[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(!1);N.useEffect(()=>{const u=sessionStorage.getItem(zb);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(zb)}},[]);const i=async(u,p)=>{l(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)return me.error("No active session found"),!1;const g={access_token:f.access_token,refresh_token:f.refresh_token};sessionStorage.setItem(U2,JSON.stringify(g)),p&&sessionStorage.setItem(Mxe,p);const v=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await v.json();if(!v.ok)throw new Error(_.error||"Failed to impersonate user");const w={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(zb,JSON.stringify(w)),_.method==="session"){const{error:j}=await H.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(j)throw console.error("Set session error:",j),sessionStorage.removeItem(U2),sessionStorage.removeItem(zb),new Error("Failed to establish impersonation session")}else{const j=_.type||"recovery",{error:k}=await H.auth.verifyOtp({token_hash:_.token_hash,type:j});if(k)throw console.error("Verify OTP error:",k),sessionStorage.removeItem(U2),sessionStorage.removeItem(zb),new Error("Failed to establish impersonation session")}return r(!0),a(w),me.success(`Now viewing as ${w.name}`),window.location.href="/dashboard",!0}catch(f){return console.error("Impersonation error:",f),me.error(f.message||"Failed to impersonate user"),sessionStorage.removeItem(U2),sessionStorage.removeItem(zb),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(U2);if(!u){await H.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await H.auth.signOut();const{error:f}=await H.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(U2),sessionStorage.removeItem(zb),f){console.error("Failed to restore admin session:",f),me.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),me.success("Returned to your account");const g=sessionStorage.getItem(Mxe)||"/admin/members";sessionStorage.removeItem(Mxe),window.location.href=g}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(U2),sessionStorage.removeItem(zb),window.location.href="/auth"}finally{l(!1)}};return e.jsx(WVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},Vde=()=>{const t=N.useContext(WVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},lD=b3("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-full px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),K=N.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?j2e:"button";return e.jsx(l,{className:It(lD({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const Vwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Vde();return!t||!s?null:e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[100] bg-amber-500 text-amber-950 px-4 py-2 shadow-lg",children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Yu,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"font-medium text-sm md:text-base",children:[e.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),e.jsx("strong",{children:s.name}),e.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",s.email,")"]})]})]}),e.jsx(K,{size:"sm",variant:"secondary",onClick:r,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Mr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),e.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},KVe=N.createContext(void 0),k5="levelup_acting_as",cz="levelup_acting_as_self",Hwt=({children:t})=>{const{user:s}=Os(),[r,n]=N.useState(!1),[a,o]=N.useState([]),[l,i]=N.useState(null),[c,u]=N.useState({}),[p,f]=N.useState(!0),[g,v]=N.useState(()=>sessionStorage.getItem(cz)==="true");N.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:M}=await H.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!M){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:L,error:P}=await H.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(P||!L||L.length===0){o([]),f(!1);return}const O=L.map(B=>B.agent_id),{data:$}=await H.from("profiles").select("id, name, email, avatar_url").in("id",O),U=($||[]).map(B=>({id:B.id,name:B.name||B.email||"Unknown",email:B.email||"",avatar_url:B.avatar_url}));if(o(U),sessionStorage.getItem(cz)==="true")v(!0),i(null),u({});else{const B=sessionStorage.getItem(k5);if(B){const V=U.find(X=>X.id===B);if(V){i(V);const X=L.find(Y=>Y.agent_id===B);u((X==null?void 0:X.permissions)||{})}else if(U.length>0){i(U[0]);const X=L.find(Y=>Y.agent_id===U[0].id);u((X==null?void 0:X.permissions)||{}),sessionStorage.setItem(k5,U[0].id)}}else if(U.length>0){i(U[0]);const V=L.find(X=>X.agent_id===U[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(k5,U[0].id)}}}catch(M){console.error("Error loading assistant data:",M)}finally{f(!1)}})()},[s==null?void 0:s.id]);const _=S=>{i(S),v(!1),sessionStorage.removeItem(cz),S?(sessionStorage.setItem(k5,S.id),H.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:M})=>{u((M==null?void 0:M.permissions)||{})})):(sessionStorage.removeItem(k5),u({}))},w=()=>{v(!0),i(null),u({}),sessionStorage.setItem(cz,"true"),sessionStorage.removeItem(k5)},j=S=>!r||g?!0:c[S]===!0,k=r&&l&&!g?l.id:(s==null?void 0:s.id)||null;return e.jsx(KVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:_,effectiveUserId:k,permissions:c,hasPermission:j,isLoading:p,isActingAsSelf:g,setActingAsSelf:w},children:t})},oje=()=>{const t=N.useContext(KVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ri=()=>{const{effectiveUserId:t}=oje();return t};var ZVe={exports:{}},YVe={};/** * @license React * use-sync-external-store-shim.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var UT=N;function Gwt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Wwt=typeof Object.is=="function"?Object.is:Gwt,Kwt=UT.useState,Zwt=UT.useEffect,Ywt=UT.useLayoutEffect,Qwt=UT.useDebugValue;function Xwt(t,s){var r=s(),n=Kwt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Ywt(function(){a.value=r,a.getSnapshot=s,Txe(a)&&o({inst:a})},[t,r,s]),Zwt(function(){return Txe(a)&&o({inst:a}),t(function(){Txe(a)&&o({inst:a})})},[t]),Qwt(r),r}function Txe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Wwt(t,r)}catch{return!0}}function Jwt(t,s){return s()}var e2t=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Jwt:Xwt;YVe.useSyncExternalStore=UT.useSyncExternalStore!==void 0?UT.useSyncExternalStore:e2t;ZVe.exports=YVe;var t2t=ZVe.exports;function s2t(){return t2t.useSyncExternalStore(r2t,()=>!0,()=>!1)}function r2t(){return()=>{}}var lje="Avatar",[n2t]=od(lje),[a2t,QVe]=n2t(lje),XVe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=N.useState("idle");return e.jsx(a2t,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(an.span,{...n,ref:s})})});XVe.displayName=lje;var JVe="AvatarImage",eHe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=QVe(JVe,r),i=i2t(n,o),c=bd(u=>{a(u),l.onImageLoadingStatusChange(u)});return jd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(an.img,{...o,ref:s,src:n}):null});eHe.displayName=JVe;var tHe="AvatarFallback",sHe=N.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=QVe(tHe,r),[l,i]=N.useState(n===void 0);return N.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(c)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(an.span,{...a,ref:s}):null});sHe.displayName=tHe;function s6e(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function i2t(t,{referrerPolicy:s,crossOrigin:r}){const n=s2t(),a=N.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=N.useState(()=>s6e(o,t));return jd(()=>{i(s6e(o,t))},[o,t]),jd(()=>{const c=f=>()=>{i(f)};if(!o)return;const u=c("loaded"),p=c("error");return o.addEventListener("load",u),o.addEventListener("error",p),s&&(o.referrerPolicy=s),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",u),o.removeEventListener("error",p)}},[o,r,s]),l}var rHe=XVe,nHe=eHe,aHe=sHe;const kn=N.forwardRef(({className:t,...s},r)=>e.jsx(rHe,{ref:r,className:It("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));kn.displayName=rHe.displayName;const Ua=N.forwardRef(({className:t,...s},r)=>e.jsx(nHe,{ref:r,className:It("aspect-square h-full w-full",t),...s}));Ua.displayName=nHe.displayName;const Sn=N.forwardRef(({className:t,...s},r)=>e.jsx(aHe,{ref:r,className:It("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));Sn.displayName=aHe.displayName;const o2t=b3("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function st({className:t,variant:s,...r}){return e.jsx("div",{className:It(o2t({variant:s}),t),...r})}var l2t=N.createContext(void 0);function Lw(t){const s=N.useContext(l2t);return t||s||"ltr"}var Axe=0;function Hde(){N.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??r6e()),document.body.insertAdjacentElement("beforeend",t[1]??r6e()),Axe++,()=>{Axe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),Axe--}},[])}function r6e(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Exe="focusScope.autoFocusOnMount",Pxe="focusScope.autoFocusOnUnmount",n6e={bubbles:!1,cancelable:!0},c2t="FocusScope",RO=N.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=N.useState(null),u=bd(a),p=bd(o),f=N.useRef(null),g=Va(s,w=>c(w)),v=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(n){let w=function(M){if(v.paused||!i)return;const L=M.target;i.contains(L)?f.current=L:Gb(f.current,{select:!0})},j=function(M){if(v.paused||!i)return;const L=M.relatedTarget;L!==null&&(i.contains(L)||Gb(f.current,{select:!0}))},k=function(M){if(document.activeElement===document.body)for(const P of M)P.removedNodes.length>0&&Gb(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const S=new MutationObserver(k);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),S.disconnect()}}},[n,i,v.paused]),N.useEffect(()=>{if(i){i6e.add(v);const w=document.activeElement;if(!i.contains(w)){const k=new CustomEvent(Exe,n6e);i.addEventListener(Exe,u),i.dispatchEvent(k),k.defaultPrevented||(d2t(f2t(iHe(i)),{select:!0}),document.activeElement===w&&Gb(i))}return()=>{i.removeEventListener(Exe,u),setTimeout(()=>{const k=new CustomEvent(Pxe,n6e);i.addEventListener(Pxe,p),i.dispatchEvent(k),k.defaultPrevented||Gb(w??document.body,{select:!0}),i.removeEventListener(Pxe,p),i6e.remove(v)},0)}}},[i,u,p,v]);const _=N.useCallback(w=>{if(!r&&!n||v.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(j&&k){const S=w.currentTarget,[M,L]=u2t(S);M&&L?!w.shiftKey&&k===L?(w.preventDefault(),r&&Gb(M,{select:!0})):w.shiftKey&&k===M&&(w.preventDefault(),r&&Gb(L,{select:!0})):k===S&&w.preventDefault()}},[r,n,v.paused]);return e.jsx(an.div,{tabIndex:-1,...l,ref:g,onKeyDown:_})});RO.displayName=c2t;function d2t(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Gb(n,{select:s}),document.activeElement!==r)return}function u2t(t){const s=iHe(t),r=a6e(s,t),n=a6e(s.reverse(),t);return[r,n]}function iHe(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function a6e(t,s){for(const r of t)if(!h2t(r,{upTo:s}))return r}function h2t(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function m2t(t){return t instanceof HTMLInputElement&&"select"in t}function Gb(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&m2t(t)&&s&&t.select()}}var i6e=p2t();function p2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=o6e(t,s),t.unshift(s)},remove(s){var r;t=o6e(t,s),(r=t[0])==null||r.resume()}}}function o6e(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function f2t(t){return t.filter(s=>s.tagName!=="A")}var Ixe="rovingFocusGroup.onEntryFocus",x2t={bubbles:!1,cancelable:!0},FO="RovingFocusGroup",[Lve,oHe,g2t]=TO(FO),[y2t,Dw]=od(FO,[g2t]),[v2t,b2t]=y2t(FO),lHe=N.forwardRef((t,s)=>e.jsx(Lve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Lve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(_2t,{...t,ref:s})})}));lHe.displayName=FO;var _2t=N.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...f}=t,g=N.useRef(null),v=Va(s,g),_=Lw(o),[w,j]=oh({prop:l,defaultProp:i??null,onChange:c,caller:FO}),[k,S]=N.useState(!1),M=bd(u),L=oHe(r),P=N.useRef(!1),[O,$]=N.useState(0);return N.useEffect(()=>{const U=g.current;if(U)return U.addEventListener(Ixe,M),()=>U.removeEventListener(Ixe,M)},[M]),e.jsx(v2t,{scope:r,orientation:n,dir:_,loop:a,currentTabStopId:w,onItemFocus:N.useCallback(U=>j(U),[j]),onItemShiftTab:N.useCallback(()=>S(!0),[]),onFocusableItemAdd:N.useCallback(()=>$(U=>U+1),[]),onFocusableItemRemove:N.useCallback(()=>$(U=>U-1),[]),children:e.jsx(an.div,{tabIndex:k||O===0?-1:0,"data-orientation":n,...f,ref:v,style:{outline:"none",...t.style},onMouseDown:Lr(t.onMouseDown,()=>{P.current=!0}),onFocus:Lr(t.onFocus,U=>{const B=!P.current;if(U.target===U.currentTarget&&B&&!k){const V=new CustomEvent(Ixe,x2t);if(U.currentTarget.dispatchEvent(V),!V.defaultPrevented){const X=L().filter(ne=>ne.focusable),Y=X.find(ne=>ne.active),ee=X.find(ne=>ne.id===w),ce=[Y,ee,...X].filter(Boolean).map(ne=>ne.ref.current);uHe(ce,p)}}P.current=!1}),onBlur:Lr(t.onBlur,()=>S(!1))})})}),cHe="RovingFocusGroupItem",dHe=N.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=Eu(),u=o||c,p=b2t(cHe,r),f=p.currentTabStopId===u,g=oHe(r),{onFocusableItemAdd:v,onFocusableItemRemove:_,currentTabStopId:w}=p;return N.useEffect(()=>{if(n)return v(),()=>_()},[n,v,_]),e.jsx(Lve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(an.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Lr(t.onMouseDown,j=>{n?p.onItemFocus(u):j.preventDefault()}),onFocus:Lr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Lr(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){p.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const k=N2t(j,p.orientation,p.dir);if(k!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let M=g().filter(L=>L.focusable).map(L=>L.ref.current);if(k==="last")M.reverse();else if(k==="prev"||k==="next"){k==="prev"&&M.reverse();const L=M.indexOf(j.currentTarget);M=p.loop?k2t(M,L+1):M.slice(L+1)}setTimeout(()=>uHe(M))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:w!=null}):l})})});dHe.displayName=cHe;var w2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function j2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function N2t(t,s,r){const n=j2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return w2t[n]}function uHe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function k2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Gde=lHe,Wde=dHe,S2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},S5=new WeakMap,dz=new WeakMap,uz={},Lxe=0,hHe=function(t){return t&&(t.host||hHe(t.parentNode))},C2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=hHe(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},M2t=function(t,s,r,n){var a=C2t(s,Array.isArray(t)?t:[t]);uz[r]||(uz[r]=new WeakMap);var o=uz[r],l=[],i=new Set,c=new Set(a),u=function(f){!f||i.has(f)||(i.add(f),u(f.parentNode))};a.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(g){if(i.has(g))p(g);else try{var v=g.getAttribute(n),_=v!==null&&v!=="false",w=(S5.get(g)||0)+1,j=(o.get(g)||0)+1;S5.set(g,w),o.set(g,j),l.push(g),w===1&&_&&dz.set(g,!0),j===1&&g.setAttribute(r,"true"),_||g.setAttribute(n,"true")}catch(k){console.error("aria-hidden: cannot operate on ",g,k)}})};return p(s),i.clear(),Lxe++,function(){l.forEach(function(f){var g=S5.get(f)-1,v=o.get(f)-1;S5.set(f,g),o.set(f,v),g||(dz.has(f)||f.removeAttribute(n),dz.delete(f)),v||f.removeAttribute(r)}),Lxe--,Lxe||(S5=new WeakMap,S5=new WeakMap,dz=new WeakMap,uz={})}},Kde=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=S2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),M2t(n,a,r,"aria-hidden")):function(){return null}},_ie="right-scroll-bar-position",wie="width-before-scroll-bar",T2t="with-scroll-bars-hidden",A2t="--removed-body-scroll-bar-size";function Dxe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function E2t(t,s){var r=N.useState(function(){return{value:t,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var P2t=typeof window<"u"?N.useLayoutEffect:N.useEffect,l6e=new WeakMap;function I2t(t,s){var r=E2t(null,function(n){return t.forEach(function(a){return Dxe(a,n)})});return P2t(function(){var n=l6e.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||Dxe(i,null)}),o.forEach(function(i){a.has(i)||Dxe(i,l)})}l6e.set(r,t)},[t]),r}function L2t(t){return t}function D2t(t,s){s===void 0&&(s=L2t);var r=[],n=!1,a={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(o){var l=s(o,n);return r.push(l),function(){r=r.filter(function(i){return i!==l})}},assignSyncMedium:function(o){for(n=!0;r.length;){var l=r;r=[],l.forEach(o)}r={push:function(i){return o(i)},filter:function(){return r}}},assignMedium:function(o){n=!0;var l=[];if(r.length){var i=r;r=[],i.forEach(o),l=r}var c=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),r}}}};return a}function O2t(t){t===void 0&&(t={});var s=D2t(null);return s.options=gx({async:!0,ssr:!1},t),s}var mHe=function(t){var s=t.sideCar,r=Pw(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return N.createElement(n,gx({},r))};mHe.isSideCarExport=!0;function R2t(t,s){return t.useMedium(s),mHe}var pHe=O2t(),Oxe=function(){},Zde=N.forwardRef(function(t,s){var r=N.useRef(null),n=N.useState({onScrollCapture:Oxe,onWheelCapture:Oxe,onTouchMoveCapture:Oxe}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,c=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,g=t.sideCar,v=t.noRelative,_=t.noIsolation,w=t.inert,j=t.allowPinchZoom,k=t.as,S=k===void 0?"div":k,M=t.gapMode,L=Pw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=g,O=I2t([r,s]),$=gx(gx({},L),a);return N.createElement(N.Fragment,null,p&&N.createElement(P,{sideCar:pHe,removeScrollBar:u,shards:f,noRelative:v,noIsolation:_,inert:w,setCallbacks:o,allowPinchZoom:!!j,lockRef:r,gapMode:M}),l?N.cloneElement(N.Children.only(i),gx(gx({},$),{ref:O})):N.createElement(S,gx({},$,{className:c,ref:O}),i))});Zde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Zde.classNames={fullWidth:wie,zeroRight:_ie};var F2t=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function z2t(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=F2t();return s&&t.setAttribute("nonce",s),t}function B2t(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function $2t(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var q2t=function(){var t=0,s=null;return{add:function(r){t==0&&(s=z2t())&&(B2t(s,r),$2t(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},U2t=function(){var t=q2t();return function(s,r){N.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},fHe=function(){var t=U2t(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},V2t={left:0,top:0,right:0,gap:0},Rxe=function(t){return parseInt(t||"",10)||0},H2t=function(t){var s=window.getComputedStyle(document.body),r=s[t==="padding"?"paddingLeft":"marginLeft"],n=s[t==="padding"?"paddingTop":"marginTop"],a=s[t==="padding"?"paddingRight":"marginRight"];return[Rxe(r),Rxe(n),Rxe(a)]},G2t=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return V2t;var s=H2t(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,n-r+s[2]-s[0])}},W2t=fHe(),aT="data-scroll-locked",K2t=function(t,s,r,n){var a=t.left,o=t.top,l=t.right,i=t.gap;return r===void 0&&(r="margin"),` .`.concat(T2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(aT,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([s&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(a,`px; padding-top: `).concat(o,`px; padding-right: `).concat(l,`px; margin-left:0; margin-top:0; margin-right: `).concat(i,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(i,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(_ie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(wie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(_ie," .").concat(_ie,` { right: 0 `).concat(n,`; } .`).concat(wie," .").concat(wie,` { margin-right: 0 `).concat(n,`; } body[`).concat(aT,`] { `).concat(A2t,": ").concat(i,`px; } `)},c6e=function(){var t=parseInt(document.body.getAttribute(aT)||"0",10);return isFinite(t)?t:0},Z2t=function(){N.useEffect(function(){return document.body.setAttribute(aT,(c6e()+1).toString()),function(){var t=c6e()-1;t<=0?document.body.removeAttribute(aT):document.body.setAttribute(aT,t.toString())}},[])},Y2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;Z2t();var o=N.useMemo(function(){return G2t(a)},[a]);return N.createElement(W2t,{styles:K2t(o,!s,a,r?"":"!important")})},Dve=!1;if(typeof window<"u")try{var hz=Object.defineProperty({},"passive",{get:function(){return Dve=!0,!0}});window.addEventListener("test",hz,hz),window.removeEventListener("test",hz,hz)}catch{Dve=!1}var C5=Dve?{passive:!1}:!1,Q2t=function(t){return t.tagName==="TEXTAREA"},xHe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!Q2t(t)&&r[s]==="visible")},X2t=function(t){return xHe(t,"overflowY")},J2t=function(t){return xHe(t,"overflowX")},d6e=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=gHe(t,n);if(a){var o=yHe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},ejt=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},tjt=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},gHe=function(t,s){return t==="v"?X2t(s):J2t(s)},yHe=function(t,s){return t==="v"?ejt(s):tjt(s)},sjt=function(t,s){return t==="h"&&s==="rtl"?-1:1},rjt=function(t,s,r,n,a){var o=sjt(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,c=s.contains(i),u=!1,p=l>0,f=0,g=0;do{if(!i)break;var v=yHe(t,i),_=v[0],w=v[1],j=v[2],k=w-j-o*_;(_||k)&&gHe(t,i)&&(f+=k,g+=_);var S=i.parentNode;i=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&i!==document.body||c&&(s.contains(i)||s===i));return(p&&Math.abs(f)<1||!p&&Math.abs(g)<1)&&(u=!0),u},mz=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},u6e=function(t){return[t.deltaX,t.deltaY]},h6e=function(t){return t&&"current"in t?t.current:t},njt=function(t,s){return t[0]===s[0]&&t[1]===s[1]},ajt=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},ijt=0,M5=[];function ojt(t){var s=N.useRef([]),r=N.useRef([0,0]),n=N.useRef(),a=N.useState(ijt++)[0],o=N.useState(fHe)[0],l=N.useRef(t);N.useEffect(function(){l.current=t},[t]),N.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=X2e([t.lockRef.current],(t.shards||[]).map(h6e),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=N.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var k=mz(w),S=r.current,M="deltaX"in w?w.deltaX:S[0]-k[0],L="deltaY"in w?w.deltaY:S[1]-k[1],P,O=w.target,$=Math.abs(M)>Math.abs(L)?"h":"v";if("touches"in w&&$==="h"&&O.type==="range")return!1;var U=d6e($,O);if(!U)return!0;if(U?P=$:(P=$==="v"?"h":"v",U=d6e($,O)),!U)return!1;if(!n.current&&"changedTouches"in w&&(M||L)&&(n.current=P),!P)return!0;var B=n.current||P;return rjt(B,j,w,B==="h"?M:L)},[]),c=N.useCallback(function(w){var j=w;if(!(!M5.length||M5[M5.length-1]!==o)){var k="deltaY"in j?u6e(j):mz(j),S=s.current.filter(function(P){return P.name===j.type&&(P.target===j.target||j.target===P.shadowParent)&&njt(P.delta,k)})[0];if(S&&S.should){j.cancelable&&j.preventDefault();return}if(!S){var M=(l.current.shards||[]).map(h6e).filter(Boolean).filter(function(P){return P.contains(j.target)}),L=M.length>0?i(j,M[0]):!l.current.noIsolation;L&&j.cancelable&&j.preventDefault()}}},[]),u=N.useCallback(function(w,j,k,S){var M={name:w,delta:j,target:k,should:S,shadowParent:ljt(k)};s.current.push(M),setTimeout(function(){s.current=s.current.filter(function(L){return L!==M})},1)},[]),p=N.useCallback(function(w){r.current=mz(w),n.current=void 0},[]),f=N.useCallback(function(w){u(w.type,u6e(w),w.target,i(w,t.lockRef.current))},[]),g=N.useCallback(function(w){u(w.type,mz(w),w.target,i(w,t.lockRef.current))},[]);N.useEffect(function(){return M5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",c,C5),document.addEventListener("touchmove",c,C5),document.addEventListener("touchstart",p,C5),function(){M5=M5.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,C5),document.removeEventListener("touchmove",c,C5),document.removeEventListener("touchstart",p,C5)}},[]);var v=t.removeScrollBar,_=t.inert;return N.createElement(N.Fragment,null,_?N.createElement(o,{styles:ajt(a)}):null,v?N.createElement(Y2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function ljt(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const cjt=R2t(pHe,ojt);var zO=N.forwardRef(function(t,s){return N.createElement(Zde,gx({},t,{ref:s,sideCar:cjt}))});zO.classNames=Zde.classNames;var Ove=["Enter"," "],djt=["ArrowDown","PageUp","Home"],vHe=["ArrowUp","PageDown","End"],ujt=[...djt,...vHe],hjt={ltr:[...Ove,"ArrowRight"],rtl:[...Ove,"ArrowLeft"]},mjt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},BO="Menu",[cD,pjt,fjt]=TO(BO),[w3,bHe]=od(BO,[fjt,$0,Dw]),Yde=$0(),_He=Dw(),[xjt,j3]=w3(BO),[gjt,$O]=w3(BO),wHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Yde(s),[c,u]=N.useState(null),p=N.useRef(!1),f=bd(o),g=Lw(a);return N.useEffect(()=>{const v=()=>{p.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>p.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),e.jsx(IO,{...i,children:e.jsx(xjt,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(gjt,{scope:s,onClose:N.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:g,modal:l,children:n})})})};wHe.displayName=BO;var yjt="MenuAnchor",cje=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Yde(r);return e.jsx(YA,{...a,...n,ref:s})});cje.displayName=yjt;var dje="MenuPortal",[vjt,jHe]=w3(dje,{forceMount:void 0}),NHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=j3(dje,s);return e.jsx(vjt,{scope:s,forceMount:r,children:e.jsx(zd,{present:r||o.open,children:e.jsx(GA,{asChild:!0,container:a,children:n})})})};NHe.displayName=dje;var Ex="MenuContent",[bjt,uje]=w3(Ex),kHe=N.forwardRef((t,s)=>{const r=jHe(Ex,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=j3(Ex,t.__scopeMenu),l=$O(Ex,t.__scopeMenu);return e.jsx(cD.Provider,{scope:t.__scopeMenu,children:e.jsx(zd,{present:n||o.open,children:e.jsx(cD.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(_jt,{...a,ref:s}):e.jsx(wjt,{...a,ref:s})})})})}),_jt=N.forwardRef((t,s)=>{const r=j3(Ex,t.__scopeMenu),n=N.useRef(null),a=Va(s,n);return N.useEffect(()=>{const o=n.current;if(o)return Kde(o)},[]),e.jsx(hje,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Lr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),wjt=N.forwardRef((t,s)=>{const r=j3(Ex,t.__scopeMenu);return e.jsx(hje,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),jjt=mw("MenuContent.ScrollLock"),hje=N.forwardRef((t,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:v,disableOutsideScroll:_,...w}=t,j=j3(Ex,r),k=$O(Ex,r),S=Yde(r),M=_He(r),L=pjt(r),[P,O]=N.useState(null),$=N.useRef(null),U=Va(s,$,j.onContentChange),B=N.useRef(0),V=N.useRef(""),X=N.useRef(0),Y=N.useRef(null),ee=N.useRef("right"),Q=N.useRef(0),ce=_?zO:N.Fragment,ne=_?{as:jjt,allowPinchZoom:!0}:void 0,re=fe=>{var ke,pe;const ge=V.current+fe,ue=L().filter(we=>!we.disabled),xe=document.activeElement,_e=(ke=ue.find(we=>we.ref.current===xe))==null?void 0:ke.textValue,$e=ue.map(we=>we.textValue),Me=Djt($e,ge,_e),Ie=(pe=ue.find(we=>we.textValue===Me))==null?void 0:pe.ref.current;(function we(Le){V.current=Le,window.clearTimeout(B.current),Le!==""&&(B.current=window.setTimeout(()=>we(""),1e3))})(ge),Ie&&setTimeout(()=>Ie.focus())};N.useEffect(()=>()=>window.clearTimeout(B.current),[]),Hde();const oe=N.useCallback(fe=>{var ue,xe;return ee.current===((ue=Y.current)==null?void 0:ue.side)&&Rjt(fe,(xe=Y.current)==null?void 0:xe.area)},[]);return e.jsx(bjt,{scope:r,searchRef:V,onItemEnter:N.useCallback(fe=>{oe(fe)&&fe.preventDefault()},[oe]),onItemLeave:N.useCallback(fe=>{var ge;oe(fe)||((ge=$.current)==null||ge.focus(),O(null))},[oe]),onTriggerLeave:N.useCallback(fe=>{oe(fe)&&fe.preventDefault()},[oe]),pointerGraceTimerRef:X,onPointerGraceIntentChange:N.useCallback(fe=>{Y.current=fe},[]),children:e.jsx(ce,{...ne,children:e.jsx(RO,{asChild:!0,trapped:a,onMountAutoFocus:Lr(o,fe=>{var ge;fe.preventDefault(),(ge=$.current)==null||ge.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(Aw,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:v,children:e.jsx(Gde,{asChild:!0,...M,dir:k.dir,orientation:"vertical",loop:n,currentTabStopId:P,onCurrentTabStopIdChange:O,onEntryFocus:Lr(c,fe=>{k.isUsingKeyboardRef.current||fe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(LO,{role:"menu","aria-orientation":"vertical","data-state":$He(j.open),"data-radix-menu-content":"",dir:k.dir,...S,...w,ref:U,style:{outline:"none",...w.style},onKeyDown:Lr(w.onKeyDown,fe=>{const ue=fe.target.closest("[data-radix-menu-content]")===fe.currentTarget,xe=fe.ctrlKey||fe.altKey||fe.metaKey,_e=fe.key.length===1;ue&&(fe.key==="Tab"&&fe.preventDefault(),!xe&&_e&&re(fe.key));const $e=$.current;if(fe.target!==$e||!ujt.includes(fe.key))return;fe.preventDefault();const Ie=L().filter(ke=>!ke.disabled).map(ke=>ke.ref.current);vHe.includes(fe.key)&&Ie.reverse(),Ijt(Ie)}),onBlur:Lr(t.onBlur,fe=>{fe.currentTarget.contains(fe.target)||(window.clearTimeout(B.current),V.current="")}),onPointerMove:Lr(t.onPointerMove,dD(fe=>{const ge=fe.target,ue=Q.current!==fe.clientX;if(fe.currentTarget.contains(ge)&&ue){const xe=fe.clientX>Q.current?"right":"left";ee.current=xe,Q.current=fe.clientX}}))})})})})})})});kHe.displayName=Ex;var Njt="MenuGroup",mje=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(an.div,{role:"group",...n,ref:s})});mje.displayName=Njt;var kjt="MenuLabel",SHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(an.div,{...n,ref:s})});SHe.displayName=kjt;var Aoe="MenuItem",m6e="menu.itemSelect",Qde=N.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=N.useRef(null),l=$O(Aoe,t.__scopeMenu),i=uje(Aoe,t.__scopeMenu),c=Va(s,o),u=N.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const g=new CustomEvent(m6e,{bubbles:!0,cancelable:!0});f.addEventListener(m6e,v=>n==null?void 0:n(v),{once:!0}),N2e(f,g),g.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(CHe,{...a,ref:c,disabled:r,onClick:Lr(t.onClick,p),onPointerDown:f=>{var g;(g=t.onPointerDown)==null||g.call(t,f),u.current=!0},onPointerUp:Lr(t.onPointerUp,f=>{var g;u.current||(g=f.currentTarget)==null||g.click()}),onKeyDown:Lr(t.onKeyDown,f=>{const g=i.searchRef.current!=="";r||g&&f.key===" "||Ove.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Qde.displayName=Aoe;var CHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=uje(Aoe,r),i=_He(r),c=N.useRef(null),u=Va(s,c),[p,f]=N.useState(!1),[g,v]=N.useState("");return N.useEffect(()=>{const _=c.current;_&&v((_.textContent??"").trim())},[o.children]),e.jsx(cD.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:e.jsx(Wde,{asChild:!0,...i,focusable:!n,children:e.jsx(an.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Lr(t.onPointerMove,dD(_=>{n?l.onItemLeave(_):(l.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Lr(t.onPointerLeave,dD(_=>l.onItemLeave(_))),onFocus:Lr(t.onFocus,()=>f(!0)),onBlur:Lr(t.onBlur,()=>f(!1))})})})}),Sjt="MenuCheckboxItem",MHe=N.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(IHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Qde,{role:"menuitemcheckbox","aria-checked":Eoe(r)?"mixed":r,...a,ref:s,"data-state":fje(r),onSelect:Lr(a.onSelect,()=>n==null?void 0:n(Eoe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});MHe.displayName=Sjt;var THe="MenuRadioGroup",[Cjt,Mjt]=w3(THe,{value:void 0,onValueChange:()=>{}}),AHe=N.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=bd(n);return e.jsx(Cjt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(mje,{...a,ref:s})})});AHe.displayName=THe;var EHe="MenuRadioItem",PHe=N.forwardRef((t,s)=>{const{value:r,...n}=t,a=Mjt(EHe,t.__scopeMenu),o=r===a.value;return e.jsx(IHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Qde,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":fje(o),onSelect:Lr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});PHe.displayName=EHe;var pje="MenuItemIndicator",[IHe,Tjt]=w3(pje,{checked:!1}),LHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=Tjt(pje,r);return e.jsx(zd,{present:n||Eoe(o.checked)||o.checked===!0,children:e.jsx(an.span,{...a,ref:s,"data-state":fje(o.checked)})})});LHe.displayName=pje;var Ajt="MenuSeparator",DHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(an.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});DHe.displayName=Ajt;var Ejt="MenuArrow",OHe=N.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Yde(r);return e.jsx(DO,{...a,...n,ref:s})});OHe.displayName=Ejt;var Pjt="MenuSub",[qTs,RHe]=w3(Pjt),PI="MenuSubTrigger",FHe=N.forwardRef((t,s)=>{const r=j3(PI,t.__scopeMenu),n=$O(PI,t.__scopeMenu),a=RHe(PI,t.__scopeMenu),o=uje(PI,t.__scopeMenu),l=N.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},p=N.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return N.useEffect(()=>p,[p]),N.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(cje,{asChild:!0,...u,children:e.jsx(CHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":$He(r.open),...t,ref:P1(s,a.onTriggerChange),onClick:f=>{var g;(g=t.onClick)==null||g.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Lr(t.onPointerMove,dD(f=>{o.onItemEnter(f),!f.defaultPrevented&&!t.disabled&&!r.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:Lr(t.onPointerLeave,dD(f=>{var v,_;p();const g=(v=r.content)==null?void 0:v.getBoundingClientRect();if(g){const w=(_=r.content)==null?void 0:_.dataset.side,j=w==="right",k=j?-5:5,S=g[j?"left":"right"],M=g[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+k,y:f.clientY},{x:S,y:g.top},{x:M,y:g.top},{x:M,y:g.bottom},{x:S,y:g.bottom}],side:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Lr(t.onKeyDown,f=>{var v;const g=o.searchRef.current!=="";t.disabled||g&&f.key===" "||hjt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(v=r.content)==null||v.focus(),f.preventDefault())})})})});FHe.displayName=PI;var zHe="MenuSubContent",BHe=N.forwardRef((t,s)=>{const r=jHe(Ex,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=j3(Ex,t.__scopeMenu),l=$O(Ex,t.__scopeMenu),i=RHe(zHe,t.__scopeMenu),c=N.useRef(null),u=Va(s,c);return e.jsx(cD.Provider,{scope:t.__scopeMenu,children:e.jsx(zd,{present:n||o.open,children:e.jsx(cD.Slot,{scope:t.__scopeMenu,children:e.jsx(hje,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var f;l.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Lr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Lr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Lr(t.onKeyDown,p=>{var v;const f=p.currentTarget.contains(p.target),g=mjt[l.dir].includes(p.key);f&&g&&(o.onOpenChange(!1),(v=i.trigger)==null||v.focus(),p.preventDefault())})})})})})});BHe.displayName=zHe;function $He(t){return t?"open":"closed"}function Eoe(t){return t==="indeterminate"}function fje(t){return Eoe(t)?"indeterminate":t?"checked":"unchecked"}function Ijt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function Ljt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function Djt(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=Ljt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function Ojt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=g>n&&r<(f-u)*(n-p)/(g-p)+u&&(a=!a)}return a}function Rjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return Ojt(r,s)}function dD(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Fjt=wHe,zjt=cje,Bjt=NHe,$jt=kHe,qjt=mje,Ujt=SHe,Vjt=Qde,Hjt=MHe,Gjt=AHe,Wjt=PHe,Kjt=LHe,Zjt=DHe,Yjt=OHe,Qjt=FHe,Xjt=BHe,Xde="DropdownMenu",[Jjt]=od(Xde,[bHe]),Gm=bHe(),[eNt,qHe]=Jjt(Xde),UHe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Gm(s),u=N.useRef(null),[p,f]=oh({prop:a,defaultProp:o??!1,onChange:l,caller:Xde});return e.jsx(eNt,{scope:s,triggerId:Eu(),triggerRef:u,contentId:Eu(),open:p,onOpenChange:f,onOpenToggle:N.useCallback(()=>f(g=>!g),[f]),modal:i,children:e.jsx(Fjt,{...c,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};UHe.displayName=Xde;var VHe="DropdownMenuTrigger",HHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=qHe(VHe,r),l=Gm(r);return e.jsx(zjt,{asChild:!0,...l,children:e.jsx(an.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...a,ref:P1(s,o.triggerRef),onPointerDown:Lr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Lr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});HHe.displayName=VHe;var tNt="DropdownMenuPortal",GHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Gm(s);return e.jsx(Bjt,{...n,...r})};GHe.displayName=tNt;var WHe="DropdownMenuContent",KHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=qHe(WHe,r),o=Gm(r),l=N.useRef(!1);return e.jsx($jt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Lr(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Lr(t.onInteractOutside,i=>{const c=i.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,p=c.button===2||u;(!a.modal||p)&&(l.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});KHe.displayName=WHe;var sNt="DropdownMenuGroup",rNt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(qjt,{...a,...n,ref:s})});rNt.displayName=sNt;var nNt="DropdownMenuLabel",ZHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Ujt,{...a,...n,ref:s})});ZHe.displayName=nNt;var aNt="DropdownMenuItem",YHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Vjt,{...a,...n,ref:s})});YHe.displayName=aNt;var iNt="DropdownMenuCheckboxItem",QHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Hjt,{...a,...n,ref:s})});QHe.displayName=iNt;var oNt="DropdownMenuRadioGroup",lNt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Gjt,{...a,...n,ref:s})});lNt.displayName=oNt;var cNt="DropdownMenuRadioItem",XHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Wjt,{...a,...n,ref:s})});XHe.displayName=cNt;var dNt="DropdownMenuItemIndicator",JHe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Kjt,{...a,...n,ref:s})});JHe.displayName=dNt;var uNt="DropdownMenuSeparator",eGe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Zjt,{...a,...n,ref:s})});eGe.displayName=uNt;var hNt="DropdownMenuArrow",mNt=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Yjt,{...a,...n,ref:s})});mNt.displayName=hNt;var pNt="DropdownMenuSubTrigger",tGe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Qjt,{...a,...n,ref:s})});tGe.displayName=pNt;var fNt="DropdownMenuSubContent",sGe=N.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Gm(r);return e.jsx(Xjt,{...a,...n,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sGe.displayName=fNt;var xNt=UHe,gNt=HHe,yNt=GHe,rGe=KHe,nGe=ZHe,aGe=YHe,iGe=QHe,oGe=XHe,lGe=JHe,cGe=eGe,dGe=tGe,uGe=sGe;const ou=xNt,lu=gNt,vNt=N.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(dGe,{ref:a,className:It("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(oa,{className:"ml-auto h-4 w-4"})]}));vNt.displayName=dGe.displayName;const bNt=N.forwardRef(({className:t,...s},r)=>e.jsx(uGe,{ref:r,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s}));bNt.displayName=uGe.displayName;const Bd=N.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(yNt,{children:e.jsx(rGe,{ref:n,sideOffset:s,className:It("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));Bd.displayName=rGe.displayName;const Aa=N.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(aGe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Aa.displayName=aGe.displayName;const _Nt=N.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(iGe,{ref:a,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(lGe,{children:e.jsx(ba,{className:"h-4 w-4"})})}),s]}));_Nt.displayName=iGe.displayName;const wNt=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(oGe,{ref:n,className:It("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(lGe,{children:e.jsx(wd,{className:"h-2 w-2 fill-current"})})}),s]}));wNt.displayName=oGe.displayName;const Rve=N.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(nGe,{ref:n,className:It("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));Rve.displayName=nGe.displayName;const xw=N.forwardRef(({className:t,...s},r)=>e.jsx(cGe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));xw.displayName=cGe.displayName;const jNt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=oje();if(!t)return null;const l=i=>i.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2);return e.jsx("div",{className:"fixed top-0 left-0 right-0 z-[2147483647] bg-primary text-primary-foreground px-4 py-1.5 shadow-lg",style:{height:"40px"},children:e.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Wi,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(hr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[a?e.jsxs(e.Fragment,{children:[e.jsx(Wi,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(kn,{className:"h-5 w-5",children:[e.jsx(Ua,{src:s.avatar_url||void 0}),e.jsx(Sn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(oo,{className:"h-3 w-3"})]})}),e.jsxs(Bd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Aa,{onClick:o,className:"gap-2",children:[e.jsx(Wi,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(st,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(xw,{}),r.map(i=>e.jsxs(Aa,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:i.avatar_url||void 0}),e.jsx(Sn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(st,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(st,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},ar=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,rolesLoading:o,isAdmin:l,isBrokerageManager:i}=Os(),c=dc();if(a||(s||r)&&o)return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})});if(!n){const u=c.pathname+c.search+c.hash;return u&&u!=="/auth"&&sessionStorage.setItem("redirectAfterLogin",u),e.jsx(fxe,{to:"/auth",replace:!0})}return s&&!l?e.jsx(fxe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(fxe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t})};var xje={};(function t(s,r,n,a){var o=!!(s.Worker&&s.Blob&&s.Promise&&s.OffscreenCanvas&&s.OffscreenCanvasRenderingContext2D&&s.HTMLCanvasElement&&s.HTMLCanvasElement.prototype.transferControlToOffscreen&&s.URL&&s.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!s.OffscreenCanvas)return!1;try{var ge=new OffscreenCanvas(1,1),ue=ge.getContext("2d");ue.fillRect(0,0,1,1);var xe=ge.transferToImageBitmap();ue.createPattern(xe,"no-repeat")}catch{return!1}return!0}();function c(){}function u(ge){var ue=r.exports.Promise,xe=ue!==void 0?ue:s.Promise;return typeof xe=="function"?new xe(ge):(ge(c,c),null)}var p=function(ge,ue){return{transform:function(xe){if(ge)return xe;if(ue.has(xe))return ue.get(xe);var _e=new OffscreenCanvas(xe.width,xe.height),$e=_e.getContext("2d");return $e.drawImage(xe,0,0),ue.set(xe,_e),_e},clear:function(){ue.clear()}}}(i,new Map),f=function(){var ge=Math.floor(16.666666666666668),ue,xe,_e={},$e=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ue=function(Me){var Ie=Math.random();return _e[Ie]=requestAnimationFrame(function ke(pe){$e===pe||$e+ge-1{const{data:s,error:r}=await H.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function kNt(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function SNt(){const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{error:n}=await H.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var Jde="Dialog",[hGe,mGe]=od(Jde),[CNt,my]=hGe(Jde),pGe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=N.useRef(null),c=N.useRef(null),[u,p]=oh({prop:n,defaultProp:a??!1,onChange:o,caller:Jde});return e.jsx(CNt,{scope:s,triggerRef:i,contentRef:c,contentId:Eu(),titleId:Eu(),descriptionId:Eu(),open:u,onOpenChange:p,onOpenToggle:N.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};pGe.displayName=Jde;var fGe="DialogTrigger",xGe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=my(fGe,r),o=Va(s,a.triggerRef);return e.jsx(an.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":vje(a.open),...n,ref:o,onClick:Lr(t.onClick,a.onOpenToggle)})});xGe.displayName=fGe;var gje="DialogPortal",[MNt,gGe]=hGe(gje,{forceMount:void 0}),yGe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=my(gje,s);return e.jsx(MNt,{scope:s,forceMount:r,children:N.Children.map(n,l=>e.jsx(zd,{present:r||o.open,children:e.jsx(GA,{asChild:!0,container:a,children:l})}))})};yGe.displayName=gje;var Poe="DialogOverlay",vGe=N.forwardRef((t,s)=>{const r=gGe(Poe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=my(Poe,t.__scopeDialog);return o.modal?e.jsx(zd,{present:n||o.open,children:e.jsx(ANt,{...a,ref:s})}):null});vGe.displayName=Poe;var TNt=mw("DialogOverlay.RemoveScroll"),ANt=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=my(Poe,r);return e.jsx(zO,{as:TNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(an.div,{"data-state":vje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),GS="DialogContent",bGe=N.forwardRef((t,s)=>{const r=gGe(GS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=my(GS,t.__scopeDialog);return e.jsx(zd,{present:n||o.open,children:o.modal?e.jsx(ENt,{...a,ref:s}):e.jsx(PNt,{...a,ref:s})})});bGe.displayName=GS;var ENt=N.forwardRef((t,s)=>{const r=my(GS,t.__scopeDialog),n=N.useRef(null),a=Va(s,r.contentRef,n);return N.useEffect(()=>{const o=n.current;if(o)return Kde(o)},[]),e.jsx(_Ge,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Lr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Lr(t.onFocusOutside,o=>o.preventDefault())})}),PNt=N.forwardRef((t,s)=>{const r=my(GS,t.__scopeDialog),n=N.useRef(!1),a=N.useRef(!1);return e.jsx(_Ge,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),_Ge=N.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=my(GS,r),c=N.useRef(null),u=Va(s,c);return Hde(),e.jsxs(e.Fragment,{children:[e.jsx(RO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Aw,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":vje(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(LNt,{titleId:i.titleId}),e.jsx(ONt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),yje="DialogTitle",wGe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=my(yje,r);return e.jsx(an.h2,{id:a.titleId,...n,ref:s})});wGe.displayName=yje;var jGe="DialogDescription",NGe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=my(jGe,r);return e.jsx(an.p,{id:a.descriptionId,...n,ref:s})});NGe.displayName=jGe;var kGe="DialogClose",SGe=N.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=my(kGe,r);return e.jsx(an.button,{type:"button",...n,ref:s,onClick:Lr(t.onClick,()=>a.onOpenChange(!1))})});SGe.displayName=kGe;function vje(t){return t?"open":"closed"}var CGe="DialogTitleWarning",[INt,MGe]=xxt(CGe,{contentName:GS,titleName:yje,docsSlug:"dialog"}),LNt=({titleId:t})=>{const s=MGe(CGe),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return N.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},DNt="DialogDescriptionWarning",ONt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${MGe(DNt).contentName}}.`;return N.useEffect(()=>{var o;const a=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,t,s]),null},eue=pGe,bje=xGe,tue=yGe,sE=vGe,rE=bGe,qO=wGe,UO=NGe,VO=SGe;const xs=eue,qi=bje,RNt=tue,UTs=VO,TGe=N.forwardRef(({className:t,...s},r)=>e.jsx(sE,{ref:r,className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));TGe.displayName=sE.displayName;const fs=N.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(RNt,{children:[e.jsx(TGe,{className:r}),e.jsxs(rE,{ref:a,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(VO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Mr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fs.displayName=rE.displayName;const js=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});js.displayName="DialogHeader";const Un=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Un.displayName="DialogFooter";const _s=N.forwardRef(({className:t,...s},r)=>e.jsx(qO,{ref:r,className:It("text-lg font-semibold leading-none tracking-tight",t),...s}));_s.displayName=qO.displayName;const Wr=N.forwardRef(({className:t,...s},r)=>e.jsx(UO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));Wr.displayName=UO.displayName;const FNt={points_earned:vo,listing_created:dn,deal_closed:hl,custom:Jn},f6e={points_earned:"from-amber-500 to-orange-500",listing_created:"from-emerald-500 to-teal-500",deal_closed:"from-green-500 to-emerald-500",custom:"from-purple-500 to-pink-500"},x6e=()=>{const t=window.location.hostname;return t.startsWith("cards.")||t.startsWith("cardstudio.")||t.startsWith("listings.")||t.startsWith("presentations.")||t.startsWith("guestbook.")||t.startsWith("clients.")||t.startsWith("booking.")||t.startsWith("contacts.")};function zNt(){const{user:t}=Os(),s=Xt(),{data:r}=NNt(),n=kNt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=N.useCallback(()=>{const v=Date.now()+3e3,_={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(k,S)=>Math.random()*(S-k)+k,j=setInterval(()=>{const k=v-Date.now();if(k<=0){clearInterval(j);return}const S=50*(k/3e3);p6e({..._,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),p6e({..._,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);N.useEffect(()=>{x6e()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(c,100))},[r,a,c]);const u=async()=>{if(a){const g=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],v=>(v==null?void 0:v.filter(_=>_.id!==g))??[]),await n.mutateAsync(g)}};if(x6e()||!a)return null;const p=FNt[a.celebration_type]||Jn,f=f6e[a.celebration_type]||f6e.custom;return e.jsx(xs,{open:l,onOpenChange:g=>!g&&u(),children:e.jsxs(fs,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(fn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(fn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(fn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",a.title]}),a.points_amount&&a.points_amount>0&&e.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&e.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),e.jsx(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const AGe="/assets/levelup-logo-horizontal-DEFNc0ms.png",_je="/assets/levelup-logo-white-C2RAgAoG.png",BNt="/assets/listings-hero-BI9Ki9Dq.jpg",ze=N.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:It("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));ze.displayName="Input";var EGe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Yv,function(){var r,n,a;function o(i,c){if(!r)r=c;else if(!n)n=c;else{var u="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+r+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",p={};r(p),a=c(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([u],{type:"text/javascript"})))}}o(["exports"],function(i){var c=1e-6,u=typeof Float32Array<"u"?Float32Array:Array;function p(x,d){var m=d[0],b=d[1],C=d[2],E=d[3],I=m*E-C*b;return I?(x[0]=E*(I=1/I),x[1]=-b*I,x[2]=-C*I,x[3]=m*I,x):null}function f(){var x=new u(9);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x}function g(x,d){var m=d[0],b=d[1],C=d[2],E=d[3],I=d[4],R=d[5],q=d[6],W=d[7],te=d[8];return x[0]=I*te-R*W,x[1]=C*W-b*te,x[2]=b*R-C*I,x[3]=R*q-E*te,x[4]=m*te-C*q,x[5]=C*E-m*R,x[6]=E*W-I*q,x[7]=b*q-m*W,x[8]=m*I-b*E,x}function v(x,d,m){var b=d[0],C=d[1],E=d[2],I=d[3],R=d[4],q=d[5],W=d[6],te=d[7],se=d[8],ie=m[0],de=m[1],he=m[2],Ce=m[3],Fe=m[4],Re=m[5],Ke=m[6],Xe=m[7],lt=m[8];return x[0]=ie*b+de*I+he*W,x[1]=ie*C+de*R+he*te,x[2]=ie*E+de*q+he*se,x[3]=Ce*b+Fe*I+Re*W,x[4]=Ce*C+Fe*R+Re*te,x[5]=Ce*E+Fe*q+Re*se,x[6]=Ke*b+Xe*I+lt*W,x[7]=Ke*C+Xe*R+lt*te,x[8]=Ke*E+Xe*q+lt*se,x}function _(){var x=new u(16);return u!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=0,x[12]=0,x[13]=0,x[14]=0),x[0]=1,x[5]=1,x[10]=1,x[15]=1,x}function w(x){var d=new u(16);return d[0]=x[0],d[1]=x[1],d[2]=x[2],d[3]=x[3],d[4]=x[4],d[5]=x[5],d[6]=x[6],d[7]=x[7],d[8]=x[8],d[9]=x[9],d[10]=x[10],d[11]=x[11],d[12]=x[12],d[13]=x[13],d[14]=x[14],d[15]=x[15],d}function j(x){return x[0]=1,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=1,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=1,x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function k(x,d){var m=d[0],b=d[1],C=d[2],E=d[3],I=d[4],R=d[5],q=d[6],W=d[7],te=d[8],se=d[9],ie=d[10],de=d[11],he=d[12],Ce=d[13],Fe=d[14],Re=d[15],Ke=m*R-b*I,Xe=m*q-C*I,lt=m*W-E*I,kt=b*q-C*R,vt=b*W-E*R,At=C*W-E*q,zt=te*Ce-se*he,qt=te*Fe-ie*he,ss=te*Re-de*he,Wt=se*Fe-ie*Ce,ds=se*Re-de*Ce,ks=ie*Re-de*Fe,Ss=Ke*ks-Xe*ds+lt*Wt+kt*ss-vt*qt+At*zt;return Ss?(x[0]=(R*ks-q*ds+W*Wt)*(Ss=1/Ss),x[1]=(C*ds-b*ks-E*Wt)*Ss,x[2]=(Ce*At-Fe*vt+Re*kt)*Ss,x[3]=(ie*vt-se*At-de*kt)*Ss,x[4]=(q*ss-I*ks-W*qt)*Ss,x[5]=(m*ks-C*ss+E*qt)*Ss,x[6]=(Fe*lt-he*At-Re*Xe)*Ss,x[7]=(te*At-ie*lt+de*Xe)*Ss,x[8]=(I*ds-R*ss+W*zt)*Ss,x[9]=(b*ss-m*ds-E*zt)*Ss,x[10]=(he*vt-Ce*lt+Re*Ke)*Ss,x[11]=(se*lt-te*vt-de*Ke)*Ss,x[12]=(R*qt-I*Wt-q*zt)*Ss,x[13]=(m*Wt-b*qt+C*zt)*Ss,x[14]=(Ce*Xe-he*kt-Fe*Ke)*Ss,x[15]=(te*kt-se*Xe+ie*Ke)*Ss,x):null}function S(x,d,m){var b=d[0],C=d[1],E=d[2],I=d[3],R=d[4],q=d[5],W=d[6],te=d[7],se=d[8],ie=d[9],de=d[10],he=d[11],Ce=d[12],Fe=d[13],Re=d[14],Ke=d[15],Xe=m[0],lt=m[1],kt=m[2],vt=m[3];return x[0]=Xe*b+lt*R+kt*se+vt*Ce,x[1]=Xe*C+lt*q+kt*ie+vt*Fe,x[2]=Xe*E+lt*W+kt*de+vt*Re,x[3]=Xe*I+lt*te+kt*he+vt*Ke,x[4]=(Xe=m[4])*b+(lt=m[5])*R+(kt=m[6])*se+(vt=m[7])*Ce,x[5]=Xe*C+lt*q+kt*ie+vt*Fe,x[6]=Xe*E+lt*W+kt*de+vt*Re,x[7]=Xe*I+lt*te+kt*he+vt*Ke,x[8]=(Xe=m[8])*b+(lt=m[9])*R+(kt=m[10])*se+(vt=m[11])*Ce,x[9]=Xe*C+lt*q+kt*ie+vt*Fe,x[10]=Xe*E+lt*W+kt*de+vt*Re,x[11]=Xe*I+lt*te+kt*he+vt*Ke,x[12]=(Xe=m[12])*b+(lt=m[13])*R+(kt=m[14])*se+(vt=m[15])*Ce,x[13]=Xe*C+lt*q+kt*ie+vt*Fe,x[14]=Xe*E+lt*W+kt*de+vt*Re,x[15]=Xe*I+lt*te+kt*he+vt*Ke,x}function M(x,d,m){var b,C,E,I,R,q,W,te,se,ie,de,he,Ce=m[0],Fe=m[1],Re=m[2];return d===x?(x[12]=d[0]*Ce+d[4]*Fe+d[8]*Re+d[12],x[13]=d[1]*Ce+d[5]*Fe+d[9]*Re+d[13],x[14]=d[2]*Ce+d[6]*Fe+d[10]*Re+d[14],x[15]=d[3]*Ce+d[7]*Fe+d[11]*Re+d[15]):(C=d[1],E=d[2],I=d[3],R=d[4],q=d[5],W=d[6],te=d[7],se=d[8],ie=d[9],de=d[10],he=d[11],x[0]=b=d[0],x[1]=C,x[2]=E,x[3]=I,x[4]=R,x[5]=q,x[6]=W,x[7]=te,x[8]=se,x[9]=ie,x[10]=de,x[11]=he,x[12]=b*Ce+R*Fe+se*Re+d[12],x[13]=C*Ce+q*Fe+ie*Re+d[13],x[14]=E*Ce+W*Fe+de*Re+d[14],x[15]=I*Ce+te*Fe+he*Re+d[15]),x}function L(x,d,m){var b=m[0],C=m[1],E=m[2];return x[0]=d[0]*b,x[1]=d[1]*b,x[2]=d[2]*b,x[3]=d[3]*b,x[4]=d[4]*C,x[5]=d[5]*C,x[6]=d[6]*C,x[7]=d[7]*C,x[8]=d[8]*E,x[9]=d[9]*E,x[10]=d[10]*E,x[11]=d[11]*E,x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15],x}function P(x,d,m){var b=Math.sin(m),C=Math.cos(m),E=d[4],I=d[5],R=d[6],q=d[7],W=d[8],te=d[9],se=d[10],ie=d[11];return d!==x&&(x[0]=d[0],x[1]=d[1],x[2]=d[2],x[3]=d[3],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[4]=E*C+W*b,x[5]=I*C+te*b,x[6]=R*C+se*b,x[7]=q*C+ie*b,x[8]=W*C-E*b,x[9]=te*C-I*b,x[10]=se*C-R*b,x[11]=ie*C-q*b,x}function O(x,d,m){var b=Math.sin(m),C=Math.cos(m),E=d[0],I=d[1],R=d[2],q=d[3],W=d[8],te=d[9],se=d[10],ie=d[11];return d!==x&&(x[4]=d[4],x[5]=d[5],x[6]=d[6],x[7]=d[7],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C-W*b,x[1]=I*C-te*b,x[2]=R*C-se*b,x[3]=q*C-ie*b,x[8]=E*b+W*C,x[9]=I*b+te*C,x[10]=R*b+se*C,x[11]=q*b+ie*C,x}function $(x,d,m){var b=Math.sin(m),C=Math.cos(m),E=d[0],I=d[1],R=d[2],q=d[3],W=d[4],te=d[5],se=d[6],ie=d[7];return d!==x&&(x[8]=d[8],x[9]=d[9],x[10]=d[10],x[11]=d[11],x[12]=d[12],x[13]=d[13],x[14]=d[14],x[15]=d[15]),x[0]=E*C+W*b,x[1]=I*C+te*b,x[2]=R*C+se*b,x[3]=q*C+ie*b,x[4]=W*C-E*b,x[5]=te*C-I*b,x[6]=se*C-R*b,x[7]=ie*C-q*b,x}function U(x,d){return x[0]=d[0],x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=d[1],x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=d[2],x[11]=0,x[12]=0,x[13]=0,x[14]=0,x[15]=1,x}function B(x,d,m){var b,C,E,I=m[0],R=m[1],q=m[2],W=Math.sqrt(I*I+R*R+q*q);return W0&&(E=1/Math.sqrt(E)),x[0]=d[0]*E,x[1]=d[1]*E,x[2]=d[2]*E,x}function Le(x,d){return x[0]*d[0]+x[1]*d[1]+x[2]*d[2]}function Qe(x,d,m){var b=d[0],C=d[1],E=d[2],I=m[0],R=m[1],q=m[2];return x[0]=C*q-E*R,x[1]=E*I-b*q,x[2]=b*R-C*I,x}function Te(x,d,m,b){var C=d[0],E=d[1],I=d[2];return x[0]=C+b*(m[0]-C),x[1]=E+b*(m[1]-E),x[2]=I+b*(m[2]-I),x}function pt(x,d,m){var b=d[0],C=d[1],E=d[2],I=m[3]*b+m[7]*C+m[11]*E+m[15];return x[0]=(m[0]*b+m[4]*C+m[8]*E+m[12])/(I=I||1),x[1]=(m[1]*b+m[5]*C+m[9]*E+m[13])/I,x[2]=(m[2]*b+m[6]*C+m[10]*E+m[14])/I,x}function ye(x,d,m){var b=d[0],C=d[1],E=d[2];return x[0]=b*m[0]+C*m[3]+E*m[6],x[1]=b*m[1]+C*m[4]+E*m[7],x[2]=b*m[2]+C*m[5]+E*m[8],x}function qe(x,d,m){var b=m[0],C=m[1],E=m[2],I=m[3],R=d[0],q=d[1],W=d[2],te=C*W-E*q,se=E*R-b*W,ie=b*q-C*R;return x[0]=R+I*(te+=te)+C*(ie+=ie)-E*(se+=se),x[1]=q+I*se+E*te-b*ie,x[2]=W+I*ie+b*se-C*te,x}function at(x){return x[0]=0,x[1]=0,x[2]=0,x}function tt(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]}var Ae=fe,rt=ge,He=ce;function ct(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function Ue(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x[2]=d[2]*m,x[3]=d[3]*m,x}function Ze(x,d){var m=d[0],b=d[1],C=d[2],E=d[3],I=m*m+b*b+C*C+E*E;return I>0&&(I=1/Math.sqrt(I)),x[0]=m*I,x[1]=b*I,x[2]=C*I,x[3]=E*I,x}function Je(x,d,m){var b=d[0],C=d[1],E=d[2],I=d[3];return x[0]=m[0]*b+m[4]*C+m[8]*E+m[12]*I,x[1]=m[1]*b+m[5]*C+m[9]*E+m[13]*I,x[2]=m[2]*b+m[6]*C+m[10]*E+m[14]*I,x[3]=m[3]*b+m[7]*C+m[11]*E+m[15]*I,x}function Ge(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function et(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function it(x,d,m){m*=.5;var b=d[0],C=d[1],E=d[2],I=d[3],R=Math.sin(m),q=Math.cos(m);return x[0]=b*q+I*R,x[1]=C*q+E*R,x[2]=E*q-C*R,x[3]=I*q-b*R,x}function Dt(x,d,m){m*=.5;var b=d[0],C=d[1],E=d[2],I=d[3],R=Math.sin(m),q=Math.cos(m);return x[0]=b*q-E*R,x[1]=C*q+I*R,x[2]=E*q+b*R,x[3]=I*q-C*R,x}ee(),ct();var Vt,hs,As,Ms=Ze,cs=(Vt=ee(),hs=ne(1,0,0),As=ne(0,1,0),function(x,d,m){var b=Le(d,m);return b<-.999999?(Qe(Vt,hs,d),He(Vt)<1e-6&&Qe(Vt,As,d),we(Vt,Vt),function(C,E,I){I*=.5;var R=Math.sin(I);C[0]=R*E[0],C[1]=R*E[1],C[2]=R*E[2],C[3]=Math.cos(I)}(x,Vt,Math.PI),x):b>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(Qe(Vt,d,m),x[0]=Vt[0],x[1]=Vt[1],x[2]=Vt[2],x[3]=1+b,Ms(x,x))});function er(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function xt(x,d){var m=new u(2);return m[0]=x,m[1]=d,m}function Ps(x,d,m){return x[0]=d,x[1]=m,x}function mr(x,d,m){return x[0]=d[0]+m[0],x[1]=d[1]+m[1],x}function Tr(x,d,m){return x[0]=d[0]-m[0],x[1]=d[1]-m[1],x}function Dr(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x}function xn(x){var d=x[0],m=x[1];return Math.sqrt(d*d+m*m)}function Si(x,d){var m=d[0],b=d[1],C=m*m+b*b;return C>0&&(C=1/Math.sqrt(C)),x[0]=d[0]*C,x[1]=d[1]*C,x}function Ia(x,d){return x[0]*d[0]+x[1]*d[1]}Ge(),Ge(),f();var ur,Jr,Gr=Tr;function mn(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}er();var Yr=function(){if(Jr)return ur;function x(d,m,b,C){this.cx=3*d,this.bx=3*(b-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(C-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=m,this.p2x=b,this.p2y=C}return Jr=1,ur=x,x.prototype={sampleCurveX:function(d){return((this.ax*d+this.bx)*d+this.cx)*d},sampleCurveY:function(d){return((this.ay*d+this.by)*d+this.cy)*d},sampleCurveDerivativeX:function(d){return(3*this.ax*d+2*this.bx)*d+this.cx},solveCurveX:function(d,m){if(m===void 0&&(m=1e-6),d<0)return 0;if(d>1)return 1;for(var b=d,C=0;C<8;C++){var E=this.sampleCurveX(b)-d;if(Math.abs(E)E?R=b:q=b,b=.5*(q-R)+R;return b},solve:function(d,m){return this.sampleCurveY(this.solveCurveX(d,m))}},ur}(),bi=mn(Yr);function ft(x,d){this.x=x,this.y=d}function or(x,d){if(Array.isArray(x)){if(!Array.isArray(d)||x.length!==d.length)return!1;for(let m=0;m=1)return 1;const d=x*x,m=d*x;return 4*(x<.5?m:3*(x-d)+m-.75)}function Fo(x,d,m,b){const C=new bi(x,d,m,b);return function(E){return C.solve(E)}}const $t=Fo(.25,.1,.25,1);function Se(x,d,m){return Math.min(m,Math.max(d,x))}function Be(x,d,m){return(m=Se((m-x)/(d-x),0,1))*m*(3-2*m)}function Ye(x,d,m){const b=m-d,C=((x-d)%b+b)%b+d;return C===d?m:C}function bt(x,d,m){if(!x.length)return m(null,[]);let b=x.length;const C=new Array(x.length);let E=null;x.forEach((I,R)=>{d(I,(q,W)=>{q&&(E=q),C[R]=W,--b==0&&m(E,C)})})}let gt=1;function Ft(){return gt++}function Zt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Ut(x,d){x.forEach(m=>{d[m]&&(d[m]=d[m].bind(d))})}function Qt(x,d,m){const b={};for(const C in x)b[C]=d.call(this,x[C],C,x);return b}function Is(x,d,m){const b={};for(const C in x)d.call(this,x[C],C,x)&&(b[C]=x[C]);return b}function ys(x){return Array.isArray(x)?x.map(ys):typeof x=="object"&&x?Qt(x,ys):x}function vr(x,d){for(let m=0;m=0)return!0;return!1}const Hr={};function xr(x){Hr[x]||(typeof console<"u"&&console.warn(x),Hr[x]=!0)}function On(x,d,m){return(m.y-x.y)*(d.x-x.x)>(d.y-x.y)*(m.x-x.x)}function Rn(x){let d=0;for(let m,b,C=0,E=x.length,I=E-1;C@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,b,C,E)=>{const I=C||E;return d[b]=!I||I.toLowerCase(),""}),d["max-age"]){const m=parseInt(d["max-age"],10);isNaN(m)?delete d["max-age"]:d["max-age"]=m}return d}let cl=null;function ni(x,d){return[x[4*d],x[4*d+1],x[4*d+2],x[4*d+3]]}function pl(x,d,m,b){for(;d>1;x[C]>1;x[C]<=b?d=C+1:m=C}return d}function Da(x){return x>0?1/(1.001-x):1+x}function uo(x){return x>0?1-1/(1.001-x):-x}function Ai(x,d,m){return(x-d.min)*(m.max-m.min)/(d.max-d.min)+m.min}const ha={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!ha.API_URL)return null;try{const x=new URL(ha.API_URL);return x.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":x.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function ho(x){return ha.API_URL_REGEX.test(x)}function Tc(x){return ha.API_SPRITE_REGEX.test(x)}let Wc,cu,Rf,ql,uh,Sd;function Km(){return Wc==null&&(Wc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Wc}const Ul={now:()=>ql!==void 0?ql:performance.now(),setNow(x){ql=x},restoreNow(){ql=void 0},frame(x){const d=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(x,d=0){const{width:m,height:b}=x;uh||(uh=document.createElement("canvas"));const C=uh.getContext("2d",{willReadFrequently:!0});if(!C)throw new Error("failed to create canvas 2d context");return(m>uh.width||b>uh.height)&&(uh.width=m,uh.height=b),C.clearRect(-d,-d,m+2*d,b+2*d),C.drawImage(x,0,0,m,b),C.getImageData(-d,-d,m+2*d,b+2*d)},resolveURL:x=>(cu||(cu=document.createElement("a")),cu.href=x,cu.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Rf==null&&(Rf=window.matchMedia("(prefers-reduced-motion: reduce)")),Rf.matches)},hasCanvasFingerprintNoise(){if(Sd!==void 0)return Sd;if(!Km())return Sd=!1,!1;const x=new OffscreenCanvas(85,1),d=x.getContext("2d",{willReadFrequently:!0});let m=0;for(let C=0;C0?`?${E}`:""}`}const Q1="mapbox-tiles";let X1=500,J1=50;const Dp=["language","worldview","jobid"];let im,du;function om(){try{return caches}catch{}}function $d(){const x=om();x&&im==null&&(im=x.open(Q1))}let Cd=1/0;const uu={supported:!1,testSupport:function(x){!Zm&&zf&&(Ym?J0(x):Ff=x)}};let Ff,zf,Zm=!1,Ym=!1;const Md=typeof self<"u"?self:{};function J0(x){const d=x.createTexture();x.bindTexture(x.TEXTURE_2D,d);try{if(x.texImage2D(x.TEXTURE_2D,0,x.RGBA,x.RGBA,x.UNSIGNED_BYTE,zf),x.isContextLost())return;uu.supported=!0}catch{}x.deleteTexture(d),Zm=!0}Md.document&&(zf=Md.document.createElement("img"),zf.onload=function(){Ff&&J0(Ff),Ff=null,Ym=!0},zf.onerror=function(){Zm=!0,Ff=null},zf.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Jx={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};typeof Object.freeze=="function"&&Object.freeze(Jx);class Pl extends Error{constructor(d,m,b){m===401&&ho(b)&&(d+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(d),this.status=m,this.url=b}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const eb=wa()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,eg=function(x,d){if(!(/^file:/.test(m=x.url)||/^file:/.test(eb())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(b,C){const E=new AbortController,I=new Request(b.url,{method:b.method||"GET",body:b.body,credentials:b.credentials,headers:b.headers,referrer:eb(),referrerPolicy:b.referrerPolicy,signal:E.signal});let R=!1,q=!1;const W=(te=I.url).indexOf("sku=")>0&&ho(te);var te;b.type==="json"&&I.headers.set("Accept","application/json");const se=(de,he,Ce)=>{if(q)return;if(de&&de.message!=="SecurityError"&&xr(de.toString()),he&&Ce)return ie(he);const Fe=Date.now();fetch(I).then(Re=>{if(Re.ok){const Ke=W?Re.clone():null;return ie(Re,Ke,Fe)}return C(new Pl(Re.statusText,Re.status,b.url))}).catch(Re=>{Re.name!=="AbortError"&&C(new Error(`${Re.message} ${b.url}`))})},ie=(de,he,Ce)=>{(b.type==="arrayBuffer"?de.arrayBuffer():b.type==="json"?de.json():de.text()).then(Fe=>{q||(he&&Ce&&function(Re,Ke,Xe){if($d(),im==null)return;const lt=_o(Ke.headers.get("Cache-Control")||"");if(lt["no-store"])return;const kt={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((zt,qt)=>kt.headers.set(qt,zt)),lt["max-age"]&&kt.headers.set("Expires",new Date(Xe+1e3*lt["max-age"]).toUTCString());const vt=kt.headers.get("Expires");if(!vt||new Date(vt).getTime()-Xe<42e4)return;let At=by(Re.url,{persistentParams:Dp});if(Ke.status===206){const zt=Re.headers.get("Range");if(!zt)return;kt.status=200,At=Xx(At,{range:zt})}(function(zt,qt){if(du===void 0)try{new Response(new ReadableStream),du=!0}catch{du=!1}du?qt(zt.body):zt.blob().then(qt).catch(ss=>xr(ss.message))})(Ke,zt=>{const qt=new Response((ss=Ke.status)!==200&&ss!==404&&[101,103,204,205,304].includes(ss)?null:zt,kt);var ss;$d(),im!=null&&im.then(Wt=>Wt.put(At,qt)).catch(Wt=>xr(Wt.message))})}(I,he,Ce),R=!0,C(null,Fe,de.headers))}).catch(Fe=>{q||C(new Error(Fe.message))})};return W?function(de,he){if($d(),im==null)return he(null);im.then(Ce=>{let Fe=by(de.url,{persistentParams:Dp});const Re=de.headers.get("Range");Re&&(Fe=Xx(Fe,{range:Re})),Ce.match(Fe).then(Ke=>{const Xe=function(lt){if(!lt)return!1;const kt=new Date(lt.headers.get("Expires")||0),vt=_o(lt.headers.get("Cache-Control")||"");return Number(kt)>Date.now()&&!vt["no-cache"]}(Ke);Ce.delete(Fe).catch(he),Xe&&Ce.put(Fe,Ke.clone()).catch(he),he(null,Ke,Xe)}).catch(he)}).catch(he)}(I,se):se(null,null),{cancel:()=>{q=!0,R||E.abort()}}}(x,d);if(wa(self)&&self.worker.actor)return self.worker.actor.send("getResource",x,d,void 0,!0)}var m;return function(b,C){const E=new XMLHttpRequest;E.open(b.method||"GET",b.url,!0),b.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const I in b.headers)E.setRequestHeader(I,b.headers[I]);return b.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=b.credentials==="include",E.onerror=()=>{C(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let I=E.response;if(b.type==="json")try{I=JSON.parse(E.response)}catch(q){return C(q)}const R=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(q=>{const W=q.split(": "),te=W.shift(),se=W.join(": ");R.append(te,se)}),C(null,I,R)}else C(new Pl(E.statusText,E.status,b.url))},E.send(b.body),{cancel:()=>E.abort()}}(x,d)},Oh=function(x,d){return eg(Object.assign(x,{type:"arrayBuffer"}),d)};function Qw(x){const d=document.createElement("a");return d.href=x,d.protocol===location.protocol&&d.host===location.host}const z3="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ev,Oa;ev=[],Oa=0;const _y=function(x,d){if(uu.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),Oa>=ha.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:x,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return ev.push(E),E}Oa++;let m=!1;const b=()=>{if(!m)for(m=!0,Oa--;ev.length&&Oa{b(),E?d(E):I&&(self.createImageBitmap?function(q,W){const te=new Blob([new Uint8Array(q)],{type:"image/png"});createImageBitmap(te).then(se=>{W(null,se)}).catch(se=>{W(new Error(`Could not load image because of ${se.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(I,(q,W)=>d(q,W,R)):function(q,W){const te=new Image;te.onload=()=>{W(null,te),URL.revokeObjectURL(te.src),te.onload=null,requestAnimationFrame(()=>{te.src=z3})},te.onerror=()=>W(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const se=new Blob([new Uint8Array(q)],{type:"image/png"});te.src=q.byteLength?URL.createObjectURL(se):z3}(I,(q,W)=>d(q,W,R)))});return{cancel:()=>{C.cancel(),b()}}};var Xw,B3,$3,lm={exports:{}},tv={exports:{}},sv={exports:{}},Jw=function(){if($3)return lm.exports;$3=1;var x=(Xw||(Xw=1,tv.exports=function(m,b){var C,E,I,R,q,W,te,se;for(E=m.length-(C=3&m.length),I=b,q=3432918353,W=461845907,se=0;se>>16)*q&65535)<<16)&4294967295)<<15|te>>>17))*W+(((te>>>16)*W&65535)<<16)&4294967295)<<13|I>>>19))+((5*(I>>>16)&65535)<<16)&4294967295))+((58964+(R>>>16)&65535)<<16);switch(te=0,C){case 3:te^=(255&m.charCodeAt(se+2))<<16;case 2:te^=(255&m.charCodeAt(se+1))<<8;case 1:I^=te=(65535&(te=(te=(65535&(te^=255&m.charCodeAt(se)))*q+(((te>>>16)*q&65535)<<16)&4294967295)<<15|te>>>17))*W+(((te>>>16)*W&65535)<<16)&4294967295}return I^=m.length,I=2246822507*(65535&(I^=I>>>16))+((2246822507*(I>>>16)&65535)<<16)&4294967295,I=3266489909*(65535&(I^=I>>>13))+((3266489909*(I>>>16)&65535)<<16)&4294967295,(I^=I>>>16)>>>0}),tv.exports),d=(B3||(B3=1,sv.exports=function(m,b){for(var C,E=m.length,I=b^E,R=0;E>=4;)C=1540483477*(65535&(C=255&m.charCodeAt(R)|(255&m.charCodeAt(++R))<<8|(255&m.charCodeAt(++R))<<16|(255&m.charCodeAt(++R))<<24))+((1540483477*(C>>>16)&65535)<<16),I=1540483477*(65535&I)+((1540483477*(I>>>16)&65535)<<16)^(C=1540483477*(65535&(C^=C>>>24))+((1540483477*(C>>>16)&65535)<<16)),E-=4,++R;switch(E){case 3:I^=(255&m.charCodeAt(R+2))<<16;case 2:I^=(255&m.charCodeAt(R+1))<<8;case 1:I=1540483477*(65535&(I^=255&m.charCodeAt(R)))+((1540483477*(I>>>16)&65535)<<16)}return I=1540483477*(65535&(I^=I>>>13))+((1540483477*(I>>>16)&65535)<<16),(I^=I>>>15)>>>0}),sv.exports);return lm.exports=x,lm.exports.murmur3=x,lm.exports.murmur2=d,lm.exports}(),tb=mn(Jw);class Qm{constructor(d,...m){Object.assign(this,m[0]||{}),this.type=d}}class wy extends Qm{constructor(d,m={}){super("error",Object.assign({error:d},m))}}function e2(x,d,m){m[x]&&m[x].indexOf(d)!==-1||(m[x]=m[x]||[],m[x].push(d))}function wt(x,d,m){if(m&&m[x]){const b=m[x].indexOf(d);b!==-1&&m[x].splice(b,1)}}class Es{on(d,m){return this._listeners=this._listeners||{},e2(d,m,this._listeners),this}off(d,m){return wt(d,m,this._listeners),wt(d,m,this._oneTimeListeners),this}once(d,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},e2(d,m,this._oneTimeListeners),this):new Promise(b=>{this.once(d,b)})}fire(d,m){const b=typeof d=="string"?new Qm(d,m):d,C=b.type;if(this.listens(C)){b.target=this;const E=this._listeners&&this._listeners[C]?this._listeners[C].slice():[];for(const q of E)q.call(this,b);const I=this._oneTimeListeners&&this._oneTimeListeners[C]?this._oneTimeListeners[C].slice():[];for(const q of I)wt(C,q,this._oneTimeListeners),q.call(this,b);const R=this._eventedParent;if(R){const q=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(b,q),R.fire(b)}}else b instanceof wy&&console.error(b.error);return this}listens(d){return!!(this._listeners&&this._listeners[d]&&this._listeners[d].length>0||this._oneTimeListeners&&this._oneTimeListeners[d]&&this._oneTimeListeners[d].length>0||this._eventedParent&&this._eventedParent.listens(d))}setEventedParent(d,m){return this._eventedParent=d,this._eventedParentData=m,this}}class Xs{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Xs(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[m,b]=d.split("");return new Xs({name:m,iconsetId:b})}static isEqual(d,m){return d.name===m.name&&d.iconsetId===m.iconsetId}toString(){return Xs.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var gn,yn={},ua=function(){if(gn)return yn;gn=1;var x={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(E){return(E=Math.round(E))<0?0:E>255?255:E}function m(E){return d(E[E.length-1]==="%"?parseFloat(E)/100*255:parseInt(E))}function b(E){return(I=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:I>1?1:I;var I}function C(E,I,R){return R<0?R+=1:R>1&&(R-=1),6*R<1?E+(I-E)*R*6:2*R<1?I:3*R<2?E+(I-E)*(2/3-R)*6:E}try{yn.parseCSSColor=function(E){var I,R=E.replace(/ /g,"").toLowerCase();if(R in x)return x[R].slice();if(R[0]==="#")return R.length===4?(I=parseInt(R.substr(1),16))>=0&&I<=4095?[(3840&I)>>4|(3840&I)>>8,240&I|(240&I)>>4,15&I|(15&I)<<4,1]:null:R.length===7&&(I=parseInt(R.substr(1),16))>=0&&I<=16777215?[(16711680&I)>>16,(65280&I)>>8,255&I,1]:null;var q=R.indexOf("("),W=R.indexOf(")");if(q!==-1&&W+1===R.length){var te=R.substr(0,q),se=R.substr(q+1,W-(q+1)).split(","),ie=1;switch(te){case"rgba":if(se.length!==4)return null;ie=b(se.pop());case"rgb":return se.length!==3?null:[m(se[0]),m(se[1]),m(se[2]),ie];case"hsla":if(se.length!==4)return null;ie=b(se.pop());case"hsl":if(se.length!==3)return null;var de=(parseFloat(se[0])%360+360)%360/360,he=b(se[1]),Ce=b(se[2]),Fe=Ce<=.5?Ce*(he+1):Ce+he-Ce*he,Re=2*Ce-Fe;return[d(255*C(Re,Fe,de+1/3)),d(255*C(Re,Fe,de)),d(255*C(Re,Fe,de-1/3)),ie];default:return null}}return null}}catch{}return yn}();class Ur{constructor(d,m,b,C=1){this.r=d,this.g=m,this.b=b,this.a=C}static parse(d){if(!d)return;if(d instanceof Ur)return d;if(typeof d!="string")return;const m=ua.parseCSSColor(d);return m?new Ur(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[d,m,b,C]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*m)},${Math.round(255*b)},${C})`}toNonPremultipliedRenderColor(d){const{r:m,g:b,b:C,a:E}=this;return new tg(d,m,b,C,E)}toPremultipliedRenderColor(d){const{r:m,g:b,b:C,a:E}=this;return new Op(d,m*E,b*E,C*E,E)}clone(){return new Ur(this.r,this.g,this.b,this.a)}}class mo{constructor(d,m,b,C,E,I=!1){if(this.premultiplied=!1,this.premultiplied=I,d){const R=d.image.height,q=R*R;this.premultiplied?(m=E===0?0:m/E*(R-1),b=E===0?0:b/E*(R-1),C=E===0?0:C/E*(R-1)):(m*=R-1,b*=R-1,C*=R-1);const W=Math.floor(m),te=Math.floor(b),se=Math.floor(C),ie=Math.ceil(m),de=Math.ceil(b),he=Math.ceil(C),Ce=m-W,Fe=b-te,Re=C-se,Ke=d.image.data,Xe=4*(W+te*q+se*R),lt=4*(W+te*q+he*R),kt=4*(W+de*q+se*R),vt=4*(W+de*q+he*R),At=4*(ie+te*q+se*R),zt=4*(ie+te*q+he*R),qt=4*(ie+de*q+se*R),ss=4*(ie+de*q+he*R);if(Xe<0||ss>=Ke.length)throw new Error("out of range");this.r=Zr(Zr(Zr(Ke[Xe],Ke[lt],Re),Zr(Ke[kt],Ke[vt],Re),Fe),Zr(Zr(Ke[At],Ke[zt],Re),Zr(Ke[qt],Ke[ss],Re),Fe),Ce)/255*(this.premultiplied?E:1),this.g=Zr(Zr(Zr(Ke[Xe+1],Ke[lt+1],Re),Zr(Ke[kt+1],Ke[vt+1],Re),Fe),Zr(Zr(Ke[At+1],Ke[zt+1],Re),Zr(Ke[qt+1],Ke[ss+1],Re),Fe),Ce)/255*(this.premultiplied?E:1),this.b=Zr(Zr(Zr(Ke[Xe+2],Ke[lt+2],Re),Zr(Ke[kt+2],Ke[vt+2],Re),Fe),Zr(Zr(Ke[At+2],Ke[zt+2],Re),Zr(Ke[qt+2],Ke[ss+2],Re),Fe),Ce)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=b,this.b=C,this.a=E}toArray(){const{r:d,g:m,b,a:C}=this;return[255*d,255*m,255*b,C]}toHslaArray(){let{r:d,g:m,b,a:C}=this;if(this.premultiplied){if(C===0)return[0,0,0,0];const he=1/C;d*=he,m*=he,b*=he}const E=Math.min(Math.max(d,0),1),I=Math.min(Math.max(m,0),1),R=Math.min(Math.max(b,0),1),q=Math.min(E,I,R),W=Math.max(E,I,R),te=W-q,se=.5*(q+W);if(te===0)return[0,0,100*se,C];const ie=se>.5?te/(2-W-q):te/(W+q);let de;switch(W){case E:de=60*((I-R)/te+(IZr(b,d[C],m))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var nv=Object.freeze({__proto__:null,array:rv,color:function(x,d,m){return new Ur(Zr(x.r,d.r,m),Zr(x.g,d.g,m),Zr(x.b,d.b,m),Zr(x.a,d.a,m))},number:Zr});class Xm extends Error{constructor(d,m){super(m),this.message=m,this.key=d}}class sb{constructor(d,m=[]){this.parent=d,this.bindings={};for(const[b,C]of m)this.bindings[b]=C}concat(d){return new sb(this,d)}get(d){if(this.bindings[d])return this.bindings[d];if(this.parent)return this.parent.get(d);throw new Error(`${d} not found in scope.`)}has(d){return!!this.bindings[d]||!!this.parent&&this.parent.has(d)}}const Rp={kind:"null"},$r={kind:"number"},Ra={kind:"string"},Ci={kind:"boolean"},hh={kind:"color"},Bf={kind:"object"},fi={kind:"value"},q3={kind:"collator"},t2={kind:"formatted"},s2={kind:"resolvedImage"};function qd(x,d){return{kind:"array",itemType:x,N:d}}function jl(x){if(x.kind==="array"){const d=jl(x.itemType);return typeof x.N=="number"?`array<${d}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${d}>`}return x.kind}const Ome=[Rp,$r,Ra,Ci,hh,t2,Bf,qd(fi),s2];function jy(x,d){if(d.kind==="error")return null;if(x.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!jy(x.itemType,d.itemType))&&(typeof x.N!="number"||x.N===d.N))return null}else{if(x.kind===d.kind)return null;if(x.kind==="value"){for(const m of Ome)if(!jy(m,d))return null}}return`Expected ${jl(x)} but found ${jl(d)} instead.`}function YE(x,d){return d.some(m=>m.kind===x.kind)}function r2(x,d){return d.some(m=>m==="null"?x===null:m==="array"?Array.isArray(x):m==="object"?x&&!Array.isArray(x)&&typeof x=="object":m===typeof x)}function U3(x,d){return x.kind==="array"&&d.kind==="array"?x.N===d.N&&U3(x.itemType,d.itemType):x.kind===d.kind}class QE{constructor(d,m,b){this.sensitivity=d?m?"variant":"case":m?"accent":"base",this.locale=b,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(d,m){return this.collator.compare(d,m)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class V3{constructor(d,m,b,C,E){this.text=d.normalize?d.normalize():d,this.image=m,this.scale=b,this.fontStack=C,this.textColor=E}}class Ru{constructor(d){this.sections=d}static fromString(d){return new Ru([new V3(d,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(d=>d.text.length!==0||!!d.image&&d.image.hasPrimary())}static factory(d){return d instanceof Ru?d:Ru.fromString(d)}toString(){return this.sections.length===0?"":this.sections.map(d=>d.text).join("")}serialize(){const d=["format"];for(const m of this.sections){if(m.image){const C=m.image.getPrimary().id.toString();d.push(["image",C]);continue}d.push(m.text);const b={};m.fontStack&&(b["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(b["font-scale"]=m.scale),m.textColor&&(b["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),d.push(b)}return d}}class sg{constructor(d,m={}){this.id=Xs.from(d),this.params=m.params,this.sx=m.sx||1,this.sy=m.sy||1}toString(){return JSON.stringify(this)}static parse(d){let m,b,C,E;try{({id:m,params:b,sx:C,sy:E}=JSON.parse(d)||{})}catch{return null}return m?new sg(m,{params:b,sx:C,sy:E}):null}scaleSelf(d,m=d){return this.sx*=d,this.sy*=m,this}}class Fu{constructor(d,m,b,C,E=!1){this.primaryId=Xs.from(d),this.primaryOptions=m,b&&(this.secondaryId=Xs.from(b)),this.secondaryOptions=C,this.available=E}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new sg(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new sg(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Fu.build({name:d}):d}static build(d,m,b,C){return!d||typeof d=="object"&&!("name"in d)?null:new Fu(d,b,m,C)}}function av(x,d,m,b){return typeof x=="number"&&x>=0&&x<=255&&typeof d=="number"&&d>=0&&d<=255&&typeof m=="number"&&m>=0&&m<=255?b===void 0||typeof b=="number"&&b>=0&&b<=1?null:`Invalid rgba value [${[x,d,m,b].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof b=="number"?[x,d,m,b]:[x,d,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function rb(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof Ur||x instanceof QE||x instanceof Ru||x instanceof Fu)return!0;if(Array.isArray(x)){for(const d of x)if(!rb(d))return!1;return!0}if(typeof x=="object"){for(const d in x)if(!rb(x[d]))return!1;return!0}return!1}function Ac(x){if(x===null)return Rp;if(typeof x=="string")return Ra;if(typeof x=="boolean")return Ci;if(typeof x=="number")return $r;if(x instanceof Ur)return hh;if(x instanceof QE)return q3;if(x instanceof Ru)return t2;if(x instanceof Fu)return s2;if(Array.isArray(x)){const d=x.length;let m;for(const b of x){const C=Ac(b);if(m){if(m===C)continue;m=fi;break}m=C}return qd(m||fi,d)}return Bf}function Jm(x){const d=typeof x;return x===null?"":d==="string"||d==="number"||d==="boolean"?String(x):x instanceof Ru||x instanceof Fu||x instanceof Ur?x.toString():JSON.stringify(x)}class rg{constructor(d,m){this.type=d,this.value=m}static parse(d,m){if(d.length!==2)return m.error(`'literal' expression requires exactly one argument, but found ${d.length-1} instead.`);if(!rb(d[1]))return m.error("invalid value");const b=d[1];let C=Ac(b);const E=m.expectedType;return C.kind!=="array"||C.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(C=E),new rg(C,b)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Ru?this.value.serialize():this.value}}class mc{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const XE={string:Ra,number:$r,boolean:Ci,object:Bf};class Fp{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");let b,C=1;const E=d[0];if(E==="array"){let R,q;if(d.length>2){const W=d[1];if(typeof W!="string"||!(W in XE)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);R=XE[W],C++}else R=fi;if(d.length>3){if(d[2]!==null&&(typeof d[2]!="number"||d[2]<0||d[2]!==Math.floor(d[2])))return m.error('The length argument to "array" must be a positive integer literal',2);q=d[2],C++}b=qd(R,q)}else b=XE[E];const I=[];for(;Cd.outputDefined())}serialize(){const d=this.type,m=[d.kind];if(d.kind==="array"){const b=d.itemType;if(b.kind==="string"||b.kind==="number"||b.kind==="boolean"){m.push(b.kind);const C=d.N;(typeof C=="number"||this.args.length>1)&&m.push(C)}}return m.concat(this.args.map(b=>b.serialize()))}}class $f{constructor(d){this.type=t2,this.sections=d}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const b=d[1];if(!Array.isArray(b)&&typeof b=="object")return m.error("First argument must be an image or text section.");const C=[];let E=!1;for(let I=1;I<=d.length-1;++I){const R=d[I];if(E&&typeof R=="object"&&!Array.isArray(R)){E=!1;let q=null;if(R["font-scale"]&&(q=m.parseObjectValue(R["font-scale"],I,"font-scale",$r),!q))return null;let W=null;if(R["text-font"]&&(W=m.parseObjectValue(R["text-font"],I,"text-font",qd(Ra)),!W))return null;let te=null;if(R["text-color"]&&(te=m.parseObjectValue(R["text-color"],I,"text-color",hh),!te))return null;const se=C[C.length-1];se.scale=q,se.font=W,se.textColor=te}else{const q=m.parse(d[I],I,fi);if(!q)return null;const W=q.type.kind;if(W!=="string"&&W!=="value"&&W!=="null"&&W!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,C.push({content:q,scale:null,font:null,textColor:null})}}return new $f(C)}evaluate(d){return new Ru(this.sections.map(m=>{const b=m.content.evaluate(d);return U3(Ac(b),s2)?new V3("",b,null,null,null):new V3(Jm(b),null,m.scale?m.scale.evaluate(d):null,m.font?m.font.evaluate(d).join(","):null,m.textColor?m.textColor.evaluate(d):null)}))}eachChild(d){for(const m of this.sections)d(m.content),m.scale&&d(m.scale),m.font&&d(m.font),m.textColor&&d(m.textColor)}outputDefined(){return!1}serialize(){const d=["format"];for(const m of this.sections){d.push(m.content.serialize());const b={};m.scale&&(b["font-scale"]=m.scale.serialize()),m.font&&(b["text-font"]=m.font.serialize()),m.textColor&&(b["text-color"]=m.textColor.serialize()),d.push(b)}return d}}class Hn{constructor(d,m,b,C){this._imageWarnHistory={},this.type=s2,this.namePrimary=d,this.nameSecondary=m,b&&(this.paramsPrimary=b.params,this.iconsetIdPrimary=b.iconset?b.iconset.id:void 0),C&&(this.paramsSecondary=C.params,this.iconsetIdSecondary=C.iconset?C.iconset.id:void 0)}static parse(d,m){if(d.length<2)return m.error("Expected two or more arguments.");let b=1;const C=[];function E(){if(bXs.isEqual(I,E)),C.available){const I=C.getSecondary()?C.getSecondary().id:null;I&&(C.available=d.availableImages.some(R=>Xs.isEqual(R,I)))}}return C}eachChild(d){if(d(this.namePrimary),this.paramsPrimary)for(const m in this.paramsPrimary)this.paramsPrimary[m]&&d(this.paramsPrimary[m]);if(this.nameSecondary&&(d(this.nameSecondary),this.paramsSecondary))for(const m in this.paramsSecondary)this.paramsSecondary[m]&&d(this.paramsSecondary[m])}outputDefined(){return!1}serializeOptions(d,m){const b={};if(m&&(b.iconset={id:m}),d){b.params={};for(const C in d)d[C]&&(b.params[C]=d[C].serialize())}return Object.keys(b).length>0?b:void 0}serialize(){const d=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const m=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);m&&d.push(m)}if(this.nameSecondary&&(d.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const m=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);m&&d.push(m)}return d}}function Fr(x){return vn(x)?"string":nb(x)?"number":G3(x)?"boolean":Array.isArray(x)?"array":x===null?"null":H3(x)?"object":typeof x}function H3(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function vn(x){return typeof x=="string"||x instanceof String}function nb(x){return typeof x=="number"||x instanceof Number}function G3(x){return typeof x=="boolean"||x instanceof Boolean}const pn={"to-boolean":Ci,"to-color":hh,"to-number":$r,"to-string":Ra};class qf{constructor(d,m){this.type=d,this.args=m}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const b=d[0],C=[];let E=Rp;if(b==="to-array"){if(!Array.isArray(d[1]))return null;const I=d[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=qd(m.expectedType.itemType,I)}else{if(!(I>0&&rb(d[1][0])))return null;E=qd(Ac(d[1][0]),I)}for(let R=0;R4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:av(m[0],m[1],m[2],m[3]),!b))return new Ur(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new mc(b||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const b of this.args){if(m=b.evaluate(d),m===null)return 0;const C=Number(m);if(!isNaN(C))return C}throw new mc(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Ru.fromString(Jm(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Fu.build(Jm(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(m=>m.evaluate(d)):Jm(this.args[0].evaluate(d))}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){if(this.type.kind==="formatted")return new $f([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Hn(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{d.push(m.serialize())}),d}}const JE=["Unknown","Point","LineString","Polygon"];class W3{constructor(d,m,b){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=d,this.options=m,this.iconImageUseTheme=b}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?JE[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(d){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const d=this.featureDistanceData.center,m=this.featureDistanceData.scale,{x:b,y:C}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(b*m-d[0])+this.featureDistanceData.bearing[1]*(C*m-d[1])}return 0}parseColor(d){let m=this._parseColorCache[d];return m||(m=this._parseColorCache[d]=Ur.parse(d)),m}getConfig(d){return this.options?this.options.get(d):null}}class zu{constructor(d,m,b,C,E){this.name=d,this.type=m,this._evaluate=b,this.args=C,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const m=zu.definitions[this.name];this._evaluate=Array.isArray(m)?m[2]:m.overloads[this._overloadIndex][1]}return this._evaluate(d,this.args)}eachChild(d){this.args.forEach(d)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(d=>d.serialize()))}static parse(d,m){const b=d[0],C=zu.definitions[b];if(!C)return m.error(`Unknown expression "${b}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(C)?C[0]:C.type,I=Array.isArray(C)?[[C[1],C[2]]]:C.overloads,R=[];let q=null,W=-1;for(const[te,se]of I){if(Array.isArray(te)&&te.length!==d.length-1)continue;R.push(te),W++,q=new aC(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ie=[];let de=!1;for(let he=1;heie)).map(K3).join(" | "),se=[];for(let ie=1;iem;){if(b-m>600){const q=b-m+1,W=d-m+1,te=Math.log(q),se=.5*Math.exp(2*te/3),ie=.5*Math.sqrt(te*se*(q-se)/q)*(W-q/2<0?-1:1);Z3(x,d,Math.max(m,Math.floor(d-W*se/q+ie)),Math.min(b,Math.floor(d+(q-W)*se/q+ie)),C)}const E=x[d];let I=m,R=b;for(zp(x,m,d),C(x[b],E)>0&&zp(x,m,b);I0;)R--}C(x[m],E)===0?zp(x,m,R):(R++,zp(x,R,b)),R<=d&&(m=R+1),d<=R&&(b=R-1)}}function zp(x,d,m){const b=x[d];x[d]=x[m],x[m]=b}function e6(x,d){return xd?1:0}function Ny(x){let d=0;for(let m,b,C=0,E=x.length,I=E-1;C=d[2]||x[1]<=d[1]||x[3]>=d[3])}function Rme(x,d,m){const b=x[0]-d[0],C=x[1]-d[1],E=x[0]-m[0],I=x[1]-m[1];return b*I-E*C==0&&b*E<=0&&C*I<=0}function ab(x,d,m=!1){let b=!1;for(let R=0,q=d.length;R(C=x)[1]!=(I=he)[1]>C[1]&&C[0]<(I[0]-E[0])*(C[1]-E[1])/(I[1]-E[1])+E[0]&&(b=!b)}}var C,E,I;return b}function a2(x,d,m,b){const C=b[0]-m[0],E=b[1]-m[1],I=(x[0]-m[0])*E-C*(x[1]-m[1]),R=(d[0]-m[0])*E-C*(d[1]-m[1]);return I>0&&R<0||I<0&&R>0}function i2(x,d,m,b){return(C=[b[0]-m[0],b[1]-m[1]])[0]*(E=[d[0]-x[0],d[1]-x[1]])[1]-C[1]*E[0]!=0&&!(!a2(x,d,m,b)||!a2(m,b,x,d));var C,E}function ng(x){const d=new ft(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new ft(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const b of x[0])d.x>b.x&&(d.x=b.x),d.y>b.y&&(d.y=b.y),m.xm[2]){const C=.5*b;let E=x[0]-m[0]>C?-b:m[0]-x[0]>C?b:0;E===0&&(E=x[0]-m[2]>C?-b:m[2]-x[0]>C?b:0),x[0]+=E}ep(d,x)}function UR(x,d,m,b){const C=Math.pow(2,b.z)*ky,E=[b.x*ky,b.y*ky],I=[];if(!x)return I;for(const R of x)for(const q of R){const W=[q.x+E[0],q.y+E[1]];qR(W,d,m,C),I.push(W)}return I}function Y3(x,d,m,b){const C=Math.pow(2,b.z)*ky,E=[b.x*ky,b.y*ky],I=[];if(!x)return I;for(const q of x){const W=[];for(const te of q){const se=[te.x+E[0],te.y+E[1]];ep(d,se),W.push(se)}I.push(W)}if(d[2]-d[0]<=C/2){(R=d)[0]=R[1]=1/0,R[2]=R[3]=-1/0;for(const q of I)for(const W of q)qR(W,d,m,C)}var R;return I}class Cy{constructor(d,m){this.type=Ci,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'within' expression requires exactly one argument, but found ${d.length-1} instead.`);if(rb(d[1])){const b=d[1];if(b.type==="FeatureCollection")for(let C=0;Cm)return Q3(E,I,(m-(b-R))/R)}return d[d.length-1]}pointToSegmentDistance(d,m,b){let[C,E]=m,I=cm(b[0]-C)*this.kx,R=(b[1]-E)*this.ky;if(I!==0||R!==0){const q=(cm(d[0]-C)*this.kx*I+(d[1]-E)*this.ky*R)/(I*I+R*R);q>1?(C=b[0],E=b[1]):q>0&&(C+=I/this.kx*q,E+=R/this.ky*q)}return I=cm(d[0]-C)*this.kx,R=(d[1]-E)*this.ky,Math.sqrt(I*I+R*R)}pointOnLine(d,m){let b=1/0,C=d[0][0],E=d[0][1],I=0,R=0;for(let q=0;q1?(W=d[q+1][0],te=d[q+1][1]):de>0&&(W+=se/this.kx*de,te+=ie/this.ky*de)),se=cm(m[0]-W)*this.kx,ie=(m[1]-te)*this.ky;const he=se*se+ie*ie;heE.index||C.index===E.index&&C.t>E.t){const W=C;C=E,E=W}const I=[C.point],R=C.index+1,q=E.index;!r6(b[R],I[0])&&R<=q&&I.push(b[R]);for(let W=R+1;W<=q;W++)I.push(b[W]);return r6(b[q],E.point)||I.push(E.point),I}lineSliceAlong(d,m,b){let C=0;const E=[];for(let I=0;Id&&E.length===0&&E.push(Q3(R,q,(d-(C-W))/W)),C>=m)return E.push(Q3(R,q,(m-(C-W))/W)),E;C>d&&E.push(q)}return E}bufferPoint(d,m){const b=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-b,d[0]+C,d[1]+b]}bufferBBox(d,m){const b=m/this.ky,C=m/this.kx;return[d[0]-C,d[1]-b,d[2]+C,d[3]+b]}insideBBox(d,m){return cm(d[0]-m[0])>=0&&cm(d[0]-m[2])<=0&&d[1]>=m[1]&&d[1]<=m[3]}}function r6(x,d){return x[0]===d[0]&&x[1]===d[1]}function Q3(x,d,m){const b=cm(d[0]-x[0]);return[x[0]+b*m,x[1]+(d[1]-x[1])*m]}function cm(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class X3{constructor(d=[],m=(b,C)=>bC?1:0){if(this.data=d,this.length=this.data.length,this.compare=m,this.length>0)for(let b=(this.length>>1)-1;b>=0;b--)this._down(b)}push(d){this.data.push(d),this._up(this.length++)}pop(){if(this.length===0)return;const d=this.data[0],m=this.data.pop();return--this.length>0&&(this.data[0]=m,this._down(0)),d}peek(){return this.data[0]}_up(d){const{data:m,compare:b}=this,C=m[d];for(;d>0;){const E=d-1>>1,I=m[E];if(b(C,I)>=0)break;m[d]=I,d=E}m[d]=C}_down(d){const{data:m,compare:b}=this,C=this.length>>1,E=m[d];for(;d=0)break;m[d]=m[I],d=I}m[d]=E}}var tr=8192;function n6(x,d){return d.dist-x.dist}const J3=100,eC=50;function a6(x){const d=[1/0,1/0,-1/0,-1/0];if(d.length!==x.length)return!1;for(let m=0;m=x[0]&&x[1]x[1])return[null,null];const m=l2(x);if(d){if(m===2)return[x,null];const b=Math.floor(m/2);return[[x[0],x[0]+b],[x[0]+b,x[1]]]}{if(m===1)return[x,null];const b=Math.floor(m/2)-1;return[[x[0],x[0]+b],[x[0]+b+1,x[1]]]}}function iv(x,d){const m=[1/0,1/0,-1/0,-1/0];if(!Uf(d,x.length))return m;for(let b=d[0];b<=d[1];++b)ep(m,x[b]);return m}function ov(x){const d=[1/0,1/0,-1/0,-1/0];for(let m=0;md[2]&&(b=x[0]-d[2]),x[1]>d[3]&&(C=x[1]-d[3]),x[3]=b)return b;if(n2(C,E)){if(l6(x,d))return 0}else if(l6(d,x))return 0;let I=b;for(const R of x)for(let q=0,W=R.length,te=W-1;q=E)continue;const te=W.range1;if(l2(te)<=R){if(!Uf(te,x.length))return NaN;if(d){const se=Ume(x,te,m,b);if((E=Math.min(E,se))===0)return E}else for(let se=te[0];se<=te[1];++se){const ie=qme(x[se],m,b);if((E=Math.min(E,ie))===0)return E}}else{const se=i6(te,d);if(se[0]!==null){const ie=My(iv(x,se[0]),q,b);ie=I)continue;const se=te.range1,ie=te.range2;if(l2(se)<=q&&l2(ie)<=W){if(!Uf(se,x.length)||!Uf(ie,m.length))return NaN;if(d&&b?I=Math.min(I,Ba(x,se,m,ie,C)):d||b?d&&!b?I=Math.min(I,o6(m,ie,x,se,C)):!d&&b&&(I=Math.min(I,o6(x,se,m,ie,C))):I=Math.min(I,$me(x,se,m,ie,C)),I===0)return I}else{const de=i6(se,d),he=i6(ie,b);po(R,I,C,x,m,de[0],he[0]),po(R,I,C,x,m,de[0],he[1]),po(R,I,C,x,m,de[1],he[0]),po(R,I,C,x,m,de[1],he[1])}}return I}function c6(x,d,m,b,C=1/0){let E=C;const I=iv(x,[0,x.length-1]);for(const R of m)if(!(E!==1/0&&My(I,iv(R,[0,R.length-1]),b)>=E)&&(E=Math.min(E,WR(x,d,R,!0,b,E)),E===0))return E;return E}function rC(x,d,m,b,C=1/0){let E=C;const I=iv(x,[0,x.length-1]);for(const R of m){if(E!==1/0&&My(I,ov(R),b)>=E)continue;const q=Hme(x,d,R,b,E);if(isNaN(q))return q;if((E=Math.min(E,q))===0)return E}return E}function d6(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class lv{constructor(d,m){this.type=$r,this.geojson=d,this.geometries=m}static parse(d,m){if(d.length!==2)return m.error(`'distance' expression requires either one argument, but found ' ${d.length-1} instead.`);if(rb(d[1])){const b=d[1];if(b.type==="FeatureCollection"){for(let C=0;C{d&&!lb(m)&&(d=!1)}),d}function c2(x){if(x instanceof zu&&x.name==="feature-state")return!1;let d=!0;return x.eachChild(m=>{d&&!c2(m)&&(d=!1)}),d}function cb(x,d){if(x instanceof zu&&d.indexOf(x.name)>=0)return!1;let m=!0;return x.eachChild(b=>{m&&!cb(b,d)&&(m=!1)}),m}function KR(x,d,m){return[x,d,m].filter(Boolean).join("")}function u6(x,d){switch(x){case"string":return Jm(d);case"number":return+d;case"boolean":return!!d;case"color":return Ur.parse(d);case"formatted":return Ru.fromString(Jm(d));case"resolvedImage":return Fu.build(Jm(d))}return d}function ZR(x,d,m,b){return b!==void 0&&(x=b*Math.round(x/b)),d!==void 0&&xm&&(x=m),x}class db{constructor(d,m,b,C=!1){this.type=d,this.key=m,this.scope=b,this.featureConstant=C}static parse(d,m){let b=m.expectedType;if(b==null&&(b=fi),d.length<2||d.length>3)return m.error("Invalid number of arguments for 'config' expression.");const C=m.parse(d[1],1);if(!(C instanceof rg))return m.error("Key name of 'config' expression must be a string literal.");let E,I=!0;const R=Jm(C.value);if(d.length>=3){const q=m.parse(d[2],2);if(!(q instanceof rg))return m.error("Scope of 'config' expression must be a string literal.");E=Jm(q.value)}if(m.options){const q=KR(R,E,m._scope),W=m.options.get(q);W&&(I=lb(W.value||W.default))}return new db(b,R,E,I)}evaluate(d){const m=KR(this.key,this.scope,d.scope),b=d.getConfig(m);if(!b)return null;const{type:C,value:E,values:I,minValue:R,maxValue:q,stepValue:W}=b,te=b.default.evaluate(d);let se=te;if(E){const ie=d.scope;d.scope=(ie||"").split("").slice(1).join(""),se=E.evaluate(d),d.scope=ie}return C&&(se=u6(C,se)),se===void 0||R===void 0&&q===void 0&&W===void 0||(typeof se=="number"?se=ZR(se,R,q,W):Array.isArray(se)&&(se=se.map(ie=>typeof ie=="number"?ZR(ie,R,q,W):ie))),E!==void 0&&se!==void 0&&I&&!I.includes(se)&&(se=te,C&&(se=u6(C,se))),(C&&C!==this.type||se!==void 0&&!U3(Ac(se),this.type))&&(se=u6(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class nC{constructor(d,m){this.type=m.type,this.name=d,this.boundExpression=m}static parse(d,m){if(d.length!==2||typeof d[1]!="string")return m.error("'var' expression requires exactly one string literal argument.");const b=d[1];return m.scope.has(b)?new nC(b,m.scope.get(b)):m.error(`Unknown variable "${b}". Make sure "${b}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(d){return this.boundExpression.evaluate(d)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class aC{constructor(d,m=[],b,C=new sb,E=[],I,R,q){this.registry=d,this.path=m,this.key=m.map(W=>typeof W=="string"?`['${W}']`:`[${W}]`).join(""),this.scope=C,this.errors=E,this.expectedType=b,this._scope=I,this.options=R,this.iconImageUseTheme=q}parse(d,m,b,C,E={}){return m||b?this.concat(m,null,b,C)._parse(d,E):this._parse(d,E)}parseObjectValue(d,m,b,C,E,I={}){return this.concat(m,b,C,E)._parse(d,I)}_parse(d,m){function b(C,E,I){return I==="assert"?new Fp(E,[C]):I==="coerce"?new qf(E,[C]):C}if(d!==null&&typeof d!="string"&&typeof d!="boolean"&&typeof d!="number"||(d=["literal",d]),Array.isArray(d)){if(d.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const C=typeof d[0]=="string"?this.registry[d[0]]:void 0;if(C){let E=C.parse(d,this);if(!E)return null;if(this.expectedType){const I=this.expectedType,R=E.type;if(I.kind!=="string"&&I.kind!=="number"&&I.kind!=="boolean"&&I.kind!=="object"&&I.kind!=="array"||R.kind!=="value")if(I.kind!=="color"&&I.kind!=="formatted"&&I.kind!=="resolvedImage"||R.kind!=="value"&&R.kind!=="string"){if(this.checkSubtype(I,R))return null}else E=b(E,I,m.typeAnnotation||"coerce");else E=b(E,I,m.typeAnnotation||"assert")}if(!(E instanceof rg)&&E.type.kind!=="resolvedImage"&&h6(E)){const I=new W3(this._scope,this.options,this.iconImageUseTheme);try{E=new rg(E.type,E.evaluate(I))}catch(R){return this.error(R.message),null}}return E}return qf.parse(["to-array",d],this)}return this.error(d===void 0?"'undefined' value invalid. Use null instead.":typeof d=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof d} instead.`)}concat(d,m,b,C){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof m=="string"?E.concat(m):E;const I=C?this.scope.concat(C):this.scope;return new aC(this.registry,E,b||null,I,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...m){const b=`${this.key}${m.map(C=>`[${C}]`).join("")}`;this.errors.push(new Xm(b,d))}checkSubtype(d,m){const b=jy(d,m);return b&&this.error(b),b}}function h6(x){if(x instanceof nC)return h6(x.boundExpression);if(x instanceof zu&&x.name==="error"||x instanceof Kc||x instanceof Cy||x instanceof lv||x instanceof db)return!1;const d=x instanceof qf||x instanceof Fp;let m=!0;return x.eachChild(b=>{m=d?m&&h6(b):m&&b instanceof rg}),!!m&&lb(x)&&cb(x,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function iC(x,d){const m=x.length-1;let b,C,E=0,I=m,R=0;for(;E<=I;)if(R=Math.floor((E+I)/2),b=x[R],C=x[R+1],b<=d){if(R===m||dd))throw new mc("Input is not a number.");I=R-1}return 0}class d2{constructor(d,m,b){this.type=d,this.input=m,this.labels=[],this.outputs=[];for(const[C,E]of b)this.labels.push(C),this.outputs.push(E)}static parse(d,m){if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if((d.length-1)%2!=0)return m.error("Expected an even number of arguments.");const b=m.parse(d[1],1,$r);if(!b)return null;const C=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let I=1;I=R)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',W);const se=m.parse(q,te,E);if(!se)return null;E=E||se.type,C.push([R,se])}return new d2(E,b,C)}evaluate(d){const m=this.labels,b=this.outputs;if(m.length===1)return b[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return b[0].evaluate(d);const E=m.length;return C>=m[E-1]?b[E-1].evaluate(d):b[iC(m,C)].evaluate(d)}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){const d=["step",this.input.serialize()];for(let m=0;m0&&d.push(this.labels[m]),d.push(this.outputs[m].serialize());return d}}const YR=.95047,QR=1.08883,XR=4/29,ub=6/29,JR=3*ub*ub,Gme=ub*ub*ub,Wme=Math.PI/180,Kme=180/Math.PI;function m6(x){return x>Gme?Math.pow(x,1/3):x/JR+XR}function p6(x){return x>ub?x*x*x:JR*(x-XR)}function f6(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function x6(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function eF(x){const d=x6(x.r),m=x6(x.g),b=x6(x.b),C=m6((.4124564*d+.3575761*m+.1804375*b)/YR),E=m6((.2126729*d+.7151522*m+.072175*b)/1);return{l:116*E-16,a:500*(C-E),b:200*(E-m6((.0193339*d+.119192*m+.9503041*b)/QR)),alpha:x.a}}function oC(x){let d=(x.l+16)/116,m=isNaN(x.a)?d:d+x.a/500,b=isNaN(x.b)?d:d-x.b/200;return d=1*p6(d),m=YR*p6(m),b=QR*p6(b),new Ur(f6(3.2404542*m-1.5371385*d-.4985314*b),f6(-.969266*m+1.8760108*d+.041556*b),f6(.0556434*m-.2040259*d+1.0572252*b),x.alpha)}function lC(x,d,m){const b=d-x;return x+m*(b>180||b<-180?b-360*Math.round(b/360):b)}const hb={forward:eF,reverse:oC,interpolate:function(x,d,m){return{l:Zr(x.l,d.l,m),a:Zr(x.a,d.a,m),b:Zr(x.b,d.b,m),alpha:Zr(x.alpha,d.alpha,m)}}},u2={forward:function(x){const{l:d,a:m,b}=eF(x),C=Math.atan2(b,m)*Kme;return{h:C<0?C+360:C,c:Math.sqrt(m*m+b*b),l:d,alpha:x.a}},reverse:function(x){const d=x.h*Wme,m=x.c;return oC({l:x.l,a:Math.cos(d)*m,b:Math.sin(d)*m,alpha:x.alpha})},interpolate:function(x,d,m){return{h:lC(x.h,d.h,m),c:Zr(x.c,d.c,m),l:Zr(x.l,d.l,m),alpha:Zr(x.alpha,d.alpha,m)}}};var tF=Object.freeze({__proto__:null,hcl:u2,lab:hb});class dm{constructor(d,m,b,C,E){this.type=d,this.operator=m,this.interpolation=b,this.input=C,this.labels=[],this.outputs=[];for(const[I,R]of E)this.labels.push(I),this.outputs.push(R)}static interpolationFactor(d,m,b,C){let E=0;if(d.name==="exponential")E=cC(m,d.base,b,C);else if(d.name==="linear")E=cC(m,1,b,C);else if(d.name==="cubic-bezier"){const I=d.controlPoints;E=new bi(I[0],I[1],I[2],I[3]).solve(cC(m,1,b,C))}return E}static parse(d,m){let[b,C,E,...I]=d;if(!Array.isArray(C)||C.length===0)return m.error("Expected an interpolation type expression.",1);if(C[0]==="linear")C={name:"linear"};else if(C[0]==="exponential"){const W=C[1];if(typeof W!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);C={name:"exponential",base:W}}else{if(C[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(C[0])}`,1,0);{const W=C.slice(1);if(W.length!==4||W.some(te=>typeof te!="number"||te<0||te>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);C={name:"cubic-bezier",controlPoints:W}}}if(d.length-1<4)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length-1>3&&(d.length-1)%2!=0)return m.error("Expected an even number of arguments.");if(E=m.parse(E,2,$r),!E)return null;const R=[];let q=null;b==="interpolate-hcl"||b==="interpolate-lab"?q=hh:m.expectedType&&m.expectedType.kind!=="value"&&(q=m.expectedType);for(let W=0;W=te)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ie);const he=m.parse(se,de,q);if(!he)return null;q=q||he.type,R.push([te,he])}return q.kind==="number"||q.kind==="color"||q.kind==="array"&&q.itemType.kind==="number"&&typeof q.N=="number"?new dm(q,b,C,E,R):m.error(`Type ${jl(q)} is not interpolatable.`)}evaluate(d){const m=this.labels,b=this.outputs;if(m.length===1)return b[0].evaluate(d);const C=this.input.evaluate(d);if(C<=m[0])return b[0].evaluate(d);const E=m.length;if(C>=m[E-1])return b[E-1].evaluate(d);const I=iC(m,C),R=dm.interpolationFactor(this.interpolation,C,m[I],m[I+1]),q=b[I].evaluate(d),W=b[I+1].evaluate(d);return this.operator==="interpolate"?nv[this.type.kind.toLowerCase()](q,W,R):this.operator==="interpolate-hcl"?u2.reverse(u2.interpolate(u2.forward(q),u2.forward(W),R)):hb.reverse(hb.interpolate(hb.forward(q),hb.forward(W),R))}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){let d;d=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const m=[this.operator,d,this.input.serialize()];for(let b=0;bjy(C,R.type));return new h2(I?fi:b,E)}evaluate(d){let m,b=null,C=0;for(const E of this.args){if(C++,b=E.evaluate(d),b&&b instanceof Fu&&!b.available&&(m||(m=b),b=null,C===this.args.length))return m;if(b!==null)break}return b}eachChild(d){this.args.forEach(d)}outputDefined(){return this.args.every(d=>d.outputDefined())}serialize(){const d=["coalesce"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class ag{constructor(d,m){this.type=m.type,this.bindings=[].concat(d),this.result=m}evaluate(d){return this.result.evaluate(d)}eachChild(d){for(const m of this.bindings)d(m[1]);d(this.result)}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found ${d.length-1} instead.`);const b=[];for(let E=1;E=b.length)throw new mc("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new mc("Array index must be an integer. Use at-interpolated for fractional indices");return b[m]}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class uC{constructor(d,m,b){this.type=d,this.index=m,this.input=b}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=m.parse(d[1],1,$r),C=m.parse(d[2],2,qd(m.expectedType||fi));return b&&C?new uC(C.type.itemType,b,C):null}evaluate(d){const m=this.index.evaluate(d),b=this.input.evaluate(d);if(m<0)throw new mc(`Array index out of bounds: ${m} < 0.`);if(m>b.length-1)throw new mc(`Array index out of bounds: ${m} > ${b.length-1}.`);if(m===Math.floor(m))return b[m];const C=Math.floor(m),E=Math.ceil(m),I=b[C],R=b[E];if(typeof I!="number"||typeof R!="number")throw new mc(`Cannot interpolate between non-number values at index ${m}.`);const q=m-C;return I*(1-q)+R*q}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class g6{constructor(d,m){this.type=Ci,this.needle=d,this.haystack=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=m.parse(d[1],1,fi),C=m.parse(d[2],2,fi);return b&&C?YE(b.type,[Ci,Ra,$r,Rp,fi])?new g6(b,C):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${jl(b.type)} instead`):null}evaluate(d){const m=this.needle.evaluate(d),b=this.haystack.evaluate(d);if(b==null)return!1;if(!r2(m,["boolean","string","number","null"]))throw new mc(`Expected first argument to be of type boolean, string, number or null, but found ${jl(Ac(m))} instead.`);if(!r2(b,["string","array"]))throw new mc(`Expected second argument to be of type array or string, but found ${jl(Ac(b))} instead.`);return b.indexOf(m)>=0}eachChild(d){d(this.needle),d(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class mb{constructor(d,m,b){this.type=$r,this.needle=d,this.haystack=m,this.fromIndex=b}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const b=m.parse(d[1],1,fi),C=m.parse(d[2],2,fi);if(!b||!C)return null;if(!YE(b.type,[Ci,Ra,$r,Rp,fi]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${jl(b.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new mb(b,C,E):null}return new mb(b,C)}evaluate(d){const m=this.needle.evaluate(d),b=this.haystack.evaluate(d);if(!r2(m,["boolean","string","number","null"]))throw new mc(`Expected first argument to be of type boolean, string, number or null, but found ${jl(Ac(m))} instead.`);if(!r2(b,["string","array"]))throw new mc(`Expected second argument to be of type array or string, but found ${jl(Ac(b))} instead.`);if(this.fromIndex){const C=this.fromIndex.evaluate(d);return b.indexOf(m,C)}return b.indexOf(m)}eachChild(d){d(this.needle),d(this.haystack),this.fromIndex&&d(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const d=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),d]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class m2{constructor(d,m,b,C,E,I){this.inputType=d,this.type=m,this.input=b,this.cases=C,this.outputs=E,this.otherwise=I}static parse(d,m){if(d.length<5)return m.error(`Expected at least 4 arguments, but found only ${d.length-1}.`);if(d.length%2!=1)return m.error("Expected an even number of arguments.");let b,C;m.expectedType&&m.expectedType.kind!=="value"&&(C=m.expectedType);const E={},I=[];for(let W=2;WNumber.MAX_SAFE_INTEGER)return ie.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof he=="number"&&Math.floor(he)!==he)return ie.error("Numeric branch labels must be integer values.");if(b){if(ie.checkSubtype(b,Ac(he)))return null}else b=Ac(he);if(E[String(he)]!==void 0)return ie.error("Branch labels must be unique.");E[String(he)]=I.length}const de=m.parse(se,W,C);if(!de)return null;C=C||de.type,I.push(de)}const R=m.parse(d[1],1,fi);if(!R)return null;const q=m.parse(d[d.length-1],d.length-1,C);return q?R.type.kind!=="value"&&m.concat(1).checkSubtype(b,R.type)?null:new m2(b,C,R,E,I,q):null}evaluate(d){const m=this.input.evaluate(d);return(U3(Ac(m),this.inputType)&&this.outputs[this.cases[m]]||this.otherwise).evaluate(d)}eachChild(d){d(this.input),this.outputs.forEach(d),d(this.otherwise)}outputDefined(){return this.outputs.every(d=>d.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["match",this.input.serialize()],m=Object.keys(this.cases).sort(),b=[],C={};for(const I of m){const R=C[this.cases[I]];R===void 0?(C[this.cases[I]]=b.length,b.push([this.cases[I],[I]])):b[R][1].push(I)}const E=I=>this.inputType.kind==="number"?Number(I):I;for(const[I,R]of b)d.push(R.length===1?E(R[0]):R.map(E)),d.push(this.outputs[I].serialize());return d.push(this.otherwise.serialize()),d}}class p2{constructor(d,m,b){this.type=d,this.branches=m,this.otherwise=b}static parse(d,m){if(d.length<4)return m.error(`Expected at least 3 arguments, but found only ${d.length-1}.`);if(d.length%2!=0)return m.error("Expected an odd number of arguments.");let b;m.expectedType&&m.expectedType.kind!=="value"&&(b=m.expectedType);const C=[];for(let I=1;Im.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class hC{constructor(d,m,b,C){this.type=d,this.input=m,this.beginIndex=b,this.endIndex=C}static parse(d,m){if(d.length<=2||d.length>=5)return m.error(`Expected 3 or 4 arguments, but found ${d.length-1} instead.`);const b=m.parse(d[1],1,fi),C=m.parse(d[2],2,$r);if(!b||!C)return null;if(!YE(b.type,[qd(fi),Ra,fi]))return m.error(`Expected first argument to be of type array or string, but found ${jl(b.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,$r);return E?new hC(b.type,b,C,E):null}return new hC(b.type,b,C)}evaluate(d){const m=this.input.evaluate(d),b=this.beginIndex.evaluate(d);if(!r2(m,["string","array"]))throw new mc(`Expected first argument to be of type array or string, but found ${jl(Ac(m))} instead.`);if(this.endIndex){const C=this.endIndex.evaluate(d);return m.slice(b,C)}return m.slice(b)}eachChild(d){d(this.input),d(this.beginIndex),this.endIndex&&d(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const d=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),d]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class y6{constructor(d,m){this.type=qd(Ra),this.str=d,this.delimiter=m}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const b=m.parse(d[1],1,Ra),C=m.parse(d[2],2,Ra);return b&&C?new y6(b,C):void 0}evaluate(d){const m=this.str.evaluate(d),b=this.delimiter.evaluate(d);return m.split(b)}eachChild(d){d(this.str),d(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function v6(x,d){return x==="=="||x==="!="?d.kind==="boolean"||d.kind==="string"||d.kind==="number"||d.kind==="null"||d.kind==="value":d.kind==="string"||d.kind==="number"||d.kind==="value"}function b6(x,d,m,b){return b.compare(d,m)===0}function pb(x,d,m){const b=x!=="=="&&x!=="!=";return class PGe{constructor(E,I,R){this.type=Ci,this.lhs=E,this.rhs=I,this.collator=R,this.hasUntypedArgument=E.type.kind==="value"||I.type.kind==="value"}static parse(E,I){if(E.length!==3&&E.length!==4)return I.error("Expected two or three arguments.");const R=E[0];let q=I.parse(E[1],1,fi);if(!q)return null;if(!v6(R,q.type))return I.concat(1).error(`"${R}" comparisons are not supported for type '${jl(q.type)}'.`);let W=I.parse(E[2],2,fi);if(!W)return null;if(!v6(R,W.type))return I.concat(2).error(`"${R}" comparisons are not supported for type '${jl(W.type)}'.`);if(q.type.kind!==W.type.kind&&q.type.kind!=="value"&&W.type.kind!=="value")return I.error(`Cannot compare types '${jl(q.type)}' and '${jl(W.type)}'.`);b&&(q.type.kind==="value"&&W.type.kind!=="value"?q=new Fp(W.type,[q]):q.type.kind!=="value"&&W.type.kind==="value"&&(W=new Fp(q.type,[W])));let te=null;if(E.length===4){if(q.type.kind!=="string"&&W.type.kind!=="string"&&q.type.kind!=="value"&&W.type.kind!=="value")return I.error("Cannot use collator to compare non-string types.");if(te=I.parse(E[3],3,q3),!te)return null}return new PGe(q,W,te)}evaluate(E){const I=this.lhs.evaluate(E),R=this.rhs.evaluate(E);if(b&&this.hasUntypedArgument){const q=Ac(I),W=Ac(R);if(q.kind!==W.kind||q.kind!=="string"&&q.kind!=="number")throw new mc(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${q.kind}, ${W.kind}) instead.`)}if(this.collator&&!b&&this.hasUntypedArgument){const q=Ac(I),W=Ac(R);if(q.kind!=="string"||W.kind!=="string")return d(E,I,R)}return this.collator?m(E,I,R,this.collator.evaluate(E)):d(E,I,R)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[x];return this.eachChild(I=>{E.push(I.serialize())}),E}}}const Zme=pb("==",function(x,d,m){return d===m},b6),Yme=pb("!=",function(x,d,m){return d!==m},function(x,d,m,b){return!b6(0,d,m,b)}),sF=pb("<",function(x,d,m){return d",function(x,d,m){return d>m},function(x,d,m,b){return b.compare(d,m)>0}),mC=pb("<=",function(x,d,m){return d<=m},function(x,d,m,b){return b.compare(d,m)<=0}),Qme=pb(">=",function(x,d,m){return d>=m},function(x,d,m,b){return b.compare(d,m)>=0});class pC{constructor(d,m,b,C,E,I){this.type=Ra,this.number=d,this.locale=m,this.currency=b,this.unit=C,this.minFractionDigits=E,this.maxFractionDigits=I}static parse(d,m){if(d.length!==3)return m.error("Expected two arguments.");const b=m.parse(d[1],1,$r);if(!b)return null;const C=d[2];if(typeof C!="object"||Array.isArray(C))return m.error("NumberFormat options argument must be an object.");let E=null;if(C.locale&&(E=m.parseObjectValue(C.locale,2,"locale",Ra),!E))return null;let I=null;if(C.currency&&(I=m.parseObjectValue(C.currency,2,"currency",Ra),!I))return null;let R=null;if(C.unit&&(R=m.parseObjectValue(C.unit,2,"unit",Ra),!R))return null;let q=null;if(C["min-fraction-digits"]&&(q=m.parseObjectValue(C["min-fraction-digits"],2,"min-fraction-digits",$r),!q))return null;let W=null;return C["max-fraction-digits"]&&(W=m.parseObjectValue(C["max-fraction-digits"],2,"max-fraction-digits",$r),!W)?null:new pC(b,E,I,R,q,W)}evaluate(d){return new Intl.NumberFormat(this.locale?this.locale.evaluate(d):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(d):void 0,unit:this.unit?this.unit.evaluate(d):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(d):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(d):void 0}).format(this.number.evaluate(d))}eachChild(d){d(this.number),this.locale&&d(this.locale),this.currency&&d(this.currency),this.unit&&d(this.unit),this.minFractionDigits&&d(this.minFractionDigits),this.maxFractionDigits&&d(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const d={};return this.locale&&(d.locale=this.locale.serialize()),this.currency&&(d.currency=this.currency.serialize()),this.unit&&(d.unit=this.unit.serialize()),this.minFractionDigits&&(d["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(d["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),d]}}class _6{constructor(d){this.type=$r,this.input=d}static parse(d,m){if(d.length!==2)return m.error(`Expected 1 argument, but found ${d.length-1} instead.`);const b=m.parse(d[1],1);return b?b.type.kind!=="array"&&b.type.kind!=="string"&&b.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${jl(b.type)} instead.`):new _6(b):null}evaluate(d){const m=this.input.evaluate(d);if(typeof m=="string"||Array.isArray(m))return m.length;throw new mc(`Expected value to be of type string or array, but found ${jl(Ac(m))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(m=>{d.push(m.serialize())}),d}}function nF(x){return function(){x=1831565813+(x|=0)|0;let d=Math.imul(x^x>>>15,1|x);return d=d+Math.imul(d^d>>>7,61|d)^d,((d^d>>>14)>>>0)/4294967296}}const fb={"==":Zme,"!=":Yme,">":rF,"<":sF,">=":Qme,"<=":mC,array:Fp,at:dC,"at-interpolated":uC,boolean:Fp,case:p2,coalesce:h2,collator:Kc,format:$f,image:Hn,in:g6,"index-of":mb,interpolate:dm,"interpolate-hcl":dm,"interpolate-lab":dm,length:_6,let:ag,literal:rg,match:m2,number:Fp,"number-format":pC,object:Fp,slice:hC,step:d2,string:Fp,"to-boolean":qf,"to-color":qf,"to-number":qf,"to-string":qf,var:nC,within:Cy,distance:lv,config:db,split:y6};function w6(x,[d,m,b,C]){d=d.evaluate(x),m=m.evaluate(x),b=b.evaluate(x);const E=C?C.evaluate(x):1,I=av(d,m,b,E);if(I)throw new mc(I);return new Ur(d/255,m/255,b/255,E)}function j6(x,[d,m,b,C]){d=d.evaluate(x),m=m.evaluate(x),b=b.evaluate(x);const E=C?C.evaluate(x):1,I=function(W,te,se,ie){return typeof W=="number"&&W>=0&&W<=360?typeof te=="number"&&te>=0&&te<=100&&typeof se=="number"&&se>=0&&se<=100?ie===void 0||typeof ie=="number"&&ie>=0&&ie<=1?null:`Invalid hsla value [${[W,te,se,ie].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ie=="number"?[W,te,se,ie]:[W,te,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ie=="number"?[W,te,se,ie]:[W,te,se]).join(", ")}]: 'h' must be between 0 and 360.`}(d,m,b,E);if(I)throw new mc(I);const R=`hsla(${d}, ${m}%, ${b}%, ${E})`,q=Ur.parse(R);if(!q)throw new mc(`Failed to parse HSLA color: ${R}`);return q}function aF(x,d){return x in d}function N6(x,d){const m=d[x];return m===void 0?null:m}function Ay(x){return{type:x}}function cv(x){if(x instanceof db)return new Set([x.key]);let d=new Set;return x.eachChild(m=>{d=new Set([...d,...cv(m)])}),d}function fC(x){if(x instanceof zu&&x.name==="is-active-floor")return!0;let d=!1;return x.eachChild(m=>{!d&&fC(m)&&(d=!0)}),d}function iF(x){return{result:"success",value:x}}function Ey(x){return{result:"error",value:x}}function k6(x,d){return!!x&&!!x.parameters&&x.parameters.indexOf(d)>-1}function f2(x){return x["property-type"]==="data-driven"}function oF(x){return k6(x.expression,"measure-light")}function lF(x){return k6(x.expression,"zoom")}function xC(x){return!!x.expression&&x.expression.interpolated}function gC(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function cF(x){return x}function dF(x,d){const m=d.type==="color",b=x.stops&&typeof x.stops[0][0]=="object",C=b||!(b||x.property!==void 0),E=x.type||(xC(d)?"exponential":"interval");if(m&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(W=>[W[0],Ur.parse(W[1])])),x.default=Ur.parse(x.default?x.default:d.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!tF[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let I,R,q;if(E==="exponential")I=uF;else if(E==="interval")I=Jme;else if(E==="categorical"){I=Xme,R=Object.create(null);for(const W of x.stops)R[W[0]]=W[1];q=typeof x.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);I=hF}if(b){const W={},te=[];for(let de=0;dede[0]),evaluate:({zoom:de},he)=>uF({stops:se,base:x.base},d,de).evaluate(de,he)}}if(C){const W=E==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:dm.interpolationFactor.bind(void 0,W),zoomStops:x.stops.map(te=>te[0]),evaluate:({zoom:te})=>I(x,d,te,R,q)}}return{kind:"source",evaluate(W,te){const se=te&&te.properties?te.properties[x.property]:void 0;return se===void 0?Vf(x.default,d.default):I(x,d,se,R,q)}}}function Vf(x,d,m){return x!==void 0?x:d!==void 0?d:m!==void 0?m:void 0}function Xme(x,d,m,b,C){return Vf(typeof m===C?b[m]:void 0,x.default,d.default)}function Jme(x,d,m){if(!nb(m))return Vf(x.default,d.default);const b=x.stops.length;if(b===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[b-1][0])return x.stops[b-1][1];const C=iC(x.stops.map(E=>E[0]),m);return x.stops[C][1]}function uF(x,d,m){const b=x.base!==void 0?x.base:1;if(!nb(m))return Vf(x.default,d.default);const C=x.stops.length;if(C===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[C-1][0])return x.stops[C-1][1];const E=iC(x.stops.map(te=>te[0]),m),I=function(te,se,ie,de){const he=de-ie,Ce=te-ie;return he===0?0:se===1?Ce/he:(Math.pow(se,Ce)-1)/(Math.pow(se,he)-1)}(m,b,x.stops[E][0],x.stops[E+1][0]),R=x.stops[E][1],q=x.stops[E+1][1];let W=nv[d.type]||cF;if(x.colorSpace&&x.colorSpace!=="rgb"){const te=tF[x.colorSpace];W=(se,ie)=>te.reverse(te.interpolate(te.forward(se),te.forward(ie),I))}return typeof R.evaluate=="function"?{evaluate(...te){const se=R.evaluate.apply(void 0,te),ie=q.evaluate.apply(void 0,te);if(se!==void 0&&ie!==void 0)return W(se,ie,I)}}:W(R,q,I)}function hF(x,d,m){return d.type==="color"?m=Ur.parse(m):d.type==="formatted"?m=Ru.fromString(m.toString()):d.type==="resolvedImage"?m=Fu.build(m.toString()):Fr(m)===d.type||d.type==="enum"&&d.values[m]||(m=void 0),Vf(m,x.default,d.default)}zu.register(fb,{error:[{kind:"error"},[Ra],(x,[d])=>{throw new mc(d.evaluate(x))}],typeof:[Ra,[fi],(x,[d])=>jl(Ac(d.evaluate(x)))],"to-rgba":[qd($r,4),[hh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[qd($r,4),[hh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[hh,[$r,$r,$r],w6],rgba:[hh,[$r,$r,$r,$r],w6],hsl:[hh,[$r,$r,$r],j6],hsla:[hh,[$r,$r,$r,$r],j6],has:{type:Ci,overloads:[[[Ra],(x,[d])=>aF(d.evaluate(x),x.properties())],[[Ra,Bf],(x,[d,m])=>aF(d.evaluate(x),m.evaluate(x))]]},get:{type:fi,overloads:[[[Ra],(x,[d])=>N6(d.evaluate(x),x.properties())],[[Ra,Bf],(x,[d,m])=>N6(d.evaluate(x),m.evaluate(x))]]},"feature-state":[fi,[Ra],(x,[d])=>N6(d.evaluate(x),x.featureState||{})],properties:[Bf,[],x=>x.properties()],"geometry-type":[Ra,[],x=>x.geometryType()],worldview:[Ra,[],x=>x.globals.worldview||""],"is-active-floor":[Ci,Ay(Ra),(x,d)=>{if(!(x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;const m=x.globals.activeFloors;return d.some(b=>{const C=b.evaluate(x);return m.has(C)})}],id:[fi,[],x=>x.id()],zoom:[$r,[],x=>x.globals.zoom],pitch:[$r,[],x=>x.globals.pitch||0],"distance-from-center":[$r,[],x=>x.distanceFromCenter()],"measure-light":[$r,[Ra],(x,[d])=>x.measureLight(d.evaluate(x))],"heatmap-density":[$r,[],x=>x.globals.heatmapDensity||0],"line-progress":[$r,[],x=>x.globals.lineProgress||0],"raster-value":[$r,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[$r,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[$r,[],x=>x.globals.skyRadialProgress||0],accumulated:[fi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[$r,Ay($r),(x,d)=>{let m=0;for(const b of d)m+=b.evaluate(x);return m}],"*":[$r,Ay($r),(x,d)=>{let m=1;for(const b of d)m*=b.evaluate(x);return m}],"-":{type:$r,overloads:[[[$r,$r],(x,[d,m])=>d.evaluate(x)-m.evaluate(x)],[[$r],(x,[d])=>-d.evaluate(x)]]},"/":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)/m.evaluate(x)],"%":[$r,[$r,$r],(x,[d,m])=>d.evaluate(x)%m.evaluate(x)],ln2:[$r,[],()=>Math.LN2],pi:[$r,[],()=>Math.PI],e:[$r,[],()=>Math.E],"^":[$r,[$r,$r],(x,[d,m])=>Math.pow(d.evaluate(x),m.evaluate(x))],sqrt:[$r,[$r],(x,[d])=>Math.sqrt(d.evaluate(x))],log10:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))/Math.LN10],ln:[$r,[$r],(x,[d])=>Math.log(d.evaluate(x))],log2:[$r,[$r],(x,[d])=>Math.log2(d.evaluate(x))],sin:[$r,[$r],(x,[d])=>Math.sin(d.evaluate(x))],cos:[$r,[$r],(x,[d])=>Math.cos(d.evaluate(x))],tan:[$r,[$r],(x,[d])=>Math.tan(d.evaluate(x))],asin:[$r,[$r],(x,[d])=>Math.asin(d.evaluate(x))],acos:[$r,[$r],(x,[d])=>Math.acos(d.evaluate(x))],atan:[$r,[$r],(x,[d])=>Math.atan(d.evaluate(x))],min:[$r,Ay($r),(x,d)=>Math.min(...d.map(m=>m.evaluate(x)))],max:[$r,Ay($r),(x,d)=>Math.max(...d.map(m=>m.evaluate(x)))],abs:[$r,[$r],(x,[d])=>Math.abs(d.evaluate(x))],round:[$r,[$r],(x,[d])=>{const m=d.evaluate(x);return m<0?-Math.round(-m):Math.round(m)}],floor:[$r,[$r],(x,[d])=>Math.floor(d.evaluate(x))],ceil:[$r,[$r],(x,[d])=>Math.ceil(d.evaluate(x))],"filter-==":[Ci,[Ra,fi],(x,[d,m])=>x.properties()[d.value]===m.value],"filter-id-==":[Ci,[fi],(x,[d])=>x.id()===d.value],"filter-type-==":[Ci,[Ra],(x,[d])=>x.geometryType()===d.value],"filter-<":[Ci,[Ra,fi],(x,[d,m])=>{const b=x.properties()[d.value],C=m.value;return typeof b==typeof C&&b{const m=x.id(),b=d.value;return typeof m==typeof b&&m":[Ci,[Ra,fi],(x,[d,m])=>{const b=x.properties()[d.value],C=m.value;return typeof b==typeof C&&b>C}],"filter-id->":[Ci,[fi],(x,[d])=>{const m=x.id(),b=d.value;return typeof m==typeof b&&m>b}],"filter-<=":[Ci,[Ra,fi],(x,[d,m])=>{const b=x.properties()[d.value],C=m.value;return typeof b==typeof C&&b<=C}],"filter-id-<=":[Ci,[fi],(x,[d])=>{const m=x.id(),b=d.value;return typeof m==typeof b&&m<=b}],"filter->=":[Ci,[Ra,fi],(x,[d,m])=>{const b=x.properties()[d.value],C=m.value;return typeof b==typeof C&&b>=C}],"filter-id->=":[Ci,[fi],(x,[d])=>{const m=x.id(),b=d.value;return typeof m==typeof b&&m>=b}],"filter-has":[Ci,[fi],(x,[d])=>d.value in x.properties()],"filter-has-id":[Ci,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[Ci,[qd(Ra)],(x,[d])=>d.value.indexOf(x.geometryType())>=0],"filter-id-in":[Ci,[qd(fi)],(x,[d])=>d.value.indexOf(x.id())>=0],"filter-in-small":[Ci,[Ra,qd(fi)],(x,[d,m])=>m.value.indexOf(x.properties()[d.value])>=0],"filter-in-large":[Ci,[Ra,qd(fi)],(x,[d,m])=>function(b,C,E,I){for(;E<=I;){const R=E+I>>1;if(C[R]===b)return!0;C[R]>b?I=R-1:E=R+1}return!1}(x.properties()[d.value],m.value,0,m.value.length-1)],all:{type:Ci,overloads:[[[Ci,Ci],(x,[d,m])=>d.evaluate(x)&&m.evaluate(x)],[Ay(Ci),(x,d)=>{for(const m of d)if(!m.evaluate(x))return!1;return!0}]]},any:{type:Ci,overloads:[[[Ci,Ci],(x,[d,m])=>d.evaluate(x)||m.evaluate(x)],[Ay(Ci),(x,d)=>{for(const m of d)if(m.evaluate(x))return!0;return!1}]]},"!":[Ci,[Ci],(x,[d])=>!d.evaluate(x)],"is-supported-script":[Ci,[Ra],(x,[d])=>{const m=x.globals&&x.globals.isSupportedScript;return!m||m(d.evaluate(x))}],upcase:[Ra,[Ra],(x,[d])=>d.evaluate(x).toUpperCase()],downcase:[Ra,[Ra],(x,[d])=>d.evaluate(x).toLowerCase()],concat:[Ra,Ay(fi),(x,d)=>d.map(m=>Jm(m.evaluate(x))).join("")],"resolved-locale":[Ra,[q3],(x,[d])=>d.evaluate(x).resolvedLocale()],random:[$r,[$r,$r,fi],(x,d)=>{const[m,b,C]=d.map(I=>I.evaluate(x));if(m>b||m===b)return m;let E;if(typeof C=="string")E=function(I){let R=0;if(I.length===0)return R;for(let q=0;qJSON.stringify(se)).join(", ")}, but found ${JSON.stringify(te)} instead.`);return te}catch(te){const se=te;return this._warningHistory[se.message]||(this._warningHistory[se.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${se.message}`)),this._defaultValue}}}function x2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in fb}function Py(x,d,m,b,C){const E=new aC(fb,[],d?function(R){const q={color:hh,string:Ra,number:$r,enum:Ra,boolean:Ci,formatted:t2,resolvedImage:s2};return R.type==="array"?qd(q[R.value]||fi,R.length):q[R.type]}(d):void 0,void 0,void 0,m,b,C),I=E.parse(x,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return I?iF(new yC(I,d,m,b,C)):Ey(E.errors)}class xb{constructor(d,m,b,C){this.kind=d,this._styleExpression=m,this.isLightConstant=b,this.isLineProgressConstant=C,this.isStateDependent=d!=="constant"&&!c2(m.expression),this.configDependencies=cv(m.expression),this.isIndoorDependent=fC(m.expression)}evaluateWithoutErrorHandling(d,m,b,C,E,I){return this._styleExpression.evaluateWithoutErrorHandling(d,m,b,C,E,I)}evaluate(d,m,b,C,E,I,R){return this._styleExpression.evaluate(d,m,b,C,E,I,void 0,void 0,R)}}class dv{constructor(d,m,b,C,E,I){this.kind=d,this.zoomStops=b,this._styleExpression=m,this.isStateDependent=d!=="camera"&&!c2(m.expression),this.isIndoorDependent=fC(m.expression),this.isLightConstant=E,this.isLineProgressConstant=I,this.configDependencies=cv(m.expression),this.interpolationType=C}evaluateWithoutErrorHandling(d,m,b,C,E,I){return this._styleExpression.evaluateWithoutErrorHandling(d,m,b,C,E,I)}evaluate(d,m,b,C,E,I){return this._styleExpression.evaluate(d,m,b,C,E,I)}interpolationFactor(d,m,b){return this.interpolationType?dm.interpolationFactor(this.interpolationType,d,m,b):0}}function S6(x,d,m,b,C){if((x=Py(x,d,m,b,C)).result==="error")return x;const E=x.value.expression,I=lb(E);if(!I&&!f2(d))return Ey([new Xm("","data expressions not supported")]);const R=cb(E,["zoom","pitch","distance-from-center"]);if(!R&&!lF(d))return Ey([new Xm("","zoom expressions not supported")]);const q=cb(E,["measure-light"]);if(!q&&!oF(d))return Ey([new Xm("","measure-light expression not supported")]);const W=cb(E,["line-progress"]);if(!W&&!function(ie){return k6(ie.expression,"line-progress")}(d))return Ey([new Xm("","line-progress expression not supported")]);const te=d.expression&&d.expression.relaxZoomRestriction,se=Bp(E);return se||R||te?se instanceof Xm?Ey([se]):se instanceof dm&&!xC(d)?Ey([new Xm("",'"interpolate" expressions cannot be used with this property')]):iF(se?new dv(I&&W?"camera":"composite",x.value,se.labels,se instanceof dm?se.interpolation:void 0,q,W):new xb(I&&W?"constant":"source",x.value,q,W)):Ey([new Xm("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class vC{constructor(d,m){this._parameters=d,this._specification=m,Object.assign(this,dF(this._parameters,this._specification))}static deserialize(d){return new vC(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function Bp(x){let d=null;if(x instanceof ag)d=Bp(x.result);else if(x instanceof h2){for(const m of x.args)if(d=Bp(m),d)break}else(x instanceof d2||x instanceof dm)&&x.input instanceof zu&&x.input.name==="zoom"&&(d=x);return d instanceof Xm||x.eachChild(m=>{const b=Bp(m);b instanceof Xm?d=b:d&&b&&d!==b&&(d=new Xm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var C6,mF,pF=function(){if(mF)return C6;mF=1,C6=d;var x=3;function d(m,b,C){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var I=new Int32Array(this.arrayBuffer);m=I[0],this.d=(b=I[1])+2*(C=I[2]);for(var R=0;R=ie[Ce+0]&&E>=ie[Ce+1])?(q[he]=!0,R.push(se[he])):q[he]=!1}}},d.prototype._forEachCell=function(m,b,C,E,I,R,q,W){for(var te=this._convertToCellCoord(m),se=this._convertToCellCoord(b),ie=this._convertToCellCoord(C),de=this._convertToCellCoord(E),he=te;he<=ie;he++)for(var Ce=se;Ce<=de;Ce++){var Fe=this.d*Ce+he;if((!W||W(this._convertFromCellCoord(he),this._convertFromCellCoord(Ce),this._convertFromCellCoord(he+1),this._convertFromCellCoord(Ce+1)))&&I.call(this,m,b,C,E,Fe,R,q,W))return}},d.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},d.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},d.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,b=x+this.cells.length+1+1,C=0,E=0;E=0||(C[E]=ig(x[E],d)));x instanceof Error&&(C.message=x.message)}if(C.$name)throw new Error("$name property is reserved for worker serialization logic.");return b!=="Object"&&(C.$name=b),C}throw new Error("can't serialize object of type "+typeof x)}function Iy(x){if(x==null||typeof x=="boolean"||typeof x=="number"||typeof x=="string"||x instanceof Boolean||x instanceof Number||x instanceof String||x instanceof Date||x instanceof RegExp||g2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(Iy);if(typeof x=="object"){const d=x.$name||"Object";if(d==="Map"){const C=x.entries||[],E=new Map;for(let I=0;Ix>=128&&x<=255,Arabic:x=>x>=1536&&x<=1791,"Arabic Supplement":x=>x>=1872&&x<=1919,"Arabic Extended-A":x=>x>=2208&&x<=2303,"Hangul Jamo":x=>x>=4352&&x<=4607,"Unified Canadian Aboriginal Syllabics":x=>x>=5120&&x<=5759,Khmer:x=>x>=6016&&x<=6143,"Unified Canadian Aboriginal Syllabics Extended":x=>x>=6320&&x<=6399,"General Punctuation":x=>x>=8192&&x<=8303,"Letterlike Symbols":x=>x>=8448&&x<=8527,"Number Forms":x=>x>=8528&&x<=8591,"Miscellaneous Technical":x=>x>=8960&&x<=9215,"Control Pictures":x=>x>=9216&&x<=9279,"Optical Character Recognition":x=>x>=9280&&x<=9311,"Enclosed Alphanumerics":x=>x>=9312&&x<=9471,"Geometric Shapes":x=>x>=9632&&x<=9727,"Miscellaneous Symbols":x=>x>=9728&&x<=9983,"Miscellaneous Symbols and Arrows":x=>x>=11008&&x<=11263,"CJK Radicals Supplement":x=>x>=11904&&x<=12031,"Kangxi Radicals":x=>x>=12032&&x<=12255,"Ideographic Description Characters":x=>x>=12272&&x<=12287,"CJK Symbols and Punctuation":x=>x>=12288&&x<=12351,Hiragana:x=>x>=12352&&x<=12447,Katakana:x=>x>=12448&&x<=12543,Bopomofo:x=>x>=12544&&x<=12591,"Hangul Compatibility Jamo":x=>x>=12592&&x<=12687,Kanbun:x=>x>=12688&&x<=12703,"Bopomofo Extended":x=>x>=12704&&x<=12735,"CJK Strokes":x=>x>=12736&&x<=12783,"Katakana Phonetic Extensions":x=>x>=12784&&x<=12799,"Enclosed CJK Letters and Months":x=>x>=12800&&x<=13055,"CJK Compatibility":x=>x>=13056&&x<=13311,"CJK Unified Ideographs Extension A":x=>x>=13312&&x<=19903,"Yijing Hexagram Symbols":x=>x>=19904&&x<=19967,"CJK Unified Ideographs":x=>x>=19968&&x<=40959,"Yi Syllables":x=>x>=40960&&x<=42127,"Yi Radicals":x=>x>=42128&&x<=42191,"Hangul Jamo Extended-A":x=>x>=43360&&x<=43391,"Hangul Syllables":x=>x>=44032&&x<=55215,"Hangul Jamo Extended-B":x=>x>=55216&&x<=55295,"Private Use Area":x=>x>=57344&&x<=63743,"CJK Compatibility Ideographs":x=>x>=63744&&x<=64255,"Arabic Presentation Forms-A":x=>x>=64336&&x<=65023,"Vertical Forms":x=>x>=65040&&x<=65055,"CJK Compatibility Forms":x=>x>=65072&&x<=65103,"Small Form Variants":x=>x>=65104&&x<=65135,"Arabic Presentation Forms-B":x=>x>=65136&&x<=65279,"Halfwidth and Fullwidth Forms":x=>x>=65280&&x<=65519,Osage:x=>x>=66736&&x<=66815,"CJK Unified Ideographs Extension B":x=>x>=131072&&x<=173791};function y2(x){for(const d of x)if(bC(d.charCodeAt(0)))return!0;return!1}function M6(x){for(const d of x)if(!fF(d.charCodeAt(0)))return!1;return!0}function fF(x){return!(tn.Arabic(x)||tn["Arabic Supplement"](x)||tn["Arabic Extended-A"](x)||tn["Arabic Presentation Forms-A"](x)||tn["Arabic Presentation Forms-B"](x))}function bC(x){return!(x!==746&&x!==747&&(x<4352||!(tn["Bopomofo Extended"](x)||tn.Bopomofo(x)||tn["CJK Compatibility Forms"](x)&&!(x>=65097&&x<=65103)||tn["CJK Compatibility Ideographs"](x)||tn["CJK Compatibility"](x)||tn["CJK Radicals Supplement"](x)||tn["CJK Strokes"](x)||!(!tn["CJK Symbols and Punctuation"](x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||tn["CJK Unified Ideographs Extension A"](x)||tn["CJK Unified Ideographs"](x)||tn["Enclosed CJK Letters and Months"](x)||tn["Hangul Compatibility Jamo"](x)||tn["Hangul Jamo Extended-A"](x)||tn["Hangul Jamo Extended-B"](x)||tn["Hangul Jamo"](x)||tn["Hangul Syllables"](x)||tn.Hiragana(x)||tn["Ideographic Description Characters"](x)||tn.Kanbun(x)||tn["Kangxi Radicals"](x)||tn["Katakana Phonetic Extensions"](x)||tn.Katakana(x)&&x!==12540||!(!tn["Halfwidth and Fullwidth Forms"](x)||x===65288||x===65289||x===65293||x>=65306&&x<=65310||x===65339||x===65341||x===65343||x>=65371&&x<=65503||x===65507||x>=65512&&x<=65519)||!(!tn["Small Form Variants"](x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||tn["Unified Canadian Aboriginal Syllabics"](x)||tn["Unified Canadian Aboriginal Syllabics Extended"](x)||tn["Vertical Forms"](x)||tn["Yijing Hexagram Symbols"](x)||tn["Yi Syllables"](x)||tn["Yi Radicals"](x))))}function _C(x){return!(bC(x)||function(d){return!!(tn["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||tn["General Punctuation"](d)&&(d===8214||d===8224||d===8225||d===8240||d===8241||d===8251||d===8252||d===8258||d===8263||d===8264||d===8265||d===8273)||tn["Letterlike Symbols"](d)||tn["Number Forms"](d)||tn["Miscellaneous Technical"](d)&&(d>=8960&&d<=8967||d>=8972&&d<=8991||d>=8996&&d<=9e3||d===9003||d>=9085&&d<=9114||d>=9150&&d<=9165||d===9167||d>=9169&&d<=9179||d>=9186&&d<=9215)||tn["Control Pictures"](d)&&d!==9251||tn["Optical Character Recognition"](d)||tn["Enclosed Alphanumerics"](d)||tn["Geometric Shapes"](d)||tn["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||tn["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||tn["CJK Symbols and Punctuation"](d)||tn.Katakana(d)||tn["Private Use Area"](d)||tn["CJK Compatibility Forms"](d)||tn["Small Form Variants"](d)||tn["Halfwidth and Fullwidth Forms"](d)||d===8734||d===8756||d===8757||d>=9984&&d<=10087||d>=10102&&d<=10131||d===65532||d===65533)}(x))}function wC(x){return tn.Arabic(x)||tn["Arabic Supplement"](x)||tn["Arabic Extended-A"](x)||tn["Arabic Presentation Forms-A"](x)||tn["Arabic Presentation Forms-B"](x)}function T6(x){return x>=1424&&x<=2303||tn["Arabic Presentation Forms-A"](x)||tn["Arabic Presentation Forms-B"](x)}function og(x,d){return!(!d&&T6(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||tn.Khmer(x))}function epe(x){for(const d of x)if(T6(d.charCodeAt(0)))return!0;return!1}const Rh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let A6=null,Bu=Rh.unavailable,lg=null;const v2=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Bu=Rh.error),A6&&A6(x)};function jC(){NC.fire(new Qm("pluginStateChange",{pluginStatus:Bu,pluginURL:lg}))}const NC=new Es,b2=function(){return Bu},xF=function(){if(Bu!==Rh.deferred||!lg)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Bu=Rh.loading,jC(),lg&&Oh({url:lg},x=>{x?v2(x):(Bu=Rh.loaded,jC())})},cg={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Bu===Rh.loaded||cg.applyArabicShaping!=null,isLoading:()=>Bu===Rh.loading,setState(x){Bu=x.pluginStatus,lg=x.pluginURL},isParsing:()=>Bu===Rh.parsing,isParsed:()=>Bu===Rh.parsed,getPluginURL:()=>lg};class Zi{constructor(d,m){this.zoom=d,m?(this.now=m.now,this.fadeDuration=m.fadeDuration,this.transition=m.transition,this.pitch=m.pitch,this.brightness=m.brightness,this.worldview=m.worldview,this.activeFloors=m.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(d){return function(m,b){for(const C of m)if(!og(C.charCodeAt(0),b))return!1;return!0}(d,cg.isLoaded())}}class kC{constructor(d,m,b,C,E){this.property=d,this.value=m,this.expression=function(I,R,q,W,te){if(gC(I))return new vC(I,R);if(x2(I)||Array.isArray(I)&&I.length>0){const se=S6(I,R,q,W,te);if(se.result==="error")throw new Error(se.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));return se.value}{let se=I;return typeof I=="string"&&R.type==="color"&&(se=Ur.parse(I)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(m===void 0?d.specification.default:m,d.specification,b,C,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,m,b,C){return this.property.possiblyEvaluate(this,d,m,b,C)}}class E6{constructor(d,m,b,C){this.property=d,this.value=new kC(d,void 0,m,b,C)}transitioned(d,m){return new yF(this.property,this.value,m,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new yF(this.property,this.value,null,{},0)}}class gF{constructor(d,m,b,C){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=m,this._options=b,this._iconImageUseTheme=C,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(d){return ys(this._values[d].value.value)}setValue(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new E6(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new kC(this._values[d].property,m===null?void 0:ys(m),this._scope,this._options,this._iconImageUseTheme),this._values[d].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[d].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[d].value.isIndoorDependent())}setTransitionOrValue(d,m){m&&(this._options=m);const b=this._properties.properties;if(d)for(const C in d){const E=d[C];if(C.endsWith("-transition")){const I=C.slice(0,-11);b[I]&&this.setTransition(I,E)}else b.hasOwnProperty(C)&&this.setValue(C,E)}}getTransition(d){return ys(this._values[d].transition)}setTransition(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new E6(this._values[d].property)),this._values[d].transition=ys(m)||void 0}serialize(){const d={};for(const m of Object.keys(this._values)){const b=this.getValue(m);b!==void 0&&(d[m]=b);const C=this.getTransition(m);C!==void 0&&(d[`${m}-transition`]=C)}return d}transitioned(d,m){const b=new vF(this._properties);for(const C of Object.keys(this._values))b._values[C]=this._values[C].transitioned(d,m._values[C]);return b}untransitioned(){const d=new vF(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class yF{constructor(d,m,b,C,E){const I=C.delay||0,R=C.duration||0;E=E||0,this.property=d,this.value=m,this.begin=E+I,this.end=this.begin+R,d.specification.transition&&(C.delay||C.duration)&&(this.prior=b)}possiblyEvaluate(d,m,b){const C=d.now||0,E=this.value.possiblyEvaluate(d,m,b),I=this.prior;if(I){if(C>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(C":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function _F(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function SC(x){if(Array.isArray(x))return x.map(SC);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const d={};for(const m in x)d[m]=SC(x[m]);return d}return _F(x)}function Hf(x){if(x===!0||x===!1)return!0;if(!Array.isArray(x)||x.length===0)return!1;switch(x[0]){case"has":return x.length>=2&&x[1]!=="$id"&&x[1]!=="$type";case"in":return x.length>=3&&(typeof x[1]!="string"||Array.isArray(x[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return x.length!==3||Array.isArray(x[1])||Array.isArray(x[2]);case"any":case"all":for(const d of x.slice(1))if(!Hf(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function CC(x,d="",m=null,b="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Hf(x)||(x=MC(x));const C=x;let E=!0;try{E=function(te){if(!yb(te))return te;let se=SC(te);return wF(se),se=fv(se),se}(C)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(C,null,2)} `)}let I=null,R=null;if(b!=="background"&&b!=="sky"&&b!=="slot"){R=Kt[`filter_${b}`];const te=Py(E,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));I=(se,ie,de)=>te.value.evaluate(se,ie,{},de)}let q=null,W=null;if(E!==C){const te=Py(C,R,d,m);if(te.result==="error")throw new Error(te.value.map(se=>`${se.key}: ${se.message}`).join(", "));q=(se,ie,de,he,Ce)=>te.value.evaluate(se,ie,{},de,void 0,void 0,he,Ce),W=!lb(te.value.expression)}return{filter:I,dynamicFilter:q||void 0,needGeometry:jF(E),needFeature:!!W}}function fv(x){if(!Array.isArray(x))return x;const d=function(m){if(tpe.has(m[0])){for(let b=1;bfv(m))}function wF(x){let d=!1;const m=[];if(x[0]==="case"){for(let b=1;b",">=","<","<=","to-boolean"]);function spe(x,d){return xd?1:0}function jF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?TC(x[1],x[2],d):d==="any"?(m=x.slice(1),["any"].concat(m.map(MC))):d==="all"?["all"].concat(x.slice(1).map(MC)):d==="none"?["all"].concat(x.slice(1).map(MC).map(_2)):d==="in"?AC(x[1],x.slice(2)):d==="!in"?_2(AC(x[1],x.slice(2))):d==="has"?EC(x[1]):d!=="!has"||_2(EC(x[1]));var m}function TC(x,d,m){switch(x){case"$type":return[`filter-type-${m}`,d];case"$id":return[`filter-id-${m}`,d];default:return[`filter-${m}`,x,d]}}function AC(x,d){if(d.length===0)return!1;switch(x){case"$type":return["filter-type-in",["literal",d]];case"$id":return["filter-id-in",["literal",d]];default:return d.length>200&&!d.some(m=>typeof m!=typeof d[0])?["filter-in-large",x,["literal",d.sort(spe)]]:["filter-in-small",x,["literal",d]]}}function EC(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function _2(x){return["!",x]}const xv="";function $p(x,d){return d?`${x}${xv}${d}`:x}let NF;const kF=()=>NF||(NF=new Io({"icon-size":new ir(Kt.layout_symbol["icon-size"]),"icon-image":new ir(Kt.layout_symbol["icon-image"]),"icon-rotate":new ir(Kt.layout_symbol["icon-rotate"]),"icon-offset":new ir(Kt.layout_symbol["icon-offset"]),"text-size":new ir(Kt.layout_symbol["text-size"]),"text-rotate":new ir(Kt.layout_symbol["text-rotate"]),"text-offset":new ir(Kt.layout_symbol["text-offset"])}));class SF{constructor(d,m,b,C,E,I){const R=Py(d,Kt.appearance.condition);if(R.result==="success"&&(this.condition=R.value),this.name=m,b){this.properties=new mv(kF()),this.unevaluatedLayout=new bF(kF(),C,E,I);for(const q in b)this.unevaluatedLayout.setValue(q,b[q])}}isActive(d){return!(this.condition||!d.isHidden||this.name!=="hidden")||this.condition.evaluate(d.globals,d.feature,d.featureState,d.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(d){return this.properties.get(d)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(d){return this.unevaluatedLayout._values[d]}recalculate(d,m,b){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(d,void 0,m,b))}serialize(){const d={};return d.condition=this.condition.expression.serialize(),this.name&&(d.name=this.name),this.unevaluatedLayout&&(d.properties=this.unevaluatedLayout.serialize()),d}hasIconProperties(){const d=this.hasProperty("icon-image"),m=this.hasProperty("icon-size"),b=this.hasProperty("icon-offset"),C=this.hasProperty("icon-rotate");return d||m||b||C}hasTextProperties(){const d=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),b=this.hasProperty("text-rotate");return d||m||b}hasProperty(d){return this.getUnevaluatedProperty(d).value!==void 0}}const CF="-transition",Gf=new Set(["fill","line","background","hillshade","raster"]);class $u extends Es{constructor(d,m,b,C,E,I){if(super(),this.id=d.id,this.fqid=$p(this.id,b),this.type=d.type,this.scope=b,this.lut=C,this.options=E,this.iconImageUseTheme=I,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},d.type!=="custom"){if(this.metadata=d.metadata,this.minzoom=d.minzoom,this.maxzoom=d.maxzoom,d.type&&d.type!=="background"&&d.type!=="sky"&&d.type!=="slot"){this.source=d.source,this.sourceLayer=d["source-layer"],this.filter=d.filter;const R=Py(this.filter,Kt[`filter_${d.type}`]);R.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...R.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||R.value.isIndoorDependent)}if(d.slot&&(this.slot=d.slot),d.appearances&&this.setAppearances(d.appearances),m.layout&&(this._unevaluatedLayout=new bF(m.layout,this.scope,E,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),m.paint){this._transitionablePaint=new gF(m.paint,this.scope,E);for(const R in d.paint)this.setPaintProperty(R,d.paint[R]);for(const R in d.layout)this.setLayoutProperty(R,d.layout[R]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new mv(m.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Gf.has(this.type)}getLayoutProperty(d){return d==="visibility"?this.visibility:this._unevaluatedLayout.getValue(d)}setLayoutProperty(d,m){if(this.type==="custom"&&d==="visibility")return void(this.visibility=m);const b=this._unevaluatedLayout;b._properties.properties[d]&&(b.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...b.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||b.isIndoorDependent(),d==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(d){this.appearances=[],d.forEach(m=>{this.appearances.push(new SF(m.condition,m.name,m.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(d){return d.endsWith(CF)?this._transitionablePaint.getTransition(d.slice(0,-11)):this._transitionablePaint.getValue(d)}isPaintProperty(d){return!!this._transitionablePaint._properties.properties[d]}setPaintProperty(d,m){const b=this._transitionablePaint,C=b._properties.properties;if(d.endsWith(CF)){const se=d.slice(0,-11);return C[se]&&b.setTransition(se,m||void 0),!1}if(!C[d])return!1;const E=b._values[d],I=E.value.isDataDriven(),R=E.value;b.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...b.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||b.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const q=b._values[d].value,W=q.isDataDriven(),te=d.endsWith("pattern")||d==="line-dasharray";return W||I||te||this._handleOverridablePaintPropertyUpdate(d,R,q)}_handleSpecialPaintPropertyUpdate(d){}getProgramIds(){return null}getDefaultProgramParams(d,m,b){return null}_handleOverridablePaintPropertyUpdate(d,m,b){return!1}isHidden(d){return!!(this.minzoom&&d=this.maxzoom)||this.visibility==="none"}updateTransitions(d){this._transitioningPaint=this._transitionablePaint.transitioned(d,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(d,m){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(d,void 0,m,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(d,void 0,m)}serialize(){const d={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.appearances.length!==0&&(d.appearances=this.appearances.map(m=>m.serialize())),Is(d,(m,b)=>!(m===void 0||b==="layout"&&!Object.keys(m).length||b==="paint"&&!Object.keys(m).length))}is3D(d){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const d in this.paint._values){const m=this.paint.get(d);if(m instanceof hv&&f2(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const d of this.appearances)if(!c2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=CC(this.filter,this.scope,d),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(d){this._stats&&(d.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(d,m,b){return{}}queryRadius(d){}queryIntersectsFeature(d,m,b,C,E,I,R,q,W){}}const MF={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class w2{constructor(d,m){this._structArray=d,this._pos1=m*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const rpe=new ArrayBuffer(0);class ro{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(d,m){return d._trim(),m&&d.arrayBuffer&&m.add(d.arrayBuffer),{length:d.length,arrayBuffer:d.arrayBuffer}}static deserialize(d){const m=Object.create(this.prototype);return m.arrayBuffer=d.arrayBuffer,m.length=d.length,d.arrayBuffer?m.capacity=d.arrayBuffer.byteLength/m.bytesPerElement:(m.capacity=0,m.arrayBuffer=rpe),m._refreshViews(),m}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(d){this.reserve(d),this.length=d}reserve(d){if(d>this.capacity){this._reallocCount++,this.capacity=Math.max(d,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const m=this.uint8;this._refreshViews(),m&&this.uint8.set(m)}}reserveForAdditional(d){this.reserve(this.length+d)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...d){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...d){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function xa(x,d=1){let m=0,b=0;return{members:x.map(C=>{const E=MF[C.type].BYTES_PER_ELEMENT,I=m=TF(m,Math.max(d,E)),R=C.components||1;return b=Math.max(b,E),m+=E*R,{name:C.name,type:C.type,components:R,offset:I}}),size:TF(m,Math.max(b,d)),alignment:d}}function TF(x,d){return Math.ceil(x/d)*d}class Ly extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m){const b=this.length;return this.resize(b+1),this.emplace(b,d,m)}emplace(d,m,b){const C=2*d;return this.int16[C+0]=m,this.int16[C+1]=b,d}}Ly.prototype.bytesPerElement=4,kr(Ly,"StructArrayLayout2i4");class vb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,b)}emplace(d,m,b,C){const E=3*d;return this.int16[E+0]=m,this.int16[E+1]=b,this.int16[E+2]=C,d}}vb.prototype.bytesPerElement=6,kr(vb,"StructArrayLayout3i6");class bb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,b,C)}emplace(d,m,b,C,E){const I=4*d;return this.int16[I+0]=m,this.int16[I+1]=b,this.int16[I+2]=C,this.int16[I+3]=E,d}}bb.prototype.bytesPerElement=8,kr(bb,"StructArrayLayout4i8");class dg extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.float32[1*d+0]=m,d}}dg.prototype.bytesPerElement=4,kr(dg,"StructArrayLayout1f4");class P6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,b)}emplace(d,m,b,C){const E=4*d,I=2*d;return this.int16[E+0]=m,this.int16[E+1]=b,this.float32[I+1]=C,d}}P6.prototype.bytesPerElement=8,kr(P6,"StructArrayLayout2i1f8");class I6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,b)}emplace(d,m,b,C){const E=4*d;return this.int16[E+0]=m,this.int16[E+1]=b,this.int16[E+2]=C,d}}I6.prototype.bytesPerElement=8,kr(I6,"StructArrayLayout3i8");class L6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E){const I=this.length;return this.resize(I+1),this.emplace(I,d,m,b,C,E)}emplace(d,m,b,C,E,I){const R=5*d;return this.int16[R+0]=m,this.int16[R+1]=b,this.int16[R+2]=C,this.int16[R+3]=E,this.int16[R+4]=I,d}}L6.prototype.bytesPerElement=10,kr(L6,"StructArrayLayout5i10");class PC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R){const q=this.length;return this.resize(q+1),this.emplace(q,d,m,b,C,E,I,R)}emplace(d,m,b,C,E,I,R,q){const W=6*d,te=12*d,se=3*d;return this.int16[W+0]=m,this.int16[W+1]=b,this.uint8[te+4]=C,this.uint8[te+5]=E,this.uint8[te+6]=I,this.uint8[te+7]=R,this.float32[se+2]=q,d}}PC.prototype.bytesPerElement=12,kr(PC,"StructArrayLayout2i4ub1f12");class um extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,b)}emplace(d,m,b,C){const E=3*d;return this.float32[E+0]=m,this.float32[E+1]=b,this.float32[E+2]=C,d}}um.prototype.bytesPerElement=12,kr(um,"StructArrayLayout3f12");class mh extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E){const I=this.length;return this.resize(I+1),this.emplace(I,d,m,b,C,E)}emplace(d,m,b,C,E,I){const R=6*d,q=3*d;return this.uint16[R+0]=m,this.uint16[R+1]=b,this.uint16[R+2]=C,this.uint16[R+3]=E,this.float32[q+2]=I,d}}mh.prototype.bytesPerElement=12,kr(mh,"StructArrayLayout4ui1f12");class gv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,b,C)}emplace(d,m,b,C,E){const I=4*d;return this.uint16[I+0]=m,this.uint16[I+1]=b,this.uint16[I+2]=C,this.uint16[I+3]=E,d}}gv.prototype.bytesPerElement=8,kr(gv,"StructArrayLayout4ui8");class IC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,b,C,E,I)}emplace(d,m,b,C,E,I,R){const q=6*d;return this.int16[q+0]=m,this.int16[q+1]=b,this.int16[q+2]=C,this.int16[q+3]=E,this.int16[q+4]=I,this.int16[q+5]=R,d}}IC.prototype.bytesPerElement=12,kr(IC,"StructArrayLayout6i12");class D6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se,ie){const de=this.length;return this.resize(de+1),this.emplace(de,d,m,b,C,E,I,R,q,W,te,se,ie)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie,de){const he=12*d;return this.int16[he+0]=m,this.int16[he+1]=b,this.int16[he+2]=C,this.int16[he+3]=E,this.uint16[he+4]=I,this.uint16[he+5]=R,this.uint16[he+6]=q,this.uint16[he+7]=W,this.int16[he+8]=te,this.int16[he+9]=se,this.int16[he+10]=ie,this.int16[he+11]=de,d}}D6.prototype.bytesPerElement=24,kr(D6,"StructArrayLayout4i4ui4i24");class O6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,b,C,E,I)}emplace(d,m,b,C,E,I,R){const q=10*d,W=5*d;return this.int16[q+0]=m,this.int16[q+1]=b,this.int16[q+2]=C,this.float32[W+2]=E,this.float32[W+3]=I,this.float32[W+4]=R,d}}O6.prototype.bytesPerElement=20,kr(O6,"StructArrayLayout3i3f20");class Dy extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,b,C)}emplace(d,m,b,C,E){const I=4*d;return this.float32[I+0]=m,this.float32[I+1]=b,this.float32[I+2]=C,this.float32[I+3]=E,d}}Dy.prototype.bytesPerElement=16,kr(Dy,"StructArrayLayout4f16");class LC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint32[1*d+0]=m,d}}LC.prototype.bytesPerElement=4,kr(LC,"StructArrayLayout1ul4");class hm extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m){const b=this.length;return this.resize(b+1),this.emplace(b,d,m)}emplace(d,m,b){const C=2*d;return this.uint16[C+0]=m,this.uint16[C+1]=b,d}}hm.prototype.bytesPerElement=4,kr(hm,"StructArrayLayout2ui4");class DC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se,ie,de){const he=this.length;return this.resize(he+1),this.emplace(he,d,m,b,C,E,I,R,q,W,te,se,ie,de)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie,de,he){const Ce=20*d,Fe=10*d;return this.int16[Ce+0]=m,this.int16[Ce+1]=b,this.int16[Ce+2]=C,this.int16[Ce+3]=E,this.int16[Ce+4]=I,this.float32[Fe+3]=R,this.float32[Fe+4]=q,this.float32[Fe+5]=W,this.float32[Fe+6]=te,this.int16[Ce+14]=se,this.uint32[Fe+8]=ie,this.uint16[Ce+18]=de,this.uint16[Ce+19]=he,d}}DC.prototype.bytesPerElement=40,kr(DC,"StructArrayLayout5i4f1i1ul2ui40");class OC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R){const q=this.length;return this.resize(q+1),this.emplace(q,d,m,b,C,E,I,R)}emplace(d,m,b,C,E,I,R,q){const W=8*d;return this.int16[W+0]=m,this.int16[W+1]=b,this.int16[W+2]=C,this.int16[W+4]=E,this.int16[W+5]=I,this.int16[W+6]=R,this.int16[W+7]=q,d}}OC.prototype.bytesPerElement=16,kr(OC,"StructArrayLayout3i2i2i16");class RC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E){const I=this.length;return this.resize(I+1),this.emplace(I,d,m,b,C,E)}emplace(d,m,b,C,E,I){const R=4*d,q=8*d;return this.float32[R+0]=m,this.float32[R+1]=b,this.float32[R+2]=C,this.int16[q+6]=E,this.int16[q+7]=I,d}}RC.prototype.bytesPerElement=16,kr(RC,"StructArrayLayout2f1f2i16");class R6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,b,C,E,I)}emplace(d,m,b,C,E,I,R){const q=20*d,W=5*d;return this.uint8[q+0]=m,this.uint8[q+1]=b,this.float32[W+1]=C,this.float32[W+2]=E,this.float32[W+3]=I,this.float32[W+4]=R,d}}R6.prototype.bytesPerElement=20,kr(R6,"StructArrayLayout2ub4f20");class Vl extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,b){const C=this.length;return this.resize(C+1),this.emplace(C,d,m,b)}emplace(d,m,b,C){const E=3*d;return this.uint16[E+0]=m,this.uint16[E+1]=b,this.uint16[E+2]=C,d}}Vl.prototype.bytesPerElement=6,kr(Vl,"StructArrayLayout3ui6");class _b extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt){const vt=this.length;return this.resize(vt+1),this.emplace(vt,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt,vt){const At=30*d,zt=15*d,qt=60*d;return this.int16[At+0]=m,this.int16[At+1]=b,this.int16[At+2]=C,this.float32[zt+2]=E,this.float32[zt+3]=I,this.uint16[At+8]=R,this.uint16[At+9]=q,this.uint32[zt+5]=W,this.uint32[zt+6]=te,this.uint32[zt+7]=se,this.uint16[At+16]=ie,this.uint16[At+17]=de,this.uint16[At+18]=he,this.float32[zt+10]=Ce,this.float32[zt+11]=Fe,this.uint8[qt+48]=Re,this.uint8[qt+49]=Ke,this.uint8[qt+50]=Xe,this.uint32[zt+13]=lt,this.int16[At+28]=kt,this.uint8[qt+58]=vt,d}}_b.prototype.bytesPerElement=60,kr(_b,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class F6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Wt,ds,ks,Ss,zs,$s,Ds){const Rs=this.length;return this.resize(Rs+1),this.emplace(Rs,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Wt,ds,ks,Ss,zs,$s,Ds)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt,vt,At,zt,qt,ss,Wt,ds,ks,Ss,zs,$s,Ds,Rs){const ls=20*d,rs=40*d,Fs=80*d;return this.float32[ls+0]=m,this.float32[ls+1]=b,this.int16[rs+4]=C,this.int16[rs+5]=E,this.int16[rs+6]=I,this.int16[rs+7]=R,this.int16[rs+8]=q,this.int16[rs+9]=W,this.int16[rs+10]=te,this.int16[rs+11]=se,this.int16[rs+12]=ie,this.uint16[rs+13]=de,this.uint16[rs+14]=he,this.uint16[rs+15]=Ce,this.uint16[rs+16]=Fe,this.uint16[rs+17]=Re,this.uint16[rs+18]=Ke,this.uint16[rs+19]=Xe,this.uint16[rs+20]=lt,this.uint16[rs+21]=kt,this.uint16[rs+22]=vt,this.uint16[rs+23]=At,this.uint16[rs+24]=zt,this.uint16[rs+25]=qt,this.uint16[rs+26]=ss,this.uint16[rs+27]=Wt,this.uint32[ls+14]=ds,this.float32[ls+15]=ks,this.float32[ls+16]=Ss,this.float32[ls+17]=zs,this.float32[ls+18]=$s,this.uint8[Fs+76]=Ds,this.uint16[rs+39]=Rs,d}}F6.prototype.bytesPerElement=80,kr(F6,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class z6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I){const R=this.length;return this.resize(R+1),this.emplace(R,d,m,b,C,E,I)}emplace(d,m,b,C,E,I,R){const q=6*d;return this.float32[q+0]=m,this.float32[q+1]=b,this.float32[q+2]=C,this.float32[q+3]=E,this.float32[q+4]=I,this.float32[q+5]=R,d}}z6.prototype.bytesPerElement=24,kr(z6,"StructArrayLayout6f24");class yv extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E){const I=this.length;return this.resize(I+1),this.emplace(I,d,m,b,C,E)}emplace(d,m,b,C,E,I){const R=5*d;return this.float32[R+0]=m,this.float32[R+1]=b,this.float32[R+2]=C,this.float32[R+3]=E,this.float32[R+4]=I,d}}yv.prototype.bytesPerElement=20,kr(yv,"StructArrayLayout5f20");class B6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R){const q=this.length;return this.resize(q+1),this.emplace(q,d,m,b,C,E,I,R)}emplace(d,m,b,C,E,I,R,q){const W=7*d;return this.float32[W+0]=m,this.float32[W+1]=b,this.float32[W+2]=C,this.float32[W+3]=E,this.float32[W+4]=I,this.float32[W+5]=R,this.float32[W+6]=q,d}}B6.prototype.bytesPerElement=28,kr(B6,"StructArrayLayout7f28");class $6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se){const ie=this.length;return this.resize(ie+1),this.emplace(ie,d,m,b,C,E,I,R,q,W,te,se)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie){const de=11*d;return this.float32[de+0]=m,this.float32[de+1]=b,this.float32[de+2]=C,this.float32[de+3]=E,this.float32[de+4]=I,this.float32[de+5]=R,this.float32[de+6]=q,this.float32[de+7]=W,this.float32[de+8]=te,this.float32[de+9]=se,this.float32[de+10]=ie,d}}$6.prototype.bytesPerElement=44,kr($6,"StructArrayLayout11f44");class wb extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W){const te=this.length;return this.resize(te+1),this.emplace(te,d,m,b,C,E,I,R,q,W)}emplace(d,m,b,C,E,I,R,q,W,te){const se=9*d;return this.float32[se+0]=m,this.float32[se+1]=b,this.float32[se+2]=C,this.float32[se+3]=E,this.float32[se+4]=I,this.float32[se+5]=R,this.float32[se+6]=q,this.float32[se+7]=W,this.float32[se+8]=te,d}}wb.prototype.bytesPerElement=36,kr(wb,"StructArrayLayout9f36");class Wf extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m){const b=this.length;return this.resize(b+1),this.emplace(b,d,m)}emplace(d,m,b){const C=2*d;return this.float32[C+0]=m,this.float32[C+1]=b,d}}Wf.prototype.bytesPerElement=8,kr(Wf,"StructArrayLayout2f8");class ph extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,b,C){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,b,C)}emplace(d,m,b,C,E){const I=6*d;return this.uint32[3*d+0]=m,this.uint16[I+2]=b,this.uint16[I+3]=C,this.uint16[I+4]=E,d}}ph.prototype.bytesPerElement=12,kr(ph,"StructArrayLayout1ul3ui12");class Oy extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint16[1*d+0]=m,d}}Oy.prototype.bytesPerElement=2,kr(Oy,"StructArrayLayout1ui2");class q6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe){const Re=this.length;return this.resize(Re+1),this.emplace(Re,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe)}emplace(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re){const Ke=16*d;return this.float32[Ke+0]=m,this.float32[Ke+1]=b,this.float32[Ke+2]=C,this.float32[Ke+3]=E,this.float32[Ke+4]=I,this.float32[Ke+5]=R,this.float32[Ke+6]=q,this.float32[Ke+7]=W,this.float32[Ke+8]=te,this.float32[Ke+9]=se,this.float32[Ke+10]=ie,this.float32[Ke+11]=de,this.float32[Ke+12]=he,this.float32[Ke+13]=Ce,this.float32[Ke+14]=Fe,this.float32[Ke+15]=Re,d}}q6.prototype.bytesPerElement=64,kr(q6,"StructArrayLayout16f64");class FC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,b,C,E,I,R){const q=this.length;return this.resize(q+1),this.emplace(q,d,m,b,C,E,I,R)}emplace(d,m,b,C,E,I,R,q){const W=10*d,te=5*d;return this.uint16[W+0]=m,this.uint16[W+1]=b,this.uint16[W+2]=C,this.uint16[W+3]=E,this.float32[te+2]=I,this.float32[te+3]=R,this.float32[te+4]=q,d}}FC.prototype.bytesPerElement=20,kr(FC,"StructArrayLayout4ui3f20");class U6 extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.int16[1*d+0]=m,d}}U6.prototype.bytesPerElement=2,kr(U6,"StructArrayLayout1i2");class zC extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(d){const m=this.length;return this.resize(m+1),this.emplace(m,d)}emplace(d,m){return this.uint8[1*d+0]=m,d}}zC.prototype.bytesPerElement=1,kr(zC,"StructArrayLayout1ub1");class BC extends w2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}BC.prototype.size=40;class AF extends DC{get(d){return new BC(this,d)}}kr(AF,"CollisionBoxArray");class $C extends w2{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(d){this._structArray.uint8[this._pos1+49]=d}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(d){this._structArray.uint8[this._pos1+50]=d}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(d){this._structArray.uint32[this._pos4+13]=d}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(d){this._structArray.uint8[this._pos1+58]=d}}$C.prototype.size=60;class EF extends _b{get(d){return new $C(this,d)}}kr(EF,"PlacedSymbolArray");class PF extends w2{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(d){this._structArray.uint32[this._pos4+14]=d}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(d){this._structArray.float32[this._pos4+18]=d}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}PF.prototype.size=80;class V6 extends F6{get(d){return new PF(this,d)}}kr(V6,"SymbolInstanceArray");class qC extends dg{getoffsetX(d){return this.float32[1*d+0]}}kr(qC,"GlyphOffsetArray");class IF extends Ly{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}kr(IF,"SymbolLineVertexArray");class H6 extends w2{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}H6.prototype.size=12;class G6 extends ph{get(d){return new H6(this,d)}}kr(G6,"FeatureIndexArray");class LF extends hm{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}kr(LF,"FillExtrusionCentroidArray");class UC extends w2{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}UC.prototype.size=6;class j2 extends vb{get(d){return new UC(this,d)}}kr(j2,"FillExtrusionWallArray");const DF=xa([{name:"a_pos",components:2,type:"Int16"}],4),npe=xa([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),OF=xa([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class wo{constructor(d=[]){this.segments=d}_prepareSegment(d,m,b,C){let E=this.segments[this.segments.length-1];return d>wo.MAX_VERTEX_ARRAY_LENGTH&&xr(`Max vertices per segment is ${wo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>wo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==C)&&(E={vertexOffset:m,primitiveOffset:b,vertexLength:0,primitiveLength:0},C!==void 0&&(E.sortKey=C),this.segments.push(E)),E}prepareSegment(d,m,b,C){return this._prepareSegment(d,m.length,b.length,C)}get(){return this.segments}destroy(){for(const d of this.segments)for(const m in d.vaos)d.vaos[m].destroy()}static simpleSegment(d,m,b,C){return new wo([{vertexOffset:d,primitiveOffset:m,vertexLength:b,primitiveLength:C,vaos:{},sortKey:0}])}}function VC(x,d){return 256*(x=Se(Math.floor(x),0,255))+Se(Math.floor(d),0,255)}wo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kr(wo,"SegmentVector");const ape=xa([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ipe=xa([{name:"a_pattern_b",components:4,type:"Uint16"}]),ope=xa([{name:"a_dash",components:4,type:"Uint16"}]);class N2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,m,b,C){this.ids.push(W6(d)),this.positions.push(m,b,C)}eachPosition(d,m){const b=W6(d);let C=0,E=this.ids.length-1;for(;C>1;this.ids[I]>=b?E=I:C=I+1}for(;this.ids[C]===b;)m(this.positions[3*C],this.positions[3*C+1],this.positions[3*C+2]),C++}static serialize(d,m){const b=new Float64Array(d.ids),C=new Uint32Array(d.positions);return K6(b,C,0,b.length-1),m&&(m.add(b.buffer),m.add(C.buffer)),{ids:b,positions:C}}static deserialize(d){const m=new N2;let b;m.ids=d.ids,m.positions=d.positions;for(const C of m.ids)C!==b&&m.uniqueIds.push(C),b=C;return m.indexed=!0,m}}function W6(x){const d=+x;return Number.isSafeInteger(d)?d:tb(String(x))}function K6(x,d,m,b){for(;m>1];let E=m-1,I=b+1;for(;;){do E++;while(x[E]C);if(E>=I)break;HC(x,E,I),HC(d,3*E,3*I),HC(d,3*E+1,3*I+1),HC(d,3*E+2,3*I+2)}I-m`u_${E}`),this.type=b,this.context=C}setUniform(d,m,b,C,E){const I=C.constantOr(this.value);m.set(d,E,I instanceof Ur?I.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):I)}getBinding(d,m){return this.type==="color"?new S2(d):new Hl(d)}}class jb{constructor(d,m){this.uniformNames=m.map(b=>`u_${b}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(d,m){this.pixelRatio=d.pixelRatio||1,this.pattern=d.tl.concat(d.br),this.patternTransition=m?m.tl.concat(m.br):this.pattern}setUniform(d,m,b,C,E){let I=null;E!=="u_pattern"&&E!=="u_dash"||(I=this.pattern),E==="u_pattern_b"&&(I=this.patternTransition),E==="u_pixel_ratio"&&(I=this.pixelRatio),I&&m.set(d,E,I)}getBinding(d,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new WC(d):new Hl(d)}}class hg{constructor(d,m,b,C){this.expression=d,this.type=b,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:b==="color"?2:1,offset:0})),this.paintVertexArray=new C}populatePaintArray(d,m,b,C,E,I,R,q){const W=this.paintVertexArray.length,te=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Zi(0,{brightness:I,worldview:q}),m,{},E,C,R):this.expression.kind==="constant"&&this.expression.value,se=M2(this.lutExpression,m,{},C,E,I,R,q);this.paintVertexArray.resize(d),this._setPaintValue(W,d,te,se?null:this.context.lut)}updatePaintArray(d,m,b,C,E,I,R,q){const W=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:R,worldview:q},b,C,void 0,E):this.expression.kind==="constant"&&this.expression.value,te=M2(this.lutExpression,b,C,E,void 0,R,void 0,q);this._setPaintValue(d,m,W,te?null:this.context.lut)}_setPaintValue(d,m,b,C){if(this.type==="color"){const E=Z6(b.toPremultipliedRenderColor(C));for(let I=d;I`u_${R}_t`),this.type=b,this.useIntegerZoom=C,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(R=>({name:`a_${R}`,type:"Float32",components:b==="color"?4:2,offset:0})),this.paintVertexArray=new I}populatePaintArray(d,m,b,C,E,I,R,q){const W=this.expression.evaluate(new Zi(this.context.zoom,{brightness:I,worldview:q}),m,{},E,C,R),te=this.expression.evaluate(new Zi(this.context.zoom+1,{brightness:I,worldview:q}),m,{},E,C,R),se=M2(this.lutExpression,m,{},C,E,I,R,q),ie=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ie,d,W,te,se?null:this.context.lut)}updatePaintArray(d,m,b,C,E,I,R,q){const W=this.expression.evaluate({zoom:this.context.zoom,brightness:R,worldview:q},b,C,void 0,E),te=this.expression.evaluate({zoom:this.context.zoom+1,brightness:R,worldview:q},b,C,void 0,E),se=M2(this.lutExpression,b,C,E,void 0,R,void 0,q);this._setPaintValue(d,m,W,te,se?null:this.context.lut)}_setPaintValue(d,m,b,C,E){if(this.type==="color"){const I=Z6(b.toPremultipliedRenderColor(E)),R=Z6(b.toPremultipliedRenderColor(E));for(let q=d;q!0){this.binders={},this._buffers=[],this.context=m;const C=[];for(const E in d.paint._values){const I=d.paint.get(E);if(E.endsWith("-use-theme")||!b(E)||!(I instanceof hv&&f2(I.property.specification)))continue;const R=upe(E,d.type),q=I.value,W=I.property.specification.type,te=!!I.property.useIntegerZoom,se=E==="line-dasharray"||E.endsWith("pattern"),ie=d.paint.get(`${E}-use-theme`),de=E==="line-dasharray"&&d.layout.get("line-cap").value.kind!=="constant"||ie&&ie.value.kind!=="constant";if(q.kind!=="constant"||de)if(q.kind==="source"||de||se){const he=Y6(E,W,"source");this.binders[E]=se?new pg(q,R,W,he,d.id):new hg(q,R,W,he),C.push(`/a_${E}`)}else{const he=Y6(E,W,"composite");this.binders[E]=new mg(q,R,W,te,m,he),C.push(`/z_${E}`)}else this.binders[E]=se?new jb(q.value,R):new T2(q.value,R,W,m),C.push(`/u_${E}`);ie&&(this.binders[E].lutExpression=ie.value)}this.cacheKey=C.sort().join("")}getMaxValue(d){const m=this.binders[d];return m instanceof hg||m instanceof mg?m.maxValue:0}populatePaintArrays(d,m,b,C,E,I,R,q){for(const W in this.binders){const te=this.binders[W];te.context=this.context,(te instanceof hg||te instanceof mg||te instanceof pg)&&te.populatePaintArray(d,m,b,C,E,I,R,q)}}setConstantPatternPositions(d,m){for(const b in this.binders){const C=this.binders[b];C instanceof jb&&C.setConstantPatternPositions(d,m)}}getPatternTransitionVertexBuffer(d){const m=this.binders[d];return m instanceof pg?m.paintTransitionVertexBuffer:null}updatePaintArrays(d,m,b,C,E,I,R,q,W,te){let se=!1;const ie=Object.keys(d),de=ie.length!==0&&!q,he=de?ie:m.uniqueIds;this.context.lut=E.lut;for(const Ce in this.binders){const Fe=this.binders[Ce];if(Fe.context=this.context,(Fe instanceof hg||Fe instanceof mg||Fe instanceof pg)&&Fe.expression&&Fe.expression.kind&&Fe.expression.kind!=="constant"&&(Fe.expression.isStateDependent===!0||Fe.expression.isLightConstant===!1)){const Re=E.paint.get(Ce);Fe.expression=Re.value;for(const Ke of he){const Xe=d[Ke.toString()];m.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,I,R,W,te)})}if(!de)for(const Ke of b.uniqueIds){const Xe=d[Ke.toString()];b.eachPosition(Ke,(lt,kt,vt)=>{const At=C.feature(lt);Fe.updatePaintArray(kt,vt,At,Xe,I,R,W,te)})}se=!0}}return se}defines(){const d=[];for(const m in this.binders){const b=this.binders[m];(b instanceof T2||b instanceof jb)&&d.push(...b.uniformNames.map(C=>`#define HAS_UNIFORM_${C}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const m=[];for(const b in this.binders){const C=this.binders[b];if(C instanceof T2||C instanceof jb||C instanceof mg)for(const E of C.uniformNames)m.push({name:E,property:b,binding:C.getBinding(d,E)})}return m}setUniforms(d,m,b,C,E){for(const{name:I,property:R,binding:q}of b)this.binders[R].setUniform(d,q,E,C.get(R),I)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const m=this.binders[d];(m instanceof hg||m instanceof mg||m instanceof pg)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof pg&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(d){for(const m in this.binders){const b=this.binders[m];(b instanceof hg||b instanceof mg||b instanceof pg)&&b.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const m=this.binders[d];(m instanceof hg||m instanceof mg||m instanceof pg)&&m.destroy()}}}class qp{constructor(d,m,b=()=>!0){this.programConfigurations={};for(const C of d)this.programConfigurations[C.id]=new Ry(C,m,b);this.needsUpload=!1,this._featureMap=new N2,this._featureMapWithoutIds=new N2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,m,b,C,E,I,R,q,W){for(const te in this.programConfigurations)this.programConfigurations[te].populatePaintArrays(d,m,C,E,I,R,q,W);m.id!==void 0?this._featureMap.add(m.id,b,this._bufferOffset,d):(this._featureMapWithoutIds.add(this._idlessCounter,b,this._bufferOffset,d),this._idlessCounter+=1),this._bufferOffset=d,this.needsUpload=!0}updatePaintArrays(d,m,b,C,E,I,R,q){for(const W of b)this.needsUpload=this.programConfigurations[W.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,m,W,C,E,I,R||0,q)||this.needsUpload}get(d){return this.programConfigurations[d]}upload(d){if(this.needsUpload){for(const m in this.programConfigurations)this.programConfigurations[m].upload(d);this.needsUpload=!1}}destroy(){for(const d in this.programConfigurations)this.programConfigurations[d].destroy()}}const dpe={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function upe(x,d){return dpe[x]||[x.replace(`${d}-`,"").replace(/-/g,"_")]}const hpe={"line-pattern":{source:mh,composite:mh},"fill-pattern":{source:mh,composite:mh},"fill-extrusion-pattern":{source:mh,composite:mh},"line-dasharray":{source:gv,composite:gv}},mpe={color:{source:Wf,composite:Dy},number:{source:dg,composite:Wf}};function Y6(x,d,m){const b=hpe[x];return b&&b[m]||mpe[d][m]}kr(T2,"ConstantBinder"),kr(jb,"PatternConstantBinder"),kr(hg,"SourceExpressionBinder"),kr(pg,"PatternCompositeBinder"),kr(mg,"CompositeExpressionBinder"),kr(Ry,"ProgramConfiguration",{omit:["_buffers"]}),kr(qp,"ProgramConfigurationSet");const Ud=tr/Math.PI/2,sp=5,YC=6,ppe=16383,Nb=64,Q6=[Nb,32,16],rp=-Ud,np=Ud;function vv(x,d,m,b=Ud){return m=jr(m),[x*Math.sin(m)*b,-d*b,x*Math.cos(m)*b]}function kb(x,d,m){return vv(Math.cos(jr(x)),Math.sin(jr(x)),d,m)}const T=63710088e-1,h=2*Math.PI*T;class y{constructor(d,m){if(isNaN(d)||isNaN(m))throw new Error(`Invalid LngLat object: (${d}, ${m})`);if(this.lng=+d,this.lat=+m,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new y(Ye(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(d){const m=Math.PI/180,b=this.lat*m,C=d.lat*m,E=Math.sin(b)*Math.sin(C)+Math.cos(b)*Math.cos(C)*Math.cos((d.lng-this.lng)*m);return T*Math.acos(Math.min(E,1))}toBounds(d=0){const m=360*d/40075017,b=m/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-b,lat:this.lat-m},{lng:this.lng+b,lat:this.lat+m})}toEcef(d){return kb(this.lat,this.lng,Ud+d*Ud/T)}static convert(d){if(d instanceof y)return d;if(Array.isArray(d)&&(d.length===2||d.length===3))return new y(Number(d[0]),Number(d[1]));if(!Array.isArray(d)&&typeof d=="object"&&d!==null)return new y(Number("lng"in d?d.lng:d.lon),Number(d.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class A{constructor(d,m){d&&(m?this.setSouthWest(d).setNorthEast(m):Array.isArray(d)&&d.length===4?this.setSouthWest([d[0],d[1]]).setNorthEast([d[2],d[3]]):this.setSouthWest(d[0]).setNorthEast(d[1]))}setNorthEast(d){return this._ne=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}setSouthWest(d){return this._sw=d instanceof y?new y(d.lng,d.lat):y.convert(d),this}extend(d){const m=this._sw,b=this._ne;let C,E;if(d instanceof y)C=d,E=d;else{if(!(d instanceof A))return Array.isArray(d)?d.length===4||d.every(Array.isArray)?this.extend(A.convert(d)):this.extend(y.convert(d)):typeof d=="object"&&d!==null&&d.hasOwnProperty("lat")&&(d.hasOwnProperty("lon")||d.hasOwnProperty("lng"))?this.extend(y.convert(d)):this;if(C=d._sw,E=d._ne,!C||!E)return this}return m||b?(m.lng=Math.min(C.lng,m.lng),m.lat=Math.min(C.lat,m.lat),b.lng=Math.max(E.lng,b.lng),b.lat=Math.max(E.lat,b.lat)):(this._sw=new y(C.lng,C.lat),this._ne=new y(E.lng,E.lat)),this}getCenter(){return new y((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new y(this.getWest(),this.getNorth())}getSouthEast(){return new y(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(d){const{lng:m,lat:b}=y.convert(d);let C=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(C=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&C}static convert(d){if(d)return d instanceof A?d:new A(d)}}const D=0,F=25.5;function z(x){return h*Math.cos(x*Math.PI/180)}function G(x){return(180+x)/360}function J(x){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+x*Math.PI/360)))/360}function ae(x,d){return x/z(d)}function le(x){return 360*x-180}function je(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function ve(x,d){return x*z(je(d))}const Ne=85.051129;function De(x){return Math.cos(jr(Se(x,-Ne,Ne)))}function Pe(x,d){const m=Se(d,D,F),b=Math.pow(2,m);return De(x)*h/(512*b)}function We(x){return 1/Math.cos(x*Math.PI/180)}function Ve(x,d=0){const m=Math.exp(Math.PI*(1-(x.y+d/tr)/(1<=q?(ut(x,d,m,W,te,E,se,R,q),ut(x,W,te,b,C,se,I,R,q)):x.push(I)}function ot(x,d,m){let b=x[0],C=b.x,E=b.y;d(b);const I=[b];for(let R=1;Rx.x+1||bx.y+1)&&xr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Ot(x,d,m){const b=x.loadGeometry(),C=x.extent,E=tr/C;if(d&&m&&m.projection.isReprojectedInTileSpace){const I=1<{const de=le((d.x+ie.x/C)/I),he=je((d.y+ie.y/C)/I),Ce=te.project(de,he);ie.x=(Ce.x*R-q)*C,ie.y=(Ce.y*R-W)*C};for(let ie=0;ie=C||he.y<0||he.y>=C||(se(he),de.push(he));b[ie]=de}}for(const I of b)for(const R of I)yt(R,E);return b}function Gt(x,d){return{type:x.type,id:x.id,properties:x.properties,geometry:d?Ot(x):[]}}class Ht{constructor(d,m,b,C,E){this.properties={},this.extent=b,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=C,this._values=E,d.readFields(es,this,m)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos,b=[];let C,E=1,I=0,R=0,q=0;for(;d.pos>3}if(I--,E===1||E===2)R+=d.readSVarint(),q+=d.readSVarint(),E===1&&(C&&b.push(C),C=[]),C&&C.push(new ft(R,q));else{if(E!==7)throw new Error(`unknown command ${E}`);C&&C.push(C[0].clone())}}return C&&b.push(C),b}bbox(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos;let b=1,C=0,E=0,I=0,R=1/0,q=-1/0,W=1/0,te=-1/0;for(;d.pos>3}if(C--,b===1||b===2)E+=d.readSVarint(),I+=d.readSVarint(),Eq&&(q=E),Ite&&(te=I);else if(b!==7)throw new Error(`unknown command ${b}`)}return[R,W,q,te]}toGeoJSON(d,m,b){const C=this.extent*Math.pow(2,b),E=this.extent*d,I=this.extent*m,R=this.loadGeometry();function q(ie){return[360*(ie.x+E)/C-180,360/Math.PI*Math.atan(Math.exp((1-2*(ie.y+I)/C)*Math.PI))-90]}function W(ie){return ie.map(q)}let te;if(this.type===1){const ie=[];for(const he of R)ie.push(he[0]);const de=W(ie);te=ie.length===1?{type:"Point",coordinates:de[0]}:{type:"MultiPoint",coordinates:de}}else if(this.type===2){const ie=R.map(W);te=ie.length===1?{type:"LineString",coordinates:ie[0]}:{type:"MultiLineString",coordinates:ie}}else{if(this.type!==3)throw new Error("unknown feature type");{const ie=function(he){const Ce=he.length;if(Ce<=1)return[he];const Fe=[];let Re,Ke;for(let Xe=0;Xe=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[d];const m=this._pbf.readVarint()+this._pbf.pos;return new Ht(this._pbf,m,this.extent,this._keys,this._values)}}function Us(x,d,m){x===15?d.version=m.readVarint():x===1?d.name=m.readString():x===5?d.extent=m.readVarint():x===2?d._features.push(m.pos):x===3?d._keys.push(m.readString()):x===4&&d._values.push(function(b){let C=null;const E=b.readVarint()+b.pos;for(;b.pos>3;C=I===1?b.readString():I===2?b.readFloat():I===3?b.readDouble():I===4?b.readVarint64():I===5?b.readVarint():I===6?b.readSVarint():I===7?b.readBoolean():null}if(C==null)throw new Error("unknown feature value");return C}(m))}class Yt{constructor(d,m){this.layers=d.readFields(Bt,{},m)}}function Bt(x,d,m){if(x===3){const b=new gs(m,m.readVarint()+m.pos);b.length&&(d[b.name]=b)}}const as="3d_elevation_id",Jt="level";class Ls{constructor(){this._valid=!1}reset(d){return this.feature=d,this._valid=!0,this._geometry=d.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(d,m){return this._valid&&d(m(this._geometry)),this}require(d,m,b){return this.get(d,!0,m,b)}optional(d,m,b){return this.get(d,!1,m,b)}success(){return this._valid}get(d,m,b,C){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?b(C?C(E):E):m&&(this._valid=!1),this}}class rr{constructor(d,m){this.featureFunc=d,this.vertexFunc=m}parseFeature(d,m,b){return this.featureFunc(d,m,b)}parseVertex(d,m,b){return this.vertexFunc(d,m,b)}}const yr=new rr((x,d,m)=>x.reset(d).require(as,b=>{m.id=b}).optional("fixed_height_relative",b=>{m.constantHeight=b},Vs.decodeRelativeHeight).geometry(b=>{m.bounds=b},ng).success(),(x,d,m)=>x.reset(d).require(as,b=>{m.id=b}).require("elevation_idx",b=>{m.idx=b}).require("extent",b=>{m.extent=b}).require("height_relative",b=>{m.height=b},Vs.decodeRelativeHeight).geometry(b=>{m.position=b},Vs.getPoint).success()),Js=new rr((x,d,m)=>x.reset(d).require(as,b=>{m.id=b}).optional("fixed_height",b=>{m.constantHeight=b},Vs.decodeMetricHeight).geometry(b=>{m.bounds=b},ng).success(),(x,d,m)=>x.reset(d).require(as,b=>{m.id=b}).require("elevation_idx",b=>{m.idx=b}).require("extent",b=>{m.extent=b}).require("height",b=>{m.height=b},Vs.decodeMetricHeight).geometry(b=>{m.position=b},Vs.getPoint).success());class Vs{static getPoint(d){return xt(d[0][0].x,d[0][0].y)}static decodeRelativeHeight(d){return 1e-4*d*5}static decodeMetricHeight(d){return 1e-4*d}static getVersionSchema(d){return d?d==="1.0.1"?Js:void 0:yr}static parse(d){const m=[],b=[],C=d.length,E=new Ls;for(let I=0;I=0);if(E===0)return 0;E!==d.length&&(m=!1)}return m?2:1}function In(x,d){for(const m of x.projections){const b=br(d,x.points[0],m.axis);if(m.projection[1]b[1])return 0}return 1}function ja(x,d){let m=0;const b=[0,0,0,0];for(let I=0;I=0&&m++;var C,E;return m}class ai{constructor(d,m){this.points=d||new Array(8).fill([0,0,0]),this.planes=m||new Array(6).fill([0,0,0,0]),this.bounds=Rr.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ae([],this.points[2],this.points[3]),Ae([],this.points[0],this.points[3]),Ae([],this.points[4],this.points[0]),Ae([],this.points[5],this.points[1]),Ae([],this.points[6],this.points[2]),Ae([],this.points[7],this.points[3])];for(const b of this.frustumEdges){const C=[0,-b[2],b[1]],E=[b[2],0,-b[0]];this.projections.push({axis:C,projection:br(this.points,this.points[0],C)}),this.projections.push({axis:E,projection:br(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,m,b,C){const E=Math.pow(2,b),I=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(W=>{const te=Je([],W,d),se=1/te[3]/m*E;return(ie=te)[0]=(de=te)[0]*(he=[se,se,C?1/te[3]:se,se])[0],ie[1]=de[1]*he[1],ie[2]=de[2]*he[2],ie[3]=de[3]*he[3],ie;var ie,de,he}),R=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(W=>{const te=we([],Qe([],Ae([],I[W[0]],I[W[1]]),Ae([],I[W[2]],I[W[1]]))),se=-Le(te,I[W[1]]);return te.concat(se)}),q=[];for(let W=0;WW[1]||W[0]>q[1])return 0}return 1}containsPoint(d){for(const m of this.planes){const b=m[3];if(Le([m[0],m[1],m[2]],d)+b<0)return!1}return!0}}class Rr{static fromPoints(d){const m=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];for(const C of d)ue(m,m,C),xe(b,b,C);return new Rr(m,b)}static fromTileIdAndHeight(d,m,b){const C=1<d.max[m]||d.min[m]>this.max[m])return!1;return!0}intersectsAabbXY(d){return!(this.min[0]>d.max[0]||d.min[0]>this.max[0]||this.min[1]>d.max[1]||d.min[1]>this.max[1])}encapsulate(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d.min[m]),this.max[m]=Math.max(this.max[m],d.max[m])}encapsulatePoint(d){for(let m=0;m<3;m++)this.min[m]=Math.min(this.min[m],d[m]),this.max[m]=Math.max(this.max[m],d[m])}closestPoint(d){return[Math.max(Math.min(this.max[0],d[0]),this.min[0]),Math.max(Math.min(this.max[1],d[1]),this.min[1]),Math.max(Math.min(this.max[2],d[2]),this.min[2])]}}kr(Rr,"Aabb");class Xa{constructor(d,m){this.feature=d,this.metersToTile=m,this.index=0}get(){const d=this.feature.vertices[this.index],m=this.feature.vertexProps[this.index].dir,b=m[1],C=-m[0],E=(d.extent+1)*this.metersToTile;return[new ft(Math.trunc(d.position[0]+b*E),Math.trunc(d.position[1]+C*E)),new ft(Math.trunc(d.position[0]-b*E),Math.trunc(d.position[1]-C*E))]}next(){this.index++}valid(){return this.index{return R.a0?_e(q,q,1/W):re(q,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(d){if(this.edges.length===0)return;let m=0,b=Number.POSITIVE_INFINITY,C=0;const[E,I,R,q,W,te,se]=this._tmpVec2;Ps(se,d.x,d.y);const ie=new Ir(se,null);for(let de=0;de0?Ia(q,R)/lt:0,vt=Se(kt,0,1),At=Math.abs((kt-vt)*this.edgeProps[de].len);Tr(W,se,Fe),Ps(te,Ce[1],-Ce[0]);const zt=At+Math.abs(Ia(W,te));zt=0;--I){const R=this.edges[I].a,q=this.edges[I].b,{position:W,height:te,extent:se}=this.vertices[R],{position:ie,height:de,extent:he}=this.vertices[q],Ce=this.vertexProps[R].dir,Fe=this.vertexProps[q].dir;if(re(m,W[0]/d,W[1]/d,te),re(b,ie[0]/d,ie[1]/d,de),re(C,Ce[1],-Ce[0],0),_e(C,C,se),re(E,Fe[1],-Fe[0],0),_e(E,E,he),this.distSqLines(ne(m[0]+.5*C[0],m[1]+.5*C[1],m[2]+.5*C[2]),ne(b[0]-.5*E[0],b[1]-.5*E[1],b[2]-.5*E[2]),ne(m[0]-.5*C[0],m[1]-.5*C[1],m[2]-.5*C[2]),ne(b[0]+.5*E[0],b[1]+.5*E[1],b[2]+.5*E[2]))<=.0025000000000000005)continue;const Re=this.vertices.length,Ke=mr(er(),W,ie);this.vertices.push({position:Dr(Ke,Ke,.5),height:.5*(te+de),extent:.5*(se+he)});const Xe=mr(er(),Ce,Fe);this.vertexProps.push({dir:Si(Xe,Xe)}),this.edges.splice(I,1),this.edgeProps.splice(I,1),this.edges.push({a:R,b:Re}),this.edges.push({a:Re,b:q});const lt=Tr(er(),this.vertices[Re].position,W),kt=xn(lt),vt={vec:lt,dir:Dr(er(),lt,1/kt),len:kt};this.edgeProps.push(vt),this.edgeProps.push(vt)}}distSqLines(d,m,b,C){const E=fe(ee(),m,d),I=fe(ee(),C,b),R=fe(ee(),d,b),q=Le(E,E),W=Le(E,I),te=Le(E,R),se=Le(I,I),ie=Le(I,R),de=q*se-W*W;if(de===0)return Ie(Te(E,b,C,Le(R,I)/Le(I,I)),d);const he=(q*ie-W*te)/de;return Ie(Te(E,d,m,(W*ie-te*se)/de),Te(I,b,C,he))}}class ui{static parseFrom(d,m){const b=Vs.parse(d);if(!b)return[];let{vertices:C,features:E}=b;const I=1/Ve(m);E.sort((te,se)=>te.id-se.id),C.sort((te,se)=>te.id-se.id||te.idx-se.idx),C=C.filter((te,se,ie)=>se===ie.findIndex(de=>de.id===te.id&&de.idx===te.idx));const R=new Array;let q=0;const W=C.length;for(const te of E){if(te.constantHeight){R.push(new Tn(te.id,te.bounds,te.constantHeight));continue}for(;q!==W&&C[q].idC.id===b)}}class Mi{constructor(d,m){this.zScale=1,this.xOffset=0,this.yOffset=0,d.equals(m)||(this.zScale=Math.pow(2,m.z-d.z),this.xOffset=(d.x*this.zScale-m.x)*tr,this.yOffset=(d.y*this.zScale-m.y)*tr)}constantElevation(d,m){if(d.constantHeight!=null)return this.computeBiasedHeight(d.constantHeight,m)}pointElevation(d,m,b){const C=this.constantElevation(m,b);return C??(d.x=d.x*this.zScale+this.xOffset,d.y=d.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(d),b))}computeBiasedHeight(d,m){return m<=0?d:d+m*Be(0,m,d>=0?d:Math.abs(.5*d))}}kr(Tn,"ElevationFeature");class _i{constructor(d){this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.projection=d.projection,this.layoutVertexArray=new Ly,this.indexArray=new Vl,this.segments=new wo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new dg),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,b,C){}populate(d,m,b,C){const E=this.layers[0],I=[];let R=null;E.type==="circle"&&(R=E.layout.get("circle-sort-key"));for(const{feature:W,id:te,index:se,sourceLayerIndex:ie}of d){const de=this.layers[0]._featureFilter.needGeometry,he=Gt(W,de);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),he,b))continue;const Ce=R?R.evaluate(he,{},b):void 0,Fe={id:te,properties:W.properties,type:W.type,sourceLayerIndex:ie,index:se,geometry:de?he.geometry:Ot(W,b,C),patterns:{},sortKey:Ce};I.push(Fe)}R&&I.sort((W,te)=>W.sortKey-te.sortKey);let q=null;C.projection.name==="globe"&&(this.globeExtVertexArray=new IC,q=C.projection);for(const W of I){const{geometry:te,index:se,sourceLayerIndex:ie}=W,de=d[se].feature;this.addFeature(W,te,se,m.availableImages,b,q,m.brightness,m.elevationFeatures),m.featureIndex.insert(de,te,se,ie,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,m,b,C,E,I,R){this.programConfigurations.updatePaintArrays(d,m,E,b,C,I,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,DF.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,OF.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,npe.members))),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(d,m,b,C,E,I,R,q){let W;this.elevationMode!=="none"&&(W=ui.getElevationFeature(d,q));for(const te of m)for(const se of te){const ie=se.x,de=se.y;if(ie<0||ie>=tr||de<0||de>=tr)continue;if(I){const Fe=I.projectTilePoint(ie,de,E),Re=I.upVector(E,ie,de);this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re),this.addGlobeExtVertex(Fe,Re)}const he=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),Ce=he.vertexLength;if(this.addCircleVertex(ie,de,-1,-1),this.addCircleVertex(ie,de,1,-1),this.addCircleVertex(ie,de,1,1),this.addCircleVertex(ie,de,-1,1),this.elevationMode!=="none"){const Fe=W?W.pointElevation(new ft(ie,de)):0;this.hasElevation=this.hasElevation||Fe!==0;for(let Re=0;Re<4;Re++)this.elevatedLayoutVertexArray.emplaceBack(Fe)}this.indexArray.emplaceBack(Ce,Ce+1,Ce+2),this.indexArray.emplaceBack(Ce,Ce+2,Ce+3),he.vertexLength+=4,he.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,b,{},C,E,R,void 0,this.worldview)}addCircleVertex(d,m,b,C){this.layoutVertexArray.emplaceBack(2*d+(b+1)/2,2*m+(C+1)/2)}addGlobeExtVertex(d,m){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Za(x,d){for(let m=0;m1){if(no(x,d))return!0;for(let b=0;b1?m:m.sub(d)._mult(C)._add(d))}function jo(x,d){let m,b,C,E=!1;for(let I=0;Id.y!=C.y>d.y&&d.x<(C.x-b.x)*(d.y-b.y)/(C.y-b.y)+b.x&&(E=!E)}return E}function Di(x,d){let m=!1;for(let b=0,C=x.length-1;bd.y!=I.y>d.y&&d.x<(I.x-E.x)*(d.y-E.y)/(I.y-E.y)+E.x&&(m=!m)}return m}function qu(x,d,m,b,C){for(const I of x)if(d<=I.x&&m<=I.y&&b>=I.x&&C>=I.y)return!0;const E=[new ft(d,m),new ft(d,C),new ft(b,C),new ft(b,m)];if(x.length>2){for(const I of E)if(Di(x,I))return!0}for(let I=0;IC.x&&d.x>C.x||x.yC.y&&d.y>C.y)return!1;const E=On(x,d,m[0]);return E!==On(x,d,m[1])||E!==On(x,d,m[2])||E!==On(x,d,m[3])}function Gl(x,d,m,b,C,E){let I=d.y-x.y,R=x.x-d.x;if(E=E||0){const q=I*I+R*R;if(q===0)return!0;const W=Math.sqrt(q);I/=W,R/=W}return!((m.x-x.x)*I+(m.y-x.y)*R-E<0||(b.x-x.x)*I+(b.y-x.y)*R-E<0||(C.x-x.x)*I+(C.y-x.y)*R-E<0)}function Vd(x,d,m,b,C,E,I){return!(Gl(x,d,b,C,E,I)||Gl(d,m,b,C,E,I)||Gl(m,x,b,C,E,I)||Gl(b,C,x,d,m,I)||Gl(C,E,x,d,m,I)||Gl(E,b,x,d,m,I))}function Hd(x,d,m){const b=d.paint.get(x).value;return b.kind==="constant"?b.value:m.programConfigurations.get(d.id).getMaxValue(x)}function ld(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function mm(x,d,m,b,C){if(!d[0]&&!d[1])return x;const E=ft.convert(d)._mult(C);m==="viewport"&&E._rotate(-b);const I=[];for(let R=0;R>m&&d.y===this.y>>m}url(d,m){const b=function(E,I,R){var q=tl(256*E,256*(I=Math.pow(2,R)-I-1),R),W=tl(256*(E+1),256*(I+1),R);return q[0]+","+q[1]+","+W[0]+","+W[1]}(this.x,this.y,this.z),C=function(E,I,R){let q,W="";for(let te=E;te>0;te--)q=1<this.canonical.z?new Mo(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Mo(d,this.wrap,d,this.canonical.x>>m,this.canonical.y>>m)}calculateScaledKey(d,m=!0){if(this.overscaledZ===d&&m)return this.key;if(d>this.canonical.z)return No(this.wrap*+m,d,this.canonical.z,this.canonical.x,this.canonical.y);{const b=this.canonical.z-d;return No(this.wrap*+m,d,d,this.canonical.x>>b,this.canonical.y>>b)}}isChildOf(d){if(d.wrap!==this.wrap)return!1;const m=this.canonical.z-d.canonical.z;return d.overscaledZ===0||d.overscaledZ>m&&d.canonical.y===this.canonical.y>>m}children(d){if(this.overscaledZ>=d)return[new Mo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,b=2*this.canonical.x,C=2*this.canonical.y;return[new Mo(m,this.wrap,m,b,C),new Mo(m,this.wrap,m,b+1,C),new Mo(m,this.wrap,m,b,C+1),new Mo(m,this.wrap,m,b+1,C+1)]}isLessThan(d){return this.wrapd.wrap)&&(this.overscaledZd.overscaledZ)&&(this.canonical.xd.canonical.x)&&this.canonical.y{let d=x.canonical.x-1,m=x.wrap;return d<0&&(d=(1<{let d=x.canonical.x+1,m=x.wrap;return d===1<new Mo(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new Mo(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(b,C,E,I){const R=Math.sin(E);return b*(Math.sin((1-I)*E)/R)+C*(Math.sin(I*E)/R)}(x.a[d],x.b[d],x.angle,Se(m,0,1))+x.center[d]}function Vp(x){if(x.z<=1)return fg[x.z+2*x.y+x.x];const d=fpe(RF(x));return Rr.fromPoints(d)}function gg(x,d,m){return _e(x,x,1-m),$e(x,x,d,m)}function I3e(x,d,m){for(const b of x)pt(b,b,d),_e(b,b,m)}function L3e(x,d,m,b){const C=d/x.worldSize,E=x.globeMatrix;if(m.z<=1){const qt=Vp(m).getCorners();return I3e(qt,E,C),Rr.fromPoints(qt)}const I=RF(m,b),R=fpe(I,Ud+Zf(x._tileCoverLift));I3e(R,E,C);const q=Number.MAX_VALUE,W=[-q,-q,-q],te=[q,q,q];if(I.contains(x.center)){for(const Wt of R)ue(te,te,Wt),xe(W,W,Wt);W[2]=0;const qt=x.point,ss=[qt.x*C,qt.y*C,0];return ue(te,te,ss),xe(W,W,ss),new Rr(te,W)}if(x._tileCoverLift>0){for(const qt of R)ue(te,te,qt),xe(W,W,qt);return new Rr(te,W)}const se=[E[12]*C,E[13]*C,E[14]*C],ie=I.getCenter(),de=Se(x.center.lat,-Ne,Ne),he=Se(ie.lat,-Ne,Ne),Ce=G(x.center.lng),Fe=J(de);let Re=Ce-G(ie.lng);const Ke=Fe-J(he);Re>.5?Re-=1:Re<-.5&&(Re+=1);let Xe=0;Math.abs(Re)>Math.abs(Ke)?Xe=Re>=0?1:3:(Xe=Ke>=0?0:2,$e(se,se,[E[4]*C,E[5]*C,E[6]*C],-Math.sin(jr(Ke>=0?I.getSouth():I.getNorth()))*Ud));const lt=R[Xe],kt=R[(Xe+1)%4],vt=new Fy(lt,kt,se),At=[xg(vt,0)||lt[0],xg(vt,1)||lt[1],xg(vt,2)||lt[2]],zt=Mb(x.zoom);if(zt>0){const qt=function({x:Wt,y:ds,z:ks},Ss,zs,$s,Ds){const Rs=1/(1<.5?Hs=-1:zr<-.5&&(Hs=1),ls=((ls+Hs)*Ss-($s*=Ss))*zs+$s,rs=((rs+Hs)*Ss-$s)*zs+$s,Fs=(Fs*Ss-(Ds*=Ss))*zs+Ds,sr=(sr*Ss-Ds)*zs+Ds,[[ls,sr,0],[rs,sr,0],[rs,Fs,0],[ls,Fs,0]]}(m,d,x._pixelsPerMercatorPixel,Ce,Fe);for(let Wt=0;WtMath.PI/2*1.01}const z3e=jr(85),Xct=Math.cos(z3e),Jct=Math.sin(z3e),edt=_(),B3e=x=>{const d=[];return x.paint.get("circle-pitch-alignment")==="map"&&d.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&d.push("SCALE_WITH_MAP"),d};function $3e(x,d,m,b,C,E,I,R,q){if(E&&x.queryGeometry.isAboveHorizon)return!1;E&&(q*=x.pixelToTileUnitsFactor);const W=x.tileID.canonical,te=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const se of d)for(const ie of se){const de=ie.add(R),he=C&&m.elevation?m.elevation.exaggeration()*C.getElevationAt(de.x,de.y,!0):0,Ce=m.projection.projectTilePoint(de.x,de.y,W);if(he>0){const Xe=m.projection.upVector(W,de.x,de.y);Ce.x+=Xe[0]*te*he,Ce.y+=Xe[1]*te*he,Ce.z+=Xe[2]*te*he}const Fe=E?de:tdt(Ce.x,Ce.y,Ce.z,b),Re=E?x.tilespaceRays.map(Xe=>rdt(Xe,he)):x.queryGeometry.screenGeometry,Ke=Je([],[Ce.x,Ce.y,Ce.z,1],b);if(!I&&E?q*=Ke[3]/m.cameraToCenterDistance:I&&!E&&(q*=m.cameraToCenterDistance/Ke[3]),E){const Xe=je((ie.y/tr+W.y)/(1<x.width||C.height>x.height||m.x>x.width-C.width||m.y>x.height-C.height)throw new RangeError("out of range source coordinates for image copy");if(C.width>d.width||C.height>d.height||b.x>d.width-C.width||b.y>d.height-C.height)throw new RangeError("out of range destination coordinates for image copy");const q=x.data,W=d.data,te=E===4&&R;for(let se=0;se{d[x.evaluationKey]=q;const W=x.expression.evaluate(d),te=W?W.toNonPremultipliedRenderColor(null):null;te&&(C.data[I+R+0]=Math.floor(255*te.r),C.data[I+R+1]=Math.floor(255*te.g),C.data[I+R+2]=Math.floor(255*te.b),C.data[I+R+3]=Math.floor(255*te.a))};if(x.clips)for(let I=0,R=0;I80*m){R=x[0],q=x[1];let te=R,se=q;for(let ie=m;iete&&(te=de),he>se&&(se=he)}W=Math.max(te-R,se-q),W=W!==0?32767/W:0}return eP(E,I,m,R,q,W,0),I}function Q3e(x,d,m,b,C){let E;if(C===function(I,R,q,W){let te=0;for(let se=R,ie=q-W;se0)for(let I=d;I=d;I-=b)E=tCe(I/b|0,x[I],x[I+1],E);return E&&XC(E,E.next)&&(rP(E),E=E.next),E}function P2(x,d){if(!x)return x;d||(d=x);let m,b=x;do if(m=!1,b.steiner||!XC(b,b.next)&&Zc(b.prev,b,b.next)!==0)b=b.next;else{if(rP(b),b=d=b.prev,b===b.next)break;m=!0}while(m||b!==d);return d}function eP(x,d,m,b,C,E,I){if(!x)return;!I&&E&&function(q,W,te,se){let ie=q;do ie.z===0&&(ie.z=bpe(ie.x,ie.y,W,te,se)),ie.prevZ=ie.prev,ie.nextZ=ie.next,ie=ie.next;while(ie!==q);ie.prevZ.nextZ=null,ie.prevZ=null,function(de){let he,Ce=1;do{let Fe,Re=de;de=null;let Ke=null;for(he=0;Re;){he++;let Xe=Re,lt=0;for(let vt=0;vt0||kt>0&&Xe;)lt!==0&&(kt===0||!Xe||Re.z<=Xe.z)?(Fe=Re,Re=Re.nextZ,lt--):(Fe=Xe,Xe=Xe.nextZ,kt--),Ke?Ke.nextZ=Fe:de=Fe,Fe.prevZ=Ke,Ke=Fe;Re=Xe}Ke.nextZ=null,Ce*=2}while(he>1)}(ie)}(x,b,C,E);let R=x;for(;x.prev!==x.next;){const q=x.prev,W=x.next;if(E?cdt(x,b,C,E):ldt(x))d.push(q.i,x.i,W.i),rP(x),x=W.next,R=W.next;else if((x=W)===R){I?I===1?eP(x=ddt(P2(x),d),d,m,b,C,E,2):I===2&&udt(x,d,m,b,C,E):eP(P2(x),d,m,b,C,E,1);break}}}function ldt(x){const d=x.prev,m=x,b=x.next;if(Zc(d,m,b)>=0)return!1;const C=d.x,E=m.x,I=b.x,R=d.y,q=m.y,W=b.y,te=Math.min(C,E,I),se=Math.min(R,q,W),ie=Math.max(C,E,I),de=Math.max(R,q,W);let he=b.next;for(;he!==d;){if(he.x>=te&&he.x<=ie&&he.y>=se&&he.y<=de&&tP(C,R,E,q,I,W,he.x,he.y)&&Zc(he.prev,he,he.next)>=0)return!1;he=he.next}return!0}function cdt(x,d,m,b){const C=x.prev,E=x,I=x.next;if(Zc(C,E,I)>=0)return!1;const R=C.x,q=E.x,W=I.x,te=C.y,se=E.y,ie=I.y,de=Math.min(R,q,W),he=Math.min(te,se,ie),Ce=Math.max(R,q,W),Fe=Math.max(te,se,ie),Re=bpe(de,he,d,m,b),Ke=bpe(Ce,Fe,d,m,b);let Xe=x.prevZ,lt=x.nextZ;for(;Xe&&Xe.z>=Re&<&<.z<=Ke;){if(Xe.x>=de&&Xe.x<=Ce&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==I&&tP(R,te,q,se,W,ie,Xe.x,Xe.y)&&Zc(Xe.prev,Xe,Xe.next)>=0||(Xe=Xe.prevZ,lt.x>=de&<.x<=Ce&<.y>=he&<.y<=Fe&<!==C&<!==I&&tP(R,te,q,se,W,ie,lt.x,lt.y)&&Zc(lt.prev,lt,lt.next)>=0))return!1;lt=lt.nextZ}for(;Xe&&Xe.z>=Re;){if(Xe.x>=de&&Xe.x<=Ce&&Xe.y>=he&&Xe.y<=Fe&&Xe!==C&&Xe!==I&&tP(R,te,q,se,W,ie,Xe.x,Xe.y)&&Zc(Xe.prev,Xe,Xe.next)>=0)return!1;Xe=Xe.prevZ}for(;lt&<.z<=Ke;){if(lt.x>=de&<.x<=Ce&<.y>=he&<.y<=Fe&<!==C&<!==I&&tP(R,te,q,se,W,ie,lt.x,lt.y)&&Zc(lt.prev,lt,lt.next)>=0)return!1;lt=lt.nextZ}return!0}function ddt(x,d){let m=x;do{const b=m.prev,C=m.next.next;!XC(b,C)&&J3e(b,m,m.next,C)&&sP(b,C)&&sP(C,b)&&(d.push(b.i,m.i,C.i),rP(m),rP(m.next),m=x=C),m=m.next}while(m!==x);return P2(m)}function udt(x,d,m,b,C,E){let I=x;do{let R=I.next.next;for(;R!==I.prev;){if(I.i!==R.i&&xdt(I,R)){let q=eCe(I,R);return I=P2(I,I.next),q=P2(q,q.next),eP(I,d,m,b,C,E,0),void eP(q,d,m,b,C,E,0)}R=R.next}I=I.next}while(I!==x)}function hdt(x,d){let m=x.x-d.x;return m===0&&(m=x.y-d.y,m===0)&&(m=(x.next.y-x.y)/(x.next.x-x.x)-(d.next.y-d.y)/(d.next.x-d.x)),m}function mdt(x,d){const m=function(C,E){let I=E;const R=C.x,q=C.y;let W,te=-1/0;if(XC(C,I))return I;do{if(XC(C,I.next))return I.next;if(q<=I.y&&q>=I.next.y&&I.next.y!==I.y){const Ce=I.x+(q-I.y)*(I.next.x-I.x)/(I.next.y-I.y);if(Ce<=R&&Ce>te&&(te=Ce,W=I.x=I.x&&I.x>=ie&&R!==I.x&&X3e(qW.x||I.x===W.x&&pdt(W,I)))&&(W=I,he=Ce)}I=I.next}while(I!==se);return W}(x,d);if(!m)return d;const b=eCe(m,x);return P2(b,b.next),P2(m,m.next)}function pdt(x,d){return Zc(x.prev,x,d.prev)<0&&Zc(d.next,x,x.next)<0}function bpe(x,d,m,b,C){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-m)*C|0)|x<<8))|x<<4))|x<<2))|x<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-b)*C|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function fdt(x){let d=x,m=x;do(d.x=(x-I)*(E-R)&&(x-I)*(b-R)>=(m-I)*(d-R)&&(m-I)*(E-R)>=(C-I)*(b-R)}function tP(x,d,m,b,C,E,I,R){return!(x===I&&d===R)&&X3e(x,d,m,b,C,E,I,R)}function xdt(x,d){return x.next.i!==d.i&&x.prev.i!==d.i&&!function(m,b){let C=m;do{if(C.i!==m.i&&C.next.i!==m.i&&C.i!==b.i&&C.next.i!==b.i&&J3e(C,C.next,m,b))return!0;C=C.next}while(C!==m);return!1}(x,d)&&(sP(x,d)&&sP(d,x)&&function(m,b){let C=m,E=!1;const I=(m.x+b.x)/2,R=(m.y+b.y)/2;do C.y>R!=C.next.y>R&&C.next.y!==C.y&&I<(C.next.x-C.x)*(R-C.y)/(C.next.y-C.y)+C.x&&(E=!E),C=C.next;while(C!==m);return E}(x,d)&&(Zc(x.prev,x,d.prev)||Zc(x,d.prev,d))||XC(x,d)&&Zc(x.prev,x,x.next)>0&&Zc(d.prev,d,d.next)>0)}function Zc(x,d,m){return(d.y-x.y)*(m.x-d.x)-(d.x-x.x)*(m.y-d.y)}function XC(x,d){return x.x===d.x&&x.y===d.y}function J3e(x,d,m,b){const C=$F(Zc(x,d,m)),E=$F(Zc(x,d,b)),I=$F(Zc(m,b,x)),R=$F(Zc(m,b,d));return C!==E&&I!==R||!(C!==0||!BF(x,m,d))||!(E!==0||!BF(x,b,d))||!(I!==0||!BF(m,x,b))||!(R!==0||!BF(m,d,b))}function BF(x,d,m){return d.x<=Math.max(x.x,m.x)&&d.x>=Math.min(x.x,m.x)&&d.y<=Math.max(x.y,m.y)&&d.y>=Math.min(x.y,m.y)}function $F(x){return x>0?1:x<0?-1:0}function sP(x,d){return Zc(x.prev,x,x.next)<0?Zc(x,d,x.next)>=0&&Zc(x,x.prev,d)>=0:Zc(x,d,x.prev)<0||Zc(x,x.next,d)<0}function eCe(x,d){const m=_pe(x.i,x.x,x.y),b=_pe(d.i,d.x,d.y),C=x.next,E=d.prev;return x.next=d,d.prev=x,m.next=C,C.prev=m,b.next=m,m.prev=b,E.next=b,b.prev=E,b}function tCe(x,d,m,b){const C=_pe(x,d,m);return b?(C.next=b.next,C.prev=b,b.next.prev=C,b.next=C):(C.prev=C,C.next=C),C}function rP(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function _pe(x,d,m){return{i:x,x:d,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function nP(x,d){const m=x.length;if(m<=1)return[x];const b=[];let C,E;for(let I=0;I1)for(let I=0;I=tr&&m>=tr}static evaluate(d){if(d.length===0)return new bv;let m=[];for(const q of d)m.push(...q.portals);if(m.length===0)return new bv;for(const q of m){const W=q.va,te=q.vb;(bv.isOnBorder(W.x,te.x)||bv.isOnBorder(W.y,te.y))&&(q.type="border")}const b=m.filter(q=>q.type!=="unevaluated"),C=m.filter(q=>q.type==="unevaluated");if(C.length===0)return new bv;C.sort((q,W)=>q.hash===W.hash?q.isTunnel===W.isTunnel?0:q.isTunnel?-1:1:q.hashq.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new qp(m,{zoom:b,lut:C},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,m){const b=this.unevalVertices.length;for(let C=0;C=E.min.x&&se.x<=E.max.x&&se.y>=E.min.y&&se.y<=E.max.y||ie.x>=E.min.x&&ie.x<=E.max.x&&ie.y>=E.min.y&&ie.y<=E.max.y||Td(se,ie,R))||this.isOnBorder(se.x,ie.x)||this.isOnBorder(se.y,ie.y))continue;const de=pm.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[te]);let he,Ce=this.vertexHashLookup.get(pm.computePosHash(se));Ce!=null?he=Ce.next:(Ce=this.vertexHashLookup.get(pm.computePosHash(ie)),he=Ce!=null?Ce.prev:de),this.unevalEdges.push({polygonIdx:d,a:W,b:te,hash:de,portalHash:he,isTunnel:C,type:"unevaluated",featureInfo:I})}}addPortalCandidates(d,m,b,C,E){if(m.length===0)return;this.portalPolygons.add(d,{geometry:m,zLevel:E});const I=m[0];this.vertexHashLookup.clear();let R=pm.computeEdgeHash(I[I.length-2],I[I.length-1]);for(let q=0;q({vertexOffset:0,primitiveOffset:this.indexArray.length}),b=ie=>{ie.primitiveLength=this.indexArray.length-ie.primitiveOffset},C=new ydt(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=m(),I=m(),R=m(),q=(ie,de)=>{ie.sort((Ce,Fe)=>Ce.type===de&&Fe.type!==de?-1:Ce.type!==de&&Fe.type===de?1:0);const he=ie.findIndex(Ce=>Ce.type!==de);return he>=0?he:ie.length};let W=0;this.unevalEdges.length>0&&(W=q(this.unevalEdges,"none"),this.constructBridgeStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},this.tileToMeters)),b(R);const te=m(),se=m();if(this.unevalEdges.length>0){const ie=this.unevalEdges.splice(W),de=q(ie,"tunnel")+W;this.unevalEdges.push(...ie),this.constructTunnelStructures(C,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:de})}b(te),C.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),b(se),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),b(I),C.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),b(E),this.maskSegments=wo.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=wo.simpleSegment(0,I.primitiveOffset,0,I.primitiveLength),this.renderableBridgeSegments=wo.simpleSegment(0,R.primitiveOffset,0,R.primitiveLength),this.renderableTunnelSegments=wo.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.shadowCasterSegments=wo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,m,b,C,E,I,R,q){this.bridgeProgramConfigurations.updatePaintArrays(d,m,E,b,C,I,R,q),this.tunnelProgramConfigurations.updatePaintArrays(d,m,E,b,C,I,R,q)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,idt.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,odt.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(d),this.tunnelProgramConfigurations.upload(d))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(d,m,b,C,E){const I=(R,q)=>{for(let W=0;Wre(zs,m[$s].x,m[$s].y,b[$s]*q),se=ee(),ie=ee(),de=ee(),he=ee(),Ce=ee(),Fe=(zs,$s)=>{const Ds=R.get(pm.computePosHash(m[$s])),Rs=Ds.from,ls=Ds.to;if(!Rs||!ls)return;te(se,Rs),te(ie,$s),te(de,ls),at(he),tt(se,ie)||(Ae(Ce,ie,se),we(he,Ce)),tt(de,ie)||(Ae(Ce,de,ie),oe(he,he,we(Ce,Ce)));const rs=He(he);return rs>0?_e(zs,he,1/rs):void 0};let Re=Number.POSITIVE_INFINITY;this.sortSubarray(C,E.min,E.max,(zs,$s)=>zs.featureInfo.featureIndex-$s.featureInfo.featureIndex);const Ke=ee(),Xe=ee(),lt=ee(),kt=ee(),vt=ee(),At=ee(),zt=ee(),qt=ee(),ss=ee(),Wt=[ee(),ee(),ee(),ee()],ds=[ee(),ee(),ee(),ee()],ks=[{coord:new ft(0,0),height:0},{coord:new ft(0,0),height:0}],Ss=(zs,$s)=>zs>$s;for(let zs=E.min;zsRe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(C,E.min,E.max,q),this.sortSubarray(C,I.min,I.max,q);const W=Re=>we(Re,Re),te=[{coord:new ft(0,0),height:0},{coord:new ft(0,0),height:0}],se=(Re,Ke)=>ReR.hash===q.hash?q.polygonIdx-R.polygonIdx:q.hash>R.hash?1:-1);let b=0,C=0,E=0,I=m[b].polygonIdx;do C++,(C===m.length||m[b].hash!==m[C].hash)&&((C-b==1||m[C-1].polygonIdx!==I)&&(EW.portalHashte.hash?R++:te.hash>W.portalHash?q++:(W.type=te.type,R++)}}}isOnBorder(d,m){return d<=0&&m<=0||d>=tr&&m>=tr}addFeatureSection(d,m,b,C){return d!==m&&(m=d,b.push({featureIndex:d,vertexStart:C.getVertexCount()}),C.clearVertexLookup()),m}sortSubarray(d,m,b,C){const E=d.slice(m,b);E.sort(C),d.splice(m,E.length,...E)}static computeEdgeHash(d,m){return(d.y===m.y&&d.x>m.x||d.y>m.y)&&([d,m]=[m,d]),BigInt(pm.computePosHash(d))<<32n|BigInt(pm.computePosHash(m))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var nCe,aCe={exports:{}},iCe=(nCe||(nCe=1,function(x){function d(_t,Ct){return _t>Ct?1:_t0){var Br=Bs+Math.floor(dr/2),Vr={key:Ct[Br],data:us[Br],parent:_t};return Vr.left=C(Vr,Ct,us,Bs,Br),Vr.right=C(Vr,Ct,us,Br+1,cr),Vr}return null}function E(_t,Ct,us,Bs,cr){if(!(us>=Bs)){for(var dr=_t[us+Bs>>1],Br=us-1,Vr=Bs+1;;){do Br++;while(cr(_t[Br],dr)<0);do Vr--;while(cr(_t[Vr],dr)>0);if(Br>=Vr)break;var Ln=_t[Br];_t[Br]=_t[Vr],_t[Vr]=Ln,Ln=Ct[Br],Ct[Br]=Ct[Vr],Ct[Vr]=Ln}E(_t,Ct,us,Vr,cr),E(_t,Ct,Vr+1,Bs,cr)}}m.prototype.rotateLeft=function(_t){var Ct=_t.right;Ct&&(_t.right=Ct.left,Ct.left&&(Ct.left.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.left=_t),_t.parent=Ct},m.prototype.rotateRight=function(_t){var Ct=_t.left;Ct&&(_t.left=Ct.right,Ct.right&&(Ct.right.parent=_t),Ct.parent=_t.parent),_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.right=_t),_t.parent=Ct},m.prototype._splay=function(_t){for(;_t.parent;){var Ct=_t.parent;Ct.parent?Ct.left===_t&&Ct.parent.left===Ct?(this.rotateRight(Ct.parent),this.rotateRight(Ct)):Ct.right===_t&&Ct.parent.right===Ct?(this.rotateLeft(Ct.parent),this.rotateLeft(Ct)):Ct.left===_t&&Ct.parent.right===Ct?(this.rotateRight(Ct),this.rotateLeft(Ct)):(this.rotateLeft(Ct),this.rotateRight(Ct)):Ct.left===_t?this.rotateRight(Ct):this.rotateLeft(Ct)}},m.prototype.splay=function(_t){for(var Ct,us,Bs,cr,dr;_t.parent;)(us=(Ct=_t.parent).parent)&&us.parent?((Bs=us.parent).left===us?Bs.left=_t:Bs.right=_t,_t.parent=Bs):(_t.parent=null,this._root=_t),cr=_t.left,dr=_t.right,_t===Ct.left?(us&&(us.left===Ct?(Ct.right?(us.left=Ct.right,us.left.parent=us):us.left=null,Ct.right=us,us.parent=Ct):(cr?(us.right=cr,cr.parent=us):us.right=null,_t.left=us,us.parent=_t)),dr?(Ct.left=dr,dr.parent=Ct):Ct.left=null,_t.right=Ct,Ct.parent=_t):(us&&(us.right===Ct?(Ct.left?(us.right=Ct.left,us.right.parent=us):us.right=null,Ct.left=us,us.parent=Ct):(dr?(us.left=dr,dr.parent=us):us.left=null,_t.right=us,us.parent=_t)),cr?(Ct.right=cr,cr.parent=Ct):Ct.right=null,_t.left=Ct,Ct.parent=_t)},m.prototype.replace=function(_t,Ct){_t.parent?_t===_t.parent.left?_t.parent.left=Ct:_t.parent.right=Ct:this._root=Ct,Ct&&(Ct.parent=_t.parent)},m.prototype.minNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.left;)_t=_t.left;return _t},m.prototype.maxNode=function(_t){if(_t===void 0&&(_t=this._root),_t)for(;_t.right;)_t=_t.right;return _t},m.prototype.insert=function(_t,Ct){var us=this._root,Bs=null,cr=this._compare;if(this._noDuplicates)for(;us;){if(Bs=us,cr(us.key,_t)===0)return;us=cr(us.key,_t)<0?us.right:us.left}else for(;us;)Bs=us,us=cr(us.key,_t)<0?us.right:us.left;return us={key:_t,data:Ct,left:null,right:null,parent:Bs},Bs?cr(Bs.key,us.key)<0?Bs.right=us:Bs.left=us:this._root=us,this.splay(us),this._size++,us},m.prototype.find=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var Bs=us(Ct.key,_t);if(Bs<0)Ct=Ct.right;else{if(!(Bs>0))return Ct;Ct=Ct.left}}return null},m.prototype.contains=function(_t){for(var Ct=this._root,us=this._compare;Ct;){var Bs=us(_t,Ct.key);if(Bs===0)return!0;Ct=Bs<0?Ct.left:Ct.right}return!1},m.prototype.remove=function(_t){var Ct=this.find(_t);if(!Ct)return!1;if(this.splay(Ct),Ct.left)if(Ct.right){var us=this.minNode(Ct.right);us.parent!==Ct&&(this.replace(us,us.right),us.right=Ct.right,us.right.parent=us),this.replace(Ct,us),us.left=Ct.left,us.left.parent=us}else this.replace(Ct,Ct.left);else this.replace(Ct,Ct.right);return this._size--,!0},m.prototype.removeNode=function(_t){if(!_t)return!1;if(this.splay(_t),_t.left)if(_t.right){var Ct=this.minNode(_t.right);Ct.parent!==_t&&(this.replace(Ct,Ct.right),Ct.right=_t.right,Ct.right.parent=Ct),this.replace(_t,Ct),Ct.left=_t.left,Ct.left.parent=Ct}else this.replace(_t,_t.left);else this.replace(_t,_t.right);return this._size--,!0},m.prototype.erase=function(_t){var Ct=this.find(_t);if(Ct){this.splay(Ct);var us=Ct.left,Bs=Ct.right,cr=null;us&&(us.parent=null,cr=this.maxNode(us),this.splay(cr),this._root=cr),Bs&&(us?cr.right=Bs:this._root=Bs,Bs.parent=cr),this._size--}},m.prototype.pop=function(){var _t=this._root,Ct=null;if(_t){for(;_t.left;)_t=_t.left;Ct={key:_t.key,data:_t.data},this.remove(_t.key)}return Ct},m.prototype.next=function(_t){var Ct=_t;if(Ct)if(Ct.right)for(Ct=Ct.right;Ct&&Ct.left;)Ct=Ct.left;else for(Ct=_t.parent;Ct&&Ct.right===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.prev=function(_t){var Ct=_t;if(Ct)if(Ct.left)for(Ct=Ct.left;Ct&&Ct.right;)Ct=Ct.right;else for(Ct=_t.parent;Ct&&Ct.left===_t;)_t=Ct,Ct=Ct.parent;return Ct},m.prototype.forEach=function(_t){for(var Ct=this._root,us=[],Bs=!1,cr=0;!Bs;)Ct?(us.push(Ct),Ct=Ct.left):us.length>0?(_t(Ct=us.pop(),cr++),Ct=Ct.right):Bs=!0;return this},m.prototype.range=function(_t,Ct,us,Bs){for(var cr=[],dr=this._compare,Br=this._root;cr.length!==0||Br;)if(Br)cr.push(Br),Br=Br.left;else{if(dr((Br=cr.pop()).key,Ct)>0)break;if(dr(Br.key,_t)>=0&&us.call(Bs,Br))return this;Br=Br.right}return this},m.prototype.keys=function(){for(var _t=this._root,Ct=[],us=[],Bs=!1;!Bs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.key),_t=_t.right):Bs=!0;return us},m.prototype.values=function(){for(var _t=this._root,Ct=[],us=[],Bs=!1;!Bs;)_t?(Ct.push(_t),_t=_t.left):Ct.length>0?(_t=Ct.pop(),us.push(_t.data),_t=_t.right):Bs=!0;return us},m.prototype.at=function(_t){for(var Ct=this._root,us=[],Bs=!1,cr=0;!Bs;)if(Ct)us.push(Ct),Ct=Ct.left;else if(us.length>0){if(Ct=us.pop(),cr===_t)return Ct;cr++,Ct=Ct.right}else Bs=!0;return null},m.prototype.load=function(_t,Ct,us){if(_t===void 0&&(_t=[]),Ct===void 0&&(Ct=[]),us===void 0&&(us=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var Bs=_t.length;return us&&E(_t,Ct,0,Bs-1,this._compare),this._root=C(null,_t,Ct,0,Bs),this._size=Bs,this},m.prototype.min=function(){var _t=this.minNode(this._root);return _t?_t.key:null},m.prototype.max=function(){var _t=this.maxNode(this._root);return _t?_t.key:null},m.prototype.isEmpty=function(){return this._root===null},b.size.get=function(){return this._size},m.createTree=function(_t,Ct,us,Bs,cr){return new m(us,cr).load(_t,Ct,Bs)},Object.defineProperties(m.prototype,b);var I=0,R=1,q=2,W=3,te=0,se=1,ie=2,de=3;function he(_t,Ct,us){Ct===null?(_t.inOut=!1,_t.otherInOut=!0):(_t.isSubject===Ct.isSubject?(_t.inOut=!Ct.inOut,_t.otherInOut=Ct.otherInOut):(_t.inOut=!Ct.otherInOut,_t.otherInOut=Ct.isVertical()?!Ct.inOut:Ct.inOut),Ct&&(_t.prevInResult=!Ce(Ct,us)||Ct.isVertical()?Ct.prevInResult:Ct));var Bs=Ce(_t,us);_t.resultTransition=Bs?function(cr,dr){var Br,Vr=!cr.inOut,Ln=!cr.otherInOut;switch(dr){case te:Br=Vr&&Ln;break;case se:Br=Vr||Ln;break;case de:Br=Vr^Ln;break;case ie:Br=cr.isSubject?Vr&&!Ln:Ln&&!Vr}return Br?1:-1}(_t,us):0}function Ce(_t,Ct){switch(_t.type){case I:switch(Ct){case te:return!_t.otherInOut;case se:return _t.otherInOut;case ie:return _t.isSubject&&_t.otherInOut||!_t.isSubject&&!_t.otherInOut;case de:return!0}break;case q:return Ct===te||Ct===se;case W:return Ct===ie;case R:return!1}return!1}var Fe=function(_t,Ct,us,Bs,cr){this.left=Ct,this.point=_t,this.otherEvent=us,this.isSubject=Bs,this.type=cr||I,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Re={inResult:{configurable:!0}};function Ke(_t,Ct){return _t[0]===Ct[0]&&_t[1]===Ct[1]}Fe.prototype.isBelow=function(_t){var Ct=this.point,us=this.otherEvent.point;return this.left?(Ct[0]-_t[0])*(us[1]-_t[1])-(us[0]-_t[0])*(Ct[1]-_t[1])>0:(us[0]-_t[0])*(Ct[1]-_t[1])-(Ct[0]-_t[0])*(us[1]-_t[1])>0},Fe.prototype.isAbove=function(_t){return!this.isBelow(_t)},Fe.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Re.inResult.get=function(){return this.resultTransition!==0},Fe.prototype.clone=function(){var _t=new Fe(this.point,this.left,this.otherEvent,this.isSubject,this.type);return _t.contourId=this.contourId,_t.resultTransition=this.resultTransition,_t.prevInResult=this.prevInResult,_t.isExteriorRing=this.isExteriorRing,_t.inOut=this.inOut,_t.otherInOut=this.otherInOut,_t},Object.defineProperties(Fe.prototype,Re);var Xe=11102230246251565e-32,lt=134217729,kt=(3+8*Xe)*Xe;function vt(_t,Ct,us,Bs,cr){var dr,Br,Vr,Ln,Kn=Ct[0],Xn=Bs[0],ga=0,on=0;Xn>Kn==Xn>-Kn?(dr=Kn,Kn=Ct[++ga]):(dr=Xn,Xn=Bs[++on]);var bn=0;if(ga<_t&&onKn==Xn>-Kn?(Vr=dr-((Br=Kn+dr)-Kn),Kn=Ct[++ga]):(Vr=dr-((Br=Xn+dr)-Xn),Xn=Bs[++on]),dr=Br,Vr!==0&&(cr[bn++]=Vr);ga<_t&&onKn==Xn>-Kn?(Vr=dr-((Br=dr+Kn)-(Ln=Br-dr))+(Kn-Ln),Kn=Ct[++ga]):(Vr=dr-((Br=dr+Xn)-(Ln=Br-dr))+(Xn-Ln),Xn=Bs[++on]),dr=Br,Vr!==0&&(cr[bn++]=Vr);for(;ga<_t;)Vr=dr-((Br=dr+Kn)-(Ln=Br-dr))+(Kn-Ln),Kn=Ct[++ga],dr=Br,Vr!==0&&(cr[bn++]=Vr);for(;on0!=ga>0)return on;var bn=Math.abs(Xn+ga);return Math.abs(on)>=zt*bn?on:-function(Ga,Ja,ei,wi,Ri,Pi,ii){var mi,Zn,Ma,fo,rn,ya,Li,Ui,Yi,sl,Hi,nn,ko,ji,ao,Wl,Pc,Nl,kl=Ga-Ri,fc=ei-Ri,xh=Ja-Pi,Gi=wi-Pi;Wt[0]=(ao=(Ui=kl-(Li=(ya=lt*kl)-(ya-kl)))*(sl=Gi-(Yi=(ya=lt*Gi)-(ya-Gi)))-((ji=kl*Gi)-Li*Yi-Ui*Yi-Li*sl))-((Hi=ao-(Pc=(Ui=xh-(Li=(ya=lt*xh)-(ya-xh)))*(sl=fc-(Yi=(ya=lt*fc)-(ya-fc)))-((Wl=xh*fc)-Li*Yi-Ui*Yi-Li*sl)))+(rn=ao-Hi))+(rn-Pc),Wt[1]=(ko=ji-((nn=ji+Hi)-(rn=nn-ji))+(Hi-rn))-((Hi=ko-Wl)+(rn=ko-Hi))+(rn-Wl),Wt[2]=nn-((Nl=nn+Hi)-(rn=Nl-nn))+(Hi-rn),Wt[3]=Nl;var Go=function($y,Ad){for(var Uu=Ad[0],xm=1;xm<4;xm++)Uu+=Ad[xm];return Uu}(0,Wt),rl=qt*ii;if(Go>=rl||-Go>=rl||(mi=Ga-(kl+(rn=Ga-kl))+(rn-Ri),Ma=ei-(fc+(rn=ei-fc))+(rn-Ri),Zn=Ja-(xh+(rn=Ja-xh))+(rn-Pi),fo=wi-(Gi+(rn=wi-Gi))+(rn-Pi),mi===0&&Zn===0&&Ma===0&&fo===0)||(rl=ss*ii+kt*Math.abs(Go),(Go+=kl*fo+Gi*mi-(xh*Ma+fc*Zn))>=rl||-Go>=rl))return Go;zs[0]=(ao=(Ui=mi-(Li=(ya=lt*mi)-(ya-mi)))*(sl=Gi-(Yi=(ya=lt*Gi)-(ya-Gi)))-((ji=mi*Gi)-Li*Yi-Ui*Yi-Li*sl))-((Hi=ao-(Pc=(Ui=Zn-(Li=(ya=lt*Zn)-(ya-Zn)))*(sl=fc-(Yi=(ya=lt*fc)-(ya-fc)))-((Wl=Zn*fc)-Li*Yi-Ui*Yi-Li*sl)))+(rn=ao-Hi))+(rn-Pc),zs[1]=(ko=ji-((nn=ji+Hi)-(rn=nn-ji))+(Hi-rn))-((Hi=ko-Wl)+(rn=ko-Hi))+(rn-Wl),zs[2]=nn-((Nl=nn+Hi)-(rn=Nl-nn))+(Hi-rn),zs[3]=Nl;var Fh=vt(4,Wt,4,zs,ds);zs[0]=(ao=(Ui=kl-(Li=(ya=lt*kl)-(ya-kl)))*(sl=fo-(Yi=(ya=lt*fo)-(ya-fo)))-((ji=kl*fo)-Li*Yi-Ui*Yi-Li*sl))-((Hi=ao-(Pc=(Ui=xh-(Li=(ya=lt*xh)-(ya-xh)))*(sl=Ma-(Yi=(ya=lt*Ma)-(ya-Ma)))-((Wl=xh*Ma)-Li*Yi-Ui*Yi-Li*sl)))+(rn=ao-Hi))+(rn-Pc),zs[1]=(ko=ji-((nn=ji+Hi)-(rn=nn-ji))+(Hi-rn))-((Hi=ko-Wl)+(rn=ko-Hi))+(rn-Wl),zs[2]=nn-((Nl=nn+Hi)-(rn=Nl-nn))+(Hi-rn),zs[3]=Nl;var Kl=vt(Fh,ds,4,zs,ks);zs[0]=(ao=(Ui=mi-(Li=(ya=lt*mi)-(ya-mi)))*(sl=fo-(Yi=(ya=lt*fo)-(ya-fo)))-((ji=mi*fo)-Li*Yi-Ui*Yi-Li*sl))-((Hi=ao-(Pc=(Ui=Zn-(Li=(ya=lt*Zn)-(ya-Zn)))*(sl=Ma-(Yi=(ya=lt*Ma)-(ya-Ma)))-((Wl=Zn*Ma)-Li*Yi-Ui*Yi-Li*sl)))+(rn=ao-Hi))+(rn-Pc),zs[1]=(ko=ji-((nn=ji+Hi)-(rn=nn-ji))+(Hi-rn))-((Hi=ko-Wl)+(rn=ko-Hi))+(rn-Wl),zs[2]=nn-((Nl=nn+Hi)-(rn=Nl-nn))+(Hi-rn),zs[3]=Nl;var Qf=vt(Kl,ks,4,zs,Ss);return Ss[Qf-1]}(cr,dr,Br,Vr,Ln,Kn,bn)}(_t[0],_t[1],Ct[0],Ct[1],us[0],us[1]);return Bs>0?-1:Bs<0?1:0}function Ds(_t,Ct){var us=_t.point,Bs=Ct.point;return us[0]>Bs[0]?1:us[0]Bs[1]?1:-1:function(cr,dr,Br,Vr){return cr.left!==dr.left?cr.left?1:-1:$s(Br,cr.otherEvent.point,dr.otherEvent.point)!==0?cr.isBelow(dr.otherEvent.point)?-1:1:!cr.isSubject&&dr.isSubject?1:-1}(_t,Ct,us)}function Rs(_t,Ct,us){var Bs=new Fe(Ct,!1,_t,_t.isSubject),cr=new Fe(Ct,!0,_t.otherEvent,_t.isSubject);return Ke(_t.point,_t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",_t),Bs.contourId=cr.contourId=_t.contourId,Ds(cr,_t.otherEvent)>0&&(_t.otherEvent.left=!0,cr.left=!1),_t.otherEvent.otherEvent=cr,_t.otherEvent=Bs,us.push(cr),us.push(Bs),us}function ls(_t,Ct){return _t[0]*Ct[1]-_t[1]*Ct[0]}function rs(_t,Ct){return _t[0]*Ct[0]+_t[1]*Ct[1]}function Fs(_t,Ct,us){var Bs=function(Ln,Kn,Xn,ga,on){var bn=[Kn[0]-Ln[0],Kn[1]-Ln[1]],Ga=[ga[0]-Xn[0],ga[1]-Xn[1]];function Ja(ya,Li,Ui){return[ya[0]+Li*Ui[0],ya[1]+Li*Ui[1]]}var ei=[Xn[0]-Ln[0],Xn[1]-Ln[1]],wi=ls(bn,Ga),Ri=wi*wi,Pi=rs(bn,bn);if(Ri>0){var ii=ls(ei,Ga)/wi;if(ii<0||ii>1)return null;var mi=ls(ei,bn)/wi;return mi<0||mi>1?null:ii===0||ii===1?[Ja(Ln,ii,bn)]:mi===0||mi===1?[Ja(Xn,mi,Ga)]:[Ja(Ln,ii,bn)]}if((Ri=(wi=ls(ei,bn))*wi)>0)return null;var Zn=rs(bn,ei)/Pi,Ma=Zn+rs(bn,Ga)/Pi,fo=Math.min(Zn,Ma),rn=Math.max(Zn,Ma);return fo<=1&&rn>=0?fo===1?[Ja(Ln,fo>0?fo:0,bn)]:rn===0?[Ja(Ln,rn<1?rn:1,bn)]:[Ja(Ln,fo>0?fo:0,bn),Ja(Ln,rn<1?rn:1,bn)]:null}(_t.point,_t.otherEvent.point,Ct.point,Ct.otherEvent.point),cr=Bs?Bs.length:0;if(cr===0||cr===1&&(Ke(_t.point,Ct.point)||Ke(_t.otherEvent.point,Ct.otherEvent.point))||cr===2&&_t.isSubject===Ct.isSubject)return 0;if(cr===1)return Ke(_t.point,Bs[0])||Ke(_t.otherEvent.point,Bs[0])||Rs(_t,Bs[0],us),Ke(Ct.point,Bs[0])||Ke(Ct.otherEvent.point,Bs[0])||Rs(Ct,Bs[0],us),1;var dr=[],Br=!1,Vr=!1;return Ke(_t.point,Ct.point)?Br=!0:Ds(_t,Ct)===1?dr.push(Ct,_t):dr.push(_t,Ct),Ke(_t.otherEvent.point,Ct.otherEvent.point)?Vr=!0:Ds(_t.otherEvent,Ct.otherEvent)===1?dr.push(Ct.otherEvent,_t.otherEvent):dr.push(_t.otherEvent,Ct.otherEvent),Br&&Vr||Br?(Ct.type=R,_t.type=Ct.inOut===_t.inOut?q:W,Br&&!Vr&&Rs(dr[1].otherEvent,dr[0].point,us),2):Vr?(Rs(dr[0],dr[1].point,us),3):dr[0]!==dr[3].otherEvent?(Rs(dr[0],dr[1].point,us),Rs(dr[1],dr[2].point,us),3):(Rs(dr[0],dr[1].point,us),Rs(dr[3].otherEvent,dr[2].point,us),3)}function sr(_t,Ct){if(_t===Ct)return 0;if($s(_t.point,_t.otherEvent.point,Ct.point)!==0||$s(_t.point,_t.otherEvent.point,Ct.otherEvent.point)!==0)return Ke(_t.point,Ct.point)?_t.isBelow(Ct.otherEvent.point)?-1:1:_t.point[0]===Ct.point[0]?_t.point[1]Ct.contourId?1:-1:Ds(_t,Ct)===1?1:-1}var Hs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function zr(_t,Ct,us,Bs){var cr,dr=_t+1,Br=Ct[_t].point,Vr=Ct.length;for(drBs;)dr--;return dr}Hs.prototype.isExterior=function(){return this.holeOf==null};var fr=Ar,_r=Ar;function Ar(_t,Ct){if(!(this instanceof Ar))return new Ar(_t,Ct);if(this.data=_t||[],this.length=this.data.length,this.compare=Ct||ta,this.length>0)for(var us=(this.length>>1)-1;us>=0;us--)this._down(us)}function ta(_t,Ct){return _tCt?1:0}Ar.prototype={push:function(_t){this.data.push(_t),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var _t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),_t}},peek:function(){return this.data[0]},_up:function(_t){for(var Ct=this.data,us=this.compare,Bs=Ct[_t];_t>0;){var cr=_t-1>>1,dr=Ct[cr];if(us(Bs,dr)>=0)break;Ct[_t]=dr,_t=cr}Ct[_t]=Bs},_down:function(_t){for(var Ct=this.data,us=this.compare,Bs=this.length>>1,cr=Ct[_t];_t=0)break;Ct[_t]=Vr,_t=dr}Ct[_t]=cr}},fr.default=_r;var Zs=Math.max,Er=Math.min,_n=0;function Na(_t,Ct,us,Bs,cr,dr){var Br,Vr,Ln,Kn,Xn,ga;for(Br=0,Vr=_t.length-1;Br0?ga.left=!0:Xn.left=!0;var on=Ln[0],bn=Ln[1];cr[0]=Er(cr[0],on),cr[1]=Er(cr[1],bn),cr[2]=Zs(cr[2],on),cr[3]=Zs(cr[3],bn),Bs.push(Xn),Bs.push(ga)}}var Ta=[];function qn(_t,Ct,us){typeof _t[0][0][0]=="number"&&(_t=[_t]),typeof Ct[0][0][0]=="number"&&(Ct=[Ct]);var Bs=function(bn,Ga,Ja){var ei=null;return bn.length*Ga.length==0&&(Ja===te?ei=Ta:Ja===ie?ei=bn:Ja!==se&&Ja!==de||(ei=bn.length===0?Ga:bn)),ei}(_t,Ct,us);if(Bs)return Bs===Ta?null:Bs;var cr=[1/0,1/0,-1/0,-1/0],dr=[1/0,1/0,-1/0,-1/0],Br=function(bn,Ga,Ja,ei,wi){var Ri,Pi,ii,mi,Zn,Ma,fo=new fr(null,Ds);for(ii=0,mi=bn.length;iiei[2]||ei[0]>Ja[2]||Ja[1]>ei[3]||ei[1]>Ja[3])&&(wi===te?Ri=Ta:wi===ie?Ri=bn:wi!==se&&wi!==de||(Ri=bn.concat(Ga))),Ri}(_t,Ct,cr,dr,us))return Bs===Ta?null:Bs;for(var Vr=function(bn){var Ga,Ja,ei=function(ii){var mi,Zn,Ma,fo,rn=[];for(Zn=0,Ma=ii.length;Zn0){var Hi=ya[sl];if(Hi.holeOf!=null){var nn=Hi.holeOf;ya[nn].holeIds.push(Li),Ui.holeOf=nn,Ui.depth=ya[sl].depth}else ya[sl].holeIds.push(Li),Ui.holeOf=sl,Ui.depth=ya[sl].depth+1}else Ui.holeOf=null,Ui.depth=ya[sl].depth}else Ui.holeOf=null,Ui.depth=0;return Ui}(ei[Ga],Ri,ii),Zn=function(rn){wi[rn]=!0,rn=ei.length)&&ei[Ma];);Ri.push(mi)}};for(Ga=0,Ja=ei.length;Gafo||Ri===ie&&rn.point[0]>ei[2])break;if(rn.left){ii=Pi=Zn.insert(rn),Pi=Pi!==(mi=Zn.minNode())?Zn.prev(Pi):null,ii=Zn.next(ii);var ya=Pi?Pi.key:null;if(he(rn,ya,Ri),ii&&Fs(rn,ii.key,bn)===2&&(he(rn,ya,Ri),he(ii.key,rn,Ri)),Pi&&Fs(Pi.key,rn,bn)===2){var Li=Pi;he(ya,(Li=Li!==mi?Zn.prev(Li):null)?Li.key:null,Ri),he(rn,ya,Ri)}}else ii=Pi=Zn.find(rn=rn.otherEvent),Pi&&ii&&(Pi=Pi!==mi?Zn.prev(Pi):null,ii=Zn.next(ii),Zn.remove(rn),ii&&Pi&&Fs(Pi.key,ii.key,bn))}return Ma}(Br,0,0,cr,dr,us)),Ln=[],Kn=0;Kn * @license MIT * @preserve */function qF(x,d,m,b){const C=[],E=b===0?(I,R,q,W,te,se)=>{I.push(new ft(se,q+(se-R)/(W-R)*(te-q)))}:(I,R,q,W,te,se)=>{I.push(new ft(R+(se-q)/(te-q)*(W-R),se))};for(const I of x){const R=[];for(const q of I){if(q.length<=2)continue;const W=[];for(let ie=0;ied&&E(W,de,he,Ce,Fe,d):Re>m?Ke=d&&E(W,de,he,Ce,Fe,d),Ke>m&&Re<=m&&E(W,de,he,Ce,Fe,m)}let te=q[q.length-1];const se=b===0?te.x:te.y;se>=d&&se<=m&&W.push(te),W.length&&(te=W[W.length-1],W[0].x===te.x&&W[0].y===te.y||W.push(W[0]),R.push(W))}R.length&&C.push(R)}return C}function vdt(x,d){const m=Npe(x),b=Npe([d]),C=iCe.intersection(m,b);return C==null?[]:oCe(C)}function bdt(x,d){let b=Npe(x,65536);const C=[];for(;d.valid();d.next()){const[E,I]=d.get(),R=E.x*65536,q=E.y*65536,W=I.x*65536,te=I.y*65536,se=W-R,ie=te-q,de=Math.hypot(se,ie);if(de===0)continue;const he=Math.trunc(ie/de*3),Ce=-Math.trunc(se/de*3);C.push([[[R,q],[W,te],[W+he,te+Ce],[R+he,q+Ce],[R,q]]])}return C.length>0&&(b=iCe.diff(b,C)),oCe(b,1/65536)}function Npe(x,d=1){return[x.map(m=>m.map(b=>[b.x*d,b.y*d]))]}function oCe(x,d=1){return x.map(m=>m.map((b,C)=>{const E=b.map(I=>new ft(I[0]*d,I[1]*d).round());return C>0&&E.reverse(),E}))}class kpe{constructor(d,m){this.layoutVertexArray=new Ly,this.indexArray=new Vl,this.lineIndexArray=new hm,this.triangleSegments=new wo,this.lineSegments=new wo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new dg)}update(d,m,b,C,E,I,R,q){this.programConfigurations.updatePaintArrays(d,m,E,b,C,I,R,q)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,ndt.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.lineIndexBuffer=d.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,adt.members))),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(d,m,b,C,E,I,R){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,m,b,C,E,I,void 0,R)}}class Spe{constructor(d){this.zoom=d.zoom,this.pixelRatio=d.pixelRatio,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=d.lut,this.bufferData=new kpe(d,!1),this.elevationBufferData=new kpe(d,!0),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=d.sourceLayerIndex,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,b,C){}populate(d,m,b,C){this.hasPattern=wpe("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),I=[];for(const{feature:R,id:q,index:W,sourceLayerIndex:te}of d){const se=this.layers[0]._featureFilter.needGeometry,ie=Gt(R,se);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ie,b))continue;const de=E?E.evaluate(ie,{},b,m.availableImages):void 0,he={id:q,properties:R.properties,type:R.type,sourceLayerIndex:te,index:W,geometry:se?ie.geometry:Ot(R,b,C),patterns:{},sortKey:de};I.push(he)}E&&I.sort((R,q)=>R.sortKey-q.sortKey);for(const R of I){const{geometry:q,index:W,sourceLayerIndex:te}=R;if(this.hasPattern){const se=jpe("fill",this.layers,R,this.zoom,this.pixelRatio,m);this.patternFeatures.push(se)}else this.addFeature(R,q,W,b,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(d[W].feature,q,W,te,this.index)}}update(d,m,b,C,E,I,R){this.bufferData.update(d,m,b,C,E,I,R,this.worldview),this.elevationBufferData.update(d,m,b,C,E,I,R,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,m,b,C,E,I,R,this.worldview)}addFeatures(d,m,b,C,E,I){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,b,C,I,d.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(d){this.bufferData.upload(d),this.elevationBufferData.upload(d),this.elevatedStructures&&this.elevatedStructures.upload(d)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(d,m,b,C,E,I=[],R,q){const W=nP(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,W,C,b,q):this.addGeometry(W,this.bufferData),this.bufferData.populatePaintArrays(d,b,E,I,C,R,this.worldview),this.elevationBufferData.populatePaintArrays(d,b,E,I,C,R,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,m,b,C,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(m,b,C,E,this.worldview))}addElevatedRoadFeature(d,m,b,C,E){const I=new Array,R=ui.getElevationFeature(d,E);if(!R)return void this.addGeometry(m,this.bufferData);{const W=this.clipPolygonsToTile(m,1);W.length>0&&I.push({polygons:W,elevationFeature:R,elevationTileID:b})}const q={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},b),featureIndex:C};for(const W of I)if(W.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new pm(W.elevationTileID,this.layers,this.zoom,this.lut));const se=W.elevationFeature.isTunnel();let ie=0;d.properties.hasOwnProperty(Jt)&&(ie=+d.properties[Jt]);for(const de of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,de,se,W.elevationFeature,ie)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const te=new Mi(b,W.elevationTileID);this.addElevatedGeometry(W.polygons,te,W.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,C,q)}}addElevatedGeometry(d,m,b,C,E,I){const R={elevation:b,elevationSampler:m,bias:C,index:E,featureInfo:I},[q,W]=this.addGeometry(d,this.elevationBufferData,R);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:q,max:W}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,q),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,W))}addGeometry(d,m,b){let C=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,I=null;b&&(I=b.elevationSampler.constantElevation(b.elevation,b.bias),I!=null&&(C=I,E=I));const R=(q,W,te)=>{if(b!=null)if(W.push(q),I!=null)m.elevatedLayoutVertexArray.emplaceBack(I),te.push(I);else{const se=b.elevationSampler.pointElevation(q,b.elevation,b.bias);m.elevatedLayoutVertexArray.emplaceBack(se),te.push(se),C=Math.min(C,se),E=Math.max(E,se)}};for(const q of d){let W=0;for(const Xe of q)W+=Xe.length;const te=m.triangleSegments.prepareSegment(W,m.layoutVertexArray,m.indexArray),se=te.vertexLength,ie=[],de=[],he=[],Ce=[],Fe=[],Re=m.layoutVertexArray.length;for(const Xe of q){if(Xe.length===0)continue;Xe!==q[0]&&de.push(ie.length/2);const lt=m.lineSegments.prepareSegment(Xe.length,m.layoutVertexArray,m.lineIndexArray),kt=lt.vertexLength;b&&Fe.push(m.layoutVertexArray.length-Re),R(Xe[0],he,Ce),m.layoutVertexArray.emplaceBack(Xe[0].x,Xe[0].y),m.lineIndexArray.emplaceBack(kt+Xe.length-1,kt),ie.push(Xe[0].x),ie.push(Xe[0].y);for(let vt=1;vt0&&b&&this.elevationMode==="hd-road-base"){const Xe=b.elevation.isTunnel(),lt=b.elevation.safeArea,kt=this.elevatedStructures.addVertices(he,Ce);this.elevatedStructures.addTriangles(Ke,kt,Xe);const vt=Fe.length;if(vt>0){for(let At=0;At=b&&de.max.x<=E&&de.min.y>=C&&de.max.y<=I?q:W).push(ie)}if(q.length===d.length)return d;const te=[new ft(b,C),new ft(E,C),new ft(E,I),new ft(b,I),new ft(b,C)],se=q;for(const ie of W)se.push(...vdt(ie,te));return se}}let lCe,cCe,dCe,uCe;kr(Spe,"FillBucket",{omit:["layers","patternFeatures"]}),kr(kpe,"FillBufferData"),kr(pm,"ElevatedStructures");class UF{constructor(d,m,b,C){if(this.triangleCount=m.length/3,this.min=new ft(0,0),this.max=new ft(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||d.length===0)return;const[E,I]=[d[0].clone(),d[0].clone()];for(let se=1;sese.cellIdx-ie.cellIdx||se.triIdx-ie.triIdx);let te=0;for(;tethis.max.x||this.min.x>d.x||d.y>this.max.y||this.min.y>d.y)return;const b=zy(d.x-this.min.x,this.xScale,this.cellsX),C=zy(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[C*this.cellsX+b];if(E){this._lazyInitLookup();for(let I=0;Ithis.max.x||this.min.x>m.x||d.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const C=zy(d.x-this.min.x,this.xScale,this.cellsX),E=zy(m.x-this.min.x,this.xScale,this.cellsX),I=zy(d.y-this.min.y,this.yScale,this.cellsY),R=zy(m.y-this.min.y,this.yScale,this.cellsY);for(let q=I;q<=R;q++)for(let W=C;W<=E;W++){const te=this.cells[q*this.cellsX+W];if(te)for(let se=0;sem.fqid),this.index=d.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.footprints=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){for(const b of this.footprints)m.push({footprint:b,id:d})}updateAppearances(d,m,b,C){}populate(d,m,b,C){const E=[];for(const{feature:I,id:R,index:q,sourceLayerIndex:W}of d){const te=this.layers[0]._featureFilter.needGeometry,se=Gt(I,te);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,b))continue;const ie={id:R,properties:I.properties,type:I.type,sourceLayerIndex:W,index:q,geometry:te?se.geometry:Ot(I,b,C),patterns:{}};E.push(ie)}for(const I of E){const{geometry:R,index:q,sourceLayerIndex:W}=I;this.addFeature(I,R,q,b,{},m.availableImages,m.brightness),m.featureIndex.insert(d[q].feature,R,q,W,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,m,b,C,E,I,R){}destroy(){}addFeature(d,m,b,C,E,I=[],R){for(const q of nP(m,2)){const W=[],te=[],se=[],ie=new ft(1/0,1/0),de=new ft(-1/0,-1/0);for(const Fe of q)if(Fe.length!==0){Fe!==q[0]&&se.push(te.length/2);for(let Re=0;ReI===C)===void 0}(b,x.clipScope)}function VF(x,d){return x.x-d.x||x.y-d.y}function fCe(x,d){return VF(x.min,d.min)===0&&VF(x.max,d.max)===0}function Cpe(x,d){return!(x.min.x>d.max.x||x.max.xd.max.y||x.max.ynew ft((q.x+E.x*tr)*R-I.x*tr,(q.y+E.y*tr)*R-I.y*tr))}return Mpe(m,C,x.indices,0,x.indices.length,0,0)}function yCe(x,d,m,b){const C=Math.pow(2,b.z-m.z);return new ft((x+m.x*tr)*C-b.x*tr,(d+m.y*tr)*C-b.y*tr)}function vCe(x,d){const m=[];d.grid.queryPoint(x,m);const b=d.indices,C=d.vertices;for(let E=0;E0&&(b.length>1&&m.push(b),b=[])}return b.length>1&&m.push(b),m}const Ape=Ht.types,Adt=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Edt=["fill-extrusion-flood-light-ground-radius"],Pdt=Math.pow(2,13),Idt=Math.pow(2,15)-1,_Ce=new ft(0,1),_v=2147483648,wCe=7,jCe=450;function iP(x,d,m,b,C,E,I,R){x.emplaceBack((d<<1)+I,(m<<1)+E,(Math.floor(b*Pdt)<<1)+C,Math.round(R))}function oP(x,d,m){x.emplaceBack(d.x*tr,d.y*tr,m?1:0)}function GF(x,d,m,b,C,E){x.emplaceBack(d.x,d.y,(m.x<<1)+b,(m.y<<1)+C,E)}function lP(x,d,m){x.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}class NCe{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class kCe{constructor(){this.centroidXY=new ft(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new ft(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ft(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new ft(this.max.x-this.min.x,this.max.y-this.min.y)}}class SCe{constructor(){this.acc=new ft(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(d,m){d.min.x===Number.MAX_VALUE&&(d.min.x=d.max.x=m.x,d.min.y=d.max.y=m.y)}appendEdge(d,m,b){this.accCount++,this.acc._add(m);let C=!!this.borders;m.xd.max.x&&(d.max.x=m.x,C=!0),m.yd.max.y&&(d.max.y=m.y,C=!0),((m.x===0||m.x===tr)&&m.x===b.x)!=((m.y===0||m.y===tr)&&m.y===b.y)&&this.processBorderOverlap(m,b),C&&this.checkBorderIntersection(m,b)}checkBorderIntersection(d,m){m.x<0!=d.x<0&&this.addBorderIntersection(0,Zr(m.y,d.y,(0-m.x)/(d.x-m.x))),m.x>tr!=d.x>tr&&this.addBorderIntersection(1,Zr(m.y,d.y,(tr-m.x)/(d.x-m.x))),m.y<0!=d.y<0&&this.addBorderIntersection(2,Zr(m.x,d.x,(0-m.y)/(d.y-m.y))),m.y>tr!=d.y>tr&&this.addBorderIntersection(3,Zr(m.x,d.x,(tr-m.y)/(d.y-m.y)))}addBorderIntersection(d,m){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const b=this.borders[d];mb[1]&&(b[1]=m)}processBorderOverlap(d,m){if(d.x===m.x){if(d.y===m.y)return;const b=d.x===0?0:1;this.addBorderIntersection(b,m.y),this.addBorderIntersection(b,d.y)}else{const b=d.y===0?2:3;this.addBorderIntersection(b,m.x),this.addBorderIntersection(b,d.x)}}centroid(){return this.accCount===0?new ft(0,0):new ft(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((d,m)=>d+ +(m[0]!==Number.MAX_VALUE),0):0}}function CCe(x,d){const m=x.add(d)._unit(),b=Se(x.x*m.x+x.y*m.y,-1,1);var C,E,I;return C=Math.acos(b),Math.min(4,Math.max(-4,Math.tan(C)))/4*Idt*((E=x).x*(I=d).y-E.y*I.x<0?-1:1)}const Ldt=[x=>x.x<0,x=>x.x>tr,x=>x.y<0,x=>x.y>tr];function Ddt(x,d,m,b){const C=[4];if(b===0)return C;m._mult(b);const E=x.sub(m),I=d.sub(m),R=[x,d,E,I];for(let q=0;q<4;q++)for(const W of R)if(Ldt[q](W)){C.push(q);break}return C}class Epe{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new L6,this.indexArray=new Vl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>Edt.includes(m)),this._segments=new wo,this.hiddenByLandmarkVertexArray=new zC,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new wo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,m,b,C=!1){const E=d.length;if(E>2){let I=Math.max(0,this._segments.get().length-1);const R=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[I].length);let q;I!==this._segments.get().length-1&&(I++,this._segmentToGroundQuads[I]=[],this._segmentToRegionTriCounts[I]=[0,0,0,0,0]);{const W=d[0],te=d[1];q=CCe(W.sub(d[E-1])._perp()._unit(),te.sub(W)._perp()._unit())}for(let W=0;WC.region-E.region);for(let b=0;bq+W,0);let R=0;for(let q=0;q<=4;q++){const W=I[q];if(W!==0){let te=this.regionSegments[q];te||(te=this.regionSegments[q]=new wo);const se={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+R,vertexLength:E.vertexLength,primitiveLength:W};te.get().push(se)}R+=W}for(let q=0;q0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,Sdt.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let d=0;d<=4;d++){const m=this.regionSegments[d];m&&m.destroy()}}}}class WF{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaling=d.overscaling,this.layers=d.layers,this.pixelRatio=d.pixelRatio,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=d.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Vl,this.footprintVertices=new Ly,this.footprintSegments=[],this.layoutVertexArray=new bb,this.centroidVertexArray=new LF,this.wallVertexArray=new j2,this.indexArray=new Vl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>Adt.includes(m)),this.segments=new wo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new Epe(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,b,C){}populate(d,m,b,C){this.features=[],this.hasPattern=wpe("fill-extrusion",this.layers,this.pixelRatio,m),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Ve(b),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:E,id:I,index:R,sourceLayerIndex:q}of d){const W=this.layers[0]._featureFilter.needGeometry,te=Gt(E,W);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),te,b))continue;const se={id:I,sourceLayerIndex:q,index:R,geometry:W?te.geometry:Ot(E,b,C),properties:E.properties,type:E.type,patterns:{}},ie=this.layoutVertexArray.length,de=Ape[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:jpe("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const he of se.geometry)for(const Ce of bCe(he,de))this.addFeature(E.id,se,[Ce],R,b,{},m.availableImages,C,m.brightness);else this.addFeature(E.id,se,se.geometry,R,b,{},m.availableImages,C,m.brightness);m.featureIndex.insert(E,se.geometry,R,q,this.index,ie)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,m,b,C,E,I){for(const{featureId:R,feature:q}of this.features){const W=Ape[q.type]==="Polygon",{geometry:te}=q;if(this.wallMode)for(const se of te)for(const ie of bCe(se,W))this.addFeature(R,q,[ie],q.index,m,b,C,E,I);else this.addFeature(R,q,te,q.index,m,b,C,E,I)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,m,b,C,E,I,R){this.programConfigurations.updatePaintArrays(d,m,E,b,C,I,R,this.worldview),this.groundEffect.update(d,m,E,b,C,I,R,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Mdt),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,kdt.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,Cdt.members,!0)),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}uploadCentroid(d){this.groundEffect.uploadHiddenByLandmark(d),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=d.createVertexBuffer(this.centroidVertexArray,Ndt.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(d,m,b,C,E,I,R,q,W){const te=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,se=[new ft(0,0),new ft(tr,tr)],ie=q.projection,de=ie.name==="globe",he=this.wallMode||Ape[m.type]==="Polygon",Ce=new SCe;Ce.centroidDataIndex=this.centroidData.length;const Fe=new kCe;Fe.buildingId=d,m.properties&&m.properties.hasOwnProperty("building_id")&&(Fe.buildingId=m.properties.building_id);const Re=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ke=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Xe;if(Fe.height=Ke,Fe.vertexArrayOffset=this.layoutVertexArray.length,Fe.groundVertexArrayOffset=this.groundEffect.vertexArray.length,de&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new IC),this.wallMode){if(de)return void xr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(b.length!==1)return;Xe=function(Wt){const ds=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(_r){let Ar=0;const ta=_r.length;for(let Zs=0;Zs=0})(Wt)||(Wt=Wt.reverse());const Ss={geometry:[],joinNormals:[],indices:[]},zs=[],$s=[],Ds=[];let Rs=Wt.length;for(;Rs>=2&&Wt[Rs-1].equals(Wt[Rs-2]);)Rs--;if(Rs<(ds?3:2))return Ss;let ls,rs,Fs,sr,Hs,zr=0;for(;zr0;let _n="miter";const Na=2;_n==="miter"&&Zs>Na&&(_n="bevel"),_n==="bevel"&&(Zs>100&&(_n="flipbevel"),Zs{const us=new ft(qn.x,qn.y),Bs=new ft(qn.x,qn.y);us.x+=Ei.x*Ct,us.y+=Ei.y*Ct,Bs.x-=Ei.x*Math.max(_t,1),Bs.y-=Ei.y*Math.max(_t,1),Ds.push(Ei),zs.push(us),$s.push(Bs)};if(_n==="miter")Ar._mult(Zs),Ta(ls,Ar,0,0);else if(_n==="flipbevel")Ar=Hs.mult(-1),Ta(ls,Ar,0,0),Ta(ls,Ar.mult(-1),0,0);else{const qn=-Math.sqrt(Zs*Zs-1),Ei=Er?qn:0,_t=Er?0:qn;rs&&Ta(ls,sr,Ei,_t),Fs&&Ta(ls,Hs,Ei,_t)}}Ss.geometry=[...zs,...$s.reverse(),zs[0]],Ss.joinNormals=[...Ds,...Ds.reverse(),Ds[Ds.length-1]];const fr=Ss.geometry.length-1;for(let _r=0;_rWt<(ds.length-1)/2||Wt===ds.length-1,kt=this.wallMode?[b]:nP(b,500);for(let Wt=kt.length-1;Wt>=0;Wt--){const ds=kt[Wt];(ds.length===0||(vt=ds[0]).every(ks=>ks.x<=0)||vt.every(ks=>ks.x>=tr)||vt.every(ks=>ks.y<=0)||vt.every(ks=>ks.y>=tr))&&kt.splice(Wt,1)}var vt;let At;if(de)At=LCe(kt,se,E);else{At=[];for(const Wt of kt)At.push({polygon:Wt,bounds:se})}const zt=he?this.edgeRadius:0,qt=zt>0&&this.zoom<17,ss=(Wt,ds)=>{if(Wt.length===0)return!1;const ks=Wt[Wt.length-1];return ds.x===ks.x&&ds.y===ks.y};for(const{polygon:Wt,bounds:ds}of At){let ks=0,Ss=0;for(const Rs of Wt)he&&!Rs[0].equals(Rs[Rs.length-1])&&Rs.push(Rs[0]),Ss+=he?Rs.length-1:Rs.length;const zs=this.segments.prepareSegment((he?5:4)*Ss,this.layoutVertexArray,this.indexArray);Fe.footprintSegIdx<0&&(Fe.footprintSegIdx=this.footprintSegments.length),Fe.polygonSegIdx<0&&(Fe.polygonSegIdx=this.polygonSegments.length);const $s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ds=new NCe;if(Ds.vertexOffset=this.footprintVertices.length,Ds.indexOffset=3*this.footprintIndices.length,Ds.ringIndices=[],he){const Rs=[],ls=[];ks=zs.vertexLength;for(let Fs=0;Fs4&&ECe(ls[ls.length-2],ls[0],ls[1]),Fs=zt?Odt(ls[ls.length-2],ls[0],ls[1],zt):0;const sr=[];let Hs,zr,fr;zr=ls[1].sub(ls[0])._perp()._unit();let _r=!0;for(let Ar=1,ta=0;Ar0?1:0,Ei=Zs.dist(Er);if(ta+Ei>32768&&(ta=0),zt){fr=_n.sub(Er)._perp()._unit();let Bs=TCe(Zs,Er,_n,MCe(zr,fr),zt);isNaN(Bs)&&(Bs=0);const cr=Er.sub(Zs)._unit();Zs=Zs.add(cr.mult(Fs))._round(),Er=Er.add(cr.mult(-Bs))._round(),Fs=Bs,zr=fr,Re&&this.zoom>=17&&(ss(sr,Zs)||sr.push(Zs),ss(sr,Er)||sr.push(Er))}const _t=zs.vertexLength,Ct=ls.length>4&&ECe(Zs,Er,_n);let us=PCe(ta,rs,_r);if(iP(this.layoutVertexArray,Zs.x,Zs.y,Ta,qn,0,0,us),iP(this.layoutVertexArray,Zs.x,Zs.y,Ta,qn,0,1,us),this.wallMode){const Bs=lt(Ar-1,ls),cr=Xe.joinNormals[Ar-1];oP(this.wallVertexArray,cr,Bs),oP(this.wallVertexArray,cr,Bs)}if(ta+=Ei,us=PCe(ta,Ct,!_r),rs=Ct,iP(this.layoutVertexArray,Er.x,Er.y,Ta,qn,0,0,us),iP(this.layoutVertexArray,Er.x,Er.y,Ta,qn,0,1,us),this.wallMode){const Bs=lt(Ar,ls),cr=Xe.joinNormals[Ar];oP(this.wallVertexArray,cr,Bs),oP(this.wallVertexArray,cr,Bs)}if(zs.vertexLength+=4,this.indexArray.emplaceBack(_t+0,_t+1,_t+2),this.indexArray.emplaceBack(_t+1,_t+3,_t+2),zs.primitiveLength+=2,zt){const Bs=ks+(Ar===1?ls.length-2:Ar-2),cr=Ar===1?ks:Bs+1;if(this.indexArray.emplaceBack(_t+1,Bs,_t+3),this.indexArray.emplaceBack(Bs,cr,_t+3),zs.primitiveLength+=2,Hs===void 0&&(Hs=_t),!Ppe(_n,ls[Ar],ds)){const dr=Ar===ls.length-1?Hs:zs.vertexLength;this.indexArray.emplaceBack(_t+2,_t+3,dr),this.indexArray.emplaceBack(_t+3,dr+1,dr),this.indexArray.emplaceBack(_t+3,cr,dr+1),zs.primitiveLength+=3}_r=!_r}if(de){const Bs=this.layoutVertexExtArray,cr=ie.projectTilePoint(Zs.x,Zs.y,E),dr=ie.projectTilePoint(Er.x,Er.y,E),Br=ie.upVector(E,Zs.x,Zs.y),Vr=ie.upVector(E,Er.x,Er.y);lP(Bs,cr,Br),lP(Bs,cr,Br),lP(Bs,dr,Vr),lP(Bs,dr,Vr)}}he&&(ks+=ls.length-1),Re&&zt&&this.zoom>=17&&(sr.length!==0&&ss(sr,sr[0])&&sr.pop(),this.groundEffect.addData(sr,ds,te,zt>0))}this.footprintSegments.push(Ds),$s.triangleCount=this.indexArray.length-$s.triangleArrayOffset,this.polygonSegments.push($s),++Fe.footprintSegLen,++Fe.polygonSegLen}if(Fe.vertexCount=this.layoutVertexArray.length-Fe.vertexArrayOffset,Fe.groundVertexCount=this.groundEffect.vertexArray.length-Fe.groundVertexArrayOffset,Fe.vertexCount!==0){if(Fe.centroidXY=Ce.borders?_Ce:this.encodeCentroid(Ce,Fe),this.centroidData.push(Fe),Ce.borders){this.featuresOnBorder.push(Ce);const Wt=this.featuresOnBorder.length-1;for(let ds=0;dsthis.featuresOnBorder[m].borders[d][0]-this.featuresOnBorder[b].borders[d][0])}splitToSubtiles(){const d=[];for(let R=0;Rtr),te=2*W+(+(q.min.x+q.max.x>tr)^W);for(let se=0;seR.triangleSegmentIdx===q.triangleSegmentIdx?R.subtile-q.subtile:R.triangleSegmentIdx-q.triangleSegmentIdx);let b=0,C=0,E=0;for(const R of d){if(R.triangleSegmentIdx!==b)break;E++}const I=d.length;for(;C!==d.length;){b=d[C].triangleSegmentIdx;let R=0,q=C,W=C;for(let te=q;te0&&this.triangleSubSegments.push({segment:de,min:se,max:ie}),q=W;for(let he=q;he[Ce[0]*(1-Re[0])+Fe[0]*Re[0],Ce[1]*(1-Re[1])+Fe[1]*Re[1]],de=[],he=[];for(const Ce of this.triangleSubSegments){de[0]=Ce.min.x/tr,de[1]=Ce.min.y/tr,he[0]=Ce.max.x/tr,he[1]=Ce.max.y/tr;const Fe=ie(te,se,de),Re=ie(te,se,he);if(new Rr([Fe[0],Fe[1],E],[Re[0],Re[1],I]).intersectsPrecise(b)===0){W&&(C.segments.push(W),W=void 0);continue}const Ke=Ce.segment;W&&W.vertexOffset!==Ke.vertexOffset&&(C.segments.push(W),W=void 0),W?(W.vertexLength+=Ke.vertexLength,W.primitiveLength+=Ke.primitiveLength):W={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.primitiveOffset,sortKey:void 0,vaos:{}}}return W&&C.segments.push(W),C}encodeCentroid(d,m){const b=d.centroid(),C=m.span(),E=Math.min(7,Math.round(C.x*this.tileToMeter/10)),I=Math.min(7,Math.round(C.y*this.tileToMeter/10));return new ft(Se(b.x,1,tr-1)<<3|E,Se(b.y,1,tr-1)<<3|I)}encodeBorderCentroid(d){if(!d.borders)return new ft(0,0);const m=d.borders,b=Number.MAX_VALUE;if(m[0][0]!==b||m[1][0]!==b){const C=m[0][0]!==b?0:1;return new ft(6|(m[0][0]!==b?0:65528),(m[C][0]+m[C][1])/2<<3|6)}{const C=m[2][0]!==b?2:3;return new ft((m[C][0]+m[C][1])/2<<3|6,6|(m[2][0]!==b?0:65528))}}showCentroid(d){const m=this.centroidData[d.centroidDataIndex];m.flags&=2147483647,m.centroidXY.x=0,m.centroidXY.y=0,this.writeCentroidToBuffer(m)}writeCentroidToBuffer(d){this.groundEffect.updateHiddenByLandmark(d);const m=d.vertexArrayOffset,b=d.vertexCount+d.vertexArrayOffset,C=d.flags&_v?_Ce:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==C.y||E!==C.x){for(let I=m;Iq.max.x||q.min.x>I.max.x||I.min.y>q.max.y||q.min.y>I.max.y||I.footprint.buildingIds.has(q.buildingId)&&(q.flags|=_v);else for(const q of this.centroidData)if(!(q.flags&_v||I.min.x>q.max.x||q.min.x>I.max.x||I.min.y>q.max.y||q.min.y>I.max.y))for(let W=0;Wm!=de>m&&d<(this.footprintVertices.int16[2*(te+I.vertexOffset)+0]-se)*(m-ie)/(de-ie)+se&&(C=!C)}R=q}}return C}getHeightAtTileCoord(d,m){let b=Number.NEGATIVE_INFINITY,C=!0;const E=4*(d+tr)*tr+(m+tr);if(this.partLookup.hasOwnProperty(E)){const I=this.partLookup[E];return I?{height:I.height,hidden:!!(I.flags&_v)}:void 0}for(const I of this.centroidData)d>I.max.x||I.min.x>d||m>I.max.y||I.min.y>m||I.height<=b||this.footprintContainsPoint(d,m,I)&&(b=I.height,this.partLookup[E]=I,C=!!(I.flags&_v));if(b!==Number.NEGATIVE_INFINITY)return{height:b,hidden:C};this.partLookup[E]=void 0}}function MCe(x,d){const m=x.add(d)._unit();return x.x*m.x+x.y*m.y}function Odt(x,d,m,b){const C=d.sub(x)._perp()._unit(),E=m.sub(d)._perp()._unit();return TCe(x,d,m,MCe(C,E),b)}function TCe(x,d,m,b,C){const E=Math.sqrt(1-b*b);return Math.min(x.dist(d)/3,d.dist(m)/3,C*E/b)}function Ppe(x,d,m){return x.xm[1].x&&d.x>m[1].x||x.ym[1].y&&d.y>m[1].y}function ACe(x,d){return x.xd[1].x||x.yd[1].y}function ECe(x,d,m){if(x.x<0||x.x>=tr||d.x<0||d.x>=tr||m.x<0||m.x>=tr)return!1;const b=m.sub(d),C=b.perp(),E=x.sub(d);return(b.x*E.x+b.y*E.y)/Math.sqrt((b.x*b.x+b.y*b.y)*(E.x*E.x+E.y*E.y))>-.866&&C.x*E.x+C.y*E.y<0}function PCe(x,d,m){const b=d?2|x:-3&x;return m?1|b:-2&b}function ICe(){const x=Math.PI/32,d=Math.tan(x),m=T;return m*Math.sqrt(1+2*d*d)-m}function LCe(x,d,m){const b=1<{for(const zt of vt)he.push({polygon:zt,bounds:At})},Fe=Math.ceil(Math.log2(te)),Re=Math.ceil(Math.log2(se)),Ke=Fe-Re,Xe=[];for(let vt=0;vt0?0:1);for(let vt=0;vtAt+1?kt.push({polygons:Ss,bounds:$s,depth:At+1}):Ce(Ss,$s)}if(zs.length){const $s=[new ft(zt===0?ks:qt.x,zt===1?ks:qt.y),ss];Xe.length>At+1?kt.push({polygons:zs,bounds:$s,depth:At+1}):Ce(zs,$s)}}return he}(x,d,Math.ceil((E-C)/11.25),Math.ceil((I-R)/11.25),1,(q,W,te)=>{if(q===0)return .5*(W+te);{const se=je((m.y+W/tr)/b);return(J(.5*(je((m.y+te/tr)/b)+se))*b-m.y)*tr}})}function Rdt(x,d,m,b,C,E){const I=Math.pow(2,b.z-C.z);for(let R=0;R=q[I]&&(R=d,q=x),R[I]C&&FCe(R,q,I,C),R[I]E&&FCe(q,R,I,E)}}function KF(x,d,m,b,C,E){const I=[];for(let R=0;R=b&&he.x>=b||(de.x>=b?de=new ft(b,de.y+(b-de.x)/(he.x-de.x)*(he.y-de.y))._round():he.x>=b&&(he=new ft(b,de.y+(b-de.x)/(he.x-de.x)*(he.y-de.y))._round()),de.y>=C&&he.y>=C||(de.y>=C?de=new ft(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round():he.y>=C&&(he=new ft(de.x+(C-de.y)/(he.y-de.y)*(he.x-de.x),C)._round()),W&&de.equals(W[W.length-1])||(W=[de],I.push(W),E&&E.push({progress:{min:Fe+BCe(Re,Ke,de)*Ce,max:1},parentIndex:R,prevPoint:Re,nextPoint:Ke})),W.push(he),E&&(E[E.length-1].progress.max=Fe+BCe(Re,Ke,he)*Ce,E[E.length-1].nextPoint=Ke)))))}if(E&&se>0)for(let ie=te;ieW.t-te.t);let I=0,R=0,q=[];for(b.push(q);I!==x.length;){if(R===E.length){for(;I!==x.length;)q.length!==0&&q[q.length-1].equals(x[I])||q.push(x[I]),I++;break}E[R].t<=I?(q.length!==0&&q[q.length-1].equals(E[R].point)||q.push(E[R].point),Math.trunc(E[R].t),R++):(q.length!==0&&q[q.length-1].equals(x[I])||q.push(x[I]),I++)}}function BCe(x,d,m){return x.x!==d.x?(m.x-x.x)/(d.x-x.x):x.y!==d.y?(m.y-x.y)/(d.y-x.y):0}function cP(x,d){return x.x*d.x+x.y*d.y}function $Ce(x,d){if(x.length===1){let m=0;const b=d[m++];let C;for(;!C||b.equals(C);)if(C=d[m++],!C)return 1/0;for(;m{ks[0]=Ss,ks[1]=zs,ks[2]=$s,ks[3]=1},ds=ICe();de>0&&(de+=ds),he+=ds;for(const ks of ie){const Ss=[],zs=[];for(const $s of ks){const Ds=$s.x+Ce.x,Rs=$s.y+Ce.y,ls=se.projection.projectTilePoint(Ds,Rs,kt),rs=se.projection.upVector(kt,$s.x,$s.y);let Fs=de,sr=he;if(Re){const Hs=VCe(Ds,Rs,de,he,Re,Ke,Xe,lt);Fs+=Hs.base,sr+=Hs.top}de!==0?Wt(qt,ls.x+rs[0]*zt*Fs,ls.y+rs[1]*zt*Fs,ls.z+rs[2]*zt*Fs):Wt(qt,ls.x,ls.y,ls.z),Wt(ss,ls.x+rs[0]*zt*sr,ls.y+rs[1]*zt*sr,ls.z+rs[2]*zt*sr),pt(qt,qt,Fe),pt(ss,ss,Fe),Ss.push(new I2(qt[0],qt[1],qt[2])),zs.push(new I2(ss[0],ss[1],ss[2]))}vt.push(Ss),At.push(zs)}return[vt,At]}(x,d,m,b,C,E,I,R,q,W,te):I?function(se,ie,de,he,Ce,Fe,Re,Ke,Xe){const lt=[],kt=[],vt=[0,0,0,1];for(const At of se){const zt=[],qt=[];for(const ss of At){const Wt=ss.x+he.x,ds=ss.y+he.y,ks=VCe(Wt,ds,ie,de,Fe,Re,Ke,Xe);vt[0]=Wt,vt[1]=ds,vt[2]=ks.base,vt[3]=1,Je(vt,vt,Ce),vt[3]=Math.max(vt[3],1e-5);const Ss=new I2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);vt[0]=Wt,vt[1]=ds,vt[2]=ks.top,vt[3]=1,Je(vt,vt,Ce),vt[3]=Math.max(vt[3],1e-5);const zs=new I2(vt[0]/vt[3],vt[1]/vt[3],vt[2]/vt[3]);zt.push(Ss),qt.push(zs)}lt.push(zt),kt.push(qt)}return[lt,kt]}(d,m,b,C,E,I,R,q,W):function(se,ie,de,he,Ce){const Fe=[],Re=[],Ke=Ce[8]*ie,Xe=Ce[9]*ie,lt=Ce[10]*ie,kt=Ce[11]*ie,vt=Ce[8]*de,At=Ce[9]*de,zt=Ce[10]*de,qt=Ce[11]*de;for(const ss of se){const Wt=[],ds=[];for(const ks of ss){const Ss=ks.x+he.x,zs=ks.y+he.y,$s=Ce[0]*Ss+Ce[4]*zs+Ce[12],Ds=Ce[1]*Ss+Ce[5]*zs+Ce[13],Rs=Ce[2]*Ss+Ce[6]*zs+Ce[14],ls=Ce[3]*Ss+Ce[7]*zs+Ce[15],rs=$s+Ke,Fs=Ds+Xe,sr=Rs+lt,Hs=Math.max(ls+kt,1e-5),zr=$s+vt,fr=Ds+At,_r=Rs+zt,Ar=Math.max(ls+qt,1e-5);Wt.push(new I2(rs/Hs,Fs/Hs,sr/Hs)),ds.push(new I2(zr/Ar,fr/Ar,_r/Ar))}Fe.push(Wt),Re.push(ds)}return[Fe,Re]}(d,m,b,C,E)}function VCe(x,d,m,b,C,E,I,R){const q=I*C.getElevationAt(x,d,!0,!0),W=E[0]!==0,te=W?E[1]===0?I*(E[0]/wCe-jCe):I*function(se,ie,de){const he=Math.floor(ie[0]/8),Ce=Math.floor(ie[1]/8),Fe=10*(ie[0]-8*he),Re=10*(ie[1]-8*Ce),Ke=se.getElevationAt(he,Ce,!0,!0),Xe=se.getMeterToDEM(de),lt=Math.floor(.5*(Fe*Xe-1)),kt=Math.floor(.5*(Re*Xe-1)),vt=se.tileCoordToPixel(he,Ce),At=2*lt+1,zt=2*kt+1,qt=function(zs,$s,Ds,Rs,ls){return[zs.getElevationAtPixel($s,Ds,!0),zs.getElevationAtPixel($s+ls,Ds,!0),zs.getElevationAtPixel($s,Ds+ls,!0),zs.getElevationAtPixel($s+Rs,Ds+ls,!0)]}(se,vt.x-lt,vt.y-kt,At,zt),ss=Math.abs(qt[0]-qt[1]),Wt=Math.abs(qt[2]-qt[3]),ds=Math.abs(qt[0]-qt[2])+Math.abs(qt[1]-qt[3]),ks=Math.min(.25,.5*Xe*(ss+Wt)/At),Ss=Math.min(.25,.5*Xe*ds/zt);return Ke+Math.max(ks*Fe,Ss*Re)}(C,E,R):q;return{base:q+(m===0?-1:m),top:W?Math.max(te+b,q+m+2):q+b}}class zdt{constructor(d){this._callback=d,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Bdt{constructor(){this.tasks={},this.taskQueue=[],Ut(["process"],this),this.invoker=new zdt(this.process),this.nextId=0}add(d,m){const b=this.nextId++,C=function({type:E,isSymbolTile:I,zoom:R}){return R=R||0,E==="message"?0:E!=="maybePrepare"||I?E!=="parseTile"||I?E==="parseTile"&&I?300-R:E==="maybePrepare"&&I?400-R:500:200-R:100-R}(m);if(C===0){try{d()}finally{}return null}return this.tasks[b]={fn:d,metadata:m,priority:C,id:b},this.taskQueue.push(b),this.invoker.trigger(),{cancel:()=>{delete this.tasks[b]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(b=>!!this.tasks[b]),!this.taskQueue.length)return;const d=this.pick();if(d===null)return;const m=this.tasks[d];if(delete this.tasks[d],this.taskQueue.length&&this.invoker.trigger(),!m)return;m.fn()}finally{}}pick(){let d=null,m=1/0;for(let C=0;C{b&&delete this.callbacks[R],this.target.postMessage({id:R,type:"",targetMapId:C,sourceMapId:this.mapId})}}}receive(d){const m=d.data;if(!m)return;const b=m.id;if(b&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const C=this.cancelCallbacks[b];delete this.cancelCallbacks[b],C&&C.cancel()}else if(m.mustQueue||wa(self)){const C=this.callbacks[b],E=this.scheduler.add(()=>this.processTask(b,m),C&&C.metadata||{type:"message"});E&&(this.cancelCallbacks[b]=E)}else this.processTask(b,m)}processTask(d,m){if(delete this.cancelCallbacks[d],m.type===""){const b=this.callbacks[d];delete this.callbacks[d],b&&(m.error?b(Iy(m.error)):b(null,Iy(m.data)))}else{const b=new Set,C=m.hasCallback?(I,R)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:I?ig(I):null,data:ig(R,b)},b)}:()=>{},E=Iy(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,C);else if(this.parent.getWorkerSource){const I=m.type.split("."),{source:R,scope:q}=E;this.parent.getWorkerSource(m.sourceMapId,I[0],R,q)[I[1]](E,C)}else C(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var dP={workerUrl:"",workerClass:null,workerParams:void 0};const Ipe="mapboxgl_preloaded_worker_pool";class L2{constructor(d){this.active={},this.name=d}acquire(d,m=L2.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ipe]}numActive(){return Object.keys(this.active).length}}L2.workerCount=2;class JC{constructor(d,m,b="Worker",C=L2.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=Ft();const E=this.workerPool.acquire(this.id,C);for(let I=0;I{this.ready=!0})}broadcast(d,m,b){bt(this.actors,(C,E)=>{C.send(d,m,E)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(d=>{d.remove()}),this.actors=[],this.workerPool.release(this.id)}}let uP,Lpe;function ZF(){return uP||(uP=new L2),uP}JC.Actor=HCe;const Dpe=4096;class $dt{constructor(d){this.module=d,this.memoryStack=this.module.malloc(Dpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Dpe?-1:(new Int32Array(this.module.heap32.buffer,m,d.length).set(d),m)}createFloatArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Dpe?-1:(new Float32Array(this.module.heapF32.buffer,m,d.length).set(d),m)}readStringBuffer(d){let m="";for(;this.module.heapU8[d]!==0;)m+=String.fromCharCode(this.module.heapU8[d]),++d;return m}setStyle(d){const m=d.normalScale;this.module.setStyle(m[0],m[1],m[2],d.tileToMeters)}setAOOptions(d,m){this.module.setAOOptions(d?1:0,m)}setMetricOptions(d,m){this.module.setMetricOptions(d?1:0,m)}setStructuralOptions(d){this.module.setStructuralOptions(d?1:0)}setFacadeOptions(d,m){this.module.setFacadeOptions(d,m?1:0)}setFauxFacadeOptions(d,m,b){this.module.setFauxFacadeOptions(d?1:0,m?1:0,b)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,m){this.memoryStackNextFree=this.memoryStack;for(const R of d){const q=this.createIntArray(R.ringIndices),W=this.createFloatArray(R.coordinates);if(q===-1||W===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(R.id,R.sourceId,R.minHeight,R.height,R.roofType,W,q,R.ringIndices.length-1)}for(const R of m){let q;q=R.entrances?JSON.parse(R.entrances):[];const W=this.createFloatArray(q),te=this.createFloatArray(R.coordinates);if(W===-1||te===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(R.sourceId,R.crossPerc,R.distanceToRoad,W,q.length,te,R.coordinates.length)}if(!this.module.generateMesh()){const R=this.module.getLastError();return this.readStringBuffer(R)}const b=this.module.getMeshCount(),C=new Array(b);for(let R=0;RC.arrayBuffer()).then(C=>{d.buffers[m]=C})}function JCe(x,d){const m=x.json.bufferViews[d];return new Uint8Array(x.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function Wdt(x,d,m,b){if(x.uri){const C=XCe(x.uri,b);return fetch(C).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[m]=E})}if(x.bufferView!==void 0){const C=JCe(d,x.bufferView),E=new Blob([C],{type:x.mimeType});return createImageBitmap(E).then(I=>{d.images[m]=I})}}function e5e(x,d=0,m){const b={json:null,images:[],buffers:[]};if(new Uint32Array(x,d,1)[0]===YCe){const te=new Uint32Array(x,d);let se=2;const ie=(te[se++]>>2)-3,de=te[se++]>>2;if(se++,b.json=JSON.parse(QCe.decode(te.subarray(se,se+de))),se+=de,se{const te=[],se=R&&R.includes(Fpe),ie=R&&R.includes(XF);if(se&&te.push(function(){if(!yg)return hP??(hP=function(de){let he,Ce=null;function Fe(){he=new Uint8Array(Ce.buffer)}function Re(){throw new Error("Unexpected Draco error.")}const Ke={a:{a:Re,d:function(Xe,lt,kt){return he.copyWithin(Xe,lt,lt+kt)},c:function(Xe){const lt=he.length,kt=Math.max(Xe>>>0,Math.ceil(1.2*lt)),vt=Math.ceil((kt-lt)/65536);try{return Ce.grow(vt),Fe(),!0}catch{return!1}},b:Re}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(de,Ke):de.then(Xe=>Xe.arrayBuffer()).then(Xe=>WebAssembly.instantiate(Xe,Ke))).then(Xe=>{const{Rb:lt,Qb:kt,P:vt,T:At,X:zt,Ja:qt,La:ss,Qa:Wt,Va:ds,Wa:ks,eb:Ss,jb:zs,f:$s,e:Ds,yb:Rs,zb:ls,Ab:rs,Bb:Fs,Db:sr,Gb:Hs}=Xe.instance.exports;Ce=Ds;const zr=(()=>{let fr=0,_r=0,Ar=0,ta=0;return Zs=>{Ar&&(lt(ta),lt(fr),_r+=Ar,Ar=fr=0),fr||(_r+=128,fr=kt(_r));const Er=Zs.length+7&-8;let _n=fr;Er>=_r&&(Ar=Er,_n=ta=kt(Er));for(let Na=0;Na{yg=de,hP=void 0}))}()),ie&&te.push(function(){if(Rpe)return;const de=function(he){let Ce;const Fe=WebAssembly.instantiateStreaming(he,{}).then(Xe=>{Ce=Xe.instance,Ce.exports.__wasm_call_ctors()}),Re={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Fe,supported:!0,decodeGltfBuffer(Xe,lt,kt,vt,At,zt){(function(qt,ss,Wt,ds,ks,Ss,zs){const $s=qt.exports.sbrk,Ds=ds+3&-4,Rs=$s(Ds*ks),ls=$s(Ss.length),rs=new Uint8Array(qt.exports.memory.buffer);rs.set(Ss,ls);const Fs=ss(Rs,ds,ks,ls,Ss.length);if(Fs===0&&zs&&zs(Rs,Ds,ks),Wt.set(rs.subarray(Rs,Rs+ds*ks)),$s(Rs-$s(0)),Fs!==0)throw new Error(`Malformed buffer data: ${Fs}`)})(Ce,Ce.exports[Ke[At]],Xe,lt,kt,vt,Ce.exports[Re[zt]])}}}(fetch(KCe()));return de.ready.then(()=>{Rpe=de})}()),E)for(let de=0;de{if(se&&I)for(const{primitives:de}of I)for(const he of de)Vdt(he,b);if(ie&&I&&q)for(const de of q)Hdt(de,b);return b})})}function t5e(x){return fetch(x).then(d=>d.arrayBuffer()).then(d=>e5e(d,0,x))}function zpe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Bpe(x){switch(x){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class $pe{constructor(d,m,b,C){this.context=d,this.format=b,this.useMipmap=C&&C.useMipmap,this.texture=d.gl.createTexture(),this.update(m,{premultiply:C&&C.premultiply})}update(d,m){const b=d&&d instanceof HTMLVideoElement&&d.width===0?d.videoWidth:d.width,C=d&&d instanceof HTMLVideoElement&&d.height===0?d.videoHeight:d.height,{context:E}=this,{gl:I}=E,{x:R,y:q}=m&&m.position?m.position:{x:0,y:0},W=R+b,te=q+C;!this.size||this.size[0]===W&&this.size[1]===te||(I.bindTexture(I.TEXTURE_2D,null),I.deleteTexture(this.texture),this.texture=I.createTexture(),this.size=null),I.bindTexture(I.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===I.RGBA8&&(!m||m.premultiply!==!1));const se=d instanceof HTMLImageElement||d instanceof HTMLCanvasElement||d instanceof HTMLVideoElement||d instanceof ImageData||ImageBitmap&&d instanceof ImageBitmap;if(!this.size&&W>0&&te>0){const ie=this.useMipmap?Math.floor(Math.log2(Math.max(W,te)))+1:1;I.texStorage2D(I.TEXTURE_2D,ie,this.format,W,te),this.size=[W,te]}this.size&&(se?I.texSubImage2D(I.TEXTURE_2D,0,R,q,zpe(this.format),Bpe(this.format),d):"data"in d&&d.data&&I.texSubImage2D(I.TEXTURE_2D,0,R,q,b,C,zpe(this.format),Bpe(this.format),d.data)),this.useMipmap&&I.generateMipmap(I.TEXTURE_2D)}bind(d,m,b=!1){const{context:C}=this,{gl:E}=C;E.bindTexture(E.TEXTURE_2D,this.texture),d!==this.minFilter&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,d),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,this.useMipmap&&!b?d===E.NEAREST?E.NEAREST_MIPMAP_NEAREST:E.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),m!==this.wrapS&&(E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,m),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,m),this.wrapS=m)}bindExtraParam(d,m,b,C,E){const{context:I}=this,{gl:R}=I;R.bindTexture(R.TEXTURE_2D,this.texture),m!==this.magFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MAG_FILTER,m),this.magFilter=m),d!==this.minFilter&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_MIN_FILTER,this.useMipmap?d===R.NEAREST?R.NEAREST_MIPMAP_NEAREST:R.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),b!==this.wrapS&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_S,b),this.wrapS=b),C!==this.wrapT&&(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_WRAP_T,C),this.wrapT=C),E!==this.compareMode&&(E?(R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.COMPARE_REF_TO_TEXTURE),R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_FUNC,E)):R.texParameteri(R.TEXTURE_2D,R.TEXTURE_COMPARE_MODE,R.NONE),this.compareMode=E)}destroy(){const{gl:d}=this.context;d.deleteTexture(this.texture),this.texture=null}}class pP{constructor(d,m){this.context=d,this.texture=m}bind(d,m){const{context:b}=this,{gl:C}=b;C.bindTexture(C.TEXTURE_2D,this.texture),d!==this.minFilter&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MAG_FILTER,d),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_MIN_FILTER,d),this.minFilter=d),m!==this.wrapS&&(C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_S,m),C.texParameteri(C.TEXTURE_2D,C.TEXTURE_WRAP_T,m),this.wrapS=m)}}const Kdt=xa([{name:"a_pos_3f",components:3,type:"Float32"}]),Zdt=xa([{name:"a_color_3f",components:3,type:"Float32"}]),Ydt=xa([{name:"a_color_4f",components:4,type:"Float32"}]),Qdt=xa([{name:"a_uv_2f",components:2,type:"Float32"}]),Xdt=xa([{name:"a_normal_3f",components:3,type:"Float32"}]),Jdt=xa([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),eut=xa([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function s5e(x,d){const m=JF(x.projection,x.zoom,x.width,x.height),b=function(E,I,R,q,W){const te=new y(R.lng-180*Ab,R.lat),se=new y(R.lng+180*Ab,R.lat),ie=E.project(te.lng,te.lat),de=E.project(se.lng,se.lat),he=-Math.atan2(de.y-ie.y,de.x-ie.x),Ce=nt.fromLngLat(R);Ce.y=Se(Ce.y,-1+Ab,1-Ab);const Fe=Ce.toLngLat(),Re=E.project(Fe.lng,Fe.lat),Ke=nt.fromLngLat(Fe);Ke.x+=Ab;const Xe=Ke.toLngLat(),lt=E.project(Xe.lng,Xe.lat),kt=n5e(lt.x-Re.x,lt.y-Re.y,he),vt=nt.fromLngLat(Fe);vt.y+=Ab;const At=vt.toLngLat(),zt=E.project(At.lng,At.lat),qt=n5e(zt.x-Re.x,zt.y-Re.y,he),ss=Math.abs(kt.x)/Math.abs(qt.y),Wt=j([]);$(Wt,Wt,-he*(1-(W?0:q)));const ds=j([]);return L(ds,ds,[1,1-(1-ss)*q,1]),ds[4]=-qt.x/qt.y*q,$(ds,ds,he),S(ds,Wt,ds),ds}(x.projection,0,x.center,m,d),C=r5e(x);return L(b,b,[C,C,1]),b}function r5e(x){const d=x.projection,m=JF(x.projection,x.zoom,x.width,x.height),b=qpe(d,x.center),C=qpe(d,y.convert(d.center));return Math.pow(2,b*m+(1-m)*C)}function JF(x,d,m,b,C=1/0){const E=x.range;if(!E)return 0;const I=Math.min(C,Math.max(m,b)),R=Math.log2(I/1024);return Be(E[0]+R,E[1]+R,d)}const Ab=1/4e4;function qpe(x,d){const m=Se(d.lat,-Ne,Ne),b=new y(d.lng-180*Ab,m),C=new y(d.lng+180*Ab,m),E=x.project(b.lng,m),I=x.project(C.lng,m),R=nt.fromLngLat(b),q=nt.fromLngLat(C),W=I.x-E.x,te=I.y-E.y,se=q.x-R.x,ie=q.y-R.y,de=Math.sqrt((se*se+ie*ie)/(W*W+te*te));return Math.log2(de)}function n5e(x,d,m){const b=Math.cos(m),C=Math.sin(m);return{x:x*b-d*C,y:x*C+d*b}}function a5e(x,d,m){j(x),$(x,x,jr(d[2])),P(x,x,jr(d[0])),O(x,x,jr(d[1])),L(x,x,m),S(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function e7(x,d,m,b,C,E,I,R){const q=[m[0]-d[0],m[1]-d[1],0],W=[b[0]-d[0],b[1]-d[1],0];if(ce(q)<1e-12||ce(W)<1e-12)return et(x);const te=Qe([],q,W);we(te,te),fe(W,b,d),q[2]=(E-C)*R,W[2]=(I-C)*R;const se=q;return Qe(se,q,W),we(se,se),cs(x,te,se)}function t7(x,d,m=!1){const b=Mb(d.zoom),C=function(E,I,R){const q=I.worldSize,W=[E[12],E[13],E[14]],te=je(W[1]/q),se=le(W[0]/q),ie=j([]),de=ae(1,te)*q,he=ae(1,0)*q*Pe(te,I.zoom),Ce=1/gpe(q);let Fe=he*Ce;if(R){const lt=JF(I.projection,I.zoom,I.width,I.height,1024);Fe=Ce*I.projection.pixelSpaceConversion(I.center.lat,q,lt)}const Re=kb(te,se);oe(Re,Re,_e([],we([],Re),de*Fe*W[2]));const Ke=function(lt){const kt=[lt[0],lt[1],lt[2]];let vt=[0,1,0];const At=Qe([],vt,kt);return Qe(vt,kt,At),ke(vt)===0&&(vt=[0,1,0],Qe(At,kt,vt)),we(At,At),we(vt,vt),we(kt,kt),[At[0],At[1],At[2],0,vt[0],vt[1],vt[2],0,kt[0],kt[1],kt[2],0,lt[0],lt[1],lt[2],1]}(Re);L(ie,ie,[Fe,Fe,Fe*de]),M(ie,ie,[-W[0],-W[1],-W[2]]);const Xe=S([],I.globeMatrix,Ke);return S(Xe,Xe,ie),S(Xe,Xe,E),Xe}(x,d,m);if(b>0){const E=function(I,R){const q=R.worldSize,W=ae(1,0)*q*Pe(R.center.lat,R.zoom)/gpe(q),te=ae(1,R.center.lat)*q,se=j([]);O(se,se,jr(R.center.lng)),P(se,se,jr(R.center.lat)),M(se,se,[0,0,Ud]),L(se,se,[W,W,W*te]);const ie=R.point;return M(se,se,[-ie.x,-ie.y,0]),S(se,se,I),S(se,R.globeMatrix,se)}(x,d);return function(I,R,q){const W=(he,Ce,Fe)=>{const Re=ce(he),Ke=ce(Ce),Xe=gg(he,Ce,Fe);return _e(Xe,Xe,1/ce(Xe)*Zr(Re,Ke,Fe))},te=W([I[0],I[1],I[2]],[R[0],R[1],R[2]],q),se=W([I[4],I[5],I[6]],[R[4],R[5],R[6]],q),ie=W([I[8],I[9],I[10]],[R[8],R[9],R[10]],q),de=gg([I[12],I[13],I[14]],[R[12],R[13],R[14]],q);return[te[0],te[1],te[2],0,se[0],se[1],se[2],0,ie[0],ie[1],ie[2],0,de[0],de[1],de[2],1]}(C,E,b)}return C}function Upe(x,d,m,b){const C=Rr.projectAabbCorners(b,m);let E=Number.MAX_VALUE;for(let R=0;R0||Fe===0&&he[0]*Ce[0]+he[1]*Ce[1]>=0&&he[0]*he[0]+he[1]*he[1]>Ce[0]*Ce[0]+Ce[1]*Ce[1])&&(te=de)}se=te}while(se!==W);return q.length>0&&q.push(q[0]),q}(C);if(Za(x,I))return E}const D2=64,r5={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function s7(x,d,m,b,C,E,I,R,q,W=!1){const te=m.zoom,se=m.project(b),ie=Pe(b.lat,te),de=1/ie;j(x),M(x,x,[se.x+I[0]*de,se.y+I[1]*de,I[2]]);let he=1,Ce=1;const Fe=m.worldSize;if(W){if(m.projection.name==="mercator"){let lt=0;m.elevation&&(lt=m.elevation.getAtPointOrZero(new nt(se.x/Fe,se.y/Fe),0));const kt=Je([],[se.x,se.y,lt,1],m.projMatrix)[3]/m.cameraToCenterDistance;he=kt,Ce=kt*Pe(m.center.lat,te)}else if(m.projection.name==="globe"){const lt=t7(x,m),kt=[0,0,0,1];Je(kt,kt,S([],m.projMatrix,lt));const vt=kt[3]/m.cameraToCenterDistance,At=Mb(te),zt=m.projection.pixelsPerMeter(b.lat,Fe)*Pe(b.lat,te),qt=m.projection.pixelsPerMeter(m.center.lat,Fe)*Pe(m.center.lat,te);he=vt/Zr(zt,De(m.center.lat),At),Ce=vt*ie/zt,he*=qt,Ce*=qt}}else he=de;L(x,x,[he,he,Ce]);const Re=[...x],Ke=d.orientation,Xe=[];if(a5e(Xe,[Ke[0]+(C?C[0]:0),Ke[1]+(C?C[1]:0),Ke[2]+(C?C[2]:0)],E),S(x,Re,Xe),R&&m.elevation){let lt=0;const kt=[];if(q&&m.elevation){lt=function(At,zt,qt,ss,Wt){const ds=zt.elevation;if(!ds)return 0;const ks=Rr.projectAabbCorners(qt,ss),Ss=ae(1,Wt.lat)*zt.worldSize,zs=function(_r,Ar){const ta=[0,0,1],Zs=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const Er of Zs){const _n=_r[Er.corners[0]],Na=_r[Er.corners[1]],Ta=_r[Er.corners[2]],qn=[Na[0]-_n[0],Na[1]-_n[1],Ar*(Na[2]-_n[2])],Ei=Qe(qn,qn,[Ta[0]-_n[0],Ta[1]-_n[1],Ar*(Ta[2]-_n[2])]);we(Ei,Ei),Er.dotProductWithUp=Le(Ei,ta)}return Zs.sort((Er,_n)=>Er.dotProductWithUp-_n.dotProductWithUp),Zs[0].corners}(ks,Ss),$s=ks[zs[0]],Ds=ks[zs[1]],Rs=ks[zs[2]],ls=ks[zs[3]],rs=ds.getAtPointOrZero(new nt($s[0]/zt.worldSize,$s[1]/zt.worldSize),0),Fs=ds.getAtPointOrZero(new nt(Ds[0]/zt.worldSize,Ds[1]/zt.worldSize),0),sr=ds.getAtPointOrZero(new nt(Rs[0]/zt.worldSize,Rs[1]/zt.worldSize),0),Hs=ds.getAtPointOrZero(new nt(ls[0]/zt.worldSize,ls[1]/zt.worldSize),0),zr=(rs+Hs)/2,fr=(Fs+sr)/2;return zr>fr?Fs=d.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function tut(x,d,m){x.indexBuffer=d.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=d.createVertexBuffer(x.vertexArray,Kdt.members,!1,!0),x.normalArray&&(x.normalBuffer=d.createVertexBuffer(x.normalArray,Xdt.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=d.createVertexBuffer(x.texcoordArray,Qdt.members,!1,!0)),x.colorArray&&(x.colorBuffer=d.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?Zdt:Ydt).members,!1,!0)),x.featureArray&&(x.pbrBuffer=d.createVertexBuffer(x.featureArray,eut.members,!0)),x.segments=wo.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const b=x.material;b.pbrMetallicRoughness.baseColorTexture&&fP(b.pbrMetallicRoughness.baseColorTexture,d),b.pbrMetallicRoughness.metallicRoughnessTexture&&fP(b.pbrMetallicRoughness.metallicRoughnessTexture,d),b.normalTexture&&fP(b.normalTexture,d),b.occlusionTexture&&fP(b.occlusionTexture,d,m),b.emissionTexture&&fP(b.emissionTexture,d)}function Vpe(x,d,m){if(x.meshes)for(const b of x.meshes)tut(b,d,m);if(x.children)for(const b of x.children)Vpe(b,d,m)}function r7(x){if(x.meshes)for(const d of x.meshes)d.indexArray.destroy(),d.vertexArray.destroy(),d.colorArray&&d.colorArray.destroy(),d.normalArray&&d.normalArray.destroy(),d.texcoordArray&&d.texcoordArray.destroy(),d.featureArray&&d.featureArray.destroy();if(x.children)for(const d of x.children)r7(d)}function Hpe(x){if(x.meshes)for(const m of x.meshes)m.vertexBuffer&&(m.vertexBuffer.destroy(),m.indexBuffer.destroy(),m.normalBuffer&&m.normalBuffer.destroy(),m.texcoordBuffer&&m.texcoordBuffer.destroy(),m.colorBuffer&&m.colorBuffer.destroy(),m.pbrBuffer&&m.pbrBuffer.destroy(),m.segments.destroy(),m.material&&((d=m.material).pbrMetallicRoughness.baseColorTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture&&d.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),d.pbrMetallicRoughness.metallicRoughnessTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&d.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),d.normalTexture&&d.normalTexture.gfxTexture&&d.normalTexture.gfxTexture.destroy(),d.emissionTexture&&d.emissionTexture.gfxTexture&&d.emissionTexture.gfxTexture.destroy(),d.occlusionTexture&&d.occlusionTexture.gfxTexture&&d.occlusionTexture.gfxTexture.destroy()));var d;if(x.children)for(const m of x.children)Hpe(m)}function O2(x,d){const m=x.json.bufferViews[d.bufferView],b=QF[d.componentType];return new b(x.buffers[m.buffer],(d.byteOffset||0)+(m.byteOffset||0),d.count*(m.byteStride&&m.byteStride!==mP[d.type]*b.BYTES_PER_ELEMENT?m.byteStride/b.BYTES_PER_ELEMENT:mP[d.type]))}function Gpe(x,d,m,b){const C=QF[d.componentType],E=function(te){switch(te){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(C),I=x.json.bufferViews[d.bufferView],R=I.byteStride?I.byteStride/C.BYTES_PER_ELEMENT:mP[d.type],q=m.float32,W=q.length/m.capacity;for(let te=0,se=0;te0){for(let Fe=0;Fe0){E.texcoordArray=new Wf;const ie=d.json.accessors[C.TEXCOORD_0];E.texcoordArray.resize(ie.count);const de=O2(d,ie);Gpe(d,ie,E.texcoordArray,de)}if(C._FEATURE_ID_RGBA4444!==void 0){const ie=d.json.accessors[C._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=O2(d,ie))}C._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(O2(d,d.json.accessors[C._FEATURE_RGBA4444]).buffer));const se=x.material;return E.material=function(ie,de){const{emissiveFactor:he=[0,0,0],alphaMode:Ce="OPAQUE",alphaCutoff:Fe=.5,normalTexture:Re,occlusionTexture:Ke,emissiveTexture:Xe,doubleSided:lt,name:kt}=ie,{baseColorFactor:vt=[1,1,1,1],metallicFactor:At=1,roughnessFactor:zt=1,baseColorTexture:qt,metallicRoughnessTexture:ss}=ie.pbrMetallicRoughness||{},Wt=Ke?de[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Wt){const ds=Ke.extensions.KHR_texture_transform;Wt.offsetScale=[ds.offset[0],ds.offset[1],ds.scale[0],ds.scale[1]]}return{name:kt,pbrMetallicRoughness:{baseColorFactor:new Ur(...vt),metallicFactor:At,roughnessFactor:zt,baseColorTexture:qt?de[qt.index]:void 0,metallicRoughnessTexture:ss?de[ss.index]:void 0},doubleSided:lt,emissiveFactor:new Ur(...he),alphaMode:Ce,alphaCutoff:Fe,normalTexture:Re?de[Re.index]:void 0,occlusionTexture:Wt,emissionTexture:Xe?de[Xe.index]:void 0,defined:ie.defined===void 0}}(se!==void 0?d.json.materials[se]:{defined:!1},m),E}function o5e(x,d,m){const{matrix:b,rotation:C,translation:E,scale:I,mesh:R,extras:q,children:W,name:te}=x,se={};if(se.name=te,se.localMatrix=b||function(ie,de,he,Ce){var Fe=de[0],Re=de[1],Ke=de[2],Xe=de[3],lt=Fe+Fe,kt=Re+Re,vt=Ke+Ke,At=Fe*lt,zt=Fe*kt,qt=Fe*vt,ss=Re*kt,Wt=Re*vt,ds=Ke*vt,ks=Xe*lt,Ss=Xe*kt,zs=Xe*vt,$s=Ce[0],Ds=Ce[1],Rs=Ce[2];return ie[0]=(1-(ss+ds))*$s,ie[1]=(zt+zs)*$s,ie[2]=(qt-Ss)*$s,ie[3]=0,ie[4]=(zt-zs)*Ds,ie[5]=(1-(At+ds))*Ds,ie[6]=(Wt+ks)*Ds,ie[7]=0,ie[8]=(qt+Ss)*Rs,ie[9]=(Wt-ks)*Rs,ie[10]=(1-(At+ss))*Rs,ie[11]=0,ie[12]=he[0],ie[13]=he[1],ie[14]=he[2],ie[15]=1,ie}([],C||[0,0,0,1],E||[0,0,0],I||[1,1,1]),se.globalMatrix=w(se.localMatrix),R!==void 0){se.meshes=m[R];const ie=se.anchor=[0,0];for(const de of se.meshes){const{min:he,max:Ce}=de.aabb;ie[0]+=he[0]+Ce[0],ie[1]+=he[1]+Ce[1]}ie[0]=Math.floor(ie[0]/se.meshes.length/2),ie[1]=Math.floor(ie[1]/se.meshes.length/2)}if(q&&(q.id&&(se.id=q.id),q.lights&&(se.lights=function(ie){if(!ie.length)return[];const de=function(Ke){const Xe=atob(Ke),lt=new Uint8Array(Xe.length);for(let kt=0;kt1&&b[b.length-1].equals(b[0])&&b.pop();let C=0;for(let I=0;I0&&b.reverse();const E=QC(b.flatMap(I=>[I.x,I.y]),[]);return E.length===0?null:{vertices:b,indices:E}}function aut(x,d){const m=[],b=[];let C=0;const E=[];for(const I of x){C=m.length;const R=I.vertexArray.float32,q=I.indexArray.uint16;for(let W=0;W0&&([b[I+1],b[I+2]]=[b[I+2],b[I+1]])}return{vertices:m,indices:b}}function Wpe(x){const d=function(q,W){const te=[],se=WebGL2RenderingContext;if(q.json.textures)for(const ie of q.json.textures){const de={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};ie.sampler!==void 0&&Object.assign(de,q.json.samplers[ie.sampler]),te.push({image:W[ie.source],sampler:de,uploaded:!1})}return te}(x,x.images),m=function(q,W){const te=[];for(const se of q.json.meshes){const ie=[];for(const de of se.primitives)ie.push(sut(de,q,W));te.push(ie)}return te}(x,d),{scenes:b,scene:C,nodes:E}=x.json,I=b?b[C||0].nodes:[...E.keys()],R=[];for(const q of I)R.push(o5e(E[q],x,m));return function(q,W,te){const se={},ie=new Set;for(let de=0;de0){const de=Array.from(ie.values()).sort((he,Ce)=>he-Ce);for(let he=de.length-1;he>=0;he--)q.splice(de[he],1)}}(R,I,x.json.nodes),R}function iut(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const d=x.vertexArray.float32,m=x.aabb.min[0]-1,b=x.aabb.min[1]-1,C=D2/(x.aabb.max[0]-m+2),E=D2/(x.aabb.max[1]-b+2);for(let I=0;Ix.heightmap[W*D2+q]&&(x.heightmap[W*D2+q]=R)}}function l5e(x,d,m,b,C){m.reserve(m.length+4*x.length),b.reserve(b.length+10*x.length),C.reserve(C.length+10*x.length);let E=b.length;for(const I of x){const R=Math.min(10,Math.max(4,1.3*I.height))*d,q=[-I.normal[1],I.normal[0],0],W=Math.min(.29,.1*I.width/I.depth),te=I.width-2*I.depth*d*(W+.01),se=$e([],I.pos,q,te/2),ie=$e([],I.pos,q,-te/2),de=[se[0],se[1],se[2]+I.height],he=[ie[0],ie[1],ie[2]+I.height],Ce=$e([],I.normal,q,W);_e(Ce,Ce,R);const Fe=$e([],I.normal,q,-W);_e(Fe,Fe,R),oe(Ce,se,Ce),oe(Fe,ie,Fe),se[2]+=.1,ie[2]+=.1,b.emplaceBack(Ce[0],Ce[1],Ce[2]),b.emplaceBack(Fe[0],Fe[1],Fe[2]),b.emplaceBack(se[0],se[1],se[2]),b.emplaceBack(ie[0],ie[1],ie[2]),b.emplaceBack(de[0],de[1],de[2]),b.emplaceBack(he[0],he[1],he[2]),b.emplaceBack(se[0],se[1],se[2]),b.emplaceBack(ie[0],ie[1],ie[2]),b.emplaceBack(Ce[0],Ce[1],Ce[2]),b.emplaceBack(Fe[0],Fe[1],Fe[2]);const Re=te/R/2;C.emplaceBack(-Re-W,-1,Re,.8),C.emplaceBack(Re+W,-1,Re,.8),C.emplaceBack(-Re,0,Re,1.3),C.emplaceBack(Re,0,Re,1.3),C.emplaceBack(Re+W,-.8,Re,.7),C.emplaceBack(Re+W,-.8,Re,.7),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(0,0,Re,1.3),C.emplaceBack(Re+W,-1.2,Re,.8),C.emplaceBack(Re+W,-1.2,Re,.8),m.emplaceBack(6+E,4+E,8+E),m.emplaceBack(7+E,9+E,5+E),m.emplaceBack(0+E,1+E,2+E),m.emplaceBack(1+E,3+E,2+E),E+=10}}function out(x,d){const m={};m.indexArray=new Vl,m.vertexArray=new um,m.colorArray=new Dy,l5e(x,d,m.indexArray,m.vertexArray,m.colorArray);const b={defined:!0};b.emissiveFactor=Ur.black;const C={};return C.baseColorFactor=Ur.white,b.pbrMetallicRoughness=C,m.material=b,m.aabb=new Rr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const c5e=xa([{name:"a_pos_3f",components:3,type:"Float32"}]),lut=xa([{name:"a_normal_3",components:3,type:"Int16"}]),cut=xa([{name:"a_centroid_3",components:3,type:"Int16"}]),d5e=xa([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),dut=xa([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),uut=xa([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),hut=xa([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),mut=xa([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),put=xa([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),u5e=Ht.types,n7=32767;function fut(x,d){const m=tr+d;for(const b of x)for(const C of b)if(C.x<-d||C.x>m||C.y<-d||C.y>m)return!1;return!0}function xut(x){switch(x){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${x}`)}}class Kpe{constructor(){this.layoutVertexArray=new um,this.layoutAttenuationArray=new Dy,this.layoutColorArray=new hm,this.indexArray=new Vl,this.indexArrayForConflation=new Vl,this.segmentsBucket=new wo}}class Zpe{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new wo,this.entranceBloom=new Kpe;const m=66560;this.layoutVertexArray=new um,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new vb,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new vb,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new hm,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Oy,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new zC,this.layoutAOArray.reserve(m),this.indexArray=new Vl,this.indexArray.reserve(66560),this.indexArrayForConflation=new Vl,this.segmentsBucket=new wo,this.entranceBloom=new Kpe,d&&(this.layoutFacadePaintArray=new hm,this.layoutFacadeDataArray=new gv,this.layoutFacadeVerticalRangeArray=new hm)}reserve(d,m,b){this.layoutVertexArray.reserveForAdditional(d),this.layoutCentroidArray.reserveForAdditional(d),this.layoutFloodLightDataArray.reserveForAdditional(d),this.layoutNormalArray.reserveForAdditional(d),this.layoutAOArray.reserveForAdditional(d),this.layoutColorArray.reserveForAdditional(d),this.indexArray.reserveForAdditional(m),b&&(this.layoutFacadePaintArray.reserveForAdditional(d),this.layoutFacadeDataArray.reserveForAdditional(d),this.layoutFacadeVerticalRangeArray.reserveForAdditional(d))}}class h5e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Wf,this.footprintsIndices=new Oy,this.footprintsMin=new ft(1/0,1/0),this.footprintsMax=new ft(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Zpe(!1),this.buildingWithFacade=new Zpe(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=d.zoom,this.canonical=d.canonical,this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.index=d.index,this.hasPattern=!1,this.worldview=d.worldview,this.lut=d.lut,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.projection=d.projection,this.groundEffect=new Epe(d),this.groundEffect.groundRadiusArray=new dg,this.hasAppearances=null}updateFootprints(d,m){const b=new UF([],[],1),C={vertices:[],indices:new Uint32Array(0),grid:b,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:C,id:d})}updateAppearances(d,m,b,C){}prepare(){return function(){if(YF!=null||GCe!=null)return null;if(s5!=null)return s5;const d=fetch(ha.BUILDING_GEN_URL);return s5=function(m){let b,C,E,I,R;function q(){b=new Uint8Array(R.buffer),C=new Int16Array(R.buffer),E=new Int32Array(R.buffer),I=new Float32Array(R.buffer)}function W(){throw new Error("Unexpected BuildingGen error.")}const te=()=>{},se={a:{a:W,f:function(ie){const de=b.length,he=Math.max(ie>>>0,Math.ceil(1.2*de)),Ce=Math.ceil((he-de)/65536);try{return R.grow(Ce),q(),!0}catch{return!1}},g:W,b:te,c:te,d:te,e:te}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,se):m.then(ie=>ie.arrayBuffer()).then(ie=>WebAssembly.instantiate(ie,se))).then(ie=>{const de=ie.instance.exports;return(0,de.g)(),R=de.f,q(),new $dt({setStyle:de.h,setAOOptions:de.i,setMetricOptions:de.j,setStructuralOptions:de.k,setFacadeOptions:de.l,setFauxFacadeOptions:de.m,setFacadeClassifierOptions:de.n,addFeature:de.o,addFacade:de.p,generateMesh:de.q,getLastError:de.r,getOuterRingLength:de.s,getMeshCount:de.t,getPositionsPtr:de.u,getPositionsLength:de.v,getNormalsPtr:de.w,getNormalsLength:de.x,getAOPtr:de.y,getAOLength:de.z,getUVPtr:de.A,getUVLength:de.B,getFauxFacadePtr:de.C,getFauxFacadeLength:de.D,getIndicesPtr:de.E,getIndicesLength:de.F,getBuildingPart:de.G,getRingCount:de.H,getRingPtr:de.I,getRingLength:de.J,malloc:de.K,free:de.L,heapU8:b,heap16:C,heap32:E,heapF32:I})})}(d).then(m=>(s5=null,YF=m,YF)).catch(m=>{xr("Could not load building-gen"),s5=null,GCe=m}),s5}()}populate(d,m,b,C){const E=qdt();if(!E)return;const I=Ve(b);this.tileToMeter=I,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,I],tileToMeters:I}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const R=new Map,q=new Map;let W=0;for(const{feature:Re}of d){if(u5e[Re.type]!=="LineString"){R.set(Re.id,Re.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Zi(this.zoom),Re,b))continue;const Xe=Gt(Re,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Zi(this.zoom),Xe,b))continue;const lt=Ke?Xe.geometry:Ot(Re,b,C),kt=[];for(const qt of lt)for(const ss of qt)kt.push(ss.x),kt.push(ss.y);const vt={coordinates:kt,crossPerc:Re.properties.cross_perc,distanceToRoad:Re.properties.distance_to_road,entrances:Re.properties.entrances,sourceId:0},At=Re.properties.source_id;let zt=q.get(At);zt||(zt=[],q.set(At,zt)),zt.push(vt),++W}this.maxHeight=0;const te=new Array,se=new Set,ie=Re=>{Re!=null&&se.add(Re)},de=(Re,Ke)=>{Re!=null&&te.push({buildingId:Re,footprintIndex:Ke})},he=64*(d.length-W),Ce=he/2;this.buildingWithFacade.reserve(he,Ce,!0),this.buildingWithoutFacade.reserve(2*he,2*Ce,!1),this.footprintsIndices.reserve(16*(d.length-W)),this.footprintsVertices.reserve(8*(d.length-W));for(const{feature:Re,id:Ke,index:Xe,sourceLayerIndex:lt}of d){if(u5e[Re.type]==="LineString")continue;const kt=this.layers[0]._featureFilter.needGeometry;if(kt&&!this.layers[0]._featureFilter.filter(new Zi(this.zoom),Re,b))continue;let vt=null;if(Re.properties&&Re.properties.hasOwnProperty("building_id")&&(vt=Re.properties.building_id,se.has(vt)))continue;const At=Gt(Re,kt);if(!kt&&!this.layers[0]._featureFilter.filter(new Zi(this.zoom),At,b))continue;const zt=kt?At.geometry:Ot(Re,b,C),qt=nP(zt,500);let ss=!1;for(const nn of qt)if(nn.length!==1){ss=!0;break}if(ss){ie(vt);continue}if(!fut(zt,163)){ie(vt);continue}const Wt=this.layers[0],ds=xut(Wt.layout.get("building-roof-shape").evaluate(Re,{},b)),ks=Wt.layout.get("building-base").evaluate(Re,{},b),Ss=Wt.layout.get("building-height").evaluate(Re,{},b),zs=Wt.layout.get("building-flood-light-ground-radius").evaluate(Re,{},b),$s=Wt.paint.get("building-ambient-occlusion-intensity"),Ds=zs/this.tileToMeter;Re.properties["building-part"]="roof";const Rs=Wt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),ls=Wt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="wall";const rs=Wt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Fs=Wt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="window";const sr=Wt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),Hs=Wt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);Re.properties["building-part"]="door";const zr=Wt.paint.get("building-color").evaluate(Re,{},this.canonical).toPremultipliedRenderColor(this.lut),fr=Wt.paint.get("building-emissive-strength").evaluate(Re,{},this.canonical);let _r=Wt.layout.get("building-flood-light-wall-radius").evaluate(Re,{},b);_r=Se(_r,0,2048);const Ar=_r/2048*n7,ta=R.get(Ke),Zs=q.get(ta)||[],Er=Zs.length!==0&&Wt.layout.get("building-facade").evaluate(Re,{},b);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Er,!1,1);let _n=0,Na=0,Ta=0,qn=0,Ei=0,_t=0,Ct=0,us=0,Bs=0,cr=0,dr=0;if(Er){let nn=Math.round(Wt.layout.get("building-facade-floors").evaluate(Re,{},b));if(ks===0){nn=Math.max(1,nn-(Zs.length>0?1:0));let ji=4;if(Ss>100){const ao=[10,13,15];ji=ao[Re.id?Re.id%ao.length:0]}else Ss<=10&&(ji=3);E.setFacadeOptions(ji,!0),Ei=(Ss<15?1.3:1.61803)*ji/I}else Ei=ks/I;_t=Ss/I,Ei=Math.min(Ei,_t),Ta=Wt.layout.get("building-facade-unit-width").evaluate(Re,{},b)/I,qn=(_t-Ei)/nn,E.setFauxFacadeOptions(!0,!0,Ta);const ko=Wt.layout.get("building-facade-window").evaluate(Re,{},b);_n=ko[0],Na=ko[1],Ct=Math.floor(65535*Math.min(1,Ei/tr)),us=Math.floor(65535*Math.min(1,_t/tr)),Bs=Math.floor(255*_n)<<8|Math.floor(255*Na),cr=Math.floor(65535*Math.min(1,Ta/tr)),dr=Math.floor(65535*Math.min(1,qn/tr))}const Br=Array(qt.length),Vr={x:1/0,y:1/0},Ln={x:-1/0,y:-1/0},Kn={x:0,y:0};let Xn=0;for(let nn=0;nn0){const ji=[],ao=Array(ko.length+1);ao[0]=0;for(let Wl=0;Wltr||Vr.y<0||Ln.y>tr)&&this.featuresOnBorder.push({featureId:Re.id,footprintIndex:this.footprints.length});{const nn=QC(Li,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+nn.length),this.footprintsIndices.uint16.set(nn,rn),this.buildingIds.add(vt??Re.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,Ui.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,Ui.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Yi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Yi.y);const ko={footprintVertexOffset:ya,footprintVertexLength:this.footprintsVertices.length-ya,footprintIndexOffset:rn,footprintIndexLength:this.footprintsIndices.length-rn,min:Ui,max:Yi,hiddenFlags:0,indicesOffset:mi,indicesLength:fo,bloomIndicesOffset:wi,bloomIndicesLength:Ri,groundEffectVertexOffset:sl,groundEffectVertexLength:Hi,hasFauxFacade:Er,height:Zn,promoteId:Ke,feature:At,parts:Ja,buildingBloom:ei},ji=this.footprints.length;Re.id!==void 0&&this.featureFootprintLookup.set(Re.id,ji),de(vt,ji),this.footprints.push(ko)}this.programConfigurations.populatePaintArrays(on.layoutVertexArray.length,Re,Xe,{},m.availableImages,b,m.brightness),this.groundEffect.addPaintPropertiesData(Re,Xe,{},m.availableImages,b,m.brightness),m.featureIndex.insert(Re,zt,Xe,lt,this.index,Pi)}te.forEach(({buildingId:Re,footprintIndex:Ke})=>{se.has(Re)&&(this.footprints[Ke].hiddenFlags|=4)});const Fe=new Set;this.buildingIds.forEach((Re,Ke,Xe)=>{se.has(Re)||Fe.add(Re)}),this.buildingIds=Fe,this.groundEffect.prepareBorderSegments()}update(d,m,b,C,E,I,R){this.programConfigurations.updatePaintArrays(d,m,E,b,C,I,R),this.groundEffect.update(d,m,E,b,C,I,R),this.evaluate(this.layers[0],d),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){const m=b=>{b.layoutVertexBuffer=d.createVertexBuffer(b.layoutVertexArray,c5e.members),b.layoutNormalBuffer=d.createVertexBuffer(b.layoutNormalArray,lut.members),b.layoutCentroidBuffer=d.createVertexBuffer(b.layoutCentroidArray,cut.members),b.layoutFloodLightDataBuffer=d.createVertexBuffer(b.layoutFloodLightDataArray,put.members),b.layoutFacadeDataArray&&b.layoutFacadeDataArray.length&&(b.layoutFacadeDataBuffer=d.createVertexBuffer(b.layoutFacadeDataArray,uut.members)),b.layoutFacadeVerticalRangeArray&&b.layoutFacadeVerticalRangeArray.length&&(b.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(b.layoutFacadeVerticalRangeArray,hut.members)),b.entranceBloom.layoutVertexArray.length&&(b.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(b.entranceBloom.layoutVertexArray,c5e.members),b.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(b.entranceBloom.layoutAttenuationArray,mut.members)),this.uploadUpdatedColorBuffer(d),this.uploadUpdatedIndexBuffer(d)};this.uploaded||(m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.groundEffect.upload(d)),this.groundEffect.uploadPaintProperties(d),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){const d=m=>{m.layoutVertexBuffer&&(m.layoutVertexBuffer.destroy(),m.layoutNormalBuffer.destroy(),m.layoutColorBuffer.destroy(),m.segmentsBucket.destroy(),m.indexBuffer&&m.indexBuffer.destroy(),m.entranceBloom.layoutVertexBuffer&&(m.entranceBloom.layoutVertexBuffer.destroy(),m.entranceBloom.layoutColorBuffer.destroy(),m.entranceBloom.layoutAttenuationBuffer.destroy(),m.entranceBloom.indexBuffer.destroy(),m.entranceBloom.segmentsBucket.destroy()))};d(this.buildingWithoutFacade),d(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(d,m,b=!0){let C=!1;const E=b?m:0,I=0|(b?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const R of d){const q=this.footprints[R],W=q.hiddenFlags&I|E;q.hiddenFlags!==W&&(q.hiddenFlags=W,C=!0,this.groundEffect.updateHiddenByLandmarkRange(q.groundEffectVertexOffset,q.groundEffectVertexLength,q.hiddenFlags!==0))}return C&&(this.indexArrayForConflationUploaded=!1),C}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const m=C=>{C.indexArray.length!==0&&(C.indexArrayForConflation.resize(C.indexArray.length),C.indexArrayForConflation.uint16.set(C.indexArray.uint16),C.entranceBloom.indexArrayForConflation.resize(C.entranceBloom.indexArray.length),C.entranceBloom.indexArrayForConflation.uint16.set(C.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const C of this.footprints){const E=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,I=C.indicesOffset+C.indicesLength;if(C.hiddenFlags!==0){for(let q=C.indicesOffset;q{C.indexArray.length!==0&&(C.indexBuffer?C.indexBuffer.updateData(C.indexArrayForConflation):C.indexBuffer=d.createIndexBuffer(C.indexArrayForConflation,!0),C.entranceBloom.indexBuffer?C.entranceBloom.indexBuffer.updateData(C.entranceBloom.indexArrayForConflation):C.entranceBloom.indexBuffer=d.createIndexBuffer(C.entranceBloom.indexArrayForConflation,!0))};b(this.buildingWithoutFacade),b(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(d){const m=b=>{b.layoutColorBuffer?b.layoutColorBuffer.updateData(b.layoutColorArray):b.layoutColorBuffer=d.createVertexBuffer(b.layoutColorArray,d5e.members,!0),b.layoutFacadePaintArray&&(b.layoutFacadePaintBuffer?b.layoutFacadePaintBuffer.updateData(b.layoutFacadePaintArray):b.layoutFacadePaintBuffer=d.createVertexBuffer(b.layoutFacadePaintArray,dut.members,!0)),b.entranceBloom.layoutColorBuffer?b.entranceBloom.layoutColorBuffer.updateData(b.entranceBloom.layoutColorArray):b.entranceBloom.layoutColorBuffer=d.createVertexBuffer(b.entranceBloom.layoutColorArray,d5e.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(d,m){const b=d.paint.get("building-ambient-occlusion-intensity");for(const C of this.footprints){if(4&C.hiddenFlags)continue;const E=m[C.promoteId],I=C.feature;I.properties["building-part"]="roof";const R=d.paint.get("building-color").evaluate(I,E,this.canonical).toPremultipliedRenderColor(this.lut),q=d.paint.get("building-emissive-strength").evaluate(I,E,this.canonical);I.properties["building-part"]="wall";const W=d.paint.get("building-color").evaluate(I,E,this.canonical).toPremultipliedRenderColor(this.lut),te=d.paint.get("building-emissive-strength").evaluate(I,E,this.canonical);I.properties["building-part"]="window";const se=d.paint.get("building-color").evaluate(I,E,this.canonical).toPremultipliedRenderColor(this.lut),ie=d.paint.get("building-emissive-strength").evaluate(I,E,this.canonical);I.properties["building-part"]="door";const de=d.paint.get("building-color").evaluate(I,E,this.canonical).toPremultipliedRenderColor(this.lut),he=d.paint.get("building-emissive-strength").evaluate(I,E,this.canonical),Ce=C.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Re of C.parts){let Ke,Xe=R;Re.part===1?(Xe=R,Ke=q):Re.part===0?(Xe=W,Ke=te):Re.part===2?(Xe=se,Ke=ie):Re.part===3&&(Xe=de,Ke=he),Ke=Se(Ke,0,1);for(let lt=0;ltI.max.x||q.max.xI.max.y||q.max.yR.max.x||R.min.x>d||m>R.max.y||R.min.y>m||R.height<=b||gut(I,this.footprintsVertices.float32.subarray(2*R.footprintVertexOffset,2*(R.footprintVertexOffset+R.footprintVertexLength)),this.footprintsIndices.uint16.subarray(R.footprintIndexOffset,R.footprintIndexOffset+R.footprintIndexLength))&&(b=R.height,this.footprintLookup[E]=R,C=R.hiddenFlags!==0);if(b!==Number.NEGATIVE_INFINITY)return{height:b,hidden:C};this.footprintLookup[E]=void 0}}function gut(x,d,m){for(let b=0;b1&&(q=d[++R]);const te=Math.abs(W-q.left),se=Math.abs(W-q.right),ie=Math.min(te,se);let de;const he=E/b*(C+1);if(q.isDash){const Ce=C-Math.abs(he);de=Math.sqrt(ie*ie+Ce*Ce)}else de=C-Math.sqrt(ie*ie+he*he);this.image.data[I+W]=Math.max(0,Math.min(255,de+128))}}}addRegularDash(d,m){for(let q=d.length-1;q>=0;--q){const W=d[q],te=d[q+1];W.zeroLength?d.splice(q,1):te&&te.isDash===W.isDash&&(te.left=W.left,d.splice(q,1))}const b=d[0],C=d[d.length-1];b.isDash===C.isDash&&(b.left=C.left-this.width,C.right=b.right+this.width);const E=this.width*this.nextRow;let I=0,R=d[I];for(let q=0;q1&&(R=d[++I]);const W=Math.abs(q-R.left),te=Math.abs(q-R.right),se=Math.min(W,te);this.image.data[E+q]=Math.max(0,Math.min(255,(R.isDash?se:-se)+m+128))}}addDash(d,m){const b=this.getKey(d,m);if(this.positions[b])return this.positions[b];const C=m==="round",E=C?7:0,I=2*E+1;if(this.nextRow+I>this.height)return xr("LineAtlas out of space"),null;d.length===0&&d.push(1);let R=0;for(let te=0;tem.fqid),this.index=d.index,this.projection=d.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(m=>{this.gradients[m.id]={}}),this.layoutVertexArray=new PC,this.layoutVertexArray2=new um,this.patternVertexArray=new um,this.indexArray=new Vl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new wo,this.maxLineLength=0,this.zOffsetVertexArray=new um,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=d.tessellationStep?d.tessellationStep:tr/64,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,b,C){}populate(d,m,b,C){this.hasPattern=wpe("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ve(b);const I=this.layers[0].layout.get("line-elevation-reference");if(I==="hd-road-markup")this.elevationType="road";else{const ie=this.layers[0].layout.get("line-z-offset"),de=ie.isConstant()&&!ie.constantOr(0);this.elevationType=I!=="sea"&&I!=="ground"&&de?"none":"offset",this.elevationType==="offset"&&I==="none"&&xr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const R=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&R!==void 0;const q=[];for(const{feature:ie,id:de,index:he,sourceLayerIndex:Ce}of d){const Fe=this.layers[0]._featureFilter.needGeometry,Re=Gt(ie,Fe);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Re,b))continue;const Ke=E?E.evaluate(Re,{},b):void 0,Xe={id:de,properties:ie.properties,type:ie.type,sourceLayerIndex:Ce,index:he,geometry:Fe?Re.geometry:Ot(ie,b,C),patterns:{},sortKey:Ke};q.push(Xe)}E&&q.sort((ie,de)=>ie.sortKey-de.sortKey);const{lineAtlas:W,featureIndex:te}=m,se=this.addConstantDashes(W);for(const ie of q){const{geometry:de,index:he,sourceLayerIndex:Ce}=ie;if(se&&this.addFeatureDashes(ie,W),this.hasPattern){const Fe=jpe("line",this.layers,ie,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Fe)}else this.addFeature(ie,de,he,b,W.positions,m.availableImages,m.brightness,m.elevationFeatures);te.insert(d[he].feature,de,he,Ce,this.index)}}addConstantDashes(d){let m=!1;for(const b of this.layers){const C=b.paint.get("line-dasharray").value,E=b.layout.get("line-cap").value;if(C.kind!=="constant"||E.kind!=="constant")m=!0;else{const I=E.value,R=C.value;if(!R)continue;d.addDash(R,I)}}return m}addFeatureDashes(d,m){const b=this.zoom;for(const C of this.layers){const E=C.paint.get("line-dasharray").value,I=C.layout.get("line-cap").value;if(E.kind==="constant"&&I.kind==="constant")continue;let R,q;if(E.kind==="constant"){if(R=E.value,!R)continue}else R=E.evaluate({zoom:b},d);q=I.kind==="constant"?I.value:I.evaluate({zoom:b},d),m.addDash(R,q),d.patterns[C.id]=[m.getKey(R,q)]}}update(d,m,b,C,E,I,R,q){this.programConfigurations.updatePaintArrays(d,m,E,b,C,I,R,q)}addFeatures(d,m,b,C,E,I){for(const R of this.patternFeatures)this.addFeature(R,R.geometry,R.index,m,b,C,I,d.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=d.createVertexBuffer(this.layoutVertexArray2,jut)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,kut)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,but.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,_ut),this.indexBuffer=d.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(d),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(d,m){let b,C;if(m&&m>0?(b=`mapbox_clip_start_${m}`,C=`mapbox_clip_end_${m}`):(b="mapbox_clip_start",C="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(b)&&d.properties.hasOwnProperty(C))return{start:+d.properties[b],end:+d.properties[C]}}addFeature(d,m,b,C,E,I,R,q){const W=this.layers[0].layout,te=W.get("line-join").evaluate(d,{}),se=W.get("line-cap").evaluate(d,{}),ie=W.get("line-miter-limit"),de=W.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const he=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=W.get("line-z-offset").value;const Ce=this.layers[0].paint.get("line-width").value;if(Ce.kind!=="constant"&&Ce.isLineProgressConstant===!1&&(this.variableWidthValue=Ce),this.elevationType==="road"){const Fe=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,m,C,q,te,se,ie,de)){const[Re,Ke]=this.clipRuntimeLinesToTile(m,1);for(let Xe=0;Xe0?kt.parentIndex:null)}this.fillNonElevatedRoadSegment(Fe)}}else for(let Fe=0;Fe0?Fe:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,b,E,I,C,R,void 0,this.worldview)}computeSegNextDir(d,m){return d.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(d,m){return m[1].sub(d.prevPoint).unit()}clipLinesToTile(d,m){return KF(d,-m,-m,tr+m,tr+m)}clipRuntimeLinesToTile(d,m){const b=[];return[KF(d,-m,-m,tr+m,tr+m,b),b]}addElevatedRoadFeature(d,m,b,C,E,I,R,q){const W=[],te=ui.getElevationFeature(d,C);if(te){const se=this.clipLinesToTile(m,1),ie=this.prepareElevatedLines(se,te,b);for(const de of ie)W.push({geometry:de,elevation:te,elevationTileID:b,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(W.length===0)return!1;for(const se of W){const ie=this.layoutVertexArray.length;this.addLine(se.geometry,d,b,E,I,R,q);const de=new Mi(b,se.elevationTileID);if(se.elevation)for(let he=ie;he>1,this.layoutVertexArray.int16[6*he+1]>>1),Fe=de.pointElevation(Ce,se.elevation,.05);this.updateHeightRange(Fe),this.zOffsetVertexArray.emplaceBack(Fe,0,0)}else this.fillNonElevatedRoadSegment(ie)}return!0}prepareElevatedLines(d,m,b){if(m.constantHeight!=null)return d;const C=[],E=1/Ve(b);for(const I of d)Fdt(I,new Xa(m,E),0,C);return C}fillNonElevatedRoadSegment(d){for(let m=d;m0,ie=q&&q.progress.max<1;if(this.lineClips){let qt={min:this.lineClips.start,max:this.lineClips.end},ss=1;if(q){const ks=this.lineClips.end-this.lineClips.start;qt=function(Ss,zs,$s){return{min:Ai(Ss.min,zs,$s),max:Ai(Ss.max,zs,$s)}}(q.progress,{min:0,max:1},qt),ks>0&&(ss=(qt.max-qt.min)/ks)}const Wt=+m.properties.mapbox_clip_feature_len,ds=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(ds)){for(let Ss=0;Ss=2&&d[he-1].equals(d[he-2]);)he--;let Ce=0;for(;Ce0,ls=this.overscaling<=16?15*tr/(512*this.overscaling):0;if(ss&&Wt==="round"){if(zsI&&(Wt="bevel"),Wt==="bevel"&&(zs>2&&(Wt="flipbevel"),zs2*ls){const sr=Re.sub(Re.sub(Ke)._mult(ls/rs)._round());this.updateDistance(Ke,sr),this.addCurrentVertex(sr,lt,0,0,Fe,zt),Ke=sr}this.updateDistance(Ke,Re),ks._mult(zs),this.addCurrentVertex(Re,ks,0,0,Fe,zt);const Fs=Re.dist(Xe);if(Fs>2*ls){const sr=Re.add(Xe.sub(Re)._mult(ls/Fs)._round());this.updateDistance(Re,sr),this.addCurrentVertex(sr,kt,0,0,Fe,zt),Re=sr}}else ks._mult(zs),this.addCurrentVertex(Re,ks,0,0,Fe,zt);else if(Wt==="flipbevel"){if(zs>100)ks=kt.mult(-1);else{const rs=zs*lt.add(kt).mag()/lt.sub(kt).mag();ks._perp()._mult(rs*(Rs?-1:1))}this.addCurrentVertex(Re,ks,0,0,Fe,zt),this.addCurrentVertex(Re,ks.mult(-1),0,0,Fe,zt)}else if(Wt==="bevel"||Wt==="fakeround"){zt!=null&&Ke&&this.addCurrentVertex(Re,At||lt,-1,-1,Fe,zt);const rs=Re.dist(Ke)<=2*ls&&Wt!=="bevel",Fs=ks.mult(Rs?1:-1);Fs._mult(zs);const sr=kt.mult(Rs?-1:1),Hs=lt.mult(Rs?-1:1),zr=this.evaluateLineProgressFeatures(this.distance);if(zt==null&&(this.addHalfVertex(Re,Fs.x,Fs.y,!1,!Rs,0,Fe,zr),rs||this.addHalfVertex(Re,Fs.x+2*Hs.x,Fs.y+2*Hs.y,!1,Rs,0,Fe,zr)),Wt==="fakeround"){const fr=Math.round(180*$s/Math.PI/20);this.addHalfVertex(Re,Hs.x,Hs.y,!1,Rs,0,Fe,zr);for(let _r=0;_r1){this.lineSoFar=d.w;const Ce=(m.x-d.x)/se,Fe=(m.y-d.y)/se,Re=(m.z-d.z)/se,Ke=(m.w-d.w)/se;for(let Xe=1;Xe=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,te),q.primitiveLength++),I?this.e2=te:this.e1=te,W!=null&&this.zOffsetVertexArray.emplaceBack(W.zOffset,W.variableWidth,W.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(d,m){this.prevDistance=this.distance,this.distance+=d.dist(m),this.updateScaledDistance()}}function Qpe(x,d,m){return x.xm||x.ym}let x5e,g5e;function y5e(x,d,m){return d*(tr/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}kr(Ype,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const v5e=(x,d,m)=>(1-m)*x+m*d;function b5e(x,d){return 1/y5e(x,1,d.tileZoom)}function _5e(x,d,m,b){return x.translatePosMatrix(b||d.tileID.projMatrix,d,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const w5e=x=>{const d=[];j5e(x)&&d.push("RENDER_LINE_DASH"),x.paint.get("line-gradient")&&d.push("RENDER_LINE_GRADIENT");const m=x.paint.get("line-trim-offset");m[0]===0&&m[1]===0||d.push("RENDER_LINE_TRIM_OFFSET"),x.paint.get("line-border-width").constantOr(1)!==0&&d.push("RENDER_LINE_BORDER");const b=x.layout.get("line-join").constantOr("miter")==="none",C=!!x.paint.get("line-pattern").constantOr(1);return b&&C&&d.push("LINE_JOIN_NONE"),d};function j5e(x){const d=x.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let Xpe;const N5e=()=>Xpe||(Xpe={layout:x5e||(x5e=new Io({"line-cap":new ir(Kt.layout_line["line-cap"]),"line-join":new ir(Kt.layout_line["line-join"]),"line-miter-limit":new Qs(Kt.layout_line["line-miter-limit"]),"line-round-limit":new Qs(Kt.layout_line["line-round-limit"]),"line-sort-key":new ir(Kt.layout_line["line-sort-key"]),"line-z-offset":new ir(Kt.layout_line["line-z-offset"]),"line-elevation-reference":new Qs(Kt.layout_line["line-elevation-reference"]),"line-cross-slope":new Qs(Kt.layout_line["line-cross-slope"]),visibility:new Qs(Kt.layout_line.visibility),"line-width-unit":new Qs(Kt.layout_line["line-width-unit"])})),paint:g5e||(g5e=new Io({"line-opacity":new ir(Kt.paint_line["line-opacity"]),"line-color":new ir(Kt.paint_line["line-color"]),"line-translate":new Qs(Kt.paint_line["line-translate"]),"line-translate-anchor":new Qs(Kt.paint_line["line-translate-anchor"]),"line-width":new ir(Kt.paint_line["line-width"]),"line-gap-width":new ir(Kt.paint_line["line-gap-width"]),"line-offset":new ir(Kt.paint_line["line-offset"]),"line-blur":new ir(Kt.paint_line["line-blur"]),"line-dasharray":new ir(Kt.paint_line["line-dasharray"]),"line-pattern":new ir(Kt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Qs(Kt.paint_line["line-pattern-cross-fade"]),"line-gradient":new pv(Kt.paint_line["line-gradient"]),"line-trim-offset":new Qs(Kt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Qs(Kt.paint_line["line-trim-fade-range"]),"line-trim-color":new Qs(Kt.paint_line["line-trim-color"]),"line-emissive-strength":new ir(Kt.paint_line["line-emissive-strength"]),"line-border-width":new ir(Kt.paint_line["line-border-width"]),"line-border-color":new ir(Kt.paint_line["line-border-color"]),"line-occlusion-opacity":new Qs(Kt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},Xpe);class Tut extends ir{possiblyEvaluate(d,m){return m=new Zi(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(d,m)}evaluate(d,m,b,C){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(d,m,b,C)}}let xP;function k5e(x,d){return d>0?d+2*x:x}const Aut=xa([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Eut=xa([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Put=xa([{name:"a_projected_pos",components:4,type:"Float32"}],4);xa([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Iut=xa([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Lut=xa([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Dut=xa([{name:"a_texb",components:2,type:"Uint16"}]),Out=xa([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Rut=xa([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);xa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const S5e=xa([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Fut=xa([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);xa([{name:"triangle",components:3,type:"Uint16"}]),xa([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),xa([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),xa([{type:"Float32",name:"offsetX"}]),xa([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ec=24;function zut(x,d,m){return x.sections.forEach(b=>{b.text=function(C,E,I){const R=E.layout.get("text-transform").evaluate(I,{});return R==="uppercase"?C=C.toLocaleUpperCase():R==="lowercase"&&(C=C.toLocaleLowerCase()),cg.applyArabicShaping&&(C=cg.applyArabicShaping(C)),C}(b.text,d,m)}),x}const gP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function But(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function $ut(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Jpe=4294967296,C5e=1/Jpe,M5e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let a7=class{constructor(x=new Uint8Array(16)){this.buf=ArrayBuffer.isView(x)?x:new Uint8Array(x),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(x,d,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&b,x(C,d,this),this.pos===E&&this.skip(b)}return d}readMessage(x,d){return this.readFields(x,d,this.readVarint()+this.pos)}readFixed32(){const x=this.dataView.getUint32(this.pos,!0);return this.pos+=4,x}readSFixed32(){const x=this.dataView.getInt32(this.pos,!0);return this.pos+=4,x}readFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Jpe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Jpe;return this.pos+=8,x}readFloat(){const x=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,x}readDouble(){const x=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,x}readVarint(x){const d=this.buf;let m,b;return b=d[this.pos++],m=127&b,b<128?m:(b=d[this.pos++],m|=(127&b)<<7,b<128?m:(b=d[this.pos++],m|=(127&b)<<14,b<128?m:(b=d[this.pos++],m|=(127&b)<<21,b<128?m:(b=d[this.pos],m|=(15&b)<<28,function(C,E,I){const R=I.buf;let q,W;if(W=R[I.pos++],q=(112&W)>>4,W<128||(W=R[I.pos++],q|=(127&W)<<3,W<128)||(W=R[I.pos++],q|=(127&W)<<10,W<128)||(W=R[I.pos++],q|=(127&W)<<17,W<128)||(W=R[I.pos++],q|=(127&W)<<24,W<128)||(W=R[I.pos++],q|=(1&W)<<31,W<128))return n5(C,q,E);throw new Error("Expected varint not more than 10 bytes")}(m,x,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const x=this.readVarint();return x%2==1?(x+1)/-2:x/2}readBoolean(){return!!this.readVarint()}readString(){const x=this.readVarint()+this.pos,d=this.pos;return this.pos=x,x-d>=12&&M5e?M5e.decode(this.buf.subarray(d,x)):function(m,b,C){let E="",I=b;for(;I239?4:R>223?3:R>191?2:1;if(I+ie>C)break;ie===1?R<128&&(se=R):ie===2?(q=m[I+1],(192&q)==128&&(se=(31&R)<<6|63&q,se<=127&&(se=null))):ie===3?(q=m[I+1],W=m[I+2],(192&q)==128&&(192&W)==128&&(se=(15&R)<<12|(63&q)<<6|63&W,(se<=2047||se>=55296&&se<=57343)&&(se=null))):ie===4&&(q=m[I+1],W=m[I+2],te=m[I+3],(192&q)==128&&(192&W)==128&&(192&te)==128&&(se=(15&R)<<18|(63&q)<<12|(63&W)<<6|63&te,(se<=65535||se>=1114112)&&(se=null))),se===null?(se=65533,ie=1):se>65535&&(se-=65536,E+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),E+=String.fromCharCode(se),I+=ie}return E}(this.buf,d,x)}readBytes(){const x=this.readVarint()+this.pos,d=this.buf.subarray(this.pos,x);return this.pos=x,d}readPackedVarint(x=[],d){const m=this.readPackedEnd();for(;this.pos127;);else if(d===2)this.pos=this.readVarint()+this.pos;else if(d===5)this.pos+=4;else{if(d!==1)throw new Error(`Unimplemented type: ${d}`);this.pos+=8}}writeTag(x,d){this.writeVarint(x<<3|d)}realloc(x){let d=this.length||16;for(;d268435455||x<0?function(d,m){let b,C;if(d>=0?(b=d%4294967296|0,C=d/4294967296|0):(b=~(-d%4294967296),C=~(-d/4294967296),4294967295^b?b=b+1|0:(b=0,C=C+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,I,R){R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,E>>>=7,R.buf[R.pos++]=127&E|128,R.buf[R.pos]=127&(E>>>=7)}(b,0,m),function(E,I){const R=(7&E)<<4;I.buf[I.pos++]|=R|((E>>>=3)?128:0),E&&(I.buf[I.pos++]=127&E|((E>>>=7)?128:0),E&&(I.buf[I.pos++]=127&E|((E>>>=7)?128:0),E&&(I.buf[I.pos++]=127&E|((E>>>=7)?128:0),E&&(I.buf[I.pos++]=127&E|((E>>>=7)?128:0),E&&(I.buf[I.pos++]=127&E)))))}(C,m)}(x,this):(this.realloc(4),this.buf[this.pos++]=127&x|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=127&(x>>>=7)|(x>127?128:0),x<=127||(this.buf[this.pos++]=x>>>7&127))))}writeSVarint(x){this.writeVarint(x<0?2*-x-1:2*x)}writeBoolean(x){this.writeVarint(+x)}writeString(x){x=String(x),this.realloc(4*x.length),this.pos++;const d=this.pos;this.pos=function(b,C,E){for(let I,R,q=0;q55295&&I<57344){if(!R){I>56319||q+1===C.length?(b[E++]=239,b[E++]=191,b[E++]=189):R=I;continue}if(I<56320){b[E++]=239,b[E++]=191,b[E++]=189,R=I;continue}I=R-55296<<10|I-56320|65536,R=null}else R&&(b[E++]=239,b[E++]=191,b[E++]=189,R=null);I<128?b[E++]=I:(I<2048?b[E++]=I>>6|192:(I<65536?b[E++]=I>>12|224:(b[E++]=I>>18|240,b[E++]=I>>12&63|128),b[E++]=I>>6&63|128),b[E++]=63&I|128)}return E}(this.buf,x,this.pos);const m=this.pos-d;m>=128&&T5e(d,m,this),this.pos=d-1,this.writeVarint(m),this.pos+=m}writeFloat(x){this.realloc(4),this.dataView.setFloat32(this.pos,x,!0),this.pos+=4}writeDouble(x){this.realloc(8),this.dataView.setFloat64(this.pos,x,!0),this.pos+=8}writeBytes(x){const d=x.length;this.writeVarint(d),this.realloc(d);for(let m=0;m=128&&T5e(m,b,this),this.pos=m-1,this.writeVarint(b),this.pos+=b}writeMessage(x,d,m){this.writeTag(x,2),this.writeRawMessage(d,m)}writePackedVarint(x,d){d.length&&this.writeMessage(x,qut,d)}writePackedSVarint(x,d){d.length&&this.writeMessage(x,Uut,d)}writePackedBoolean(x,d){d.length&&this.writeMessage(x,Gut,d)}writePackedFloat(x,d){d.length&&this.writeMessage(x,Vut,d)}writePackedDouble(x,d){d.length&&this.writeMessage(x,Hut,d)}writePackedFixed32(x,d){d.length&&this.writeMessage(x,Wut,d)}writePackedSFixed32(x,d){d.length&&this.writeMessage(x,Kut,d)}writePackedFixed64(x,d){d.length&&this.writeMessage(x,Zut,d)}writePackedSFixed64(x,d){d.length&&this.writeMessage(x,Yut,d)}writeBytesField(x,d){this.writeTag(x,2),this.writeBytes(d)}writeFixed32Field(x,d){this.writeTag(x,5),this.writeFixed32(d)}writeSFixed32Field(x,d){this.writeTag(x,5),this.writeSFixed32(d)}writeFixed64Field(x,d){this.writeTag(x,1),this.writeFixed64(d)}writeSFixed64Field(x,d){this.writeTag(x,1),this.writeSFixed64(d)}writeVarintField(x,d){this.writeTag(x,0),this.writeVarint(d)}writeSVarintField(x,d){this.writeTag(x,0),this.writeSVarint(d)}writeStringField(x,d){this.writeTag(x,2),this.writeString(d)}writeFloatField(x,d){this.writeTag(x,5),this.writeFloat(d)}writeDoubleField(x,d){this.writeTag(x,1),this.writeDouble(d)}writeBooleanField(x,d){this.writeVarintField(x,+d)}};function n5(x,d,m){return m?4294967296*d+(x>>>0):4294967296*(d>>>0)+(x>>>0)}function T5e(x,d,m){const b=d<=16383?1:d<=2097151?2:d<=268435455?3:Math.floor(Math.log(d)/(7*Math.LN2));m.realloc(b);for(let C=m.pos-1;C>=x;C--)m.buf[C+b]=m.buf[C]}function qut(x,d){for(let m=0;m=0&&b>=d&&i7[this.text.charCodeAt(b)];b--)m--;this.text=this.text.substring(d,m),this.sectionIndex=this.sectionIndex.slice(d,m)}substring(d,m){const b=new a5;return b.text=this.text.substring(d,m),b.sectionIndex=this.sectionIndex.slice(d,m),b.sections=this.sections,b}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((d,m)=>Math.max(d,this.sections[m].scale),0)}addTextSection(d,m){this.text+=d.text,this.sections.push(yP.forText(d.scale,d.fontStack||m));const b=this.sections.length-1;for(let C=0;C=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function tfe(x,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce=1){const Fe=a5.fromFeature(x,C,Ce);se===fm.vertical&&Fe.verticalizePunctuation(ie);let Re=[];const Ke=function(At,zt,qt,ss,Wt,ds){if(!At)return[];const ks=[],Ss=function(Rs,ls,rs,Fs,sr,Hs){let zr=0;for(let fr=0;fr=0;let $s=0;for(let Rs=0;Rs0&&ei>qn&&(qn=ei)}else{const Ga=qt[Bs.fontStack];if(!Ga)continue;Ga[dr]&&(Ln=Ga[dr]);const Ja=zt[Bs.fontStack];if(!Ja)continue;const ei=Ja.glyphs[dr];if(!ei)continue;if(Vr=ei.metrics,Xn=dr!==8203?Ec:0,Hs){const wi=Ja.ascender!==void 0?Math.abs(Ja.ascender):0,Ri=Ja.descender!==void 0?Math.abs(Ja.descender):0,Pi=(wi+Ri)*Br;Ei-m/2;){if(I--,I<0)return!1;R-=x[I].dist(E),E=x[I]}R+=x[I].dist(x[I+1]),I++;const q=[];let W=0;for(;Rb;)W-=q.shift().angleDelta;if(W>C)return!1;I++,R+=te.dist(se)}return!0}function B5e(x){let d=0;for(let m=0;mW){const he=(W-q)/de,Ce=Zr(se.x,ie.x,he),Fe=Zr(se.y,ie.y,he),Re=new wv(Ce,Fe,0,ie.angleTo(se),te);return!I||z5e(x,Re,R,I,d)?Re:void 0}q+=de}}function rht(x,d,m,b,C,E,I,R,q){const W=$5e(b,E,I),te=q5e(b,C),se=te*I,ie=x[0].x===0||x[0].x===q||x[0].y===0||x[0].y===q;return d-se=0&<=0&&kt=0&&ie+W<=te){const vt=new wv(lt,kt,0,Ke,he);b&&!z5e(x,vt,E,b,C)||de.push(vt)}}se+=Re}return R||de.length||I||(de=U5e(x,se/2,m,b,C,E,I,!0,q)),de}function V5e(x){let d=0,m=0;for(const I of x)d+=I.w*I.h,m=Math.max(m,I.w);x.sort((I,R)=>R.h-I.h);const b=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),m),h:1/0}];let C=0,E=0;for(const I of x)for(let R=b.length-1;R>=0;R--){const q=b[R];if(!(I.w>q.w||I.h>q.h)){if(I.x=q.x,I.y=q.y,E=Math.max(E,I.y+I.h),C=Math.max(C,I.x+I.w),I.w===q.w&&I.h===q.h){const W=b.pop();W&&R1?he-1:he,Gd.copy(se.data,W,{x:0,y:0},{x:Ce,y:Fe},se.data,b),Gd.copy(se.data,W,{x:0,y:Ke-he},{x:Ce,y:Fe-he},{width:Re,height:he},b),Gd.copy(se.data,W,{x:0,y:0},{x:Ce,y:Fe+Ke},{width:Re,height:he},b),Gd.copy(se.data,W,{x:Re-he,y:0},{x:Ce-he,y:Fe},{width:he,height:Ke},b),Gd.copy(se.data,W,{x:0,y:0},{x:Ce+Re,y:Fe},{width:he,height:Ke},b),Gd.copy(se.data,W,{x:Re-he,y:Ke-he},{x:Ce-he,y:Fe-he},{width:he,height:he},b),Gd.copy(se.data,W,{x:0,y:Ke-he},{x:Ce+Re,y:Fe-he},{width:he,height:he},b),Gd.copy(se.data,W,{x:0,y:0},{x:Ce+Re,y:Fe+Ke},{width:he,height:he},b),Gd.copy(se.data,W,{x:Re-he,y:0},{x:Ce-he,y:Fe+Ke},{width:he,height:he},b)}this.lut=b,this.image=W,this.iconPositions=C,this.patternPositions=E}addImages(d,m,b,C){for(const[E,I]of d.entries()){const{bin:R,imagePosition:q,imageVariant:W}=ife(E,I,b);m.set(E,q),C.push(R),I.hasRenderCallback&&this.haveRenderCallbacks.push(W.id)}}patchUpdatedImages(d,m,b){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(C=>d.hasImage(C,b)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,b);for(const C of d.getUpdatedImages(b)){for(const E of this.iconPositions.keys()){const I=sg.parse(E);if(Xs.isEqual(I.id,C)){const R=d.getImage(C,b);this.patchUpdatedImage(this.iconPositions.get(E),R,m,null)}}for(const E of this.patternPositions.keys()){const I=sg.parse(E);if(Xs.isEqual(I.id,C)){const R=d.getImage(C,b);this.patchUpdatedImage(this.patternPositions.get(E),R,m,this.lut)}}}}patchUpdatedImage(d,m,b,C=null){if(!d||!m||d.version===m.version)return;d.version=m.version;const[E,I]=d.tl,R=d.sdf;if(this.lut||R){const q={width:m.data.width,height:m.data.height},W=new Gd(q);Gd.copy(m.data,W,{x:0,y:0},{x:0,y:0},q,C,R),b.update(W,{position:{x:E,y:I}})}else b.update(m.data,{position:{x:E,y:I}})}}kr(vP,"ImagePosition"),kr(H5e,"ImageAtlas");const bP=1e20;function G5e(x,d,m,b,C,E,I,R,q){for(let W=d;W-1);q++,E[q]=R,I[q]=W,I[q+1]=bP}for(let R=0,q=0;R{let q=this.entries[E];q||(q=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let W=q.glyphs[I];if(W!==void 0)return void R(null,{stack:E,id:I,glyph:W});if(W=this._tinySDF(q,E,I),W)return q.glyphs[I]=W,void R(null,{stack:E,id:I,glyph:W});const te=Math.floor(I/256);if(256*te>65535)return xr("glyphs > 65535 not supported"),void R(null,{stack:E,id:I,glyph:W});if(q.ranges[te])return void R(null,{stack:E,id:I,glyph:W});let se=q.requests[te];se||(se=q.requests[te]=[],l5.loadGlyphRange(E,te,C,this.requestManager,(ie,de)=>{if(de){q.ascender=de.ascender,q.descender=de.descender;for(const he in de.glyphs)this._doesCharSupportLocalGlyph(+he)||(q.glyphs[+he]=de.glyphs[+he]);q.ranges[te]=!0}for(const he of se)he(ie,de);delete q.requests[te]})),se.push((ie,de)=>{ie?R(ie):de&&R(null,{stack:E,id:I,glyph:de.glyphs[I]||null})})},(E,I)=>{if(E)m(E);else if(I){const R={};for(const{stack:q,id:W,glyph:te}of I)R[q]===void 0&&(R[q]={}),R[q].glyphs===void 0&&(R[q].glyphs={}),R[q].glyphs[W]=te&&{id:te.id,bitmap:te.bitmap.clone(),metrics:te.metrics},R[q].ascender=this.entries[q].ascender,R[q].descender=this.entries[q].descender;m(null,R)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==ofe.none&&(this.localGlyphMode===ofe.all?!!this.localFontFamily:!!this.localFontFamily&&(tn["CJK Unified Ideographs"](d)||tn["Hangul Syllables"](d)||tn.Hiragana(d)||tn.Katakana(d)||tn["CJK Symbols and Punctuation"](d)||tn["CJK Unified Ideographs Extension A"](d)||tn["CJK Unified Ideographs Extension B"](d)||tn.Osage(d)))}_tinySDF(d,m,b){const C=this.localFontFamily;if(!C||!this._doesCharSupportLocalGlyph(b))return;let E=d.tinySDF;if(!E){let Ce="400";/bold/i.test(m)?Ce="900":/medium/i.test(m)?Ce="500":/light/i.test(m)&&(Ce="200"),E=d.tinySDF=new l5.TinySDF({fontFamily:C,fontWeight:Ce,fontSize:24*bg,buffer:3*bg,radius:8*bg}),E.fontWeight=Ce}if(this.localGlyphs[E.fontWeight][b])return this.localGlyphs[E.fontWeight][b];const I=String.fromCodePoint(b),{data:R,width:q,height:W,glyphWidth:te,glyphHeight:se,glyphLeft:ie,glyphTop:de,glyphAdvance:he}=E.draw(I);return this.localGlyphs[E.fontWeight][b]={id:b,bitmap:new Tb({width:q,height:W},R),metrics:{width:te/bg,height:se/bg,left:ie/bg,top:de/bg-27,advance:he/bg,localGlyph:!0}}}}l5.loadGlyphRange=function(x,d,m,b,C){const E=256*d,I=E+255,R=b.transformRequest(b.normalizeGlyphsURL(m).replace("{fontstack}",x).replace("{range}",`${E}-${I}`),Jx.Glyphs);Oh(R,(q,W)=>{if(q)C(q);else if(W){const te={},se=function(ie){return new a7(ie).readFields(Qut,{})}(W);for(const ie of se.glyphs)te[ie.id]=ie;C(null,{glyphs:te,ascender:se.ascender,descender:se.descender})}})},l5.TinySDF=class{constructor({fontSize:x=24,buffer:d=3,radius:m=8,cutoff:b=.25,fontFamily:C="sans-serif",fontWeight:E="normal",fontStyle:I="normal",lang:R=null}={}){this.buffer=d,this.cutoff=b,this.radius=m,this.lang=R;const q=this.size=x+4*d,W=this._createCanvas(q),te=this.ctx=W.getContext("2d",{willReadFrequently:!0});te.font=`${I} ${E} ${x}px ${C}`,te.textBaseline="alphabetic",te.textAlign="left",te.fillStyle="black",this.gridOuter=new Float64Array(q*q),this.gridInner=new Float64Array(q*q),this.f=new Float64Array(q),this.z=new Float64Array(q+1),this.v=new Uint16Array(q)}_createCanvas(x){const d=document.createElement("canvas");return d.width=d.height=x,d}draw(x){const{width:d,actualBoundingBoxAscent:m,actualBoundingBoxDescent:b,actualBoundingBoxLeft:C,actualBoundingBoxRight:E}=this.ctx.measureText(x),I=Math.ceil(m),R=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-C))),q=Math.min(this.size-this.buffer,I+Math.ceil(b)),W=R+2*this.buffer,te=q+2*this.buffer,se=Math.max(W*te,0),ie=new Uint8ClampedArray(se),de={data:ie,width:W,height:te,glyphWidth:R,glyphHeight:q,glyphTop:I,glyphLeft:0,glyphAdvance:d};if(R===0||q===0)return de;const{ctx:he,buffer:Ce,gridInner:Fe,gridOuter:Re}=this;this.lang&&(he.lang=this.lang),he.clearRect(Ce,Ce,R,q),he.fillText(x,Ce,Ce+I);const Ke=he.getImageData(Ce,Ce,R,q);Re.fill(bP,0,se),Fe.fill(0,0,se);for(let Xe=0;Xe0?At*At:0,Fe[vt]=At<0?At*At:0}}G5e(Re,0,0,W,te,W,this.f,this.v,this.z),G5e(Fe,Ce,Ce,R,q,W,this.f,this.v,this.z);for(let Xe=0;Xe{const zs=c7(Wt.stretch-Ke,Xe,te,x.left*C),$s=d7(Wt.fixed-vt,At,Wt.stretch,he),Ds=c7(ds.stretch-lt,kt,se,x.top*C),Rs=d7(ds.fixed-zt,qt,ds.stretch,Ce),ls=c7(ks.stretch-Ke,Xe,te,x.left*C),rs=d7(ks.fixed-vt,At,ks.stretch,he),Fs=c7(Ss.stretch-lt,kt,se,x.top*C),sr=d7(Ss.fixed-zt,qt,Ss.stretch,Ce),Hs=new ft(zs,Ds),zr=new ft(ls,Ds),fr=new ft(ls,Fs),_r=new ft(zs,Fs),Ar=new ft($s/R,Rs/R),ta=new ft(rs/R,sr/R),Zs=d*Math.PI/180;if(Zs){const Ei=Math.sin(Zs),_t=Math.cos(Zs),Ct=[_t,-Ei,Ei,_t];Hs._matMult(Ct),zr._matMult(Ct),_r._matMult(Ct),fr._matMult(Ct)}const Er=Wt.stretch+Wt.fixed,_n=ks.stretch+ks.fixed,Na=ds.stretch+ds.fixed,Ta=Ss.stretch+Ss.fixed,qn=x.imageSecondary;return{tl:Hs,tr:zr,bl:_r,br:fr,texPrimary:{x:I.paddedRect.x+By+Er,y:I.paddedRect.y+By+Na,w:_n-Er,h:Ta-Na},texSecondary:qn?{x:qn.paddedRect.x+By+Er,y:qn.paddedRect.y+By+Na,w:_n-Er,h:Ta-Na}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ar,pixelOffsetBR:ta,minFontScaleX:At/R/te,minFontScaleY:qt/R/se,isSDF:m}};if(b&&(I.stretchX||I.stretchY)){const Wt=Z5e(ie,Fe,he),ds=Z5e(de,Re,Ce);for(let ks=0;ksE)&&(E=he.x),(!de||he.y>I)&&(I=he.y)}const q=Math.min(E-b,I-C);let W=q/2;const te=new X3([],oht);if(q===0)return new ft(b,C);for(let de=b;dese.d||!se.d)&&(se=de,m&&console.log("found best %d after %d probes",Math.round(1e4*de.d)/1e4,ie)),de.max-se.d<=d||(W=de.h/2,te.push(new c5(de.p.x-W,de.p.y-W,W,x)),te.push(new c5(de.p.x+W,de.p.y-W,W,x)),te.push(new c5(de.p.x-W,de.p.y+W,W,x)),te.push(new c5(de.p.x+W,de.p.y+W,W,x)),ie+=4)}return m&&(console.log(`num probes: ${ie}`),console.log(`best distance: ${se.d}`)),se.p}function oht(x,d){return d.max-x.max}class c5{constructor(d,m,b,C){this.p=new ft(d,m),this.h=b,this.d=function(E,I){let R=!1,q=1/0;for(let W=0;WE.y!=Ce.y>E.y&&E.x<(Ce.x-he.x)*(E.y-he.y)/(Ce.y-he.y)+he.x&&(R=!R),q=Math.min(q,Ho(E,he,Ce))}}return(R?1:-1)*Math.sqrt(q)}(this.p,C),this.max=this.d+this.h*Math.SQRT2}}const lht=Object.keys,cfe=Number.POSITIVE_INFINITY,cht=Math.sqrt(2);function Eb(x,d,m,b,C){const E=rfe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],I={top:x.top-E[1],bottom:x.bottom+E[3],left:x.left-E[0],right:x.right+E[2],scaled:!1};return b!==void 0&&function(R,q){R.top*=q,R.bottom*=q,R.left*=q,R.right*=q,R.scaled=!0}(I,b),m&&function(R,q){if(!q)return;const W=jr(q),te=new ft(R.left,R.top),se=new ft(R.right,R.top),ie=new ft(R.left,R.bottom),de=new ft(R.right,R.bottom),he=new ft(0,0);te._rotateAround(W,he),se._rotateAround(W,he),ie._rotateAround(W,he),de._rotateAround(W,he),R.left=Math.min(te.x,se.x,ie.x,de.x),R.right=Math.max(te.x,se.x,ie.x,de.x),R.top=Math.min(te.y,se.y,ie.y,de.y),R.bottom=Math.max(te.y,se.y,ie.y,de.y)}(I,m),C&&(I.left+=C[0],I.right+=C[0],I.top+=C[1],I.bottom+=C[1]),d?{top:Math.min(d.top,I.top),bottom:Math.max(d.bottom,I.bottom),left:Math.min(d.left,I.left),right:Math.max(d.right,I.right),scaled:d.scaled||I.scaled}:I}function Q5e(x,[d,m]){let b=0,C=0;if(m===cfe){d<0&&(d=0);const E=d/cht;switch(x){case"top-right":case"top-left":C=E-7;break;case"bottom-right":case"bottom-left":C=7-E;break;case"bottom":C=7-d;break;case"top":C=d-7}switch(x){case"top-right":case"bottom-right":b=-E;break;case"top-left":case"bottom-left":b=E;break;case"left":b=d;break;case"right":b=-d}}else{switch(d=Math.abs(d),m=Math.abs(m),x){case"top-right":case"top-left":case"top":C=m-7;break;case"bottom-right":case"bottom-left":case"bottom":C=7-m}switch(x){case"top-right":case"bottom-right":case"right":b=-d;break;case"top-left":case"bottom-left":case"left":b=d}}return[b,C]}function dht(x,d,m,b,C,E,I,R,q,W,te,se,ie,de){const he=x.layers[0],Ce=he.appearances;if(Ce.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Fe={iconBBox:null,iconVerticalBBox:null},Re={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ke,baseTextRotate:Xe,iconScaleFactor:lt}=function(vt,At,zt){const qt=vt.get("icon-rotate").evaluate(At,{},zt),ss=vt.get("text-rotate").evaluate(At,{},zt),[Wt,ds]=vt.get("icon-size-scale-range");return{baseIconRotate:qt,baseTextRotate:ss,iconScaleFactor:Se(1,Wt,ds)}}(b,C,E);d&&(Fe.iconBBox=Eb(d,Fe.iconBBox,Ke,I),m)&&(Fe.iconVerticalBBox=Eb(m,Fe.iconVerticalBBox,Ke+90,I));const kt=h7(se.horizontal);kt&&(Re.textBBox=Eb(kt,Re.textBBox,Xe,1,de)),se.vertical&&(Re.textVerticalBBox=Eb(se.vertical,Re.textVerticalBBox,Xe+90,1,de));for(const vt of Ce)vt.hasIconProperties()&&uht(Fe,x,he,vt,C,E,R,Ke,I,q,d,W,lt,te),vt.hasTextProperties()&&hht(Re,he,vt,C,E,de,Xe,ie,kt,se.vertical);return{iconBBox:Fe.iconBBox,iconVerticalBBox:Fe.iconVerticalBBox,textBBox:Re.textBBox,textVerticalBBox:Re.textVerticalBBox}}function uht(x,d,m,b,C,E,I,R,q,W,te,se,ie,de){const{appearanceIconOffset:he,appearanceIconRotate:Ce,appearanceIconSize:Fe}=function(lt,kt,vt,At,zt,qt,ss,Wt){const ds=lt.hasProperty("icon-offset")?kt.getAppearanceValueAndResolveTokens(lt,"icon-offset",vt,At,[]):null,ks=ds&&Array.isArray(ds)?ds:zt,Ss=lt.hasProperty("icon-rotate")?kt.getAppearanceValueAndResolveTokens(lt,"icon-rotate",vt,At,[]):null,zs=typeof Ss=="number"?Ss:qt,$s=lt.hasProperty("icon-size")?kt.getAppearanceValueAndResolveTokens(lt,"icon-size",vt,At,[]):null;return{appearanceIconOffset:ks,appearanceIconRotate:zs,appearanceIconSize:typeof $s=="number"?$s*Wt.iconScaleFactor:ss}}(b,m,C,E,I,R,q,W);let Re=null,Ke=null,Xe=null;b.hasProperty("icon-image")?Xe=function(lt,kt,vt,At,zt,qt,ss){let Wt=null;const ds=kt.getAppearanceValueAndResolveTokens(vt,"icon-image",At,zt,[]);if(ds){const ks=lt.getResolvedImageFromTokens(ds),Ss=vt.getUnevaluatedProperty("icon-size"),zs=_P(ks,i5(lt.zoom,Ss,lt.worldview),Ss,zt,lt.zoom,At,lt.pixelRatio,ss,lt.worldview);Wt=qt.get(zs.iconPrimary.toString())}return Wt}(d,m,b,C,E,se,ie):te&&(Xe=te.imagePrimary),Xe&&(Re=o7(Xe,null,he,de),d.allowVerticalPlacement&&(Ke=o7(Xe,null,he,de))),Re&&(x.iconBBox=Eb(Re,x.iconBBox,Ce,Fe)),Ke&&(x.iconVerticalBBox=Eb(Ke,x.iconVerticalBBox,Ce+90,Fe))}function hht(x,d,m,b,C,E,I,R,q,W){const{appearanceTextOffset:te,appearanceTextRotate:se,appearanceTextSize:ie}=function(he,Ce,Fe,Re,Ke,Xe,lt){const kt=he.hasProperty("text-offset")?Ce.getAppearanceValueAndResolveTokens(he,"text-offset",Fe,Re,[]):null,vt=kt&&Array.isArray(kt)?[kt[0]*Ec,kt[1]*Ec]:Ke,At=he.hasProperty("text-rotate")?Ce.getAppearanceValueAndResolveTokens(he,"text-rotate",Fe,Re,[]):null,zt=typeof At=="number"?At:Xe,qt=he.hasProperty("text-size")?Ce.getAppearanceValueAndResolveTokens(he,"text-size",Fe,Re,[]):null;return{appearanceTextOffset:vt,appearanceTextRotate:zt,appearanceTextSize:typeof qt=="number"?qt:lt}}(m,d,b,C,E,I,R),de=ie/R;q&&(x.textBBox=Eb(q,x.textBBox,se,de,te)),W&&(x.textVerticalBBox=Eb(W,x.textVerticalBBox,se+90,de,te))}function u7(x,d,m,b,C,E,I,R,q){if(!d||!d.usvg)return;const W=F5e(b),te=F5e(C),se=E!=="both"&&E!=="width"||!O5e(b)?1:te.width/W.width,ie=E!=="both"&&E!=="height"||!R5e(b)?1:te.height/W.height;m.scaleSelf(se,ie);const de=m.toString();I.set(de,m),R.set(de,d);const{imagePosition:he}=ife(de,d,R2);q.set(de,he)}function X5e(x,d,m,b,C,E,I,R,q){if(!x)return;const W=function(te,se,ie,de,he,Ce){if(te.kind==="camera")return te.maxSize;if(te.kind==="composite"){const Fe=se.possiblyEvaluate(new Zi(te.maxZoom,{worldview:Ce}),ie).evaluate(he,{},ie),Re=se.possiblyEvaluate(new Zi(te.minZoom,{worldview:Ce}),ie).evaluate(he,{},ie);return Math.max(Fe,Re)}return se.possiblyEvaluate(new Zi(de,{worldview:Ce})).evaluate(he,{},ie)}(d,m,b,C,E,q);return x.scaleSelf(W*R*I)}function _P(x,d,m,b,C,E,I,R,q){return{iconPrimary:X5e(x.getPrimary(),d,m,b,C,E,I,R,q),iconSecondary:X5e(x.getSecondary(),d,m,b,C,E,I,R,q)}}function mht(x,d,m){if(!d)return;const b=m.get(x.toString()),C=m.get(d.toString());b&&C&&(b.paddedRect.w===C.paddedRect.w&&b.paddedRect.h===C.paddedRect.h||xr(`Mismatch in icon variant sizes: ${x.toString()} and ${d.toString()}`),b.usvg!==C.usvg&&xr(`Mismatch in icon variant image types: ${x.id} and ${d.id}`))}function J5e(x,d,m,b){if(!x)return;const C=d.get(m.toString());if(x.imagePrimary=C,b){const E=d.get(b.toString());x.imageSecondary=E}}function pht(x,d){for(const m in x.horizontal)eMe(x.horizontal[m],d);eMe(x.vertical,d)}function eMe(x,d){if(x){for(const m of x.positionedLines)for(const b of m.positionedGlyphs)if(b.image!==null){const C=b.image.toString();b.rect=d.get(C).paddedRect}}}function dfe(x){switch(x){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function fht(x,d,m,b,C,E,I,R,q){const W=h7(E.horizontal)||E.vertical,te=m.get("icon-text-fit-padding").evaluate(b,{},C);let se,ie=d;return d&&q!=="none"&&(x.allowVerticalPlacement&&E.vertical&&(se=nfe(d,E.vertical,q,te,R,I)),W&&(ie=nfe(d,W,q,te,R,I))),{defaultShapedIcon:ie,verticallyShapedIcon:se}}function xht(x,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke,Xe,lt,kt,vt,At){let zt=I.textMaxSize.evaluate(d,{},ie);zt===void 0?zt=R*I.textScaleFactor:zt*=I.textScaleFactor;const qt=x.layers[0].layout,ss=Ec,Wt=R*I.textScaleFactor/ss,ds=h7(m.horizontal)||m.vertical;if(Fe!=="none"&&x.appearanceFeatureData&&d.index18&&Fs>2&&(Fs>>=1),Math.max(tr/(512*Fs),1)*qt.get("symbol-spacing")),$s=qt.get("text-padding")*x.tilePixelRatio,Ds=qt.get("icon-padding")*x.tilePixelRatio,Rs=jr(qt.get("text-max-angle")),ls=qt.get("icon-rotation-alignment")==="map"&&Xe!=="point",rs=zs/2;var Fs;x.hasAnyIconTextFit===!1&&Fe!=="none"&&(x.hasAnyIconTextFit=!0);const sr=d.properties?+d.properties[as]:null,Hs=sr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(sr):65535,zr=(fr,_r,Ar)=>{if(_r.x<0||_r.x>=tr||_r.y<0||_r.y>=tr)return;let ta=null;if(ks){const{x:Zs,y:Er,z:_n}=de.projectTilePoint(_r.x,_r.y,Ar);ta={anchor:new wv(Zs,Er,_n,0,void 0),up:de.upVector(Ar,_r.x,_r.y)}}(function(Zs,Er,_n,Na,Ta,qn,Ei,_t,Ct,us,Bs,cr,dr,Br,Vr,Ln,Kn,Xn,ga,on,bn,Ga,Ja,ei,wi,Ri,Pi,ii,mi,Zn,Ma,fo,rn){const ya=Zs.addToLineVertexArray(Er,Na);let Li,Ui,Yi,sl,Hi,nn,ko,ji=0,ao=0,Wl=0,Pc=0,Nl=-1,kl=-1;const fc={};let xh=tb("");const Gi=_n?_n.anchor:Er,Go=ii!=="none";let rl=0,Fh=0;if(Ct._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Ad=Ct.layout.get("text-offset").evaluate(bn,{},wi);rl=Ad[0]*Ec,Fh=Ad[1]*Ec}else rl=Ct.layout.get("text-radial-offset").evaluate(bn,{},wi)*Ec,Fh=cfe;if(Zs.allowVerticalPlacement&&Ta.vertical){const Ad=Ta.vertical;if(Vr)nn=ufe(Ad),_t&&(ko=ufe(_t));else{const Uu=Ct.layout.get("text-rotate").evaluate(bn,{},wi)+90;Yi=m7(us,Gi,Er,Bs,cr,dr,Ad,Br,Uu,Ln,fo),_t&&(sl=m7(us,Gi,Er,Bs,cr,dr,_t,Xn,Uu,null,Ma))}}if(qn){const Ad=Zs.iconSizeData,Uu=Ct.layout.get("icon-rotate").evaluate(bn,{},wi),xm=lfe(qn,Uu,Ja,Go,Ga.iconScaleFactor),Lb=_t?lfe(_t,Uu,Ja,Go,Ga.iconScaleFactor):void 0;Ui=m7(us,Gi,Er,Bs,cr,dr,qn,Xn,Uu,null,Zn);const x5=function(Ng,zP,vTe,Mmt,bTe,_Te,Tmt,Amt){const wTe=Ng.layers[0],jTe=wTe.appearances;let g5=zP.length;if(vTe&&(g5=Math.max(g5,vTe.length)),jTe.length===0)return g5;const[Emt,Pmt]=Mmt.get("icon-size-scale-range"),Imt=Se(1,Emt,Pmt);for(const NTe of jTe){const kTe=NTe.getUnevaluatedProperties();if(kTe._values["icon-image"].value!==void 0){const STe=wTe.getAppearanceValueAndResolveTokens(NTe,"icon-image",bTe,_Te,[]);if(STe){const CTe=Ng.getResolvedImageFromTokens(STe);if(CTe){const MTe=kTe._values["icon-size"],Lmt=_P(CTe,i5(Ng.zoom,MTe,Ng.worldview),MTe,_Te,Ng.zoom,bTe,Ng.pixelRatio,Imt,Ng.worldview),Dmt=Tmt.get(Lmt.iconPrimary.toString());g5=Math.max(g5,nht(Dmt,Amt))}}}}return g5}(Zs,xm,Lb,Ct.layout,bn,wi,Zs.iconAtlasPositions,Go);ji=4*x5;let jg=null;Ad.kind==="source"?(jg=[vg*Ct.layout.get("icon-size").evaluate(bn,{},wi)*Ga.iconScaleFactor],jg[0]>jv&&xr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${wP}. Reduce your "icon-size".`)):Ad.kind==="composite"&&(jg=[vg*Ga.compositeIconSizes[0].evaluate(bn,{},wi)*Ga.iconScaleFactor,vg*Ga.compositeIconSizes[1].evaluate(bn,{},wi)*Ga.iconScaleFactor],(jg[0]>jv||jg[1]>jv)&&xr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${wP}. Reduce your "icon-size".`)),Zs.addSymbols(Zs.icon,xm,jg,on,ga,bn,void 0,_n,Er,ya.lineStartIndex,ya.lineLength,-1,ei,wi,Ri,Pi,Zs.symbolInstances.length,x5),Nl=Zs.icon.placedSymbolArray.length-1,Lb&&(ao=4*x5,Zs.addSymbols(Zs.icon,Lb,jg,on,ga,bn,fm.vertical,_n,Er,ya.lineStartIndex,ya.lineLength,-1,ei,wi,Ri,Pi,Zs.symbolInstances.length,x5),kl=Zs.icon.placedSymbolArray.length-1)}for(const Ad in Ta.horizontal){const Uu=Ad,xm=Ta.horizontal[Uu];Li||(xh=tb(xm.text),Vr?Hi=ufe(xm):Li=m7(us,Gi,Er,Bs,cr,dr,xm,Br,Ct.layout.get("text-rotate").evaluate(bn,{},wi),Ln,fo));const Lb=xm.positionedLines.length===1;if(Wl+=tMe(Zs,_n,Er,xm,Ei,Ct,Vr,bn,Ln,ya,Ta.vertical?fm.horizontal:fm.horizontalOnly,Lb?lht(Ta.horizontal):[Uu],fc,Nl,Ga,ei,wi,Zs.symbolInstances.length,Ri),Lb)break}Ta.vertical&&(Pc+=tMe(Zs,_n,Er,Ta.vertical,Ei,Ct,Vr,bn,Ln,ya,fm.vertical,["vertical"],fc,kl,Ga,ei,wi,Zs.symbolInstances.length,Ri));let Kl=-1;const Qf=(Ad,Uu)=>Ad?Math.max(Ad,Uu):Uu;Kl=Qf(Hi,Kl),Kl=Qf(nn,Kl),Kl=Qf(ko,Kl);const $y=Kl>-1?1:0;Zs.glyphOffsetArray.length>=65535&&xr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),bn.sortKey!==void 0&&Zs.addToSortKeyRanges(Zs.symbolInstances.length,bn.sortKey),Zs.symbolInstances.emplaceBack(Er.x,Er.y,Gi.x,Gi.y,Gi.z,fc.right>=0?fc.right:-1,fc.center>=0?fc.center:-1,fc.left>=0?fc.left:-1,fc.vertical>=0?fc.vertical:-1,Nl,kl,xh,Li!==void 0?Li:Zs.collisionBoxArray.length,Li!==void 0?Li+1:Zs.collisionBoxArray.length,Yi!==void 0?Yi:Zs.collisionBoxArray.length,Yi!==void 0?Yi+1:Zs.collisionBoxArray.length,Ui!==void 0?Ui:Zs.collisionBoxArray.length,Ui!==void 0?Ui+1:Zs.collisionBoxArray.length,sl||Zs.collisionBoxArray.length,sl?sl+1:Zs.collisionBoxArray.length,Bs,Wl,Pc,ji,ao,$y,0,rl,Fh,Kl,0,Go?1:0,mi)})(x,_r,ta,fr,m,b,E,C,x.layers[0],x.collisionBoxArray,d.index,d.sourceLayerIndex,x.index,$s,Ke,W,0,Ds,ls,Re,d,I,te,se,ie,he,Ce,Fe,Hs,lt,kt,vt)};if(Xe==="line")for(const fr of KF(d.geometry,0,0,tr,tr)){const _r=rht(fr,zs,Rs,m.vertical||ds,b,ss,Ss,x.overscaling,tr);for(const Ar of _r)ds&&ght(x,ds.text,rs,Ar)||zr(fr,Ar,ie)}else if(Xe==="line-center"){for(const fr of d.geometry)if(fr.length>1){const _r=sht(fr,Rs,m.vertical||ds,b,ss,Ss);_r&&zr(fr,_r,ie)}}else if(d.type==="Polygon")for(const fr of nP(d.geometry,0)){const _r=iht(fr,16);zr(fr[0],new wv(_r.x,_r.y,0,0,void 0),ie)}else if(d.type==="LineString")for(const fr of d.geometry)zr(fr,new wv(fr[0].x,fr[0].y,0,0,void 0),ie);else if(d.type==="Point")for(const fr of d.geometry)for(const _r of fr)zr([_r],new wv(_r.x,_r.y,0,0,void 0),ie)}const wP=255,jv=wP*vg;function tMe(x,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke){const Xe=function(vt,At,zt,qt,ss,Wt,ds,ks){const Ss=[];if(At.positionedLines.length===0)return Ss;const zs=qt.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,$s=function(Fs){const sr=Fs[0],Hs=Fs[1],zr=sr*Hs;return zr>0?[sr,-Hs]:zr<0?[-sr,Hs]:sr===0?[Hs,sr]:[Hs,-sr]}(zt);let Ds=Math.abs(At.top-At.bottom);for(const Fs of At.positionedLines)Ds-=Fs.lineOffset;const Rs=At.positionedLines.length,ls=Ds/Rs;let rs=At.top-zt[1];for(let Fs=0;Fsjv&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${wP}. Reduce your "text-size".`)):lt.kind==="composite"&&(kt=[vg*he.compositeTextSizes[0].evaluate(R,{},Fe)*he.textScaleFactor,vg*he.compositeTextSizes[1].evaluate(R,{},Fe)*he.textScaleFactor],(kt[0]>jv||kt[1]>jv)&&xr(`${x.layerIds[0]}: Value for "text-size" is >= ${wP}. Reduce your "text-size".`)),x.addSymbols(x.text,Xe,kt,q,I,R,te,d,m,W.lineStartIndex,W.lineLength,de,Ce,Fe,Ke,!1,Re,Xe.length);for(const vt of se)ie[vt]=x.text.placedSymbolArray.length-1;return 4*Xe.length}function h7(x){for(const d in x)return x[d];return null}function m7(x,d,m,b,C,E,I,R,q,W,te){let se,ie,de,he;if(se=te?te.top:I.top,ie=te?te.bottom:I.bottom,de=te?te.left:I.left,he=te?te.right:I.right,rfe(I)&&I.collisionPadding){const Ce=I.collisionPadding;de-=Ce[0],se-=Ce[1],he+=Ce[2],ie+=Ce[3]}if(q){const Ce=new ft(de,se),Fe=new ft(he,se),Re=new ft(de,ie),Ke=new ft(he,ie),Xe=jr(q);let lt=new ft(0,0);W&&(lt=new ft(W[0],W[1])),Ce._rotateAround(Xe,lt),Fe._rotateAround(Xe,lt),Re._rotateAround(Xe,lt),Ke._rotateAround(Xe,lt),de=Math.min(Ce.x,Fe.x,Re.x,Ke.x),he=Math.max(Ce.x,Fe.x,Re.x,Ke.x),se=Math.min(Ce.y,Fe.y,Re.y,Ke.y),ie=Math.max(Ce.y,Fe.y,Re.y,Ke.y)}return x.emplaceBack(d.x,d.y,d.z,m.x,m.y,de,se,he,ie,R,b,C,E),x.length-1}function ufe(x){rfe(x)&&x.collisionPadding&&(x.top-=x.collisionPadding[1],x.bottom+=x.collisionPadding[3]);const d=x.bottom-x.top;return d>0?Math.max(10,d):null}function ght(x,d,m,b){const C=x.compareText;if(d in C){const E=C[d];for(let I=E.length-1;I>=0;I--)if(b.dist(E[I])Xe&&(lt(vt,Ss,zt,qt,ds,ks),lt(Ss,At,ds,ks,ss,Wt))}lt(se,ie,b,E,C,E),lt(ie,de,C,E,C,I),lt(de,he,C,I,b,I),lt(he,se,b,I,b,E),Ce-=Xe,Fe-=Xe,Re+=Xe,Ke+=Xe;const kt=1/Math.max(Re-Ce,Ke-Fe);return{scale:kt,x:Ce*kt,y:Fe*kt,x2:Re*kt,y2:Ke*kt,projection:d}}function rMe(x,{x:d,y:m},b=0){return new ft(((d-b)*x.scale-x.x)*tr,(m*x.scale-x.y)*tr)}const yht=j(new Float32Array(16));class Pb{constructor(d){this.spec=d,this.name=d.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(d,m){return{x:0,y:0,z:0}}unproject(d,m){return new y(0,0)}projectTilePoint(d,m,b){return{x:d,y:m,z:0}}locationPoint(d,m,b,C=!0){return d._coordinatePoint(d.locationCoordinate(m,b),C)}pixelsPerMeter(d,m){return ae(1,d)*m}pixelSpaceConversion(d,m,b){return 1}farthestPixelDistance(d){return sMe(d,d.pixelsPerMeter)}pointCoordinate(d,m,b,C){const E=d.horizonLineFromTop(!1),I=new ft(m,Math.max(E,b));return d.rayIntersectionCoordinate(d.pointRayIntersection(I,C))}pointCoordinate3D(d,m,b){const C=new ft(m,b);if(d.elevation)return d.elevation.pointCoordinate(C);{const E=this.pointCoordinate(d,C.x,C.y,0);return[E.x,E.y,E.z]}}isPointAboveHorizon(d,m){if(d.elevation&&d.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(d,m.x,m.y);const b=d.horizonLineFromTop();return m.y0?m<-d5+b&&(m=-d5+b):m>d5-b&&(m=d5-b);const I=E/Math.pow(f7(m),C);let R=I*Math.sin(C*d),q=E-I*Math.cos(C*d);return R=.5*(R/Math.PI+.5),q=.5*(q/Math.PI+.5),{x:R,y:this.southernCenter?q:1-q,z:0}}unproject(d,m){d=(2*d-.5)*Math.PI,this.southernCenter&&(m=1-m),m=(2*(1-m)-.5)*Math.PI;const{n:b,f:C}=this,E=C-m,I=Math.sign(E),R=Math.sign(b)*Math.sqrt(d*d+E*E);let q=Math.atan2(d,Math.abs(E))*I;E*b<0&&(q-=Math.PI*Math.sign(d)*I);const W=Se(ea(q/b)+this.center[0],-180,180),te=Se(ea(2*Math.atan(Math.pow(C/R,1/b))-d5),-Ne,Ne);return new y(W,this.southernCenter?-te:te)}}class nMe extends Pb{constructor(d){super(d),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(d,m){return{x:G(d),y:J(m),z:0}}unproject(d,m){const b=le(d),C=je(m);return new y(b,C)}}const aMe=jr(Ne);class jht extends Pb{project(d,m){const b=(m=jr(m))*m,C=b*b;return{x:.5*((d=jr(d))*(.8707-.131979*b+C*(C*(.003971*b-.001529*C)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+b*(.015085+C*(.028874*b-.044475-.005916*C)))/Math.PI+1),z:0}}unproject(d,m){d=(2*d-.5)*Math.PI;let b=m=(2*(1-m)-1)*Math.PI,C=25,E=0,I=b*b;do{I=b*b;const W=I*I;E=(b*(1.007226+I*(.015085+W*(.028874*I-.044475-.005916*W)))-m)/(1.007226+I*(.045255+W*(.259866*I-.311325-.005916*11*W))),b=Se(b-E,-aMe,aMe)}while(Math.abs(E)>1e-6&&--C>0);I=b*b;const R=Se(ea(d/(.8707+I*(I*(I*I*I*(.003971-.001529*I)-.013791)-.131979))),-180,180),q=ea(b);return new y(R,q)}}const iMe=jr(Ne);class Nht extends Pb{project(d,m){m=jr(m),d=jr(d);const b=Math.cos(m),C=2/Math.PI,E=Math.acos(b*Math.cos(d/2)),I=Math.sin(E)/E,R=.5*(d*C+2*b*Math.sin(d/2)/I)||0,q=.5*(m+Math.sin(m)/I)||0;return{x:.5*(R/Math.PI+.5),y:1-.5*(q/Math.PI+1),z:0}}unproject(d,m){let b=d=(2*d-.5)*Math.PI,C=m=(2*(1-m)-1)*Math.PI,E=25;const I=1e-6;let R=0,q=0;do{const W=Math.cos(C),te=Math.sin(C),se=2*te*W,ie=te*te,de=W*W,he=Math.cos(b/2),Ce=Math.sin(b/2),Fe=2*he*Ce,Re=Ce*Ce,Ke=1-de*he*he,Xe=Ke?1/Ke:0,lt=Ke?Math.acos(W*he)*Math.sqrt(1/Ke):0,kt=.5*(2*lt*W*Ce+2*b/Math.PI)-d,vt=.5*(lt*te+C)-m,At=.5*Xe*(de*Re+lt*W*he*ie)+1/Math.PI,zt=Xe*(Fe*se/4-lt*te*Ce),qt=.125*Xe*(se*Ce-lt*te*de*Fe),ss=.5*Xe*(ie*he+lt*Re*W)+.5,Wt=zt*qt-ss*At;R=(vt*zt-kt*ss)/Wt,q=(kt*qt-vt*At)/Wt,b=Se(b-R,-Math.PI,Math.PI),C=Se(C-q,-iMe,iMe)}while((Math.abs(R)>I||Math.abs(q)>I)&&--E>0);return new y(ea(b),ea(C))}}class oMe extends Pb{constructor(d){super(d),this.center=d.center||[0,0],this.parallels=d.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(jr(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(d,m){const{scale:b,cosPhi:C}=this;return{x:jr(d)*C*b+.5,y:-Math.sin(jr(m))/C*b+.5,z:0}}unproject(d,m){const{scale:b,cosPhi:C}=this,E=-(m-.5)/b,I=Se(ea((d-.5)/b)/C,-180,180),R=Math.asin(Se(E*C,-1,1)),q=Se(ea(R),-Ne,Ne);return new y(I,q)}}class kht extends nMe{constructor(d){super(d),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(d,m,b){const C=X6(d,m,b);return pt(C,C,zF(Vp(b))),{x:C[0],y:C[1],z:C[2]}}locationPoint(d,m,b){const C=kb(m.lat,m.lng),E=we([],C),I=b?d._centerAltitude+b:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(m),d._centerAltitude):d._centerAltitude;$e(C,C,E,ae(1,0)*tr*I);const R=j(new Float64Array(16));return S(R,d.pixelMatrix,d.globeMatrix),pt(C,C,R),new ft(C[0],C[1])}pixelsPerMeter(d,m){return ae(1,0)*m}pixelSpaceConversion(d,m,b){const C=ae(1,d)*m,E=Zr(ae(1,45)*m,C,b);return this.pixelsPerMeter(d,m)/E}createTileMatrix(d,m,b){const C=xpe(Vp(b.canonical));return S(new Float64Array(16),d.globeMatrix,C)}createInversionMatrix(d,m){const{center:b}=d,C=zF(Vp(m));return O(C,C,jr(b.lng)),P(C,C,jr(b.lat)),L(C,C,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(C)}pointCoordinate(d,m,b,C){return Cb(d,m,b,!0)||new nt(0,0)}pointCoordinate3D(d,m,b){const C=this.pointCoordinate(d,m,b,0);return[C.x,C.y,C.z]}isPointAboveHorizon(d,m){return!Cb(d,m.x,m.y,!1)}farthestPixelDistance(d){const m=function(C,E){const I=C.cameraToCenterDistance,R=C._centerAltitude*E,q=C._camera,W=C._camera.forward(),te=oe([],_e([],W,-I),[0,0,R]),se=C.worldSize/(2*Math.PI),ie=[0,0,-se],de=C.width/C.height,he=Math.tan(C.fovAboveCenter),Ce=_e([],q.up(),he),Fe=_e([],q.right(),he*de),Re=we([],oe([],oe([],W,Ce),Fe)),Ke=[];let Xe;if(new Cr(te,Re).closestPointOnSphere(ie,se,Ke)){const lt=oe([],Ke,ie),kt=Ae([],lt,te);Xe=Math.cos(C.fovAboveCenter)*ce(kt)}else{const lt=Ae([],te,ie),kt=Ae([],ie,te);we(kt,kt);const vt=ce(lt)-se;Xe=Math.sqrt(vt*(vt+2*se));const At=Math.acos(Xe/(se+vt))-Math.acos(Le(W,kt));Xe*=Math.cos(At)}return 1.01*Xe}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),b=Mb(d.zoom);if(b>0){const C=sMe(d,ae(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),I=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Zr(m,C+E*(1-Math.cos(I)),Math.pow(b,10))}return m}upVector(d,m,b){return X6(m,b,d,1)}upVectorScale(d){return{metersToTile:Zf(FF(Vp(d)))}}}function lMe(x){const d=x.parallels,m=!!d&&Math.abs(d[0]+d[1])<.01;switch(x.name){case"mercator":return new nMe(x);case"equirectangular":return new _ht(x);case"naturalEarth":return new jht(x);case"equalEarth":return new bht(x);case"winkelTripel":return new Nht(x);case"albers":return m?new oMe(x):new vht(x);case"lambertConformalConic":return m?new oMe(x):new wht(x);case"globe":return new kht(x)}throw new Error(`Invalid projection name: ${x.name}`)}const Sht=Ht.types,Cht=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function MP(x,d,m,b,C,E,I,R,q,W,te,se,ie){const de=R?Math.min(jv,Math.round(R[0])):0,he=R?Math.min(jv,Math.round(R[1])):0;x.emplaceBack(d,m,Math.round(32*b),Math.round(32*C),E,I,(de<<1)+(q?1:0),0+(he<<1),16*W,16*te,256*se,256*ie)}function TP(x,d,m){x.emplaceBack(d,m)}function AP(x,d,m,b,C,E,I){x.emplaceBack(d,m,b,C,E,I)}const x7=(x,d,m,b)=>{for(let C=0;C0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,Dut.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,Eut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Iut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,Lut.members,!0)),this.opacityVertexBuffer.itemSize=1),(b||C)&&this.programConfigurations.upload(d))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}kr(hfe,"SymbolBuffers");class mfe{constructor(d,m,b){this.layoutVertexArray=new d,this.layoutAttributes=m,this.indexArray=new b,this.segments=new wo,this.collisionVertexArray=new R6,this.collisionVertexArrayExt=new Dy}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,Out.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,Rut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}kr(mfe,"CollisionBuffers");class g7{constructor(d){this.collisionBoxArray=d.collisionBoxArray,this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(I=>I.fqid),this.index=d.index,this.pixelRatio=d.pixelRatio,this.sourceLayerIndex=d.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=j([]),this.placementViewportMatrix=j([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=i5(this.zoom,m["text-size"],this.worldview),this.iconSizeData=i5(this.zoom,m["icon-size"],this.worldview);const b=this.layers[0].layout,C=b.get("symbol-sort-key"),E=b.get("symbol-z-order");this.lut=d.lut,this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&C.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=b.get("text-writing-mode").map(I=>fm[I]),this.stateDependentLayerIds=this.layers.filter(I=>I.isStateDependent()).map(I=>I.id),this.sourceID=d.sourceID,this.projection=d.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null,this.featureToAppearanceIndex={}}hasAnyAppearanceProperty(d){const m=this.layers[0].getAppearances();return!(!m||m.length===0)&&m.some(b=>b.getProperty(d)!=null)}createArrays(){this.text=new hfe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new hfe(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new qC,this.lineVertexArray=new IF,this.symbolInstances=new V6}calculateGlyphDependencies(d,m,b,C,E){for(const I of d){const R=I.codePointAt(0);if(R===void 0)break;if(m[R]=!0,C&&E&&R<=65535){const q=gP[I];q&&(m[q.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,m,b,C,E,I){let R=1;const q=d.getUnevaluatedProperties()._values["icon-size"],W=i5(this.zoom,q,this.worldview),te=o5(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(R=te.uSize),W.kind==="composite"){const{minZoom:se,maxZoom:ie}=W,de=q.possiblyEvaluate(new Zi(se,{worldview:this.worldview}),C),he=q.possiblyEvaluate(new Zi(ie,{worldview:this.worldview}),C),Ce=de.evaluate(b,{},C,E);R=Ce+(he.evaluate(b,{},C,E)-Ce)*te.uSizeT}return W.kind==="source"&&(R=q.possiblyEvaluate(new Zi(this.zoom,{worldview:this.worldview}),C).evaluate(b,{},C,E)),R*I}updateFootprints(d,m){}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const b=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!HF(this.activeReplacements,b)&&(this.activeReplacements=b,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Fu.build(d):d}populate(d,m,b,C){const E=this.layers[0],I=E.layout,R=this.projection.name==="globe",q=I.get("text-font"),W=I.get("text-field"),te=I.get("icon-image"),[se,ie]=I.get("icon-size-scale-range"),de=Se(m.scaleFactor||1,se,ie),he=(W.value.kind!=="constant"||W.value.value instanceof Ru&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(q.value.kind!=="constant"||q.value.value.length>0),Ce=te.value.kind!=="constant"||!!te.value.value||Object.keys(te.parameters).length>0,Fe=this.hasAnyAppearanceProperty("icon-image"),Re=I.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!he&&!Ce&&!Fe)return;const Ke=m.iconDependencies,Xe=m.glyphDependencies,lt=m.availableImages,kt=new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),vt=At=>{const zt=At.id.toString();Ke.has(zt)?Ke.get(zt).push(At):Ke.set(zt,[At])};for(const At of d){const{feature:zt,id:qt,index:ss,sourceLayerIndex:Wt}=At,ds=E._featureFilter.needGeometry,ks=Gt(zt,ds);if(!E._featureFilter.filter(kt,ks,b))continue;if(ds||(ks.geometry=Ot(zt,b,C)),R&&zt.type!==1&&b.z<=5){const Fs=ks.geometry,sr=.98078528056,Hs=(zr,fr)=>Le(X6(zr.x,zr.y,b,1),X6(fr.x,fr.y,b,1)){if(!Fs.getProperty("icon-image"))return;const sr=this.getCombinedIconPrimary(Fs,$s,ks,b,lt,ls,de);sr&&vt(sr)}),Ss){const Fs=q.evaluate(ks,{},b).join(","),sr=I.get("text-rotation-alignment")==="map"&&I.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(fm.vertical)>=0;for(const Hs of Ss.sections)if(Hs.image){const zr=Hs.image.getPrimary().scaleSelf(this.pixelRatio),fr=zr.id.toString(),_r=Ke.get(fr)||[];_r.push(zr),Ke.set(fr,_r)}else{const zr=y2(Ss.toString()),fr=Hs.fontStack||Fs,_r=Xe[fr]=Xe[fr]||{};this.calculateGlyphDependencies(Hs.text,_r,sr,this.allowVerticalPlacement,zr)}}}if(I.get("symbol-placement")==="line"&&(this.features=function(At){const zt={},qt={},ss=[];let Wt=0;function ds($s){ss.push(At[$s]),Wt++}function ks($s,Ds,Rs){const ls=qt[$s];return delete qt[$s],qt[Ds]=ls,ss[ls].geometry[0].pop(),ss[ls].geometry[0]=ss[ls].geometry[0].concat(Rs[0]),ls}function Ss($s,Ds,Rs){const ls=zt[Ds];return delete zt[Ds],zt[$s]=ls,ss[ls].geometry[0].shift(),ss[ls].geometry[0]=Rs[0].concat(ss[ls].geometry[0]),ls}function zs($s,Ds,Rs){const ls=Rs?Ds[0][Ds[0].length-1]:Ds[0][0];return`${$s}:${ls.x}:${ls.y}`}for(let $s=0;$s$s.geometry)}(this.features)),I.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",m.elevationFeatures){!this.elevationFeatures&&m.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const At of m.elevationFeatures)this.elevationFeatureIdToIndex.set(At.id,this.elevationFeatures.length),this.elevationFeatures.push(At)}}else I.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((At,zt)=>At.sortKey-zt.sortKey)}getCombinedIconPrimary(d,m,b,C,E,I,R){let q,W;const te=d.getUnevaluatedProperties();if(te._values["icon-image"].value!==void 0){const se=m.getAppearanceValueAndResolveTokens(d,"icon-image",b,C,E);q=this.getResolvedImageFromTokens(se)}else{const se=m.getValueAndResolveTokens("icon-image",b,C,E);q=this.getResolvedImageFromTokens(se)}if(q){const se=te._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];W=_P(q,i5(this.zoom,se,this.worldview),se,C,this.zoom,I,this.pixelRatio,R,this.worldview).iconPrimary}return W}updateAppearanceBasedIconTextures(d,m,b,C){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let I=!1,R=0;const q=E.layout,[W,te]=q.get("icon-size-scale-range"),se=Se(1,W,te);for(let ie=0;ie=0){const Fe=Ce.id,Re=m&&Fe!==void 0?m[String(Fe)]:void 0,Ke={type:"Point",id:Ce.id,properties:Ce.properties,geometry:[]},Xe=this.layers[0].appearances&&this.layers[0].appearances.find(lt=>lt.isActive({globals:C,feature:Ke,canonical:d,featureState:Re}));if(Ce.activeAppearance===Xe){R+=de.numIconVertices;continue}if(Xe){Ce.activeAppearance=Xe;const lt=this.getCombinedIconPrimary(Xe,E,Ke,d,b,{sortKey:void 0,text:void 0,icon:null,index:de.featureIndex,sourceLayerIndex:de.featureIndex,geometry:[],properties:Ce.properties,type:"Point",id:Ce.id},se);if(!lt)continue;const kt=lt.toString(),vt=this.iconAtlasPositions&&this.iconAtlasPositions.get(kt);if(vt){const At=E.getAppearanceValueAndResolveTokens(Xe,"icon-offset",Ke,d,b),zt=At&&Array.isArray(At)?At:[0,0];let qt=o7(vt,void 0,zt,E.layout.get("icon-anchor").evaluate(Ke,{},d));const ss=E.getAppearanceValueAndResolveTokens(Xe,"icon-rotate",Ke,d,b),Wt=typeof ss=="number"?ss:0,ds=vt.sdf,ks=E.layout.get("icon-text-fit").constantOr("none");ks!=="none"&&Ce.textShaping&&Ce.iconTextFitPadding&&Ce.fontScale&&(qt=nfe(qt,Ce.textShaping,ks,Ce.iconTextFitPadding,zt,Ce.fontScale));const Ss=this.calculateEffectiveAppearanceIconSize(Xe,C.zoom,Ke,d,b,se),zs=0,$s=1+(Math.min(jv,Math.round(Ss*vg))<<1),Ds=lfe(qt,Wt,ds,ks!=="none",se);Ce.isUsingAppearanceVertexData||(Ce.isUsingAppearanceVertexData=!0,Ce.layoutBasedVertexData=this.icon.getIconVertexData(R,de.numIconVertices));for(let ls=0;ls0&&(this.icon.updateIconVertexData(R,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(R+3,0,0,0,0,0,0,0,0,0,0,0,0),I=!0),R+=de.numIconVertices,Ce.activeAppearance=null;else if(Ce.isUsingAppearanceVertexData){const kt=Ce.layoutBasedVertexData.length/12;for(let vt=0;vt0||ie>0,Fe=de>0,Re=this.elevationFeatures[q.elevationFeatureIndex];if(Re){const Ke=new ft(q.tileAnchorX,q.tileAnchorY),Xe=.075+Re.pointElevation(Ke);q.zOffset!==Xe&&(m=!0,q.zOffset=Xe),Xe!==0&&(this.hasAnyZOffset=!0);const lt=Re.computeSlopeNormal(Ke,C),kt=cs(Ge(),ne(0,0,1),lt);qe(W,W,kt),qe(te,te,kt),W[2]*=b,te[2]*=b,W[0]===1&&W[1]===0&&W[2]===0&&te[0]===0&&te[1]===1&&te[2]===0||(E=E||Ce,I=I||Fe)}if(Ce&&(x7(this.text.orientationVertexArray,se,W,te),x7(this.text.orientationVertexArray,ie,W,te)),Fe){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:Xe}=q;Ke>=0&&x7(this.icon.orientationVertexArray,de,W,te),Xe>=0&&x7(this.icon.orientationVertexArray,he,W,te)}}E||(this.text.orientationVertexArray=void 0),I||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,I,R)=>{b+=I,b>E.length&&E.resize(b);for(let q=-I;q<0;q++)E.emplace(q+b,R)},m=(E,I,R)=>{C+=I,C>E.length&&E.resize(C);for(let q=-I;q<0;q++)E.emplace(q+C,R)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let b=0,C=0;for(let E=0;E0;if((R>0||q>0)&&(d(this.text.zOffsetVertexArray,R,te),d(this.text.zOffsetVertexArray,q,te)),se){const{placedIconSymbolIndex:ie,verticalPlacedIconSymbolIndex:de}=I;ie>=0&&m(this.icon.zOffsetVertexArray,W,te),de>=0&&m(this.icon.zOffsetVertexArray,I.numVerticalIconVertices,te)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(d,m,b,C,E){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(d),this.iconCollisionBox.upload(d)),this.text.upload(d,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,!1),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(I=>I.appearances&&I.appearances.length>0)),this.icon.upload(d,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(d,m,b,C){return!!(d&&m&&b)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,m,b,C)&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=lMe(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,m){const b=this.lineVertexArray.length;if(d.segment!==void 0)for(const{x:C,y:E}of m)this.lineVertexArray.emplaceBack(C,E);return{lineStartIndex:b,lineLength:this.lineVertexArray.length-b}}addSymbols(d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce,Fe,Re,Ke){const Xe=d.indexArray,lt=d.layoutVertexArray,kt=d.globeExtVertexArray,vt=d.segments.prepareSegment(4*Ke,lt,Xe,this.canOverlap?I.sortKey:void 0),At=this.glyphOffsetArray.length,zt=vt.vertexLength,qt=this.allowVerticalPlacement&&R===fm.vertical?Math.PI/2:0,ss=I.text&&I.text.sections;for(let ks=0;ks=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:C),I=afe(this.textSizeData,d,E)/Ec;return this.tilePixelRatio*I}getSymbolInstanceIconSize(d,m,b){const C=this.icon.placedSymbolArray.get(b),E=afe(this.iconSizeData,d,C);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,m,b,C){d.emplaceBack(m,-b,-b,C),d.emplaceBack(m,b,-b,C),d.emplaceBack(m,b,b,C),d.emplaceBack(m,-b,b,C)}_updateTextDebugCollisionBoxes(d,m,b,C,E,I,R){for(let q=C;q0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(d,m){const b=d.placedSymbolArray.get(m),C=b.vertexStartIndex+4*b.numGlyphs;for(let E=b.vertexStartIndex;EC[R]-C[q]||E[q]-E[R]),I}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let d=0;dthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(d).zOffset)}addToSortKeyRanges(d,m){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===m?b.symbolInstanceEnd=d+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:d,symbolInstanceEnd:d+1})}sortFeatures(d){if(this.sortFeaturesByY&&this.sortedAngle!==d&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(d),this.sortedAngle=d,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const b=this.symbolInstances.get(m);this.featureSortOrder.push(b.featureIndex);const{rightJustifiedTextSymbolIndex:C,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:I,verticalPlacedTextSymbolIndex:R,placedIconSymbolIndex:q,verticalPlacedIconSymbolIndex:W}=b;C>=0&&this.addIndicesForPlacedSymbol(this.text,C),E>=0&&E!==C&&this.addIndicesForPlacedSymbol(this.text,E),I>=0&&I!==E&&I!==C&&this.addIndicesForPlacedSymbol(this.text,I),R>=0&&this.addIndicesForPlacedSymbol(this.text,R),q>=0&&this.addIndicesForPlacedSymbol(this.icon,q),W>=0&&this.addIndicesForPlacedSymbol(this.icon,W)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(d){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[d]).elevationFeatureIndex;let b;return this.elevationFeatures&&mb in x?String(x[b]):"")}let dMe,uMe,pfe;kr(g7,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),g7.addDynamicAttributes=u5;class hMe{constructor(d){this.type=d.property.overrides?d.property.overrides.runtimeType:Rp,this.defaultValue=d}evaluate(d){if(d.formattedSection){const m=this.defaultValue.property.overrides;if(m&&m.hasOverride(d.formattedSection))return m.getOverride(d.formattedSection)}return d.feature&&d.featureState?this.defaultValue.evaluate(d.feature,d.featureState):this.defaultValue.property.specification.default}eachChild(d){this.defaultValue.isConstant()||d(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kr(hMe,"FormatSectionOverride",{omit:["defaultValue"]});const ffe=()=>pfe||(pfe={layout:dMe||(dMe=new Io({"symbol-placement":new Qs(Kt.layout_symbol["symbol-placement"]),"symbol-spacing":new Qs(Kt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Qs(Kt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ir(Kt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Qs(Kt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Qs(Kt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Qs(Kt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Qs(Kt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Qs(Kt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Qs(Kt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Qs(Kt.layout_symbol["icon-rotation-alignment"]),"icon-size":new ir(Kt.layout_symbol["icon-size"]),"icon-size-scale-range":new Qs(Kt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ir(Kt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ir(Kt.layout_symbol["icon-text-fit-padding"]),"icon-image":new ir(Kt.layout_symbol["icon-image"]),"icon-image-use-theme":new Qs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ir(Kt.layout_symbol["icon-rotate"]),"icon-padding":new Qs(Kt.layout_symbol["icon-padding"]),"icon-keep-upright":new Qs(Kt.layout_symbol["icon-keep-upright"]),"icon-offset":new ir(Kt.layout_symbol["icon-offset"]),"icon-anchor":new ir(Kt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Qs(Kt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Qs(Kt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Qs(Kt.layout_symbol["text-rotation-alignment"]),"text-field":new ir(Kt.layout_symbol["text-field"]),"text-font":new ir(Kt.layout_symbol["text-font"]),"text-size":new ir(Kt.layout_symbol["text-size"]),"text-size-scale-range":new Qs(Kt.layout_symbol["text-size-scale-range"]),"text-max-width":new ir(Kt.layout_symbol["text-max-width"]),"text-line-height":new ir(Kt.layout_symbol["text-line-height"]),"text-letter-spacing":new ir(Kt.layout_symbol["text-letter-spacing"]),"text-justify":new ir(Kt.layout_symbol["text-justify"]),"text-radial-offset":new ir(Kt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Qs(Kt.layout_symbol["text-variable-anchor"]),"text-anchor":new ir(Kt.layout_symbol["text-anchor"]),"text-max-angle":new Qs(Kt.layout_symbol["text-max-angle"]),"text-writing-mode":new Qs(Kt.layout_symbol["text-writing-mode"]),"text-rotate":new ir(Kt.layout_symbol["text-rotate"]),"text-padding":new Qs(Kt.layout_symbol["text-padding"]),"text-keep-upright":new Qs(Kt.layout_symbol["text-keep-upright"]),"text-transform":new ir(Kt.layout_symbol["text-transform"]),"text-offset":new ir(Kt.layout_symbol["text-offset"]),"text-allow-overlap":new Qs(Kt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Qs(Kt.layout_symbol["text-ignore-placement"]),"text-optional":new Qs(Kt.layout_symbol["text-optional"]),visibility:new Qs(Kt.layout_symbol.visibility)})),paint:uMe||(uMe=new Io({"icon-opacity":new ir(Kt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ir(Kt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ir(Kt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ir(Kt.paint_symbol["text-emissive-strength"]),"icon-color":new ir(Kt.paint_symbol["icon-color"]),"icon-halo-color":new ir(Kt.paint_symbol["icon-halo-color"]),"icon-halo-width":new ir(Kt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ir(Kt.paint_symbol["icon-halo-blur"]),"icon-translate":new Qs(Kt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Qs(Kt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Qs(Kt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ir(Kt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ir(Kt.paint_symbol["text-occlusion-opacity"]),"text-color":new ir(Kt.paint_symbol["text-color"],{runtimeType:hh,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new ir(Kt.paint_symbol["text-halo-color"]),"text-halo-width":new ir(Kt.paint_symbol["text-halo-width"]),"text-halo-blur":new ir(Kt.paint_symbol["text-halo-blur"]),"text-translate":new Qs(Kt.paint_symbol["text-translate"]),"text-translate-anchor":new Qs(Kt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Qs(Kt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Qs(Kt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Qs(Kt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Qs(Kt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ir(Kt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},pfe);class y7 extends $u{constructor(d,m,b,C){super(d,ffe(),m,b,C,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=j([]),this.hasOcclusionOpacityProperties=d.paint!==void 0&&("icon-occlusion-opacity"in d.paint||"text-occlusion-opacity"in d.paint)}_handleSpecialPaintPropertyUpdate(d){d!=="icon-occlusion-opacity"&&d!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(d,m){super.recalculate(d,m),this.appearances&&this.appearances.forEach(C=>{C.recalculate(d,m,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const b=this.layout.get("text-writing-mode");if(b){const C=[];for(const E of b)C.indexOf(E)<0&&C.push(E);this.layout._values["text-writing-mode"]=C}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(d,m,b,C){return this._saturation===d&&this._contrast===m&&this._brightnessMin===b&&this._brightnessMax===C||(this._colorAdjustmentMatrix=function(E,I,R,q){E=uo(E),I=Da(I);const W=_(),te=E/3,se=1-2*te,ie=[se,te,te,0,te,se,te,0,te,te,se,0,0,0,0,1],de=.5-.5*I,he=q-R;return S(W,[he,0,0,0,0,he,0,0,0,0,he,0,R,R,R,1],[I,0,0,0,0,I,0,0,0,0,I,0,de,de,de,1]),S(W,W,ie),W}(d,m,b,C),this._saturation=d,this._contrast=m,this._brightnessMin=b,this._brightnessMax=C),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,m,b,C){const E=this.layout.get(d).evaluate(m,{},b,C),I=this._unevaluatedLayout._values[d];return I.isDataDriven()||x2(I.value)||!E?E:cMe(m.properties,E)}getAppearanceValueAndResolveTokens(d,m,b,C,E){const I=d.getProperty(m);if(!I)return;const R=I.evaluate(b,{},C,E),q=d.getUnevaluatedProperties()._values[m];return q.isDataDriven()||x2(q.value)||!R||typeof R!="string"?R:cMe(b.properties,R)}createBucket(d){return new g7(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of ffe().paint.overridableProperties){if(!y7.hasPaintOverride(this.layout,d))continue;const m=this.paint.get(d),b=new hMe(m),C=new yC(b,m.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let E=null;E=m.value.kind==="constant"||m.value.kind==="source"?new xb("source",C):new dv("composite",C,m.value.zoomStops,m.value.interpolationType),this.paint._values[d]=new hv(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(d,m,b){return!(!this.layout||m.isDataDriven()||b.isDataDriven())&&y7.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,m){const b=d.get("text-field"),C=ffe().paint.properties[m];let E=!1;const I=R=>{for(const q of R)if(C.overrides&&C.overrides.hasOverride(q))return void(E=!0)};if(b.value.kind==="constant"&&b.value.value instanceof Ru)I(b.value.value.sections);else if(b.value.kind==="source"){const R=W=>{E||(W instanceof rg&&Ac(W.value)===t2?I(W.value.sections):W instanceof $f?I(W.sections):W.eachChild(R))},q=b.value;q._styleExpression&&R(q._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,m,b){return{config:new Ry(this,{zoom:m,lut:b}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let mMe,pMe,fMe,xMe;var xfe=xa([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function v7(x,d,m,b,C,E,I,R){const q=[x,d,1,m,b,1,C,E,1],W=[I,R,1],te=g([],q),[se,ie,de]=ye(W,W,te);return v(q,q,[se,0,0,0,ie,0,0,0,de])}function gMe(x,d,m,b,C,E,I,R){const q=function(W,te,se,ie,de,he,Ce,Fe){const Re=v7(0,0,1,0,1,1,0,1),Ke=v7(W,te,se,ie,de,he,Ce,Fe);return v(Ke,Ke,g([],Re))}(x,d,m,b,C,E,I,R);return[q[2]/q[8]/tr,q[5]/q[8]/tr]}function b7(x){return[x[0],Math.min(Math.max(x[1],-Ne),Ne)]}class yMe extends Es{constructor(d,m,b,C){super(),this.id=d,this.dispatcher=b,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(C),this.options=m,this._dirty=!1}load(d,m){if(this._loaded=m||!1,this.fire(new Qm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return d&&(this.coordinates=d),this._loaded=!0,void this._finishLoading();this._imageRequest=_y(this.map._requestManager.transformRequest(this.url,Jx.Image),(b,C)=>{this._imageRequest=null,this._loaded=!0,b?this.fire(new wy(b)):C&&(this.image=C instanceof HTMLImageElement?Ul.getImageData(C):C,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,d&&(this.coordinates=d),this._finishLoading())})}loaded(){return this._loaded}updateImage(d){return d.url?(this._imageRequest&&d.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=d.url,this.load(d.coordinates,this._loaded),this):this}setTexture(d){if(!(d.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new pP(this.map.painter.context,d.handle),this.width=d.dimensions[0],this.height=d.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Qm("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(d){this.map=d,this.load()}onRemove(d){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof pP||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(d){if(this.coordinates=d,this._boundsArray=void 0,this._unsupportedCoords=!1,!d.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let m=d[0][1],b=d[0][1];for(const E of d)E[1]>b&&(b=E[1]),E[1]Ne?this.onNorthPole=!0:C<-Ne&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(nt.fromLngLat);this.tileID=function(I){let R=1/0,q=1/0,W=-1/0,te=-1/0;for(const Ce of I)R=Math.min(R,Ce.x),q=Math.min(q,Ce.y),W=Math.max(W,Ce.x),te=Math.max(te,Ce.y);const se=Math.max(W-R,te-q),ie=Math.max(0,Math.floor(-Math.log2(se))),de=Math.pow(2,ie);let he=Math.floor((R+W)/2*de);return he>1&&(he-=1),new Oi(ie,he,Math.floor((q+te)/2*de))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Qm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof pP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const Re in this.tiles){const Ke=this.tiles[Re];Ke.state!=="loaded"&&(Ke.state="loaded",Ke.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=jP(new Oi(0,0,0),this.map.transform.projection),b=[m.projection.project(this.coordinates[0][0],this.coordinates[0][1]),m.projection.project(this.coordinates[1][0],this.coordinates[1][1]),m.projection.project(this.coordinates[2][0],this.coordinates[2][1]),m.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Re){const Ke=Re[1].x-Re[0].x,Xe=Re[1].y-Re[0].y,lt=Re[2].x-Re[1].x,kt=Re[2].y-Re[1].y,vt=Re[3].x-Re[2].x,At=Re[3].y-Re[2].y,zt=Re[0].x-Re[3].x,qt=Re[0].y-Re[3].y,ss=Ke*kt-lt*Xe,Wt=lt*At-vt*kt,ds=vt*qt-zt*At,ks=zt*Xe-Ke*qt;return ss>0&&Wt>0&&ds>0&&ks>0||ss<0&&Wt<0&&ds<0&&ks<0}(b))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const C=jP(this.tileID,this.map.transform.projection),[E,I,R,q]=this.coordinates.map(Re=>{const Ke=C.projection.project(Re[0],Re[1]);return rMe(C,Ke)._round()});this.perspectiveTransform=gMe(E.x,E.y,I.x,I.y,R.x,R.y,q.x,q.y);const W=this._boundsArray=new bb;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(I.x,I.y,tr,0),W.emplaceBack(q.x,q.y,0,tr),W.emplaceBack(R.x,R.y,tr,tr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(W,xfe.members),this.boundsSegments=wo.simpleSegment(0,0,4,2);const te=[],se=[b7((ie=this.coordinates)[0]),b7(ie[1]),b7(ie[2]),b7(ie[3])];var ie;const[de,he,Ce,Fe]=function(Re){let Ke=Re[0][0],Xe=Ke,lt=Re[0][1],kt=lt;for(let vt=1;vtXe&&(Xe=Re[vt][0]),Re[vt][1]kt&&(kt=Re[vt][1]);return[Ke,lt,Xe-Ke,kt-lt]}(se);{const Re=new bb,[Ke,Xe,lt,kt]=function(Ds){let Rs=Ds[0].x,ls=Rs,rs=Ds[0].y,Fs=rs;for(let sr=1;srls&&(ls=Ds[sr].x),Ds[sr].yFs&&(Fs=Ds[sr].y);return[Rs,rs,ls-Rs,Fs-rs]}(b),vt=Ds=>[(Ds.x-Ke)/lt,(Ds.y-Xe)/kt],[At,zt,qt,ss]=b.map(vt),Wt=function(Ds,Rs,ls,rs,Fs,sr,Hs,zr){const fr=v7(0,0,1,0,1,1,0,1);return v(fr,fr,g([],v7(Ds,Rs,ls,rs,Fs,sr,Hs,zr)))}(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);this.elevatedGlobePerspectiveTransform=gMe(At[0],At[1],zt[0],zt[1],qt[0],qt[1],ss[0],ss[1]);const ds=(Ds,Rs)=>{te.push(Ds.lng);const ls=Math.round((Ds.lng-de)/Ce*tr),rs=Math.round((Ds.lat-he)/Fe*tr),Fs=vt(Rs),sr=ye([],[Fs[0],Fs[1],1],Wt),Hs=Math.round(sr[0]/sr[2]*tr),zr=Math.round(sr[1]/sr[2]*tr);Re.emplaceBack(ls,rs,Hs,zr)},ks=b[3].x-b[0].x,Ss=b[3].y-b[0].y,zs=b[2].x-b[1].x,$s=b[2].y-b[1].y;for(let Ds=0;Ds<65;Ds++){const Rs=Ds/64,ls=[b[0].x+Rs*ks,b[0].y+Rs*Ss],rs=[b[1].x+Rs*zs,b[1].y+Rs*$s],Fs=rs[0]-ls[0],sr=rs[1]-ls[1];for(let Hs=0;Hs<65;Hs++){const zr=Hs/64,fr={x:ls[0]+Fs*zr,y:ls[1]+sr*zr};ds(m.projection.unproject(fr.x,fr.y),fr)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(Re,xfe.members)}{this.maxLongitudeTriangleSize=0;let Re=[],Ke=new Vl;const Xe=(lt,kt,vt)=>{Ke.emplaceBack(lt,kt,vt);const At=te[lt],zt=te[kt],qt=te[vt],ss=Math.min(Math.min(At,zt),qt),Wt=Math.max(Math.max(At,zt),qt)-ss;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Re.push(ss+Wt/2)};for(let lt=0;lt<64;lt++)for(let kt=0;kt<64;kt++){const vt=65*lt+kt,At=vt+1,zt=vt+65,qt=zt+1;Xe(vt,zt,At),Xe(At,zt,qt)}[Re,Ke]=function(lt,kt){const vt=Array.from({length:lt.length},(qt,ss)=>ss);vt.sort((qt,ss)=>lt[qt]-lt[ss]);const At=[],zt=new Vl;for(let qt=0;qt{I.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:m.segments[0].vertexLength,primitiveLength:ie,sortKey:void 0,vaos:{}})},q=.51*this.maxLongitudeTriangleSize;if(Math.abs(b[0]-C)<=q){const se=co(b,0,b.length,C+q);return se===b.length||R(se,pl(b,se+1,b.length,C+360-q)-se),I}Ctr?C-tr:C,new ft(Math.trunc(C),Math.trunc(b[m+1]))}translationForInstance(d){const m=16*d,b=this.instancedDataArray.float32;return[b[m+4],b[m+5],b[m+6]]}rotationScaleForInstance(d){const m=16*d,b=this.instancedDataArray.float32;return[b[m+7],b[m+8],b[m+9],b[m+10],b[m+11],b[m+12],b[m+13],b[m+14],b[m+15]]}transformForInstance(d){const m=16*d,b=this.instancedDataArray.float32;return[b[m+7],b[m+8],b[m+9],b[m+4],b[m+10],b[m+11],b[m+12],b[m+5],b[m+13],b[m+14],b[m+15],b[m+6],0,0,0,1]}}class vfe{constructor(d){this.zoom=d.zoom,this.canonical=d.canonical,this.overscaledZ=this.canonical.z+Math.log2(d.overscaling),this.layers=d.layers,this.layerIds=this.layers.map(m=>m.fqid),this.projection=d.projection,this.index=d.index,this.worldview=d.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=d.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,b,C){}populate(d,m,b,C){this.tileToMeter=Ve(b);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:I,id:R,index:q,sourceLayerIndex:W}of d){const te=R??(I.properties&&I.properties.hasOwnProperty("id")?I.properties.id:void 0),se=Gt(I,E);if(!this.layers[0]._featureFilter.filter(new Zi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,b))continue;const ie={id:te,sourceLayerIndex:W,index:q,geometry:E?se.geometry:Ot(I,b,C),properties:I.properties,type:I.type,patterns:{}},de=this.addFeature(ie,ie.geometry,se);de&&m.featureIndex.insert(I,ie.geometry,q,W,this.index,this.instancesPerModel[de].instancedDataArray.length,tr/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const d=this.layers[0].modelManager,m=this.layers[0].scope;let b=0;for(const C of this.modelUris){const E=d.getModel(C,m);if(!E)continue;const I=this.instancesPerModel[C];if(I){const R=.5*Me(E.aabb.max,E.aabb.min)*I.maxScale+I.maxXYTranslationDistance,q=Math.min(tr,Math.max(R/this.tileToMeter,tr/32));b=Math.max(q,b)}}return b}update(d,m,b,C){for(const E in this.instancesPerModel){const I=this.instancesPerModel[E];for(const R in d)I.idToFeaturesIndex.hasOwnProperty(R)&&(this.evaluate(I.features[I.idToFeaturesIndex[R]],d[R],I,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const m in this.instancesPerModel){const b=this.instancesPerModel[m];for(const C of b.features){const E=this.layers[0],I=C.feature,R=this.canonical,q=E.paint.get("model-rotation").evaluate(I,{},R),W=E.paint.get("model-scale").evaluate(I,{},R),te=E.paint.get("model-translation").evaluate(I,{},R);tt(C.rotation,q)&&tt(C.scale,W)&&tt(C.translation,te)||(this.evaluate(C,C.featureStates,b,!0),d=!0)}}return d}updateReplacement(d,m,b,C){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(HF(this.activeReplacements,E))return!1;this.activeReplacements=E;let I=!1;for(const R in this.instancesPerModel){const q=this.instancesPerModel[R],W=q.instancedDataArray;for(const te of q.features){const se=te.instancedDataOffset,ie=te.instancedDataCount;for(let de=0;detr;Ce=Fe?Ce-tr:Ce;const Re=Math.floor(Ce),Ke=Math.floor(W.float32[he+1]);let Xe=!1;for(const lt of this.activeReplacements)if(!pCe(lt,b,SMe.Model,C)&&!(lt.min.x>Re||Re>lt.max.x||lt.min.y>Ke||Ke>lt.max.y)&&(Xe=vCe(yCe(Re,Ke,d.canonical,lt.footprintTileId.canonical),lt.footprint),Xe))break;W.float32[he]=Xe?Ce+tr:Ce,I=I||Xe!==Fe}}}return I}isEmpty(){for(const d in this.instancesPerModel)if(this.instancesPerModel[d].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(d){if(!this.uploaded)for(const m in this.instancesPerModel){const b=this.instancesPerModel[m];b.instancedDataArray.length<0||b.instancedDataArray.length===0||(b.instancedDataBuffer?b.instancedDataBuffer.updateData(b.instancedDataArray):b.instancedDataBuffer=d.createVertexBuffer(b.instancedDataArray,Jdt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const b in this.instancesPerModel){const C=this.instancesPerModel[b];C.instancedDataArray.length!==0&&C.instancedDataBuffer&&C.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(d&&m&&this.modelUris&&this.modelsRequested)for(const b of this.modelUris)m.removeModel(b,"",!0)}addFeature(d,m,b){const C=this.layers[0],E=C.layout.get("model-id").evaluate(b,{},this.canonical);if(!E)return xr(`modelId is not evaluated for layer ${C.id} and it is not going to get rendered.`),E;(yfe(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new MMe);const I=this.instancesPerModel[E],R=I.instancedDataArray,q=new CMe(b,R.length);for(const W of m)for(const te of W){if(te.x<0||te.x>=tr||te.y<0||te.y>=tr)continue;if(this.lookupDim!==0){const ie=(this.lookupDim-1)/tr,de=this.lookupDim*(te.y*ie|0)+te.x*ie|0;if(this.lookup){if(this.lookup[de]!==0)continue;this.lookup[de]=1}}this.instanceCount++;const se=R.length;R.resize(se+1),I.instancesEvaluatedElevation.push(0),R.float32[16*se]=te.x,R.float32[16*se+1]=te.y}return q.instancedDataCount=I.instancedDataArray.length-q.instancedDataOffset,q.instancedDataCount>0&&(d.id&&(I.idToFeaturesIndex[d.id]=I.features.length),I.features.push(q),this.evaluate(q,{},I,!1)),E}getModelUris(){return this.modelUris}evaluate(d,m,b,C){const E=this.layers[0],I=d.feature,R=this.canonical,q=d.rotation=E.paint.get("model-rotation").evaluate(I,m,R),W=d.scale=E.paint.get("model-scale").evaluate(I,m,R),te=d.translation=E.paint.get("model-translation").evaluate(I,m,R),se=Object.assign({},E.paint.get("model-color").evaluate(I,m,R));se.a=E.paint.get("model-color-mix-intensity").evaluate(I,m,R);const ie=[];this.maxVerticalOffset0?Math.sqrt(de):0;b.maxScale=Math.max(Math.max(b.maxScale,W[0]),Math.max(W[1],W[2])),b.maxXYTranslationDistance=Math.max(b.maxXYTranslationDistance,he),this.maxScale=Math.max(Math.max(this.maxScale,W[0]),Math.max(W[1],W[2])),a5e(ie,q,W);const Ce=Math.round(100*se.a)+se.b/1.05;for(let Fe=0;Fe10?this.tileToMeter:Ve(R,kt)),Xe[Ke+4]=te[0],Xe[Ke+5]=te[1],Xe[Ke+6]=te[2]+lt,Xe[Ke+7]=ie[0],Xe[Ke+8]=ie[1],Xe[Ke+9]=ie[2],Xe[Ke+10]=ie[4],Xe[Ke+11]=ie[5],Xe[Ke+12]=ie[6],Xe[Ke+13]=ie[8],Xe[Ke+14]=ie[9],Xe[Ke+15]=ie[10],b.instancesEvaluatedElevation[Re]=te[2]}}}let TMe,AMe;kr(vfe,"ModelBucket",{omit:["layers"]}),kr(MMe,"PerModelAttributes"),kr(CMe,"ModelFeature");class h5{constructor(d,m,b){this._demTile=d,this._dem=this._demTile.dem,this._scale=m,this._offset=b}static create(d,m,b){const C=b||d.findDEMTileFor(m);if(!C||!C.dem)return;const E=C.dem,I=C.tileID,R=1<W.fqid),this.stateDependentLayerIds=this.layers.filter(W=>W.isStateDependent()).map(W=>W.id),this.modelTraits|=r5.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,C&&(this.modelTraits|=r5.HasMapboxMeshFeatures),E&&(this.modelTraits|=r5.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=I,this.worldview=q,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const W of m)this.nodesInfo.push(new LMe(W)),PMe(W,R.featureIndexArray.length,R.grid),R.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,R.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(d,m){for(const b of this.getNodesInfo()){const C=b.node;C.footprint&&m.push({footprint:C.footprint,id:d})}}updateAppearances(d,m,b,C){}update(d){const m=Object.keys(d).length!==0;if(m&&!this.stateDependentLayers.length)return;const b=m?this.stateDependentLayers:this.layers;if(!or(d,this.states))for(const C of b)this.evaluate(C,d);this.states=structuredClone(d)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(d){if(!this.needsUpload)return;const m=this.getNodesInfo();for(const b of m){const C=b.node;this.uploaded?this.updatePbrBuffer(C):Vpe(C,d,!0)}for(const b of m)r7(b.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(d){let m=!1;if(!d.meshes)return m;for(const b of d.meshes)b.pbrBuffer&&(b.pbrBuffer.updateData(b.featureArray),m=!0);return m}needsReEvaluation(d,m,b){const C=d.transform.projectionOptions,E=d.style.getBrightness(),I=this.brightness!==E;if(!this.uploaded||this.dirty||C.name!==this.projection.name||EP(b.paint.get("model-color").value,I)||EP(b.paint.get("model-color-mix-intensity").value,I)||EP(b.paint.get("model-roughness").value,I)||EP(b.paint.get("model-emissive-strength").value,I)||EP(b.paint.get("model-height-based-emissive-strength-multiplier").value,I)){this.projection=C,this.brightness=E;const R=this.getNodesInfo();for(const q of R)q.state=null;return!0}return!1}evaluateTransform(d,m){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const b=this.getNodesInfo(),C=this.id.canonical;for(const E of b){const I=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(I,{},C),E.evaluatedScale=m.paint.get("model-scale").evaluate(I,{},C)}}evaluate(d,m){const b=this.getNodesInfo();for(const C of b){if(!C.node.meshes)continue;const E=C.feature,I=m&&m[E.id];if(or(I,C.state))continue;C.state=structuredClone(I);const R=C.node.meshes&&C.node.meshes[0].featureData,q=C.evaluatedColor[2],W=C.evaluatedRMEA[2],te=this.id.canonical;if(C.hasTranslucentParts=!1,R){for(let se=0;se=vt)continue;const Ds=bfe[$s],Rs=Math.abs(Ds);Rs>Wt&&(ss=Ds,Wt=Rs,ds=zs,ks=Ss)}if(Wt>.1){const Ss=1-(vt+.5*Math.abs(ds*ks))/he;let zs=m._dem.get(zt,At)+ss*Ss;const $s=m._dem.get(zt+ds,At+ks),Ds=m._dem.get(zt-ds,At-ks,!0);(zs-$s)*(zs-Ds)>0&&(zs=($s+Ds)/2),bfe[qt]=m._dem.set(zt,At,zs),F2[qt]=vt}}}}}R&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=Ul.now())}setFilter(d){this.filter=d?CC(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Zi(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const m of d)r7(m.node),Hpe(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const b=m.getReplacementRegionsForTile(d.toUnwrapped());for(const C of this.getNodesInfo()){const E=C.node.footprint;C.hiddenByReplacement=!!E&&!b.find(I=>I.footprint===E)}}getHeightAtTileCoord(d,m){const b=[],C=[0,0,0],E=j([]);for(const I of this.getNodesInfo()){const R=I.node.meshes[0],q=R.transformedAabb;if(dq.max[0]||m>q.max[1])continue;if(I.node.hidden===!0)return{height:1/0,maxHeight:I.feature.properties.height,hidden:!1,verticalScale:I.evaluatedScale[2]};k(E,I.node.globalMatrix),C[0]=d,C[1]=m,pt(C,C,E);const W=(C[0]-R.aabb.min[0])/(R.aabb.max[0]-R.aabb.min[0])*D2|0,te=Math.min(63,(C[1]-R.aabb.min[1])/(R.aabb.max[1]-R.aabb.min[1])*D2|0)*D2+Math.min(63,W),se=R.heightmap[te];if(!(se<0&&I.node.footprint))return I.hiddenByReplacement?void 0:{height:se,maxHeight:I.feature.properties.height,hidden:!1,verticalScale:I.evaluatedScale[2]};if(I.node.footprint.grid.query(new ft(d,m),new ft(d,m),b),b.length>0)return{height:void 0,maxHeight:I.feature.properties.height,hidden:I.hiddenByReplacement,verticalScale:I.evaluatedScale[2]}}}}function EP(x,d){return x instanceof xb&&!x.isLightConstant&&d}function Eht(x,d,m,b,C,E,I,R){let q=(61440&d|(61440&d)>>4)>>8,W=(3840&d|(3840&d)>>4)>>4,te=240&d|(240&d)>>4;m[3]>0&&(q=Zr(q,255*m[0],m[3]),W=Zr(W,255*m[1],m[3]),te=Zr(te,255*m[2],m[3]));const se=q<<8|W,ie=te<<8|Math.floor(255*b[3]),de=function(vt){const At=Se(vt,0,2);return Math.min(Math.round(.5*At*255),255)}(b[2])<<8|15*b[0]<<4|15*b[1],he=Se(C[0],0,1),Ce=Se(C[1],0,1),Fe=Se(C[2],0,1),Re=Se(C[3],0,1);let Ke,Xe,lt,kt;if(he!==Ce&&I!==E&&Ce!==he){const vt=I-E;Xe=1/(vt*(Ce-he)),lt=-(E+vt*he)/(vt*(Ce-he));const At=Se(C[4],-1,1);kt=Math.pow(10,At),Ke=255*Fe<<8|255*Re}else Ke=65535,Xe=0,lt=1,kt=1;if(x.emplaceBack(se,ie,de,Ke,Xe,lt,kt),R){const vt=R.length;R.clear();for(let At=0;At>16&65535,te=E?q>>16&65535:65535&q,se=(15&te)<8?15&te:0,ie=x.evaluatedRMEA[se],de=x.evaluatedColor[se],he=x.emissionHeightBasedParams[se];let Ce;if(R&&se===2&&b.lights&&(Ce=new FC,Ce.resize(10*b.lights.length)),Eht(I.featureArray,W,de,ie,he,I.aabb.min[2],I.aabb.max[2],Ce),Ce&&R){R=!1;const Fe=b.meshes[b.lightMeshIndex];Fe.featureArray=Ce,Fe.featureArray._trim()}}I.featureArray._trim(),C++}}kr(w7,"Tiled3dModelBucket",{omit:["layers"]}),kr(LMe,"Tiled3dModelFeature");const Iht=["id","tile","layer","source","sourceLayer","state"];class z2{constructor(d,m,b,C,E){this.type="Feature",this._vectorTileFeature=d,this._z=m,this._x=b,this._y=C,this.properties=d?d.properties:{},this.id=E}clone(){const d=new z2(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(d.state=Object.assign({},this.state)),this.layer&&(d.layer=Object.assign({},this.layer)),this.source&&(d.source=this.source),this.sourceLayer&&(d.sourceLayer=this.sourceLayer),d}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(d){this._geometry=d}toJSON(){const d={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const m of Iht)this[m]!==void 0&&(d[m]=this[m]);return d}}class B2 extends Es{constructor(d,m,b,C){super(),this.id=d,this.type="model",this.models=[],this._loaded=!1,this._options=m,this._modelsInfo=new Map}load(){const d=[];for(const m in this._options.models){const b=this._options.models[m],C=this._modelsInfo.get(m);if(C){const E=C.model;E.position=b.position!=null?new y(b.position[0],b.position[1]):new y(0,0),E.orientation=b.orientation!=null?b.orientation:[0,0,0],C.modelSpec=b,B2.applyModelSpecification(E,b),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=t5e(this.map._requestManager.transformRequest(b.uri,Jx.Model).url).then(I=>{if(!I)return;const R=Wpe(I),q=new i5e(m,b.uri,b.position,b.orientation,R);B2.applyModelSpecification(q,b),q.computeBoundsAndApplyParent(),this.models.push(q),this._modelsInfo.set(m,{modelSpec:b,model:q})}).catch(I=>{this.fire(new wy(new Error(`Could not load model ${m} from ${b.uri}: ${I.message}`)))});d.push(E)}}Promise.allSettled(d).then(()=>{this._loaded=!0,this.fire(new Qm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new wy(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(d,m){m.nodeOverrides&&B2.convertNodeOverrides(d,m.nodeOverrides),m.materialOverrides&&B2.convertMaterialOverrides(d,m.materialOverrides),m.nodeOverrideNames&&(d.nodeOverrideNames=[...m.nodeOverrideNames]),m.materialOverrideNames&&(d.materialOverrideNames=[...m.materialOverrideNames]),m.featureProperties&&(d.featureProperties=m.featureProperties)}static convertNodeOverrides(d,m){if(Array.isArray(m)&&m.every(b=>typeof b=="string")){d.nodeOverrideNames=[];for(const b of m)d.nodeOverrideNames.push(b)}else Object.entries(m).forEach(([b,C])=>{const E={orientation:[0,0,0]};if(C.hasOwnProperty("orientation")){const I=C.orientation;I&&(E.orientation=I)}d.nodeOverrides.set(b,E)})}static convertMaterialOverrides(d,m){if(Array.isArray(m)&&m.every(b=>typeof b=="string")){d.materialOverrideNames=[];for(const b of m)d.materialOverrideNames.push(b)}else Object.entries(m).forEach(([b,C])=>{const E={color:new Ur(1,1,1),colorMix:0,emissionStrength:0,opacity:1},I=C["model-color"];I!==void 0&&(E.color.r=I[0],E.color.g=I[1],E.color.b=I[2]);const R=C["model-color-mix-intensity"];R!==void 0&&(E.colorMix=R);const q=C["model-emissive-strength"];q!==void 0&&(E.emissionStrength=q);const W=C["model-opacity"];W!==void 0&&(E.opacity=W),d.materialOverrides.set(b,E)})}onAdd(d){this.map=d,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(d,m){}serialize(){return this._options}setProperty(d,m){return!1}reload(){const d=$p(this.id,this.scope);this.map.style.clearSource(d),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(d){this.models=[];const m=new Map;for(const b in d){const C=d[b];if(this._modelsInfo.has(b)){const E=this._modelsInfo.get(b);E&&E.modelSpec.uri===C.uri&&m.set(b,E)}}this._modelsInfo=m,this._options.models=d,this._loaded=!1,this.load()}}function _fe(x,d,m,b){const C=1<lt.polygon).flat());const Fe=de?R:null,[Re,Ke]=UCe(E,b,se,te,W,I,Fe,ie,he,E.center.lat,x.tileID.canonical),Xe=x.queryGeometry;return qCe(Re,Ke,Xe.isPointQuery()?Xe.screenBounds:Xe.screenGeometry)}},building:class extends $u{constructor(x,d,m,b){super(x,{layout:m5e||(m5e=new Io({visibility:new Qs(Kt.layout_building.visibility),"building-facade":new ir(Kt.layout_building["building-facade"]),"building-facade-floors":new ir(Kt.layout_building["building-facade-floors"]),"building-facade-unit-width":new ir(Kt.layout_building["building-facade-unit-width"]),"building-facade-window":new ir(Kt.layout_building["building-facade-window"]),"building-roof-shape":new ir(Kt.layout_building["building-roof-shape"]),"building-height":new ir(Kt.layout_building["building-height"]),"building-base":new ir(Kt.layout_building["building-base"]),"building-flood-light-wall-radius":new ir(Kt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ir(Kt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ir(Kt.layout_building["building-flip-roof-orientation"])})),paint:p5e||(p5e=new Io({"building-opacity":new Qs(Kt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Qs(Kt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Qs(Kt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Qs(Kt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Qs(Kt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Qs(Kt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Qs(Kt.paint_building["building-cast-shadows"]),"building-color":new ir(Kt.paint_building["building-color"]),"building-emissive-strength":new ir(Kt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Qs(Kt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Qs(Kt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Qs(Kt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Qs(Kt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Qs(Kt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},d,m,b),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new h5e(x)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(x){return!0}queryRadius(x){return 0}queryIntersectsFeature(x,d,m,b,C,E,I,R,q){let W=this.layout.get("building-height").evaluate(d,m);const te=this.layout.get("building-base").evaluate(d,m),se=x.tile.getBucket(this).getFootprint(d);if(se){if(se.hiddenFlags!==0)return!1;W=se.height}const[ie,de]=UCe(E,b,te,W,new ft(0,0),I,null,[0,0],1,E.center.lat,x.tileID.canonical),he=x.queryGeometry;return qCe(ie,de,he.isPointQuery()?he.screenBounds:he.screenGeometry)}},line:class extends $u{constructor(x,d,m,b){const C=N5e();super(x,C,d,m,b),C.layout&&(this.layout=new mv(C.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(x){if(x==="line-gradient"){const d=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=d._styleExpression&&d._styleExpression.expression instanceof d2,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(x,d){super.recalculate(x,d),this.paint._values["line-floorwidth"]=(()=>{if(xP)return xP;const m=N5e();return xP=new Tut(m.paint.properties["line-width"].specification),xP.useIntegerZoom=!0,xP})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new Ype(x)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(x,d,m){const b=w5e(this);return{config:new Ry(this,{zoom:d,lut:m}),defines:b,overrideFog:!1}}queryRadius(x){const d=x,m=k5e(Hd("line-width",this,d),Hd("line-gap-width",this,d)),b=Hd("line-offset",this,d);return m/2+Math.abs(b)+ld(this.paint.get("line-translate"))}queryIntersectsFeature(x,d,m,b,C,E){if(x.queryGeometry.isAboveHorizon)return!1;const I=mm(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,x.pixelToTileUnitsFactor),R=x.pixelToTileUnitsFactor/2*k5e(this.paint.get("line-width").evaluate(d,m),this.paint.get("line-gap-width").evaluate(d,m)),q=this.paint.get("line-offset").evaluate(d,m);return q&&(b=function(W,te){const se=[],ie=new ft(0,0);for(let de=0;de=3){for(let he=0;he>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function Kht(x,d,m){x===1?(d.rgb_color=S7(m.readVarint()),d.paint="rgb_color"):x===2?(d.linear_gradient_idx=m.readVarint(),d.paint="linear_gradient_idx"):x===3?(d.radial_gradient_idx=m.readVarint(),d.paint="radial_gradient_idx"):x===5?m.readPackedFloat(d.dasharray):x===6?d.dashoffset=m.readFloat():x===7?d.miterlimit=m.readFloat():x===8?d.opacity=m.readVarint():x===9?d.width=m.readFloat():x===10?d.linecap=m.readVarint():x===11&&(d.linejoin=m.readVarint())}function Zht(x,d,m){x===1?d.transform=k7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(FMe(m,m.readVarint()+m.pos)):x===4?d.x1=m.readFloat():x===5?d.y1=m.readFloat():x===6?d.x2=m.readFloat():x===7&&(d.y2=m.readFloat())}function FMe(x,d){return x.readFields(Yht,{offset:0,opacity:255,rgb_color:wfe},d)}function Yht(x,d,m){x===1?d.offset=m.readFloat():x===2?d.opacity=m.readVarint():x===3&&(d.rgb_color=S7(m.readVarint()))}function Qht(x,d,m){x===1?d.transform=k7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(FMe(m,m.readVarint()+m.pos)):x===4?d.cx=m.readFloat():x===5?d.cy=m.readFloat():x===6?d.r=m.readFloat():x===7?d.fx=m.readFloat():x===8?d.fy=m.readFloat():x===9&&(d.fr=m.readFloat())}function Xht(x,d,m){x===1?d.transform=k7(m,m.readVarint()+m.pos):x===2?d.clip_path_idx=m.readVarint():x===3&&d.children.push(N7(m,m.readVarint()+m.pos))}function Jht(x,d,m){x===1?d.left=d.top=m.readFloat():x===2?d.width=d.height=m.readFloat():x===3?d.top=m.readFloat():x===4?d.height=m.readFloat():x===5?d.mask_type=m.readVarint():x===6?d.mask_idx=m.readVarint():x===7&&d.children.push(N7(m,m.readVarint()+m.pos))}class emt{static calculate(d={},m=[]){const b=new Map,C=new Map;if(Object.keys(d).length===0)return b;m.forEach(E=>{C.set(E.name,E.rgb_color||new Ur(0,0,0))});for(const[E,I]of Object.entries(d))C.has(E)?b.set(C.get(E).toString(),I):console.warn(`Ignoring unknown image variable "${E}"`);return b}}function m5(x,d=255,m){const b=d/255,C=x.toString(),E=m.has(C)?m.get(C).clone():x.clone();return E.a*=b,E.toString()}function IP(x,d){if(!Km()){const m=document.createElement("canvas");return m.width=x,m.height=d,m}return new OffscreenCanvas(x,d)}let kfe,LP=null;function Sfe(x,d,m,b,C){for(const E of b.children)zMe(x,d,m,E,C)}function zMe(x,d,m,b,C){b.group?(x.save(),function(E,I,R,q,W){const te=q.mask_idx!=null?R.masks[q.mask_idx]:null,se=q.clip_path_idx!=null?R.clip_paths[q.clip_path_idx]:null;if(q.transform&&(I=p5(q.transform).preMultiplySelf(I)),!function(he,Ce,Fe){return he.opacity!==255||Ce||Fe}(q,se!=null,te!=null))return void Sfe(E,I,R,q,W);const ie=IP(E.canvas.width,E.canvas.height),de=ie.getContext("2d");Sfe(de,I,R,q,W),se&&GMe(de,I,R,se),te&&WMe(de,I,R,te,W),E.globalAlpha=q.opacity/255,E.drawImage(ie,0,0)}(x,d,m,b.group,C),x.restore()):b.path&&(x.save(),function(E,I,R,q,W){E.setTransform(I),q.paint_order===Oht.PAINT_ORDER_FILL_AND_STROKE?(BMe(E,R,q,W),qMe(E,R,q,W)):(qMe(E,R,q,W),BMe(E,R,q,W))}(x,d,m,b.path,C),x.restore())}function BMe(x,d,m,b){const C=m.fill;if(!C)return;const E=C.opacity/255;switch(x.save(),x.beginPath(),KMe(m,x),C.paint){case"rgb_color":x.fillStyle=m5(C.rgb_color,C.opacity,b);break;case"linear_gradient_idx":{const I=d.linear_gradients[C.linear_gradient_idx];I.transform&&x.setTransform(p5(I.transform).preMultiplySelf(x.getTransform())),x.fillStyle=UMe(x,I,E,b);break}case"radial_gradient_idx":{const I=d.radial_gradients[C.radial_gradient_idx];I.transform&&x.setTransform(p5(I.transform).preMultiplySelf(x.getTransform())),x.fillStyle=VMe(x,I,E,b)}}x.fill($Me(m)),x.restore()}function $Me(x){return x.rule===jfe.PATH_RULE_NON_ZERO?"nonzero":x.rule===jfe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function qMe(x,d,m,b){const C=m.stroke;if(!C)return;const E=ZMe(m);x.lineWidth=C.width,x.miterLimit=C.miterlimit,x.setLineDash(C.dasharray),x.lineDashOffset=C.dashoffset;const I=C.opacity/255;switch(C.paint){case"rgb_color":x.strokeStyle=m5(C.rgb_color,C.opacity,b);break;case"linear_gradient_idx":x.strokeStyle=UMe(x,d.linear_gradients[C.linear_gradient_idx],I,b,!0);break;case"radial_gradient_idx":x.strokeStyle=VMe(x,d.radial_gradients[C.radial_gradient_idx],I,b,!0)}switch(C.linejoin){case j7.LINE_JOIN_MITER_CLIP:case j7.LINE_JOIN_MITER:x.lineJoin="miter";break;case j7.LINE_JOIN_ROUND:x.lineJoin="round";break;case j7.LINE_JOIN_BEVEL:x.lineJoin="bevel"}switch(C.linecap){case Nfe.LINE_CAP_BUTT:x.lineCap="butt";break;case Nfe.LINE_CAP_ROUND:x.lineCap="round";break;case Nfe.LINE_CAP_SQUARE:x.lineCap="square"}x.stroke(E)}function UMe(x,d,m,b,C=!1){if(d.stops.length===1){const ie=d.stops[0];return m5(ie.rgb_color,ie.opacity*m,b)}const{x1:E,y1:I,x2:R,y2:q}=d;let W=new DOMPoint(E,I),te=new DOMPoint(R,q);if(C){const ie=p5(d.transform);W=ie.transformPoint(W),te=ie.transformPoint(te)}const se=x.createLinearGradient(W.x,W.y,te.x,te.y);for(const ie of d.stops)se.addColorStop(ie.offset,m5(ie.rgb_color,ie.opacity*m,b));return se}function VMe(x,d,m,b,C=!1){if(d.stops.length===1){const Re=d.stops[0];return m5(Re.rgb_color,Re.opacity*m,b)}const E=p5(d.transform),{fx:I,fy:R,fr:q,cx:W,cy:te,r:se}=d;let ie=new DOMPoint(I,R),de=new DOMPoint(W,te),he=q,Ce=se;if(C){ie=E.transformPoint(ie),de=E.transformPoint(de);const Re=(E.a+E.d)/2;he=q*Re,Ce=d.r*Re}const Fe=x.createRadialGradient(ie.x,ie.y,he,de.x,de.y,Ce);for(const Re of d.stops)Fe.addColorStop(Re.offset,m5(Re.rgb_color,Re.opacity*m,b));return Fe}function HMe(x,d,m,b){const C=b.transform?p5(b.transform).preMultiplySelf(d):d,E=IP(x.canvas.width,x.canvas.height),I=E.getContext("2d");for(const q of b.children)if(q.group)HMe(I,C,m,q.group);else if(q.path){const W=q.path,te=new Path2D;te.addPath(ZMe(W),C),I.fill(te,$Me(W))}const R=b.clip_path_idx!=null?m.clip_paths[b.clip_path_idx]:null;R&&GMe(I,C,m,R),x.globalCompositeOperation="source-over",x.drawImage(E,0,0)}function GMe(x,d,m,b){const C=IP(x.canvas.width,x.canvas.height);HMe(C.getContext("2d"),d,m,b),x.globalCompositeOperation="destination-in",x.drawImage(C,0,0)}function WMe(x,d,m,b,C){if(b.children.length===0)return;const E=b.mask_idx!=null?m.masks[b.mask_idx]:null;E&&WMe(x,d,m,E,C);const I=x.canvas.width,R=x.canvas.height,q=IP(I,R),W=q.getContext("2d"),te=b.width,se=b.height,ie=b.left,de=b.top,he=new Path2D,Ce=new Path2D;Ce.rect(ie,de,te,se),he.addPath(Ce,d),W.clip(he);for(const Ke of b.children)zMe(W,d,m,Ke,C);const Fe=W.getImageData(0,0,I,R),Re=Fe.data;if(b.mask_type===DMe.MASK_TYPE_LUMINANCE)for(let Ke=0;Ked[I])return null}else{const R=1/b[I];let q=(x[I]-m[I])*R,W=(d[I]-m[I])*R;if(q>W){const te=q;q=W,W=te}if(q>C&&(C=q),WE)return null}return C}function XMe(x,d,m,b,C,E,I,R,q,W,te){const se=b-x,ie=C-d,de=E-m,he=I-x,Ce=R-d,Fe=q-m,Re=te[1]*Fe-te[2]*Ce,Ke=te[2]*he-te[0]*Fe,Xe=te[0]*Ce-te[1]*he,lt=se*Re+ie*Ke+de*Xe;if(Math.abs(lt)<1e-15)return null;const kt=1/lt,vt=W[0]-x,At=W[1]-d,zt=W[2]-m,qt=(vt*Re+At*Ke+zt*Xe)*kt;if(qt<0||qt>1)return null;const ss=At*de-zt*ie,Wt=zt*se-vt*de,ds=vt*ie-At*se,ks=(te[0]*ss+te[1]*Wt+te[2]*ds)*kt;return ks<0||qt+ks>1?null:(he*ss+Ce*Wt+Fe*ds)*kt}function JMe(x,d,m){return(x-d)/(m-d)}function eTe(x,d,m,b,C,E,I,R,q){const W=1<{const Ke=Fe?1:0,Xe=(de+1)*Ce-Ke,lt=he*Ce,kt=(he+1)*Ce-Ke;Re[0]=de*Ce,Re[1]=lt,Re[2]=Xe,Re[3]=kt};let se=new YMe(q);const ie=[];for(let de=0;de=1;q/=2){const de=R[R.length-1];se=new YMe(q);for(let he=0;he0;){const{idx:he,t:Ce,nodex:Fe,nodey:Re,depth:Ke}=de.pop();if(this.leaves[he]){eTe(Fe,Re,Ke,d,m,b,C,se,ie);const lt=1<=$s[2])return Ce}continue}let Xe=0;for(let lt=0;lt=W[te[zt]]&&(te.splice(zt,0,lt),At=!0);At||(te[Xe]=lt),Xe++}}for(let lt=0;lt=this.dim+1||m<-1||m>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(m+1)*this.stride+(d+1)}static pack(d,m){const b=[0,0,0,0],C=M7.getUnpackVector(m);let E=Math.floor((d+C[3])/C[2]);return b[2]=E%256,E=Math.floor(E/256),b[1]=E%256,E=Math.floor(E/256),b[0]=E,b}getPixels(){return new Y3e({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,m,b){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let C=m*this.dim,E=m*this.dim+this.dim,I=b*this.dim,R=b*this.dim+this.dim;switch(m){case-1:C=E-1;break;case 1:E=C+1}switch(b){case-1:I=R-1;break;case 1:R=I+1}const q=-m*this.dim,W=-b*this.dim;for(let te=I;te=1;b--){const C=b===1?1:0,E=b===2?1:0;for(let I=0;I>>1^-(1&x[d]);return x}function pmt(x,d){switch(d){case"uint32":return x;case"uint16":for(let m=0;m>4|(61440&b)>>8|(240&C)<<4|61440&C,x[m+1]=15&b|(3840&b)>>4|(15&C)<<8|(3840&C)<<4}return x;case"uint8":for(let m=0;m>6|(192&C)>>4|(192&E)>>2|192&I,x[m+1]=(48&b)>>4|(48&C)>>2|48&E|(48&I)<<2,x[m+2]=(12&b)>>2|12&C|(12&E)<<2|(12&I)<<4,x[m+3]=3&b|(3&C)<<2|(3&E)<<4|(3&I)<<6}return x;default:throw new Error(`Invalid pixel format, "${d}"`)}}kr(M7,"DEMData"),kr(tTe,"DemMinMaxQuadTree",{omit:["dem"]});var Hp=Uint8Array,DP=Uint16Array,fmt=Int32Array,rTe=new Hp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nTe=new Hp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xmt=new Hp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aTe=function(x,d){for(var m=new DP(31),b=0;b<31;++b)m[b]=d+=1<>1|(21845&pc)<<1;lTe[pc]=((65280&(f5=(61680&(f5=(52428&f5)>>2|(13107&f5)<<2))>>4|(3855&f5)<<4))>>8|(255&f5)<<8)>>1}var OP=function(x,d,m){for(var b=x.length,C=0,E=new DP(d);C>q]=W;return I},RP=new Hp(288);for(pc=0;pc<144;++pc)RP[pc]=8;for(pc=144;pc<256;++pc)RP[pc]=9;for(pc=256;pc<280;++pc)RP[pc]=7;for(pc=280;pc<288;++pc)RP[pc]=8;var cTe=new Hp(32);for(pc=0;pc<32;++pc)cTe[pc]=5;var vmt=OP(RP,9),bmt=OP(cTe,5),Mfe=function(x){for(var d=x[0],m=1;md&&(d=x[m]);return d},_g=function(x,d,m){var b=d/8|0;return(x[b]|x[b+1]<<8)>>(7&d)&m},Tfe=function(x,d){var m=d/8|0;return(x[m]|x[m+1]<<8|x[m+2]<<16)>>(7&d)},_mt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wg=function(x,d,m){var b=new Error(d||_mt[x]);if(b.code=x,Error.captureStackTrace&&Error.captureStackTrace(b,wg),!m)throw b;return b},wmt=new Hp(0),jmt=typeof TextDecoder<"u"&&new TextDecoder;try{jmt.decode(wmt,{stream:!0})}catch{}const Nmt={gzip_data:"gzip"};class Yf extends Error{constructor(d){super(d),this.name="MRTError"}}const kmt={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},dTe={uint32:1,uint16:2,uint8:4},Smt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Afe;class T7{constructor(d=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=d}getLayer(d){const m=this.layers[d];if(!m)throw new Yf(`Layer '${d}' not found`);return m}getHeaderLength(d){const m=new Uint8Array(d),b=new DataView(d);if(m[0]!==13)throw new Yf("File is not a valid MRT.");return b.getUint32(1,!0)}parseHeader(d){const m=new Uint8Array(d),b=this.getHeaderLength(d);if(m.length= ${b} but got buffer of length ${m.length}`);const C=new Afe(m.subarray(0,b)).readFields(nmt,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==C.x||this.y!==C.y||this.z!==C.z))throw new Yf(`Invalid attempt to parse header ${C.z}/${C.x}/${C.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=C.x,this.y=C.y,this.z=C.z;for(const E of C.layers)this.layers[E.name]=new uTe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const m=[],b=this.getLayer(d.layerName);for(let C of d.blockIndices){const E=b.dataIndex[C],I=E.firstByte-d.firstByte,R=E.lastByte-d.firstByte;if(b._blocksInProgress.has(C))continue;const q={layerName:b.name,firstByte:I,lastByte:R,pixelFormat:b.pixelFormat,blockIndex:C,blockShape:[E.bands.length].concat(b.bandShape),buffer:b.buffer,codec:E.codec.codec,filters:E.filters.map(W=>W.filter)};b._blocksInProgress.add(C),m.push(q)}return new hTe(m,()=>{m.forEach(C=>b._blocksInProgress.delete(C.blockIndex))},(C,E)=>{if(m.forEach(I=>b._blocksInProgress.delete(I.blockIndex)),C)throw C;E.forEach(I=>{this.getLayer(I.layerName).processDecodedData(I)})})}}class uTe{constructor({version:d,name:m,units:b,tileSize:C,pixelFormat:E,buffer:I,dataIndex:R},q){if(this.version=d,this.version!==1)throw new Yf(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=m,this.units=b,this.tileSize=C,this.buffer=I,this.pixelFormat=kmt[E],this.dataIndex=R,this.bandShape=[C+2*I,C+2*I,dTe[this.pixelFormat]],this._decodedBlocks=new C7(q?q.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return dTe[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:d})=>d).flat()}processDecodedData(d){const m=d.blockIndex.toString();this._decodedBlocks.get(m)||this._decodedBlocks.put(m,d.data)}getBlockForBand(d){let m=0;switch(typeof d){case"string":for(const[b,C]of this.dataIndex.entries()){for(const[E,I]of C.bands.entries())if(I===d)return{bandIndex:m+E,blockIndex:b,blockBandIndex:E};m+=C.bands.length}break;case"number":for(const[b,C]of this.dataIndex.entries()){if(d>=m&&dthis.cacheSize)throw new Yf(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:b,blockIndices:C}}hasBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0}hasDataForBand(d){const{blockIndex:m}=this.getBlockForBand(d);return m>=0&&!!this._decodedBlocks.get(m.toString())}getBandView(d){const{blockIndex:m,blockBandIndex:b}=this.getBlockForBand(d);if(m<0)throw new Yf(`Band not found: ${JSON.stringify(d)}`);const C=this._decodedBlocks.get(m.toString());if(!C)throw new Yf(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],I=this.bandShape.reduce((W,te)=>W*te,1),R=b*I,q=C.subarray(R,R+I);return{data:q,bytes:new Uint8Array(q.buffer).subarray(q.byteOffset,q.byteOffset+q.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}T7.setPbf=function(x){Afe=x};class hTe{constructor(d,m,b){this.tasks=d,this._onCancel=m,this._onComplete=b,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(d,m){this._finalized||(this._onComplete(d,m),this._finalized=!0)}}T7.performDecoding=function(x,d){const m=new Uint8Array(x);return Promise.all(d.tasks.map(b=>{const{layerName:C,firstByte:E,lastByte:I,pixelFormat:R,blockShape:q,blockIndex:W,filters:te,codec:se}=b,ie=m.subarray(E,I+1),de=new Uint32Array(q[0]*q[1]*q[2]);let he;if(se!=="gzip_data")throw new Yf(`Unhandled codec: ${se}`);return he=function(Ce,Fe){if(!globalThis.DecompressionStream&&Fe==="gzip_data")return Promise.resolve(((lt=function(At){At[0]==31&&At[1]==139&&At[2]==8||wg(6,"invalid gzip data");var zt=At[3],qt=10;4&zt&&(qt+=2+(At[10]|At[11]<<8));for(var ss=(zt>>3&1)+(zt>>4&1);ss>0;ss-=!At[qt++]);return qt+(2&zt)}(Xe=Ce))+8>Xe.length&&wg(6,"invalid gzip data"),function(At,zt,qt,ss){var Wt=At.length;if(!Wt||zt.f&&!zt.l)return qt||new Hp(0);var ds=!qt,ks=ds||zt.i!=2,Ss=zt.i;ds&&(qt=new Hp(3*Wt));var zs,$s,Ds=function(Pi){var ii=qt.length;if(Pi>ii){var mi=new Hp(Math.max(2*ii,Pi));mi.set(qt),qt=mi}},Rs=zt.f||0,ls=zt.p||0,rs=zt.b||0,Fs=zt.l,sr=zt.d,Hs=zt.m,zr=zt.n,fr=8*Wt;do{if(!Fs){Rs=_g(At,ls,1);var _r=_g(At,ls+1,3);if(ls+=3,!_r){var Ar=At[(us=4+((ls+7)/8|0))-4]|At[us-3]<<8,ta=us+Ar;if(ta>Wt){Ss&&wg(0);break}ks&&Ds(rs+Ar),qt.set(At.subarray(us,ta),rs),zt.b=rs+=Ar,zt.p=ls=8*ta,zt.f=Rs;continue}if(_r==1)Fs=vmt,sr=bmt,Hs=9,zr=5;else if(_r==2){var Zs=_g(At,ls,31)+257,Er=_g(At,ls+10,15)+4,_n=Zs+_g(At,ls+5,31)+1;ls+=14;for(var Na=new Hp(_n),Ta=new Hp(19),qn=0;qn>4)<16)Na[qn++]=us;else{var cr=0,dr=0;for(us==16?(dr=3+_g(At,ls,3),ls+=2,cr=Na[qn-1]):us==17?(dr=3+_g(At,ls,7),ls+=3):us==18&&(dr=11+_g(At,ls,127),ls+=7);dr--;)Na[qn++]=cr}}var Br=Na.subarray(0,Zs),Vr=Na.subarray(Zs);Hs=Mfe(Br),zr=Mfe(Vr),Fs=OP(Br,Hs),sr=OP(Vr,zr)}else wg(1);if(ls>fr){Ss&&wg(0);break}}ks&&Ds(rs+131072);for(var Ln=(1<>4;if((ls+=15&cr)>fr){Ss&&wg(0);break}if(cr||wg(2),ga<256)qt[rs++]=ga;else{if(ga==256){Xn=ls,Fs=null;break}var on=ga-254;ga>264&&(on=_g(At,ls,(1<<(Ja=rTe[qn=ga-257]))-1)+oTe[qn],ls+=Ja);var bn=sr[Tfe(At,ls)&Kn],Ga=bn>>4;if(bn||wg(3),ls+=15&bn,Vr=ymt[Ga],Ga>3){var Ja=nTe[Ga];Vr+=Tfe(At,ls)&(1<fr){Ss&&wg(0);break}ks&&Ds(rs+131072);var ei=rs+on;if(rszs.length)&&($s=zs.length),new Hp(zs.subarray(0,$s))):qt.subarray(0,rs)}(Xe.subarray(lt,-8),{i:2},new Hp(((Re=Xe)[(Ke=Re.length)-4]|Re[Ke-3]<<8|Re[Ke-2]<<16|Re[Ke-1]<<24)>>>0))));var Re,Ke,Xe,lt;const kt=Nmt[Fe];if(!kt)throw new Error(`Unhandled codec: ${Fe}`);const vt=new globalThis.DecompressionStream(kt);return new Response(new Blob([Ce]).stream().pipeThrough(vt)).arrayBuffer().then(At=>new Uint8Array(At))}(ie,se).then(Ce=>(function(Fe,Re){Fe.readFields(dmt,Re)}(new Afe(Ce),de),new Smt[R](de.buffer))),he.then(Ce=>{for(let Fe=te.length-1;Fe>=0;Fe--)switch(te[Fe]){case"delta_filter":hmt(Ce,q);break;case"zigzag_filter":mmt(Ce);break;case"bitshuffle_filter":pmt(Ce,R);break;default:throw new Yf(`Unhandled filter "${te[Fe]}"`)}return{layerName:C,blockIndex:W,data:Ce}}).catch(Ce=>{throw Ce})}))},kr(hTe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),kr(T7,"MapboxRasterTile"),kr(uTe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class mTe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ie[3]>=0&&W.insert(q,ie[0],ie[1],ie[2],ie[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new a7(this.rawTileData)).layers,this.sourceLayerCoder=new mTe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const d in this.vtLayers)this.vtFeatures[d]=[]}return this.vtLayers}query(d,m){const{tilespaceGeometry:b,transform:C,tileTransform:E,pixelPosMatrix:I,availableImages:R,worldview:q}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const W=m.queryRadius?m.queryRadius:0,te=b.bufferedTilespaceBounds,se=this.grid.query(te.min.x,te.min.y,te.max.x,te.max.y,(Ce,Fe,Re,Ke)=>qu(b.bufferedTilespaceGeometry,Ce-W,Fe-W,Re+W,Ke+W));se.sort(Cmt);let ie=null;C.elevation&&se.length>0&&(ie=h5.create(C.elevation,this.tileID));const de={};let he;for(let Ce=0;Ce(Ke||(Ke=Ot(Xe,this.tileID.canonical,E)),lt.queryIntersectsFeature(b,Xe,kt,Ke,this.z,C,I,ie,vt)))}return de}loadMatchingFeature(d,m,b,C,E,I){const{featureIndex:R,bucketIndex:q,sourceLayerIndex:W,layoutVertexArrayOffset:te}=m,se=this.bucketLayerIDs[q],ie=b.layers,de=Object.keys(ie);if(de.length&&!vr(de,se))return;const he=b.sourceCache,Ce=this.sourceLayerCoder.decode(W),Fe=this.vtLayers[Ce].feature(R),Re=this.getId(Fe,Ce);for(let Ke=0;Ke`${R.key}: ${R.message}`).join(", ");return void xr(`Failed to create expression for promoteId: ${I}`)}this.promoteIdExpression=E.value}b=this.promoteIdExpression.evaluate({zoom:0},d)}else b=d.properties[C];typeof b=="boolean"&&(b=Number(b))}return b}}function fTe(x,d,m,b,C){return Qt(x,(E,I)=>{const R=d instanceof mv?d.get(I):null;return R&&R.evaluate?R.evaluate(m,b,void 0,C):R})}function Cmt(x,d){return d-x}kr(pTe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const xTe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Efe{static from(d){if(!(d instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,b]=new Uint8Array(d,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const C=b>>4;if(C!==1)throw new Error(`Got v${C} data when expected v1.`);const E=xTe[15&b];if(!E)throw new Error("Unrecognized array type.");const[I]=new Uint16Array(d,2,1),[R]=new Uint32Array(d,4,1);return new Efe(R,I,E,d)}constructor(d,m=64,b=Float64Array,C){if(isNaN(d)||d<0)throw new Error(`Unpexpected numItems value: ${d}.`);this.numItems=+d,this.nodeSize=Math.min(Math.max(+m,2),65535),this.ArrayType=b,this.IndexArrayType=d<65536?Uint16Array:Uint32Array;const E=xTe.indexOf(this.ArrayType),I=2*d*this.ArrayType.BYTES_PER_ELEMENT,R=d*this.IndexArrayType.BYTES_PER_ELEMENT,q=(8-R%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${b}.`);C&&C instanceof ArrayBuffer?(this.data=C,this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+q,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+I+R+q),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+R+q,2*d),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+E]),new Uint16Array(this.data,2,1)[0]=m,new Uint32Array(this.data,4,1)[0]=d)}add(d,m){const b=this._pos>>1;return this.ids[b]=b,this.coords[this._pos++]=d,this.coords[this._pos++]=m,b}finish(){const d=this._pos>>1;if(d!==this.numItems)throw new Error(`Added ${d} items when expected ${this.numItems}.`);return Pfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,m,b,C){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:I,nodeSize:R}=this,q=[0,E.length-1,0],W=[];for(;q.length;){const te=q.pop()||0,se=q.pop()||0,ie=q.pop()||0;if(se-ie<=R){for(let Fe=ie;Fe<=se;Fe++){const Re=I[2*Fe],Ke=I[2*Fe+1];Re>=d&&Re<=b&&Ke>=m&&Ke<=C&&W.push(E[Fe])}continue}const de=ie+se>>1,he=I[2*de],Ce=I[2*de+1];he>=d&&he<=b&&Ce>=m&&Ce<=C&&W.push(E[de]),(te===0?d<=he:m<=Ce)&&(q.push(ie),q.push(de-1),q.push(1-te)),(te===0?b>=he:C>=Ce)&&(q.push(de+1),q.push(se),q.push(1-te))}return W}within(d,m,b){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:C,coords:E,nodeSize:I}=this,R=[0,C.length-1,0],q=[],W=b*b;for(;R.length;){const te=R.pop()||0,se=R.pop()||0,ie=R.pop()||0;if(se-ie<=I){for(let Fe=ie;Fe<=se;Fe++)yTe(E[2*Fe],E[2*Fe+1],d,m)<=W&&q.push(C[Fe]);continue}const de=ie+se>>1,he=E[2*de],Ce=E[2*de+1];yTe(he,Ce,d,m)<=W&&q.push(C[de]),(te===0?d-b<=he:m-b<=Ce)&&(R.push(ie),R.push(de-1),R.push(1-te)),(te===0?d+b>=he:m+b>=Ce)&&(R.push(de+1),R.push(se),R.push(1-te))}return q}}function Pfe(x,d,m,b,C,E){if(C-b<=m)return;const I=b+C>>1;gTe(x,d,I,b,C,E),Pfe(x,d,m,b,I-1,1-E),Pfe(x,d,m,I+1,C,1-E)}function gTe(x,d,m,b,C,E){for(;C>b;){if(C-b>600){const W=C-b+1,te=m-b+1,se=Math.log(W),ie=.5*Math.exp(2*se/3),de=.5*Math.sqrt(se*ie*(W-ie)/W)*(te-W/2<0?-1:1);gTe(x,d,m,Math.max(b,Math.floor(m-te*ie/W+de)),Math.min(C,Math.floor(m+(W-te)*ie/W+de)),E)}const I=d[2*m+E];let R=b,q=C;for(FP(x,d,b,m),d[2*C+E]>I&&FP(x,d,b,C);RI;)q--}d[2*b+E]===I?FP(x,d,b,q):(q++,FP(x,d,q,C)),q<=m&&(b=q+1),m<=q&&(C=q-1)}}function FP(x,d,m,b){Ife(x,m,b),Ife(d,2*m,2*b),Ife(d,2*m+1,2*b+1)}function Ife(x,d,m){const b=x[d];x[d]=x[m],x[m]=b}function yTe(x,d,m,b){const C=x-m,E=d-b;return C*C+E*E}i.$=G3,i.A=sg,i.B=$p,i.C=2,i.D=JC,i.E=Es,i.F=vP,i.G=V5e,i.H=H3,i.I=Xs,i.J=_F,i.K=Fr,i.L=nb,i.M=xC,i.N=f2,i.O=lF,i.P=ft,i.Q=x2,i.R=Jx,i.S=SC,i.T=$pe,i.U=Py,i.V=_7,i.W=S6,i.X=cb,i.Y=lb,i.Z=c2,i._=zu,i.a=function(x){return ha.API_CDN_URL_REGEX.test(x)},i.a$=je,i.a0=vn,i.a1=ua,i.a2=Hf,i.a3=class extends _7{},i.a4=gC,i.a5=oF,i.a6=Kt,i.a7=function(x){const d=x.value;return d?vn(d)?yfe(d,!0)?[]:[new _7(x.key,d,`invalid url "${d}"`)]:[new _7(x.key,d,`string expected, "${Fr(d)}" found`)]:[]},i.a8=gF,i.a9=Io,i.aA=Se,i.aB=S,i.aC=Je,i.aD=Ud,i.aE=Di,i.aF=G,i.aG=ot,i.aH=function(x,d){const m={};for(let b=0;b{b(E,I)},d):b(E,I),()=>{}}return C.callbacks.push(b),C.cancel||(C.cancel=m((E,I)=>{C.result=[E,I];for(const R of C.callbacks)this.scheduler?this.scheduler.add(()=>{R(E,I)},d):R(E,I);setTimeout(()=>delete this.entries[x],3e3)})),()=>{C.result||(C.callbacks=C.callbacks.filter(E=>E!==b),C.callbacks.length||(C.cancel(),delete this.entries[x]))}}},i.aL=function(x,d,m){const b=JSON.stringify(x.request);return x.data&&(this.deduped.entries[b]={result:[null,x.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:x.isSymbolTile,zoom:x.tileZoom},C=>{const E=Oh(x.request,(I,R,q)=>{I?C(I):R&&C(null,{rawData:R,vectorTile:m?void 0:new Yt(new a7(R)),responseHeaders:new Map(q.entries())})});return()=>{E.cancel(),C()}},d)},i.aM=function(x){return x?{cacheControl:x.get("Cache-Control"),expires:x.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=Pl,i.aO=function(x){Cd++,Cd>J1&&(x.getActor().send("enforceCacheSizeLimit",X1),Cd=0)},i.aP=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.aQ=Mo,i.aR=vMe,i.aS=kMe,i.aT=y,i.aU=yMe,i.aV=function(x,d){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){d(null,m)};for(let b=0;b{}}},i.aW=pP,i.aX=B2,i.aY=Ut,i.aZ=jP,i.a_=le,i.aa=Qs,i.ab=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return Pn(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m),azimuthal:Zr(x.azimuthal,d.azimuthal,m),polar:Zr(x.polar,d.polar,m)}}},i.ac=Zi,i.ad=dv,i.ae=nt,i.af=pt,i.ag=ce,i.ah=Be,i.ai=mv,i.aj=Mb,i.ak=Zr,i.al=tr,i.am=rv,i.an=jr,i.ao=Ur,i.ap=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return function([m,b]){const C=Pn([1,m,b]);return{x:C.x,y:C.y,z:C.z}}(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Zr(x.x,d.x,m),y:Zr(x.y,d.y,m),z:Zr(x.z,d.z,m)}}},i.aq=function(x,d,m=0,b=!0){const C=new ft(m,m),E=x.sub(C),I=d.add(C),R=[E,new ft(I.x,E.y),I,new ft(E.x,I.y)];return b&&R.push(E.clone()),R},i.ar=function(x,d){const m=[];for(let b=0;b1)return!1;const m=d.getSource().maxzoom,b=1<1)return d;const C=b.getSource().maxzoom,E=1<{const R=this.getAtTileOffset(x,C,E,I),q=b.upVector(x.canonical,C.x,C.y);return _e(q,q,R*b.upVectorScale(x.canonical,d,m).metersToTile),q}}getForTilePoints(x,d,m,b){if(this.isUsingMockSource())return!1;const C=h5.create(this,x,b);return!!C&&(d.forEach(E=>{E[2]=this.exaggeration()*C.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(x){if(this.isUsingMockSource())return null;const d=this.findDEMTileFor(x);if(!d||!d.dem)return null;const m=d.dem.tree,b=d.tileID,C=1<0&&(b+=(x[C]-0)*(x[C]-0)),d[C]<0&&(b+=(0-d[C])*(0-d[C]));return b},i.c0=vCe,i.c1=sfe,i.c2=Q5e,i.c3=dfe,i.c4=Efe,i.c5=_e,i.c6=He,i.c7=et,i.c8=function(x,d,m){m*=.5;var b=d[0],C=d[1],E=d[2],I=d[3],R=Math.sin(m),q=Math.cos(m);return x[0]=b*q+C*R,x[1]=C*q-b*R,x[2]=E*q+I*R,x[3]=I*q-E*R,x},i.c9=it,i.cA=ee,i.cB=ai,i.cC=r5e,i.cD=Oi,i.cE=L3e,i.cF=function(x,d,m,b,C,E,I,R,q){if(q.name==="globe")return L3e(x,d,new Oi(m,b,C),!1);const W=jP({z:m,x:b,y:C},q);return new Rr([(E+W.x/W.scale)*d,d*(W.y/W.scale),I],[(E+W.x2/W.scale)*d,d*(W.y2/W.scale),R])},i.cG=function(x,d,m){return x[0]=Math.min(d[0],m[0]),x[1]=Math.min(d[1],m[1]),x[2]=Math.min(d[2],m[2]),x[3]=Math.min(d[3],m[3]),x},i.cH=function(x,d,m){return x[0]=Math.max(d[0],m[0]),x[1]=Math.max(d[1],m[1]),x[2]=Math.max(d[2],m[2]),x[3]=Math.max(d[3],m[3]),x},i.cI=function(x){const d=Math.round((x+45+360)%360/90)%4;return La[d]},i.cJ=Ne,i.cK=Ue,i.cL=YC,i.cM=function(x){const d=j(new Float64Array(16));S(d,x.pixelMatrix,x.globeMatrix);const m=[0,rp,0],b=[0,np,0];return pt(m,m,d),pt(b,b,d),[m[0]>0&&m[0]<=x.width&&m[1]>0&&m[1]<=x.height&&!ype(x,new y(x.center.lat,90)),b[0]>0&&b[0]<=x.width&&b[1]>0&&b[1]<=x.height&&!ype(x,new y(x.center.lat,-90))]},i.cN=function(x,d){const{scale:m}=x.tileTransform,b=m*tr/(x.tileSize*Math.pow(2,d.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(C,E,I){var R=E[1],q=E[2],W=E[3],te=I[0],se=I[1];return C[0]=E[0]*te,C[1]=R*te,C[2]=q*se,C[3]=W*se,C}(new Float32Array(4),d.inverseAdjustmentMatrix,[b,b])},i.cO=JF,i.cP=Y,i.cQ=s5e,i.cR=function(x){const d=s5e(x,!0);return p([],[d[0],d[1],d[4],d[5]])},i.cS=L,i.cT=pr,i.cU=P,i.cV=function(x){const{x:d,y:m}=x.point,{lng:b,lat:C}=x._center;return R3e(d,m,x.worldSize,b,C)},i.cW=ge,i.cX=ea,i.cY=No,i.cZ=Td,i.c_=sp,i.ca=ni,i.cb=function(x,d){return x[0]=-d[0],x[1]=-d[1],x[2]=-d[2],x[3]=d[3],x},i.cc=X,i.cd=function(x,d,m,b,C){var E=1/Math.tan(d/2);if(x[0]=E/m,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=E,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[11]=-1,x[12]=0,x[13]=0,x[15]=0,C!=null&&C!==1/0){var I=1/(b-C);x[10]=(C+b)*I,x[14]=2*C*b*I}else x[10]=-1,x[14]=-2*b;return x},i.ce=function(x,d,m,b,C,E,I){var R=1/(d-m),q=1/(b-C),W=1/(E-I);return x[0]=-2*R,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=-2*q,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=2*W,x[11]=0,x[12]=(d+m)*R,x[13]=(C+b)*q,x[14]=(I+E)*W,x[15]=1,x},i.cf=ae,i.cg=function(x,d,m){x[4*d+0]=m[0],x[4*d+1]=m[1],x[4*d+2]=m[2],x[4*d+3]=m[3]},i.ch=GC,i.ci=k2,i.cj=Hl,i.ck=Kf,i.cl=C2,i.cm=lMe,i.cn=function(){var x=new u(4);return u!=Float32Array&&(x[1]=0,x[2]=0),x[0]=1,x[3]=1,x},i.co=function(x,d,m){var b=d[0],C=d[1],E=d[2],I=d[3],R=Math.sin(m),q=Math.cos(m);return x[0]=b*q+E*R,x[1]=C*q+I*R,x[2]=b*-R+E*q,x[3]=C*-R+I*q,x},i.cp=function(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]&&x[3]===d[3]},i.cq=tt,i.cr=function(x){var d=x[0],m=x[1],b=x[2],C=x[3];return Math.sqrt(d*d+m*m+b*b+C*C)},i.cs=Ms,i.ct=qe,i.cu=fl,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Te,i.d=function(x){return ha.API_TILEJSON_REGEX.test(x)},i.d$=class{constructor(x,d,m,b){this.context=x,this.format=b,this.size=m,this.texture=x.gl.createTexture();const[C,E,I]=this.size,{gl:R}=x;R.bindTexture(R.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in d&&d.data&&R.texImage3D(R.TEXTURE_3D,0,this.format,C,E,I,0,zpe(this.format),Bpe(this.format),d.data)}bind(x,d){const{context:m}=this,{gl:b}=m;b.bindTexture(b.TEXTURE_3D,this.texture),x!==this.minFilter&&(b.texParameteri(b.TEXTURE_3D,b.TEXTURE_MAG_FILTER,x),b.texParameteri(b.TEXTURE_3D,b.TEXTURE_MIN_FILTER,x),this.minFilter=x),d!==this.wrapS&&(b.texParameteri(b.TEXTURE_3D,b.TEXTURE_WRAP_S,d),b.texParameteri(b.TEXTURE_3D,b.TEXTURE_WRAP_T,d),this.wrapS=d)}destroy(){const{gl:x}=this.context;x.deleteTexture(this.texture),this.texture=null}},i.d0=function(x){return x*x*x*x*x},i.d1=z,i.d2=45,i.d3=WC,i.d4=function(x,d,m){const b=Math.sqrt(x*x+d*d+m*m),C=b>0?Math.acos(m/b)*Sr:0;let E=x!==0||d!==0?Math.atan2(-d,-x)*Sr+90:0;return E<0&&(E+=360),[b,E,C]},i.d5=ne,i.d6=Pn,i.d7=Ve,i.d8=oe,i.d9=Rr,i.dA=function(x){return x({pluginStatus:Bu,pluginURL:lg}),NC.on("pluginStateChange",x),x},i.dB=S2,i.dC=class extends ug{constructor(x){super(x),this.current=KC}set(x,d,m){if(this.fetchUniformLocation(x,d)){for(let b=0;b<9;b++)if(m[b]!==this.current[b]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Ii,i.dE=function(x,d,m){const b=Mb(m.zoom),C=x.style.map._antialias,E=x.terrain&&x.terrain.exaggeration()>0;return b===0&&!C&&!E},i.dF=function(x){const d=x.pixelsPerMeter,m=d/ae(1,x.center.lat),b=j(new Float64Array(16));return M(b,b,[x.point.x,x.point.y,0]),L(b,b,[m,m,d]),Float32Array.from(b)},i.dG=RF,i.dH=function(x){const d=Ne-5;x=Se(x,-d,d)/d*90;const m=Math.pow(Math.abs(Math.sin(jr(x))),3);return Math.round(m*(Q6.length-1))},i.dI=function(x,d,m,b){const C=d.getNorth(),E=d.getSouth(),I=d.getWest(),R=d.getEast(),q=1<0){const he=180/b;v(de,de,[he/W+1,0,0,0,he/te+1,0,-.5*he/se,.5*he/ie,1])}return de[2]=q,de[5]=x.x,de[8]=x.y,de},i.dJ=Vp,i.dK=function(x,d,m){const b=j(new Float64Array(16)),C=(d/(1<({u_matrix:new C2(x),u_texsize:new Kf(x),u_pixels_to_tile_units:new ZC(x),u_device_pixel_ratio:new Hl(x),u_width_scale:new Hl(x),u_floor_width_scale:new Hl(x),u_image:new GC(x),u_units_to_pixels:new Kf(x),u_tile_units_to_pixels:new Hl(x),u_alpha_discard_threshold:new Hl(x),u_trim_offset:new Kf(x),u_trim_fade_range:new Kf(x),u_trim_color:new WC(x),u_zbias_factor:new Hl(x),u_tile_to_meter:new Hl(x),u_ground_shadow_factor:new k2(x),u_pattern_transition:new Hl(x)}),i.dX=x=>({u_matrix:new C2(x),u_pixels_to_tile_units:new ZC(x),u_device_pixel_ratio:new Hl(x),u_width_scale:new Hl(x),u_floor_width_scale:new Hl(x),u_units_to_pixels:new Kf(x),u_dash_image:new GC(x),u_gradient_image:new GC(x),u_image_height:new Hl(x),u_texsize:new Kf(x),u_tile_units_to_pixels:new Hl(x),u_alpha_discard_threshold:new Hl(x),u_trim_offset:new Kf(x),u_trim_fade_range:new Kf(x),u_trim_color:new WC(x),u_zbias_factor:new Hl(x),u_tile_to_meter:new Hl(x),u_ground_shadow_factor:new k2(x)}),i.dY=x=>({u_camera_to_center_distance:new Hl(x),u_extrude_scale:new ZC(x),u_device_pixel_ratio:new Hl(x),u_matrix:new C2(x),u_inv_rot_matrix:new C2(x),u_merc_center:new Kf(x),u_tile_id:new k2(x),u_zoom_transition:new Hl(x),u_up_dir:new k2(x),u_emissive_strength:new Hl(x)}),i.dZ=RC,i.d_=Fut,i.da=fe,i.db=function(x){return[Math.pow(x[0],1/2.2),Math.pow(x[1],1/2.2),Math.pow(x[2],1/2.2)]},i.dc=t5e,i.dd=Wpe,i.de=i5e,i.df=yfe,i.dg=function(x,d){return x.readFields(Rht,{icons:[]},d)},i.dh=ZF,i.di=l5,i.dj=ofe,i.dk=eb,i.dl=v2,i.dm=by,i.dn=tb,i.dp=ys,i.dq=function(x){const d=x.indexOf(xv);return d>=0?x.slice(0,d):x},i.dr=function(x){return x.indexOf(xv)>=0},i.ds=function(x){const d=x.lastIndexOf(xv);return d>=0?x.slice(d+1):""},i.dt=function(x){const d=[],m=x.id;return m===void 0&&d.push({message:`layers.${m}: missing required property "id"`}),x.render===void 0&&d.push({message:`layers.${m}: missing required method "render"`}),x.renderingMode&&x.renderingMode!=="2d"&&x.renderingMode!=="3d"&&d.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),d},i.du=function(x,d,m,b){return x.type==="custom"?new Aht(x,d):new Dht[x.type](x,d,m,b)},i.dv=Is,i.dw=function(x){const d=x.indexOf(xv);return d>=0?x.slice(d+1):""},i.dx=class extends z2{constructor(x,d){super(x._vectorTileFeature,x._z,x._x,x._y,x.id),x.state&&(this.state=Object.assign({},x.state)),this.target=d.target,this.namespace=d.namespace,d.properties&&(this.properties=d.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=x.source,this.sourceLayer=x.sourceLayer,this.layer=x.layer)}toJSON(){const x=super.toJSON();return x.target=this.target,x.namespace=this.namespace,x}},i.dy=NC,i.dz=eg,i.e=ha,i.e$=re,i.e0=B3e,i.e1=(x,d,m,b,C,E)=>{const I=x.transform,R=I.projection.name==="globe";let q;if(E.paint.get("circle-pitch-alignment")==="map")if(R){const te=O3e(I.zoom,d.canonical)*I._pixelsPerMercatorPixel;q=Float32Array.from([te,0,0,te])}else q=I.calculatePixelsToTileUnitsMatrix(m);else q=new Float32Array([I.pixelsToGLUnits[0],0,0,I.pixelsToGLUnits[1]]);const W={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(I.projection),u_matrix:x.translatePosMatrix(d.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Ul.devicePixelRatio,u_extrude_scale:q,u_inv_rot_matrix:edt,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:E.paint.get("circle-emissive-strength")};if(R){W.u_inv_rot_matrix=b,W.u_merc_center=C,W.u_tile_id=[d.canonical.x,d.canonical.y,1<{const te=x.transform,se=te.pitch<15?v5e(.07,.7,Se((14-te.zoom)/5,0,1)):.07,ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:_5e(x,d,m,b),u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:te.calculatePixelsToTileUnitsMatrix(d),u_device_pixel_ratio:C,u_width_scale:E,u_floor_width_scale:I,u_image:0,u_tile_units_to_pixels:b5e(d,te),u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:R,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:se,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:q,u_pattern_transition:W}},i.e5=(x,d,m,b,C,E,I,R,q,W)=>{const te=x.transform,se=te.calculatePixelsToTileUnitsMatrix(d),ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",de=te.pitch<15?v5e(.07,.7,Se((14-te.zoom)/5,0,1)):.07;return{u_matrix:_5e(x,d,m,b),u_pixels_to_tile_units:se,u_device_pixel_ratio:E,u_width_scale:I,u_floor_width_scale:R,u_units_to_pixels:[1/te.pixelsToGLUnits[0],1/te.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:C,u_texsize:j5e(m)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:b5e(d,x.transform),u_alpha_discard_threshold:0,u_trim_offset:q,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:de,u_tile_to_meter:Ve(d.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Zt,i.e7=J6,i.e8=ve,i.e9=ip,i.eA=function(x,d){var m=2*Math.acos(d[3]),b=Math.sin(m/2);return b>c?(x[0]=d[0]/b,x[1]=d[1]/b,x[2]=d[2]/b):(x[0]=1,x[1]=0,x[2]=0),m},i.eB=_fe,i.eC=s7,i.eD=t7,i.eE=[1,1,1],i.eF=h5,i.eG=ct,i.eH=function(x,d,m,b){var C=d[0],E=d[1],I=d[2],R=d[3];return x[0]=C+b*(m[0]-C),x[1]=E+b*(m[1]-E),x[2]=I+b*(m[2]-I),x[3]=R+b*(m[3]-R),x},i.eI=r5,i.eJ=hm,i.eK=Wf,i.eL=function(x,d,m,b,C,E,I,R,q,W,te,se,ie,de,he,Ce){var Fe=new u(16);return Fe[0]=x,Fe[1]=d,Fe[2]=m,Fe[3]=b,Fe[4]=C,Fe[5]=E,Fe[6]=I,Fe[7]=R,Fe[8]=q,Fe[9]=W,Fe[10]=te,Fe[11]=se,Fe[12]=ie,Fe[13]=de,Fe[14]=he,Fe[15]=Ce,Fe},i.eM=T,i.eN=wb,i.eO=$6,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new ft(1/0,1/0),max:new ft(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(x,d=!1){const m=xCe(new ft(0,0),new ft(tr,tr),x),b=[];if(d&&!Cpe(m,this._globalClipBounds))return b;for(const C of this._activeRegions){if(C.hiddenByOverlap||!Cpe(m,C))continue;const E=Tdt(C.min,C.max,x);b.push({min:E.min,max:E.max,sourceId:this._sourceIds[C.priority],footprint:C.footprint,footprintTileId:C.tileId,order:C.order,clipMask:C.clipMask,clipScope:C.clipScope})}return b}setSources(x){this._setSources(x.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const m=[];for(const b of d.cache.getVisibleCoordinates()){const C=d.cache.getTile(b).buckets[d.layer];C&&C.updateFootprints(b.toUnwrapped(),m)}return m},getOrder:()=>d.order,getClipMask:()=>d.clipMask,getClipScope:()=>d.clipScope})))}_addSource(x){const d=x.getFootprints();if(d.length===0)return;const m=x.getOrder(),b=x.getClipMask(),C=x.getClipScope();for(const E of d){if(!E.footprint)continue;const I=xCe(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:I.min,max:I.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:m,clipMask:b,clipScope:C})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,m)=>d.priority-m.priority||VF(d.min,m.min)||VF(d.max,m.max)||d.order-m.order||d.clipMask-m.clipMask||function(b,C){const E=(I,R)=>I+R;return b.length-C.length||b.reduce(E,"").localeCompare(C.reduce(E,""))}(d.clipScope,m.clipScope));let x=this._activeRegions.length!==this._prevRegions.length;if(!x){let d=0;for(;!x&&d!==this._activeRegions.length;){const m=this._activeRegions[d],b=this._prevRegions[d];x=m.priority!==b.priority||!fCe(m,b)||m.order!==b.order||m.clipMask!==b.clipMask||!or(m.clipScope,b.clipScope),this._activeRegions[d].hiddenByOverlap=b.hiddenByOverlap,++d}}if(x){++this._updateTime;for(const m of this._activeRegions)m.order!==aP&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,m.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,m.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,m.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,m.max.y));const d=m=>{const b=this._activeRegions;if(m>=b.length)return m;const C=b[m].priority;for(;m1){let m=0,b=d(m);for(;m!==b;){let C=m;const E=m;for(;C!==b;){const I=this._activeRegions[C];I.hiddenByOverlap=!1;for(let R=0;R=0;d--)this._addSource(x[d]);this._computeReplacement()}},i.eQ=aP,i.eR=class{constructor(x){this._createGrid(x),this._createPoles(x)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const x of this._poleSegments)x.destroy();for(const x of this._gridSegments)x.withSkirts.destroy(),x.withoutSkirts.destroy()}_fillGridMeshWithLods(x,d){const m=new Ly,b=new Vl,C=[],E=x+1+2,I=d[0]+1,R=d[0]+1+(1+d.length),q=(W,te,se)=>{let ie=W===E-1?W-2:W===0?W:W-1;return ie+=se?24575:0,[ie,te]};for(let W=0;W0?(Fe=2*Math.sqrt(Ce+1),x[3]=.25*Fe,x[0]=(se-de)/Fe,x[1]=(ie-q)/Fe,x[2]=(R-W)/Fe):I>te&&I>he?(Fe=2*Math.sqrt(1+I-te-he),x[3]=(se-de)/Fe,x[0]=.25*Fe,x[1]=(R+W)/Fe,x[2]=(ie+q)/Fe):te>he?(Fe=2*Math.sqrt(1+te-I-he),x[3]=(ie-q)/Fe,x[0]=(R+W)/Fe,x[1]=.25*Fe,x[2]=(se+de)/Fe):(Fe=2*Math.sqrt(1+he-I-te),x[3]=(R-W)/Fe,x[0]=(ie+q)/Fe,x[1]=(se+de)/Fe,x[2]=.25*Fe),x},i.f=function(x){return btoa(encodeURIComponent(x).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([x,d,m]){const b=Math.hypot(x,d,m),C=Math.atan2(x,m),E=.5*Math.PI-Math.acos(-d/b);return new y(ea(C),ea(E))},i.f1=Ze,i.f2=qpe,i.f3=function(x){const d=x.navigator?x.navigator.userAgent:null;return!!function(m){if(cl==null){const b=m.navigator?m.navigator.userAgent:null;cl=!!m.safari||!(!b||!(/\b(iPad|iPhone|iPod)\b/.test(b)||b.match("Safari")&&!b.match("Chrome")))}return cl}(x)&&!(!d||!(d.match("Version/15.4")||d.match("Version/15.5")||d.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(x,d){X1=x,J1=d},i.f5=ype,i.f6=F3e,i.f7=function(x){const d=[0,0,0],m=j(new Float64Array(16));return S(m,x.pixelMatrix,x.globeMatrix),pt(d,d,m),new ft(d[0],d[1])},i.f8=function(){const x=uP;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(Ipe),uP=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},i.f9=function(){ZF().acquire(Ipe)},i.fA=M7,i.fB=Ht,i.fC=function(x){let d=0;if(new Uint32Array(x,0,1)[0]!==YCe){const m=new Uint32Array(x,0,7),[,,b,C,E,I]=m;d=m.byteLength+C+E+I+E,(b!==x.byteLength||d>=x.byteLength)&&xr("Invalid b3dm header information.")}return e5e(x,d)},i.fD=function(x,d){const m=Wpe(x);for(const b of m){for(const C of b.meshes)iut(C);b.lights&&(b.lightMeshIndex=b.meshes.length,b.meshes.push(out(b.lights,d)))}return m},i.fE=w7,i.fF=wa,i.fG=HCe,i.fH=cg,i.fI=Rh,i.fJ=function(x){$d(),im!=null&&im.then(d=>{d.keys().then(m=>{for(let b=0;bxr(C.message))}).catch(m=>xr(m.message))}).catch(d=>xr(d.message))},i.fa=b2,i.fb=function(x,d,m=!1){if(Bu===Rh.deferred||Bu===Rh.loading||Bu===Rh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");lg=Ul.resolveURL(x),Bu=Rh.deferred,A6=d,jC(),m||xF()},i.fc=function(x){e5=Ul.resolveURL(x),t5||(t5=new JC(ZF(),new Es)),t5.broadcast("setMeshoptUrl",e5)},i.fd=KCe,i.fe=function(x){Ope=Ul.resolveURL(x),t5||(t5=new JC(ZF(),new Es)),t5.broadcast("setDracoUrl",Ope)},i.ff=WCe,i.fg=dP,i.fh=function(x){const d=om();if(!d)return;const m=d.delete(Q1);x&&m.then(()=>x()).catch(x)},i.fi=L2,i.fj=kr,i.fk=Tb,i.fl=bg,i.fm=mTe,i.fn=pTe,i.fo=f5e,i.fp=as,i.fq="hd_road_elevation",i.fr=ui,i.fs=Qt,i.ft=bv,i.fu=ife,i.fv=R2,i.fw=function(x,d,m,b,C,E,I,R=1,q,W,te){x.createArrays(),x.tilePixelRatio=tr/(512*x.overscaling),x.compareText={},x.iconsNeedLinear=!1;const se=x.layers[0].layout,ie=x.layers[0]._unevaluatedLayout._values,de={};de.scaleFactor=R,de.textSizeScaleRange=se.get("text-size-scale-range"),de.iconSizeScaleRange=se.get("icon-size-scale-range");const[he,Ce]=de.textSizeScaleRange,[Fe,Re]=de.iconSizeScaleRange;de.textScaleFactor=Se(de.scaleFactor,he,Ce),de.iconScaleFactor=Se(de.scaleFactor,Fe,Re);const Ke=ie["text-size"],Xe=ie["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.textSizeData;de.compositeTextSizes=[Ke.possiblyEvaluate(new Zi(qt,{worldview:te}),E),Ke.possiblyEvaluate(new Zi(ss,{worldview:te}),E)]}if(x.iconSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ss}=x.iconSizeData;de.compositeIconSizes=[Xe.possiblyEvaluate(new Zi(qt,{worldview:te}),E),Xe.possiblyEvaluate(new Zi(ss,{worldview:te}),E)]}de.layoutTextSize=Ke.possiblyEvaluate(new Zi(I+1,{worldview:te}),E),de.layoutIconSize=Xe.possiblyEvaluate(new Zi(I+1,{worldview:te}),E),de.textMaxSize=Ke.possiblyEvaluate(new Zi(18,{worldview:te}),E);const lt=se.get("symbol-placement"),kt=se.get("text-rotation-alignment")==="map"&<!=="point",vt=se.get("text-size");let At=!1;const zt=[];for(const qt of x.features){const ss=se.get("text-font").evaluate(qt,{},E).join(","),Wt=vt.evaluate(qt,{},E)*de.textScaleFactor,ds=de.layoutTextSize.evaluate(qt,{},E)*de.textScaleFactor,ks=de.layoutIconSize.evaluate(qt,{},E)*de.iconScaleFactor,Ss={horizontal:{},vertical:void 0},zs=qt.text;let $s,Ds=[0,0];if(zs){const qn=zs.toString(),Ei=se.get("text-letter-spacing").evaluate(qt,{},E)*Ec,_t=se.get("text-line-height").evaluate(qt,{},E)*Ec,Ct=M6(qn)?Ei:0,us=se.get("text-anchor").evaluate(qt,{},E),Bs=se.get("text-variable-anchor");if(!Bs){const Ln=se.get("text-radial-offset").evaluate(qt,{},E);if(Ln)Ds=Q5e(us,[Ln*Ec,cfe]);else{const Kn=se.get("text-offset").evaluate(qt,{},E);Ds=[Kn[0]*Ec,Kn[1]*Ec]}}let cr=kt?"center":se.get("text-justify").evaluate(qt,{},E);const dr=lt==="point",Br=dr?se.get("text-max-width").evaluate(qt,{},E)*Ec:1/0,Vr=Ln=>{x.allowVerticalPlacement&&y2(qn)&&(Ss.vertical=tfe(zs,d,m,C,ss,Br,_t,us,Ln,Ct,Ds,fm.vertical,!0,ds,Wt,q))};if(!kt&&Bs){const Ln=cr==="auto"?Bs.map(Xn=>dfe(Xn)):[cr];let Kn=!1;for(let Xn=0;Xn=0||!y2(qn)){const Ln=tfe(zs,d,m,C,ss,Br,_t,us,cr,Ct,Ds,fm.horizontal,!1,ds,Wt,q);Ln&&(Ss.horizontal[cr]=Ln)}Vr(dr?"left":cr)}}let Rs,ls,rs,Fs,sr,Hs,zr=!1;const fr=se.get("icon-text-fit").evaluate(qt,{},E);if(qt.icon&&qt.icon.hasPrimary()){const qn=_P(qt.icon,x.iconSizeData,ie["icon-size"],E,x.zoom,qt,q,de.iconScaleFactor,te);Rs=qn.iconPrimary,rs=qn.iconSecondary;const Ei=Rs.toString();if(ls=b.get(Ei),ls&&(sr=se.get("icon-offset").evaluate(qt,{},E),Hs=se.get("icon-anchor").evaluate(qt,{},E),$s=o7(C.get(Ei),rs?C.get(rs.toString()):void 0,sr,Hs),zr=ls.sdf,x.sdfIcons===void 0?x.sdfIcons=ls.sdf:x.sdfIcons!==ls.sdf&&xr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ls.pixelRatio!==x.pixelRatio||se.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),rs){const _t=rs.toString();Fs=b.get(_t)}}At=At||!(!qt.icon||!qt.icon.hasSecondary());const _r=h7(Ss.horizontal)||Ss.vertical;x.iconsInText||(x.iconsInText=!!_r&&_r.iconsInText);const Ar=ds*de.textScaleFactor/Ec,{defaultShapedIcon:ta,verticallyShapedIcon:Zs}=fht(x,$s,se,qt,E,Ss,Ar,sr,fr);fr!=="none"&&$s&&(O5e($s)||R5e($s))&&(u7(0,ls,Rs,$s,ta,fr,W,b,C),u7(0,Fs,rs,$s,ta,fr,W,b,C),Zs&&(u7(0,ls,Rs,$s,Zs,fr,W,b,C),u7(0,Fs,rs,$s,Zs,fr,W,b,C))),$s=ta;const{iconBBox:Er,iconVerticalBBox:_n,textBBox:Na,textVerticalBBox:Ta}=dht(x,$s,Zs,se,qt,E,ks,sr,de,C,Hs,Ss,ds,Ds);zt.push({feature:qt,shapedTextOrientations:Ss,shapedText:_r,shapedIcon:$s,iconPrimary:Rs,iconSecondary:rs,iconOffset:sr,iconAnchor:Hs,verticallyShapedIcon:Zs,layoutTextSize:ds,layoutIconSize:ks,textOffset:Ds,isSDFIcon:zr,iconTextFit:fr,iconCollisionBounds:Er,iconVerticalCollisionBounds:_n,textCollisionBounds:Na,textVerticalCollisionBounds:Ta})}return{featureData:zt,sizes:de,hasAnySecondaryIcon:At,textAlongLine:kt,symbolPlacement:lt}},i.fx=H5e,i.fy=function(x,d,m,b,C,E,I,R,q,W){x.iconAtlasPositions=W.iconPositions;const{featureData:te,hasAnySecondaryIcon:se,sizes:ie,textAlongLine:de,symbolPlacement:he}=d;for(const Ce of te){const{shapedIcon:Fe,verticallyShapedIcon:Re,feature:Ke,shapedTextOrientations:Xe,shapedText:lt,layoutTextSize:kt,textOffset:vt,isSDFIcon:At,iconPrimary:zt,iconSecondary:qt,iconTextFit:ss,iconOffset:Wt,iconCollisionBounds:ds,iconVerticalCollisionBounds:ks,textCollisionBounds:Ss}=Ce;J5e(Fe,W.iconPositions,zt,qt),J5e(Re,W.iconPositions,zt,qt),pht(Xe,W.iconPositions),mht(zt,qt,W.iconPositions),(lt||Fe)&&xht(x,Ke,Xe,Fe,Re,q,ie,kt,0,vt,At,b,C,I,R,se,ss,Wt,de,he,ds,ks,Ss)}m&&x.generateCollisionDebugBuffers(E,x.collisionBoxArray,ie.textScaleFactor)},i.fz=Yt,i.g=function(x,d){return eg(Object.assign(x,{method:"GET"}),d)},i.h=function(x){return x.indexOf("mapbox:")===0},i.i=function(x){return ha.API_STYLE_REGEX.test(x)&&!Tc(x)},i.j=ho,i.k=uu,i.l=function(x){return decodeURIComponent(atob(x).split("").map(d=>"%"+("00"+d.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(x,d){return eg(Object.assign(x,{type:"json"}),d)},i.n=_y,i.o=Ul,i.p=function(x,d){return eg(Object.assign(x,{method:"POST"}),d)},i.q=Gd,i.r=Km,i.s=function(x){try{const d=self[x];return d.setItem("_mapbox_test_",1),d.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return Lpe||(Lpe=new L2("ImageRasterizer")),Lpe},i.u=function(){return function x(d){return d?(d^Math.random()*(16>>d/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,x)}()},i.v=function(x){return!!x&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(x)},i.w=xr,i.x=Cfe,i.y=wy,i.z=Qm}),o(["./shared"],function(i){function c($t){const Se=$t?$t.url.toString():void 0;return Se?performance.getEntriesByName(Se):[]}function u($t){if(typeof $t=="number"||typeof $t=="boolean"||typeof $t=="string"||$t==null)return JSON.stringify($t);if(Array.isArray($t)){let Be="[";for(const Ye of $t)Be+=`${u(Ye)},`;return`${Be}]`}let Se="{";for(const Be of Object.keys($t).sort())Se+=`${Be}:${u($t[Be])},`;return`${Se}}`}function p($t){let Se="";for(const Be of i.bx)Se+=`/${u($t[Be])}`;return Se}class f{constructor(Se){this.keyCache={},this._layers={},this._layerConfigs={},Se&&this.replace(Se)}replace(Se,Be){this._layerConfigs={},this._layers={},this.update(Se,[],Be)}update(Se,Be,Ye){this._options=Ye;for(const gt of Se)this._layerConfigs[gt.id]=gt,(this._layers[gt.id]=i.du(gt,this.scope,null,this._options)).compileFilter(Ye),this.keyCache[gt.id]&&delete this.keyCache[gt.id];for(const gt of Be)delete this.keyCache[gt],delete this._layerConfigs[gt],delete this._layers[gt];this.familiesBySource={};const bt=function(gt,Ft){const Zt={};for(let Qt=0;Qtthis._layers[vr.id]),Zt=Ft[0];if(Zt.visibility==="none")continue;const Ut=Zt.source||"";let Qt=this.familiesBySource[Ut];Qt||(Qt=this.familiesBySource[Ut]={});const Is=Zt.sourceLayer||"_geojsonTileLayer";let ys=Qt[Is];ys||(ys=Qt[Is]=[]),ys.push(Ft)}}}const g=1*i.fl;class v{constructor(Se){const Be={},Ye=[];for(const Zt in Se){const Ut=Se[Zt],Qt=Be[Zt]={};for(const Is in Ut.glyphs){const ys=Ut.glyphs[+Is];if(!ys||ys.bitmap.width===0||ys.bitmap.height===0)continue;const vr=ys.metrics.localGlyph?g:1,Hr={x:0,y:0,w:ys.bitmap.width+2*vr,h:ys.bitmap.height+2*vr};Ye.push(Hr),Qt[Is]=Hr}}const{w:bt,h:gt}=i.G(Ye),Ft=new i.fk({width:bt||1,height:gt||1});for(const Zt in Se){const Ut=Se[Zt];for(const Qt in Ut.glyphs){const Is=Ut.glyphs[+Qt];if(!Is||Is.bitmap.width===0||Is.bitmap.height===0)continue;const ys=Be[Zt][Qt],vr=Is.metrics.localGlyph?g:1;i.fk.copy(Is.bitmap,Ft,{x:0,y:0},{x:ys.x+vr,y:ys.y+vr},Is.bitmap)}}this.image=Ft,this.positions=Be}}function _($t,Se,Be){$t[Se]?Be&&($t[Se].center=Be):$t[Se]={floorIds:new Set,center:Be||[0,0],floors:{}}}function w($t,Se,Be,Ye){for(const bt of Se)_($t,bt),$t[bt].floors[Be]=Ye,$t[bt].floorIds.add(Be)}function j($t){return{id:$t.properties.id.toString(),center:$t.properties.center.toString().split(";").map(Number)}}function k($t){return{id:$t.properties.id.toString(),isDefault:!!$t.properties.is_default&&$t.properties.is_default,connections:$t.properties.connected_floor_ids?new Set($t.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:$t.properties.conflicted_floor_ids?new Set($t.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:$t.properties.building_ids?new Set($t.properties.building_ids.toString().split(";")):new Set,name:$t.properties.name.toString(),zIndex:$t.properties.z_index}}function S($t,Se){return Se.every(Be=>$t.properties&&$t.properties[Be]!=null)}function M($t){return S($t,["type","id","name"])&&$t.properties.type==="building"}function L($t){return S($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}i.fj(v,"GlyphAtlas");class P{constructor(Se){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.lut=Se.lut,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.scope=Se.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Se.showCollisionBoxes,this.collectResourceTiming=!!Se.request&&Se.request.collectResourceTiming,this.promoteId=Se.promoteId,this.isSymbolTile=Se.isSymbolTile,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.projection=Se.projection,this.worldview=Se.worldview,this.localizableLayerIds=Se.localizableLayerIds,this.brightness=Se.brightness,this.extraShadowCaster=!!Se.extraShadowCaster,this.tessellationStep=Se.tessellationStep,this.scaleFactor=Se.scaleFactor,this.worldview=Se.worldview,this.indoor=Se.indoor}parse(Se,Be,Ye,bt,gt,Ft){this.status="parsing",this.data=Se,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(Se.layers).sort()),Ut=new i.fn(this.tileID,this.promoteId);Ut.bucketLayerIDs=[];const Qt={},Is=new i.fo(256,256),ys={featureIndex:Ut,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Is,availableImages:Ye,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const On=this.indoor.indoorState.activeFloorsVisible,Rn=function(Pn,wa,_o){const cl=function(co,Da){if(!co)return i.w("No source layers defined in indoor specification"),Da;if(co.size===0)return Da;const uo=co.difference(Da);for(const Ai of uo)i.w(`Missing source layer required in indoor specification: ${Ai}`);return Da.intersection(Da)}(wa.sourceLayers,new Set(Object.keys(Pn.layers))),ni=wa.indoorState,pl=function(co,Da,uo,Ai){const ha=new Set,ho=new Set,Tc=new Set,Wc=new Map,cu={},Rf=ql=>{const uh=Wc.get(ql)||new Set;for(const Sd of ha)if((Wc.get(Sd)||new Set).has(ql)||uh.has(Sd))return!0;return!1};for(const ql of Da){const uh=co.layers[ql];if(uh)for(let Sd=0;Sd=uo.maxzoom||uo.visibility==="none")continue;O(Da,this.zoom,ys.brightness,Ye,this.worldview);const Ai=Qt[uo.id]=uo.createBucket({index:Ut.bucketLayerIDs.length,layers:Da,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:cl,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:bt,worldview:this.worldview,localizable:pl});Ut.bucketLayerIDs.push(Da.map(ho=>i.B(ho.id,ho.scope)));let ha=Ai.prepare?Ai.prepare():null;ha!=null?(ha=ha.then(()=>Ai.populate(ni,ys,this.tileID.canonical,this.tileTransform)),vr.push(ha)):Ai.populate(ni,ys,this.tileID.canonical,this.tileTransform)}}const xr=()=>{let On,Rn,Pn,wa,_o,cl;Is.trim();const ni={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},pl=()=>{if(On)return this.status="done",Ft(On);if(this.extraShadowCaster)this.status="done",Ft(null,{buckets:Object.values(Qt).filter(Da=>!Da.isEmpty()),featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:ys.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Rn&&Pn&&wa){const Da=new v(Rn),uo=new Map;for(const[ho,Tc]of Pn.entries()){const{imagePosition:Wc}=i.fu(ho,Tc,i.fv);uo.set(ho,Wc)}const Ai={};for(const ho in Qt){const Tc=Qt[ho];Tc instanceof i.b4&&(O(Tc.layers,this.zoom,ys.brightness,Ye,this.worldview),Ai[ho]=i.fw(Tc,Rn,Da.positions,Pn,uo,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,_o,this.worldview))}const ha={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(gt,Pn,_o,()=>{ha.iconsPending=!1,co(Ai,Da,ha)}),this.rasterizeIfNeeded(gt,wa,cl,()=>{ha.patternsPending=!1,co(Ai,Da,ha)})}},co=(Da,uo,Ai,ha)=>{if(Ai.iconsPending||Ai.patternsPending)return;const ho=new i.fx(Pn,wa,this.lut);for(const Tc in Qt){const Wc=Qt[Tc];if(Tc in Da)i.fy(Wc,Da[Tc],this.showCollisionBoxes,Ye,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Pn,ho);else if(Wc.hasPattern&&(Wc instanceof i.ba||Wc instanceof i.bb||Wc instanceof i.ea)){O(Wc.layers,this.zoom,ys.brightness,Ye,this.worldview);const cu=Object.fromEntries(ho.patternPositions);Wc.addFeatures(ys,this.tileID.canonical,cu,Ye,this.tileTransform,this.brightness)}}this.status="done",Ft(null,{buckets:Object.values(Qt).filter(Tc=>!Tc.isEmpty()),featureIndex:Ut,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:uo.image,lineAtlas:Is,imageAtlas:ho,brightness:ys.brightness})};if(!this.extraShadowCaster){const Da=i.fs(ys.glyphDependencies,ha=>Object.keys(ha).map(Number));Object.keys(Da).length?gt.send("getGlyphs",{uid:this.uid,stacks:Da},(ha,ho)=>{On||(On=ha,Rn=ho,pl())},void 0,!1,ni):Rn={};const uo=Array.from(ys.iconDependencies.keys()).map(ha=>i.I.parse(ha));uo.length?gt.send("getImages",{images:uo,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ha,ho)=>{On||(On=ha,Pn=new Map,_o=this.updateImageMapAndGetImageTaskQueue(Pn,ho,ys.iconDependencies),pl())},void 0,!1,ni):(Pn=new Map,_o=new Map);const Ai=Array.from(ys.patternDependencies.keys()).map(ha=>i.I.parse(ha));Ai.length?gt.send("getImages",{images:Ai,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ha,ho)=>{On||(On=ha,wa=new Map,cl=this.updateImageMapAndGetImageTaskQueue(wa,ho,ys.patternDependencies),pl())},void 0,!1,ni):(wa=new Map,cl=new Map)}if(ys.elevationFeatures&&ys.elevationFeatures.length>0){const Da=[];for(const Ai of Object.values(Qt))if(Ai instanceof i.bb){const ha=Ai.getUnevaluatedPortalGraph();ha&&Da.push(ha)}const uo=i.ft.evaluate(Da);for(const Ai of Object.values(Qt))if(Ai instanceof i.bb){const ha=Se.layers[Zt.decode(Ai.sourceLayerIndex)];Ai.setEvaluatedPortalGraph(uo,ha,this.tileID.canonical,ys.availableImages,ys.brightness)}}pl()};vr.length>0?Promise.allSettled(vr).then(xr).catch(Ft):xr()}updateParameters(Se){this.scaleFactor=Se.scaleFactor,this.showCollisionBoxes=Se.showCollisionBoxes,this.projection=Se.projection,this.brightness=Se.brightness,this.tileTransform=i.aZ(Se.tileID.canonical,Se.projection),this.extraShadowCaster=Se.extraShadowCaster,this.lut=Se.lut,this.worldview=Se.worldview,this.indoor=Se.indoor}rasterizeIfNeeded(Se,Be,Ye,bt){Array.from(Be.values()).some(gt=>gt.usvg)?this.rasterize(Se,Be,Ye,bt):bt()}updateImageMapAndGetImageTaskQueue(Se,Be,Ye){const bt=new Map;for(const gt of Be.keys()){const Ft=Ye.get(gt)||[];for(const Zt of Ft){const Ut=Zt.toString(),Qt=Be.get(Zt.id.toString());Qt.usvg?bt.has(Ut)||(bt.set(Ut,Zt),Se.set(Ut,Object.assign({},Qt))):Se.set(Ut,Qt)}}return bt}rasterize(Se,Be,Ye,bt){this.rasterizeTask=Se.send("rasterizeImages",{scope:this.scope,tasks:Ye},(gt,Ft)=>{if(!gt)for(const[Zt,Ut]of Ft.entries()){const Qt=Object.assign(Be.get(Zt),{data:Ut});Be.set(Zt,Qt)}bt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function O($t,Se,Be,Ye,bt){const gt=new i.ac(Se,{brightness:Be,worldview:bt});for(const Ft of $t)Ft.recalculate(gt,Ye)}class $ extends i.E{constructor(Se,Be,Ye,bt,gt,Ft,Zt){super(),this.actor=Se,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=bt,this.loadVectorData=Ft||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(Se.scheduler),this.isSpriteLoaded=gt,this.scheduler=Se.scheduler,this.brightness=Zt}loadTile(Se,Be){const Ye=Se.uid,bt=Se&&Se.request,gt=bt&&bt.collectResourceTiming,Ft=this.loading[Ye]=new P(Se);Ft.abort=this.loadVectorData(Se,(Zt,Ut)=>{const Qt=!this.loading[Ye];if(delete this.loading[Ye],Ft.cancelRasterize(),Qt||Zt||!Ut)return Ft.status="done",Qt||(this.loaded[Ye]=Ft),Be(Zt);const Is=Ut.rawData,ys={},vr=i.aM(Ut.responseHeaders);vr&&vr.expires&&(ys.expires=vr.expires),vr&&vr.cacheControl&&(ys.cacheControl=vr.cacheControl),Ft.vectorTile=Ut.vectorTile||new i.fz(new i.bt(Is));const Hr=()=>{Ft.parse(Ft.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(xr,On)=>{if(xr||!On)return Be(xr);const Rn={};if(gt){const Pn=c(bt);Pn.length>0&&(Rn.resourceTiming=JSON.parse(JSON.stringify(Pn)))}Be(null,Object.assign({rawTileData:Is.slice(0),responseHeaders:Ut.responseHeaders},On,ys,Rn))})};this.isSpriteLoaded?Hr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Hr,{type:"parseTile",isSymbolTile:Se.isSymbolTile,zoom:Se.tileZoom}):Hr()}),this.loaded=this.loaded||{},this.loaded[Ye]=Ft})}reloadTile(Se,Be){const Ye=this.loaded,bt=Se.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.updateParameters(Se);const Ft=(Zt,Ut)=>{const Qt=gt.reloadCallback;Qt&&(delete gt.reloadCallback,gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Qt)),Be(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&(gt.vectorTile?gt.parse(gt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Ft):Ft())}else Be(null,void 0)}abortTile(Se,Be){const Ye=Se.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),Be()}removeTile(Se,Be){const Ye=this.loaded,bt=Se.uid;Ye&&Ye[bt]&&delete Ye[bt],Be()}}class U{loadTile(Se,Be){const{uid:Ye,encoding:bt,rawImageData:gt,padding:Ft}=Se,Zt=ImageBitmap&> instanceof ImageBitmap?this.getImageData(gt,Ft):gt;Be(null,new i.fA(Ye,Zt,bt,Ft<1))}reloadTile(Se,Be){Be(null,null)}abortTile(Se,Be){Be()}removeTile(Se,Be){Be()}getImageData(Se,Be){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Se.width,Se.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Se.width,this.offscreenCanvas.height=Se.height,this.offscreenCanvasContext.drawImage(Se,0,0,Se.width,Se.height);const Ye=this.offscreenCanvasContext.getImageData(-Be,-Be,Se.width+2*Be,Se.height+2*Be);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ye}}i.bs.setPbf(i.bt);class B{constructor(Se){this._mrt=new i.bs(Se.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=Se.uid,this.tileID=Se.tileID,this.source=Se.source}parse(Se,Be){const Ye=this._mrt;this.status="parsing",this._entireBuffer=Se;try{Ye.parseHeader(Se),this._isHeaderLoaded=!0;const bt=[];for(const gt in Ye.layers){const Ft=Ye.getLayer(gt),Zt=Ft.getDataRange(Ft.getBandList()),Ut=Ye.createDecodingTask(Zt),Qt=Se.slice(Zt.firstByte,Zt.lastByte+1),Is=i.bs.performDecoding(Qt,Ut).then(ys=>Ut.complete(null,ys)).catch(ys=>Ut.complete(ys,null));bt.push(Is)}Promise.allSettled(bt).then(()=>Be(null,Ye)).catch(gt=>Be(gt))}catch(bt){Be(bt)}}}class V{constructor(Se){this.actor=Se,this.loading={},this.loaded={}}loadTile(Se,Be){const Ye=Se.uid,bt=Se.request,gt=this.loading[Ye]=new B(Se),{cancel:Ft}=i.bu(bt,(Zt,Ut,Qt)=>{const Is=!this.loading[Ye];if(delete this.loading[Ye],Is||Zt||!Ut)return gt.status="done",Is||(this.loaded[Ye]=gt),Be(Zt);gt.parse(Ut,(ys,vr)=>{if(ys||!vr)return Be(ys);Be(null,vr,Qt)}),this.loaded[Ye]=gt});gt.abort=Ft}reloadTile(Se,Be){Be(null,void 0)}abortTile(Se,Be){const Ye=Se.uid,bt=this.loading[Ye];bt&&(bt.abort&&bt.abort(),delete this.loading[Ye]),Be()}removeTile(Se,Be){const Ye=Se.uid;this.loaded[Ye]&&delete this.loaded[Ye],Be()}decodeRasterArray(Se,Be){i.bs.performDecoding(Se.buffer,Se.task).then(Ye=>Be(null,Ye)).catch(Ye=>Be(Ye))}}const X=i.fB.prototype.toGeoJSON;class Y{constructor(Se){this._feature=Se,this.extent=i.al,this.type=Se.type,this.properties=Se.tags,"id"in Se&&!isNaN(Se.id)&&(this.id=parseInt(Se.id,10))}loadGeometry(){if(this._feature.type===1){const Se=[];for(const Be of this._feature.geometry)Se.push([new i.P(Be[0],Be[1])]);return Se}{const Se=[];for(const Be of this._feature.geometry){const Ye=[];for(const bt of Be)Ye.push(new i.P(bt[0],bt[1]));Se.push(Ye)}return Se}}toGeoJSON(Se,Be,Ye){return X.call(this,Se,Be,Ye)}}class ee{constructor(Se,Be){this.name=Se,this.extent=i.al,this.length=Be.length,this._jsonFeatures=Be}feature(Se){return new Y(this._jsonFeatures[Se])}}class Q{constructor(Se){this.layers={},this.extent=i.al;for(const Be of Object.keys(Se))this.layers[Be]=new ee(Be,Se[Be])}}const ce=64/4096,ne=128;class re{constructor(){this.features=new Map}clear(){this.features.clear()}load(Se=[],Be){for(const Ye of Se){const bt=Ye.id;if(bt==null)continue;let gt=this.features.get(bt);gt&&this.updateCache(gt,Be),Ye.geometry?(gt=fe(Ye),this.updateCache(gt,Be),this.features.set(bt,gt)):this.features.delete(bt),this.updateCache(gt,Be)}}updateCache(Se,Be){for(const{canonical:Ye,uid:bt}of Object.values(Be)){const{z:gt,x:Ft,y:Zt}=Ye;oe(Se,Math.pow(2,gt),Ft,Zt)&&delete Be[bt]}}getTile(Se,Be,Ye){const bt=Math.pow(2,Se),gt=[];for(const Ft of this.features.values())oe(Ft,bt,Be,Ye)&>.push(_e(Ft,bt,Be,Ye));return{features:gt}}getFeatures(){return[...this.features.values()]}}function oe({minX:$t,minY:Se,maxX:Be,maxY:Ye},bt,gt,Ft){return $t<(gt+1+ce)/bt&&Se<(Ft+1+ce)/bt&&Be>(gt-ce)/bt&&Ye>(Ft-ce)/bt}function fe($t){const{id:Se,geometry:Be,properties:Ye}=$t;if(!Be)return;if(Be.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:bt,coordinates:gt}=Be,Ft={id:Se,type:1,geometry:[],tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Ft.geometry;if(bt==="Point")ge(gt,Zt,Ft);else if(bt==="MultiPoint")for(const Ut of gt)ge(Ut,Zt,Ft);else if(bt==="LineString")Ft.type=2,ue(gt,Zt,Ft);else if(bt==="MultiLineString")Ft.type=2,xe(gt,Zt,Ft);else if(bt==="Polygon")Ft.type=3,xe(gt,Zt,Ft,!0);else{if(bt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Ft.type=3;for(const Ut of gt)xe(Ut,Zt,Ft,!0)}return Ft}function ge([$t,Se],Be,Ye){const bt=i.aF($t);let gt=i.aJ(Se);gt=gt<0?0:gt>1?1:gt,Be.push(bt,gt),Ye.minX=Math.min(Ye.minX,bt),Ye.minY=Math.min(Ye.minY,gt),Ye.maxX=Math.max(Ye.maxX,bt),Ye.maxY=Math.max(Ye.maxY,gt)}function ue($t,Se,Be,Ye=!1,bt=!1){const gt=[];for(const Ft of $t)ge(Ft,gt,Be);Se.push(gt),Ye&&function(Ft,Zt){let Ut=0;for(let Qt=0,Is=Ft.length,ys=Is-2;Qt0===Zt)for(let Qt=0,Is=Ft.length;Qt=Ft&&ys>=Ft||(Qt>=Ft?(Is+=Math.round(xr*((Ft-Qt)/Hr)),Qt=Ft):ys>=Ft&&(vr=Is+Math.round(xr*((Ft-Qt)/Hr)),ys=Ft),Is>=Ft&&vr>=Ft||(Is>=Ft?(Qt+=Math.round(Hr*((Ft-Is)/xr)),Is=Ft):vr>=Ft&&(ys=Qt+Math.round(Hr*((Ft-Is)/xr)),vr=Ft),Zt&&Qt===Zt[Zt.length-1][0]&&Is===Zt[Zt.length-1][1]||(Zt=[[Qt,Is]],bt.push(Zt)),Zt.push([ys,vr])))))}}function Me($t,Se,Be,Ye,bt){const gt=(Be-ce)/Se,Ft=(Ye-ce)/Se,Zt=(Be+1+ce)/Se,Ut=(Ye+1+ce)/Se;function Qt(vr,Hr){let xr=0;return vrZt&&(xr|=2),HrUt&&(xr|=8),xr}let Is=[];for(let vr=1;vr<=8;vr*=2){let Hr=$t[$t.length-2],xr=$t[$t.length-1],On=!(Qt(Hr,xr)&vr);for(let Rn=0;Rn<$t.length;Rn+=2){const Pn=$t[Rn],wa=$t[Rn+1],_o=!(Qt(Pn,wa)&vr);_o!==On&&(8&vr?Is.push(Hr+(Pn-Hr)*(Ut-xr)/(wa-xr),Ut):4&vr?Is.push(Hr+(Pn-Hr)*(Ft-xr)/(wa-xr),Ft):2&vr?Is.push(Zt,xr+(wa-xr)*(Zt-Hr)/(Pn-Hr)):1&vr&&Is.push(gt,xr+(wa-xr)*(gt-Hr)/(Pn-Hr))),_o&&Is.push(Pn,wa),Hr=Pn,xr=wa,On=_o}if(!($t=Is).length||vr===8)break;Is=[]}const ys=[];for(let vr=0;vr>31}function Qe($t,Se){const{geometry:Be,type:Ye}=$t;let bt=0,gt=0;if(Ye===1){Se.writeVarint(we(1,Be.length));for(const Ft of Be){const Zt=Ft[0]-bt,Ut=Ft[1]-gt;Se.writeVarint(Le(Zt)),Se.writeVarint(Le(Ut)),bt+=Zt,gt+=Ut}}else for(const Ft of Be){Se.writeVarint(we(1,1));const Zt=Ft.length-(Ye===3?1:0);for(let Ut=0;Ut$t},ye=Math.fround||(qe=new Float32Array(1),$t=>(qe[0]=+$t,qe[0]));var qe;const at=3,tt=5,Ae=6;class rt{constructor(Se){this.options=Object.assign(Object.create(pt),Se),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(Se){const{log:Be,minZoom:Ye,maxZoom:bt}=this.options;Be&&console.time("total time");const gt=`prepare ${Se.length} points`;Be&&console.time(gt),this.points=Se;const Ft=[];for(let Ut=0;Ut=Ye;Ut--){const Qt=+Date.now();Zt=this.trees[Ut]=this._createTree(this._cluster(Zt,Ut)),Be&&console.log("z%d: %d clusters in %dms",Ut,Zt.numItems,+Date.now()-Qt)}return Be&&console.timeEnd("total time"),this}getClusters(Se,Be){let Ye=((Se[0]+180)%360+360)%360-180;const bt=Math.max(-90,Math.min(90,Se[1]));let gt=Se[2]===180?180:((Se[2]+180)%360+360)%360-180;const Ft=Math.max(-90,Math.min(90,Se[3]));if(Se[2]-Se[0]>=360)Ye=-180,gt=180;else if(Ye>gt){const ys=this.getClusters([Ye,bt,180,Ft],Be),vr=this.getClusters([-180,bt,gt,Ft],Be);return ys.concat(vr)}const Zt=this.trees[this._limitZoom(Be)],Ut=Zt.range(Ue(Ye),Ze(Ft),Ue(gt),Ze(bt)),Qt=Zt.data,Is=[];for(const ys of Ut){const vr=this.stride*ys;Is.push(Qt[vr+tt]>1?He(Qt,vr,this.clusterProps):this.points[Qt[vr+at]])}return Is}getChildren(Se){const Be=this._getOriginId(Se),Ye=this._getOriginZoom(Se),bt="No cluster with the specified id.",gt=this.trees[Ye];if(!gt)throw new Error(bt);const Ft=gt.data;if(Be*this.stride>=Ft.length)throw new Error(bt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,Ye-1)),Ut=gt.within(Ft[Be*this.stride],Ft[Be*this.stride+1],Zt),Qt=[];for(const Is of Ut){const ys=Is*this.stride;Ft[ys+4]===Se&&Qt.push(Ft[ys+tt]>1?He(Ft,ys,this.clusterProps):this.points[Ft[ys+at]])}if(Qt.length===0)throw new Error(bt);return Qt}getLeaves(Se,Be,Ye){const bt=[];return this._appendLeaves(bt,Se,Be=Be||10,Ye=Ye||0,0),bt}getTile(Se,Be,Ye){const bt=this.trees[this._limitZoom(Se)],gt=Math.pow(2,Se),{extent:Ft,radius:Zt}=this.options,Ut=Zt/Ft,Qt=(Ye-Ut)/gt,Is=(Ye+1+Ut)/gt,ys={features:[]};return this._addTileFeatures(bt.range((Be-Ut)/gt,Qt,(Be+1+Ut)/gt,Is),bt.data,Be,Ye,gt,ys),Be===0&&this._addTileFeatures(bt.range(1-Ut/gt,Qt,1,Is),bt.data,gt,Ye,gt,ys),Be===gt-1&&this._addTileFeatures(bt.range(0,Qt,Ut/gt,Is),bt.data,-1,Ye,gt,ys),ys.features.length?ys:null}getClusterExpansionZoom(Se){let Be=this._getOriginZoom(Se)-1;for(;Be<=this.options.maxZoom;){const Ye=this.getChildren(Se);if(Be++,Ye.length!==1)break;Se=Ye[0].properties.cluster_id}return Be}_appendLeaves(Se,Be,Ye,bt,gt){const Ft=this.getChildren(Be);for(const Zt of Ft){const Ut=Zt.properties;if(Ut&&Ut.cluster?gt+Ut.point_count<=bt?gt+=Ut.point_count:gt=this._appendLeaves(Se,Ut.cluster_id,Ye,bt,gt):gt1;let Is,ys,vr;if(Qt)Is=ct(Be,Ut,this.clusterProps),ys=Be[Ut],vr=Be[Ut+1];else{const On=this.points[Be[Ut+at]];Is=On.properties;const[Rn,Pn]=On.geometry.coordinates;ys=Ue(Rn),vr=Ze(Pn)}const Hr={type:1,geometry:[[Math.round(this.options.extent*(ys*gt-Ye)),Math.round(this.options.extent*(vr*gt-bt))]],tags:Is};let xr;xr=Qt||this.options.generateId?Be[Ut+at]:this.points[Be[Ut+at]].id,xr!==void 0&&(Hr.id=xr),Ft.features.push(Hr)}}_limitZoom(Se){return Math.max(this.options.minZoom,Math.min(Math.floor(+Se),this.options.maxZoom+1))}_cluster(Se,Be){const{radius:Ye,extent:bt,reduce:gt,minPoints:Ft}=this.options,Zt=Ye/(bt*Math.pow(2,Be)),Ut=Se.data,Qt=[],Is=this.stride;for(let ys=0;ysBe&&(Rn+=Ut[wa+tt])}if(Rn>On&&Rn>=Ft){let Pn,wa=vr*On,_o=Hr*On,cl=-1;const ni=(ys/Is<<5)+(Be+1)+this.points.length;for(const pl of xr){const co=pl*Is;if(Ut[co+2]<=Be)continue;Ut[co+2]=Be;const Da=Ut[co+tt];wa+=Ut[co]*Da,_o+=Ut[co+1]*Da,Ut[co+4]=ni,gt&&(Pn||(Pn=this._map(Ut,ys,!0),cl=this.clusterProps.length,this.clusterProps.push(Pn)),gt(Pn,this._map(Ut,co)))}Ut[ys+4]=ni,Qt.push(wa/Rn,_o/Rn,1/0,ni,-1,Rn),gt&&Qt.push(cl)}else{for(let Pn=0;Pn1)for(const Pn of xr){const wa=Pn*Is;if(!(Ut[wa+2]<=Be)){Ut[wa+2]=Be;for(let _o=0;_o>5}_getOriginZoom(Se){return(Se-this.points.length)%32}_map(Se,Be,Ye){if(Se[Be+tt]>1){const Ft=this.clusterProps[Se[Be+Ae]];return Ye?Object.assign({},Ft):Ft}const bt=this.points[Se[Be+at]].properties,gt=this.options.map(bt);return Ye&>===bt?Object.assign({},gt):gt}}function He($t,Se,Be){return{type:"Feature",id:$t[Se+at],properties:ct($t,Se,Be),geometry:{type:"Point",coordinates:[(Ye=$t[Se],360*(Ye-.5)),Je($t[Se+1])]}};var Ye}function ct($t,Se,Be){const Ye=$t[Se+tt],bt=Ye>=1e4?`${Math.round(Ye/1e3)}k`:Ye>=1e3?Math.round(Ye/100)/10+"k":Ye,gt=$t[Se+Ae],Ft=gt===-1?{}:Object.assign({},Be[gt]);return Object.assign(Ft,{cluster:!0,cluster_id:$t[Se+at],point_count:Ye,point_count_abbreviated:bt})}function Ue($t){return $t/360+.5}function Ze($t){const Se=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Be<0?0:Be>1?1:Be}function Je($t){const Se=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(Se))/Math.PI-90}function Ge($t,Se,Be,Ye){let bt=Ye;const gt=Se+(Be-Se>>1);let Ft,Zt=Be-Se;const Ut=$t[Se],Qt=$t[Se+1],Is=$t[Be],ys=$t[Be+1];for(let vr=Se+3;vrbt)Ft=vr,bt=Hr;else if(Hr===bt){const xr=Math.abs(vr-gt);xrYe&&(Ft-Se>3&&Ge($t,Se,Ft,Ye),$t[Ft+2]=bt,Be-Ft>3&&Ge($t,Ft,Be,Ye))}function et($t,Se,Be,Ye,bt,gt){let Ft=bt-Be,Zt=gt-Ye;if(Ft!==0||Zt!==0){const Ut=(($t-Be)*Ft+(Se-Ye)*Zt)/(Ft*Ft+Zt*Zt);Ut>1?(Be=bt,Ye=gt):Ut>0&&(Be+=Ft*Ut,Ye+=Zt*Ut)}return Ft=$t-Be,Zt=Se-Ye,Ft*Ft+Zt*Zt}function it($t,Se,Be,Ye){const bt={id:$t??null,type:Se,geometry:Be,tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(Se==="Point"||Se==="MultiPoint"||Se==="LineString")Dt(bt,Be);else if(Se==="Polygon")Dt(bt,Be[0]);else if(Se==="MultiLineString")for(const gt of Be)Dt(bt,gt);else if(Se==="MultiPolygon")for(const gt of Be)Dt(bt,gt[0]);return bt}function Dt($t,Se){for(let Be=0;Be0&&(Ft+=Ye?(bt*Is-Qt*gt)/2:Math.sqrt(Math.pow(Qt-bt,2)+Math.pow(Is-gt,2))),bt=Qt,gt=Is}const Zt=Se.length-3;Se[2]=1,Ge(Se,0,Zt,Be),Se[Zt+2]=1,Se.size=Math.abs(Ft),Se.start=0,Se.end=Se.size}function Ms($t,Se,Be,Ye){for(let bt=0;bt<$t.length;bt++){const gt=[];As($t[bt],gt,Be,Ye),Se.push(gt)}}function cs($t){return $t/360+.5}function er($t){const Se=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+Se)/(1-Se))/Math.PI;return Be<0?0:Be>1?1:Be}function xt($t,Se,Be,Ye,bt,gt,Ft,Zt){if(Ye/=Se,gt>=(Be/=Se)&&Ft=Ye)return null;const Ut=[];for(const Qt of $t){const Is=Qt.geometry;let ys=Qt.type;const vr=bt===0?Qt.minX:Qt.minY,Hr=bt===0?Qt.maxX:Qt.maxY;if(vr>=Be&&Hr=Ye)continue;let xr=[];if(ys==="Point"||ys==="MultiPoint")Ps(Is,xr,Be,Ye,bt);else if(ys==="LineString")mr(Is,xr,Be,Ye,bt,!1,Zt.lineMetrics);else if(ys==="MultiLineString")Dr(Is,xr,Be,Ye,bt,!1);else if(ys==="Polygon")Dr(Is,xr,Be,Ye,bt,!0);else if(ys==="MultiPolygon")for(const On of Is){const Rn=[];Dr(On,Rn,Be,Ye,bt,!0),Rn.length&&xr.push(Rn)}if(xr.length){if(Zt.lineMetrics&&ys==="LineString"){for(const On of xr)Ut.push(it(Qt.id,ys,On,Qt.tags));continue}ys!=="LineString"&&ys!=="MultiLineString"||(xr.length===1?(ys="LineString",xr=xr[0]):ys="MultiLineString"),ys!=="Point"&&ys!=="MultiPoint"||(ys=xr.length===3?"Point":"MultiPoint"),Ut.push(it(Qt.id,ys,xr,Qt.tags))}}return Ut.length?Ut:null}function Ps($t,Se,Be,Ye,bt){for(let gt=0;gt<$t.length;gt+=3){const Ft=$t[gt+bt];Ft>=Be&&Ft<=Ye&&xn(Se,$t[gt],$t[gt+1],$t[gt+2])}}function mr($t,Se,Be,Ye,bt,gt,Ft){let Zt=Tr($t);const Ut=bt===0?Si:Ia;let Qt,Is,ys=$t.start;for(let Rn=0;Rn<$t.length-3;Rn+=3){const Pn=$t[Rn],wa=$t[Rn+1],_o=$t[Rn+2],cl=$t[Rn+3],ni=$t[Rn+4],pl=bt===0?Pn:wa,co=bt===0?cl:ni;let Da=!1;Ft&&(Qt=Math.sqrt(Math.pow(Pn-cl,2)+Math.pow(wa-ni,2))),plBe&&(Is=Ut(Zt,Pn,wa,cl,ni,Be),Ft&&(Zt.start=ys+Qt*Is)):pl>Ye?co=Be&&(Is=Ut(Zt,Pn,wa,cl,ni,Be),Da=!0),co>Ye&&pl<=Ye&&(Is=Ut(Zt,Pn,wa,cl,ni,Ye),Da=!0),!gt&&Da&&(Ft&&(Zt.end=ys+Qt*Is),Se.push(Zt),Zt=Tr($t)),Ft&&(ys+=Qt)}let vr=$t.length-3;const Hr=$t[vr],xr=$t[vr+1],On=bt===0?Hr:xr;On>=Be&&On<=Ye&&xn(Zt,Hr,xr,$t[vr+2]),vr=Zt.length-3,gt&&vr>=3&&(Zt[vr]!==Zt[0]||Zt[vr+1]!==Zt[1])&&xn(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&Se.push(Zt)}function Tr($t){const Se=[];return Se.size=$t.size,Se.start=$t.start,Se.end=$t.end,Se}function Dr($t,Se,Be,Ye,bt,gt){for(const Ft of $t)mr(Ft,Se,Be,Ye,bt,gt,!1)}function xn($t,Se,Be,Ye){$t.push(Se,Be,Ye)}function Si($t,Se,Be,Ye,bt,gt){const Ft=(gt-Se)/(Ye-Se);return xn($t,gt,Be+(bt-Be)*Ft,1),Ft}function Ia($t,Se,Be,Ye,bt,gt){const Ft=(gt-Be)/(bt-Be);return xn($t,Se+(Ye-Se)*Ft,gt,1),Ft}function ur($t,Se){const Be=[];for(let Ye=0;Ye<$t.length;Ye++){const bt=$t[Ye],gt=bt.type;let Ft;if(gt==="Point"||gt==="MultiPoint"||gt==="LineString")Ft=Jr(bt.geometry,Se);else if(gt==="MultiLineString"||gt==="Polygon"){Ft=[];for(const Zt of bt.geometry)Ft.push(Jr(Zt,Se))}else if(gt==="MultiPolygon"){Ft=[];for(const Zt of bt.geometry){const Ut=[];for(const Qt of Zt)Ut.push(Jr(Qt,Se));Ft.push(Ut)}}Be.push(it(bt.id,gt,Ft,bt.tags))}return Be}function Jr($t,Se){const Be=[];Be.size=$t.size,$t.start!==void 0&&(Be.start=$t.start,Be.end=$t.end);for(let Ye=0;Ye<$t.length;Ye+=3)Be.push($t[Ye]+Se,$t[Ye+1],$t[Ye+2]);return Be}function Gr($t,Se){if($t.transformed)return $t;const Be=1<<$t.z,Ye=$t.x,bt=$t.y;for(const gt of $t.features){const Ft=gt.geometry,Zt=gt.type;if(gt.geometry=[],Zt===1)for(let Ut=0;Ut0&&Se.size<(bt?Ft:Ye))return void(Be.numPoints+=Se.length/3);const Zt=[];for(let Ut=0;UtFt)&&(Be.numSimplified++,Zt.push(Se[Ut],Se[Ut+1])),Be.numPoints++;bt&&function(Ut,Qt){let Is=0;for(let ys=0,vr=Ut.length,Hr=vr-2;ys0===Qt)for(let ys=0,vr=Ut.length;ys24)throw new Error("maxZoom should be in the 0-24 range");if(Be.promoteId&&Be.generateId)throw new Error("promoteId and generateId cannot be used together.");let bt=function(gt,Ft){const Zt=[];if(gt.type==="FeatureCollection")for(let Ut=0;Ut1&&console.time("creation"),Hr=this.tiles[vr]=Yr(Se,Be,Ye,bt,Qt),this.tileCoords.push({z:Be,x:Ye,y:bt}),Is)){Is>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Be,Ye,bt,Hr.numFeatures,Hr.numPoints,Hr.numSimplified),console.timeEnd("creation"));const Da=`z${Be}`;this.stats[Da]=(this.stats[Da]||0)+1,this.total++}if(Hr.source=Se,gt==null){if(Be===Qt.indexMaxZoom||Hr.numPoints<=Qt.indexMaxPoints)continue}else{if(Be===Qt.maxZoom||Be===gt)continue;if(gt!=null){const Da=gt-Be;if(Ye!==Ft>>Da||bt!==Zt>>Da)continue}}if(Hr.source=null,Se.length===0)continue;Is>1&&console.time("clipping");const xr=.5*Qt.buffer/Qt.extent,On=.5-xr,Rn=.5+xr,Pn=1+xr;let wa=null,_o=null,cl=null,ni=null,pl=xt(Se,ys,Ye-xr,Ye+Rn,0,Hr.minX,Hr.maxX,Qt),co=xt(Se,ys,Ye+On,Ye+Pn,0,Hr.minX,Hr.maxX,Qt);Se=null,pl&&(wa=xt(pl,ys,bt-xr,bt+Rn,1,Hr.minY,Hr.maxY,Qt),_o=xt(pl,ys,bt+On,bt+Pn,1,Hr.minY,Hr.maxY,Qt),pl=null),co&&(cl=xt(co,ys,bt-xr,bt+Rn,1,Hr.minY,Hr.maxY,Qt),ni=xt(co,ys,bt+On,bt+Pn,1,Hr.minY,Hr.maxY,Qt),co=null),Is>1&&console.timeEnd("clipping"),Ut.push(wa||[],Be+1,2*Ye,2*bt),Ut.push(_o||[],Be+1,2*Ye,2*bt+1),Ut.push(cl||[],Be+1,2*Ye+1,2*bt),Ut.push(ni||[],Be+1,2*Ye+1,2*bt+1)}}getTile(Se,Be,Ye){Se=+Se,Be=+Be,Ye=+Ye;const bt=this.options,{extent:gt,debug:Ft}=bt;if(Se<0||Se>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",Se,Be,Ye);let Qt,Is=Se,ys=Be,vr=Ye;for(;!Qt&&Is>0;)Is--,ys>>=1,vr>>=1,Qt=this.tiles[Sr(Is,ys,vr)];return Qt&&Qt.source?(Ft>1&&(console.log("found parent tile z%d-%d-%d",Is,ys,vr),console.time("drilling down")),this.splitTile(Qt.source,Is,ys,vr,Se,Be,Ye),Ft>1&&console.timeEnd("drilling down"),this.tiles[Ut]?Gr(this.tiles[Ut],gt):null):null}}function Sr($t,Se,Be){return 32*((1<<$t)*Be+Se)+$t}function jr($t,Se){const Be=$t.tileID.canonical;if(!this._geoJSONIndex)return void Se(null,null);const Ye=this._geoJSONIndex.getTile(Be.z,Be.x,Be.y);if(!Ye)return void Se(null,null);const bt=Qt=>Qt.tags&&"3d_elevation_id"in Qt.tags&&"source"in Qt.tags&&Qt.tags.source==="elevation",gt=Ye.features.filter(Qt=>bt(Qt));let Ft={_geojsonTileLayer:Ye.features};gt.length>0&&(Ft={_geojsonTileLayer:Ye.features.filter(Qt=>!bt(Qt)),hd_road_elevation:gt});const Zt=new Q(Ft),Ut=function(Qt){const Is=new i.bt;for(const ys of Object.keys(Qt))Is.writeMessage(3,Ie,{name:ys,features:Qt[ys]});return Is.finish()}(Ft).buffer;Se(null,{vectorTile:Zt,rawData:Ut})}class ea extends ${constructor(Se,Be,Ye,bt,gt,Ft,Zt){super(Se,Be,Ye,bt,gt,jr,Zt),Ft&&(this.loadGeoJSON=Ft),this._dynamicIndex=new re}loadData(Se,Be){const Ye=Se&&Se.request,bt=Ye&&Ye.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(Se,(gt,Ft)=>{if(gt||!Ft)return Be(gt);if(typeof Ft!="object")return Be(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));{try{if(Se.filter){const Ut=i.U(Se.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ut.result==="error")throw new Error(Ut.value.map(Qt=>`${Qt.key}: ${Qt.message}`).join(", "));Ft.features=Ft.features.filter(Qt=>Ut.value.evaluate({zoom:0},Qt))}Se.dynamic?(Ft.type==="Feature"&&(Ft={type:"FeatureCollection",features:[Ft]}),Se.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Ft.features,this.loaded),Se.cluster&&(Ft.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=Se.cluster?new rt(function({superclusterOptions:Ut,clusterProperties:Qt}){if(!Qt||!Ut)return Ut;const Is={},ys={},vr={accumulated:null,zoom:0},Hr={properties:null},xr=Object.keys(Qt);for(const On of xr){const[Rn,Pn]=Qt[On],wa=i.U(Pn),_o=i.U(typeof Rn=="string"?[Rn,["accumulated"],["get",On]]:Rn);Is[On]=wa.value,ys[On]=_o.value}return Ut.map=On=>{Hr.properties=On;const Rn={};for(const Pn of xr)Rn[Pn]=Is[Pn].evaluate(vr,Hr);return Rn},Ut.reduce=(On,Rn)=>{Hr.properties=Rn;for(const Pn of xr)vr.accumulated=On[Pn],On[Pn]=ys[Pn].evaluate(vr,Hr)},Ut}(Se)).load(Ft.features):Se.dynamic?this._dynamicIndex:function(Ut,Qt){return new Vn(Ut,Qt)}(Ft,Se.geojsonVtOptions)}catch(Ut){return Be(Ut)}const Zt={};if(bt){const Ut=c(Ye);Ut&&(Zt.resourceTiming={},Zt.resourceTiming[Se.source]=JSON.parse(JSON.stringify(Ut)))}Be(null,Zt)}})}reloadTile(Se,Be){const Ye=this.loaded;return Ye&&Ye[Se.uid]?Se.partial?Be(null,void 0):super.reloadTile(Se,Be):this.loadTile(Se,Be)}loadGeoJSON(Se,Be){if(Se.request)i.m(Se.request,Be);else{if(typeof Se.data!="string")return Be(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Be(null,JSON.parse(Se.data))}catch{return Be(new Error(`Input data given to '${Se.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(Se,Be){try{Be(null,this._geoJSONIndex.getClusterExpansionZoom(Se.clusterId))}catch(Ye){Be(Ye)}}getClusterChildren(Se,Be){try{Be(null,this._geoJSONIndex.getChildren(Se.clusterId))}catch(Ye){Be(Ye)}}getClusterLeaves(Se,Be){try{Be(null,this._geoJSONIndex.getLeaves(Se.clusterId,Se.limit,Se.offset))}catch(Ye){Be(Ye)}}}class La{constructor(Se,Be,Ye){this.tileID=new i.aQ(Se.tileID.overscaledZ,Se.tileID.wrap,Se.tileID.canonical.z,Se.tileID.canonical.x,Se.tileID.canonical.y),this.tileZoom=Se.tileZoom,this.uid=Se.uid,this.zoom=Se.zoom,this.canonical=Se.tileID.canonical,this.pixelRatio=Se.pixelRatio,this.tileSize=Se.tileSize,this.source=Se.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=Se.projection,this.brightness=Be,this.worldview=Ye}parse(Se,Be,Ye,bt){this.status="parsing";const gt=new i.aQ(Ye.tileID.overscaledZ,Ye.tileID.wrap,Ye.tileID.canonical.z,Ye.tileID.canonical.x,Ye.tileID.canonical.y),Ft=[],Zt=Be.familiesBySource[Ye.source],Ut=new i.fn(gt,Ye.promoteId);Ut.bucketLayerIDs=[],Ut.is3DTile=!0,i.fC(Se).then(Qt=>{if(!Qt)return bt(new Error("Could not parse tile"));const Is=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Qt.json.asset.extras&&Qt.json.asset.extras.MAPBOX_mesh_features,ys=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("EXT_meshopt_compression"),vr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Hr in Zt)for(const xr of Zt[Hr]){const On=xr[0];Ut.bucketLayerIDs.push(xr.map(wa=>i.B(wa.id,wa.scope))),On.recalculate(vr,[]);const Rn=i.fD(Qt,1/i.d7(Ye.tileID.canonical)),Pn=new i.fE(xr,Rn,gt,Is,ys,this.brightness,Ut,this.worldview);Is||(Pn.needsUpload=!0),Ft.push(Pn),Pn.evaluate(On)}this.status="done",bt(null,{buckets:Ft,featureIndex:Ut,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Qt=>bt(new Error(Qt.message)))}}class Ii{constructor(Se,Be,Ye,bt,gt,Ft,Zt,Ut){this.actor=Se,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=bt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Ut}loadTile(Se,Be){const Ye=Se.uid,bt=this.loading[Ye]=new La(Se,this.brightness,this.worldview);i.bu(Se.request,(gt,Ft)=>{const Zt=!this.loading[Ye];return delete this.loading[Ye],Zt||gt?(bt.status="done",Zt||(this.loaded[Ye]=bt),Be(gt)):Ft&&Ft.byteLength!==0?void bt.parse(Ft,this.layerIndex,Se,(Ut,Qt)=>{bt.status="done",this.loaded=this.loaded||{},this.loaded[Ye]=bt,Ut||!Qt?Be(Ut):Be(null,Qt)}):(bt.status="done",this.loaded[Ye]=bt,Be())})}reloadTile(Se,Be){const Ye=this.loaded,bt=Se.uid;if(Ye&&Ye[bt]){const gt=Ye[bt];gt.projection=Se.projection,gt.brightness=Se.brightness;const Ft=(Zt,Ut)=>{gt.reloadCallback&&(delete gt.reloadCallback,this.loadTile(Se,Be)),Be(Zt,Ut)};gt.status==="parsing"?gt.reloadCallback=Ft:gt.status==="done"&&this.loadTile(Se,Be)}}abortTile(Se,Be){const Ye=Se.uid;this.loading[Ye]&&delete this.loading[Ye],Be()}removeTile(Se,Be){const Ye=this.loaded,bt=Se.uid;Ye&&Ye[bt]&&delete Ye[bt],Be()}}class Fo{constructor(Se){this.self=Se,this.actor=new i.fG(Se,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:ea,"raster-dem":U,"raster-array":V,"batched-model":Ii},this.workerSources={},this.self.registerWorkerSource=(Be,Ye)=>{if(this.workerSourceTypes[Be])throw new Error(`Worker source with name "${Be}" already registered.`);this.workerSourceTypes[Be]=Ye},this.self.registerRTLTextPlugin=Be=>{if(i.fH.isParsed())throw new Error("RTL text plugin already registered.");i.fH.setState({pluginStatus:i.fI.parsed,pluginURL:i.fH.getPluginURL()}),i.fH.applyArabicShaping=Be.applyArabicShaping,i.fH.processBidirectionalText=Be.processBidirectionalText,i.fH.processStyledBidirectionalText=Be.processStyledBidirectionalText;for(const Ye of this.rtlPluginParsingListeners)Ye(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(Se,Be,Ye){delete this.layerIndexes[Se],delete this.availableImages[Se],delete this.availableModels[Se],delete this.workerSources[Se],Ye()}checkIfReady(Se,Be,Ye){Ye()}setReferrer(Se,Be){this.referrer=Be}spriteLoaded(Se,Be){this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={});const{scope:Ye,isLoaded:bt}=Be;if(this.isSpriteLoaded[Se][Ye]=bt,this.workerSources[Se]&&this.workerSources[Se][Ye])for(const gt in this.workerSources[Se][Ye]){const Ft=this.workerSources[Se][Ye][gt];for(const Zt in Ft){const Ut=Ft[Zt];Ut instanceof $&&(Ut.isSpriteLoaded=bt,Ut.fire(new i.z("isSpriteLoaded")))}}}setImages(Se,Be,Ye){this.availableImages[Se]||(this.availableImages[Se]={});const{scope:bt,images:gt}=Be;if(this.availableImages[Se][bt]=gt,this.workerSources[Se]&&this.workerSources[Se][bt]){for(const Ft in this.workerSources[Se][bt]){const Zt=this.workerSources[Se][bt][Ft];for(const Ut in Zt)Zt[Ut].availableImages=gt}Ye()}else Ye()}setModels(Se,{scope:Be,models:Ye},bt){if(this.availableModels[Se]||(this.availableModels[Se]={}),this.availableModels[Se][Be]=Ye,this.workerSources[Se]&&this.workerSources[Se][Be]){for(const gt in this.workerSources[Se][Be]){const Ft=this.workerSources[Se][Be][gt];for(const Zt in Ft)Ft[Zt].availableModels=Ye}bt()}else bt()}setProjection(Se,Be){this.projections[Se]=i.cm(Be)}setBrightness(Se,Be,Ye){this.brightness=Be,Ye()}setWorldview(Se,Be,Ye){this.worldview=Be,Ye()}setLayers(Se,Be,Ye){this.getLayerIndex(Se,Be.scope).replace(Be.layers,Be.options),Ye()}updateLayers(Se,Be,Ye){this.getLayerIndex(Se,Be.scope).update(Be.layers,Be.removedIds,Be.options),Ye()}loadTile(Se,Be,Ye){Be.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Be.type,Be.source,Be.scope).loadTile(Be,Ye)}decodeRasterArray(Se,Be,Ye){this.getWorkerSource(Se,Be.type,Be.source,Be.scope).decodeRasterArray(Be,Ye)}reloadTile(Se,Be,Ye){Be.projection=this.projections[Se]||this.defaultProjection,this.getWorkerSource(Se,Be.type,Be.source,Be.scope).reloadTile(Be,Ye)}abortTile(Se,Be,Ye){this.getWorkerSource(Se,Be.type,Be.source,Be.scope).abortTile(Be,Ye)}removeTile(Se,Be,Ye){this.getWorkerSource(Se,Be.type,Be.source,Be.scope).removeTile(Be,Ye)}removeSource(Se,Be,Ye){if(!(this.workerSources[Se]&&this.workerSources[Se][Be.scope]&&this.workerSources[Se][Be.scope][Be.type]&&this.workerSources[Se][Be.scope][Be.type][Be.source]))return;const bt=this.workerSources[Se][Be.scope][Be.type][Be.source];delete this.workerSources[Se][Be.scope][Be.type][Be.source],bt.removeSource!==void 0?bt.removeSource(Be,Ye):Ye()}loadWorkerSource(Se,Be,Ye){try{this.self.importScripts(Be.url),Ye()}catch(bt){Ye(bt)}}syncRTLPluginState(Se,Be,Ye){if(i.fH.isParsed())Ye(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Ye);else try{i.fH.setState(Be);const bt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||bt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(bt),i.fH.isParsed()?Ye(null,!0):this.rtlPluginParsingListeners.push(Ye))}catch(bt){Ye(bt)}}setDracoUrl(Se,Be){this.dracoUrl=Be}getAvailableImages(Se,Be){this.availableImages[Se]||(this.availableImages[Se]={});let Ye=this.availableImages[Se][Be];return Ye||(Ye=[]),Ye}getAvailableModels(Se,Be){this.availableModels[Se]||(this.availableModels[Se]={});let Ye=this.availableModels[Se][Be];return Ye||(Ye={}),Ye}getLayerIndex(Se,Be){this.layerIndexes[Se]||(this.layerIndexes[Se]={});let Ye=this.layerIndexes[Se][Be];return Ye||(Ye=this.layerIndexes[Se][Be]=new f,Ye.scope=Be),Ye}getWorkerSource(Se,Be,Ye,bt){const gt=this.workerSources;return gt[Se]||(gt[Se]={}),gt[Se][bt]||(gt[Se][bt]={}),gt[Se][bt][Be]||(gt[Se][bt][Be]={}),this.isSpriteLoaded[Se]||(this.isSpriteLoaded[Se]={}),gt[Se][bt][Be][Ye]||(gt[Se][bt][Be][Ye]=new this.workerSourceTypes[Be]({send:(Ft,Zt,Ut,Qt,Is,ys)=>this.actor.send(Ft,Zt,Ut,Se,Is,ys),scheduler:this.actor.scheduler},this.getLayerIndex(Se,bt),this.getAvailableImages(Se,bt),this.getAvailableModels(Se,bt),this.isSpriteLoaded[Se][bt],void 0,this.brightness,this.worldview)),gt[Se][bt][Be][Ye]}rasterizeImagesWorker(Se,Be,Ye){const bt=new Map;for(const[gt,{image:Ft,imageVariant:Zt}]of Be.tasks.entries()){const Ut=this.imageRasterizer.rasterize(Zt,Ft,Be.scope,Se);bt.set(gt,Ut)}Ye(void 0,bt)}removeRasterizedImages(Se,Be,Ye){this.imageRasterizer.removeImagesFromCacheByIds(Be.imageIds,Be.scope,Se),Ye()}enforceCacheSizeLimit(Se,Be){i.fJ(Be)}getWorkerPerformanceMetrics(Se,Be,Ye){Ye(void 0,void 0)}}return i.fF(self)&&(self.worker=new Fo(self)),Fo}),o(["./shared"],function(i){var c="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(T){performance.mark(T)},measure(T,h,y){performance.measure(T,h,y)}};function f(T){const h=T.name.split("?")[0];return i.a(h)&&h.includes("mapbox-gl.js")?"javascript":i.a(h)&&h.includes("mapbox-gl.css")?"css":i.b(h)?"fontRange":i.c(h)?"sprite":i.i(h)?"style":i.d(h)?"tilejson":"other"}var g,v={},_=function(){if(g)return v;function T(A){return!h(A)}function h(A){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var F,z,G=new Blob([""],{type:"text/javascript"}),J=URL.createObjectURL(G);try{z=new Worker(J),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(J),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var G=z.getImageData(0,0,1,1);return G&&G.width===F.width}()?(y[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(y[D]=function(F){var z,G=function(J){var ae=document.createElement("canvas"),le=Object.create(T.webGLContextAttributes);return le.failIfMajorPerformanceCaveat=J,ae.getContext("webgl2",le)}(F);if(!G)return!1;try{z=G.createShader(G.VERTEX_SHADER)}catch{return!1}return!(!z||G.isContextLost())&&(G.shaderSource(z,"void main() {}"),G.compileShader(z),G.getShaderParameter(z,G.COMPILE_STATUS)===!0)}(D)),y[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}g=1,v.supported=T,v.notSupportedReason=h;var y={};return T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},v}();function w(T,h,y){const A=document.createElement(T);return h!=null&&(A.className=h),y&&y.appendChild(A),A}function j(T,h,y){const A=document.createElementNS("http://www.w3.org/2000/svg",T);for(const D of Object.keys(h))A.setAttributeNS(null,D,String(h[D]));return y&&y.appendChild(A),A}const k=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=k&&k.userSelect!==void 0?"userSelect":"WebkitUserSelect";let M;function L(){k&&S&&(M=k[S],k[S]="none")}function P(){k&&S&&(k[S]=M)}function O(T){T.preventDefault(),T.stopPropagation(),window.removeEventListener("click",O,!0)}function $(){window.addEventListener("click",O,!0),window.setTimeout(()=>{window.removeEventListener("click",O,!0)},0)}function U(T,h){const y=T.getBoundingClientRect();return X(T,y,h)}function B(T,h){const y=T.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,y){return this._transformRequestFn&&this._transformRequestFn(h,y)||{url:h}}normalizeStyleURL(h,y){if(!i.h(h))return h;const A=ne(h);return A.params.push(`sdk=js-${c}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeGlyphsURL(h,y){if(!i.h(h))return h;const A=ne(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeModelURL(h,y){if(!i.h(h))return h;const A=ne(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||y)}normalizeSourceURL(h,y,A,D){if(!i.h(h))return h;const F=ne(h);return F.path=`/v4/${F.authority}.json`,F.params.push("secure"),A&&F.params.push(`language=${A}`),D&&F.params.push(`worldview=${D}`),this._makeAPIURL(F,this._customAccessToken||y)}normalizeIconsetURL(h,y){const A=ne(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||y)):re(A)}normalizeSpriteURL(h,y,A,D){const F=ne(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${y}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${y}${A}`,re(F))}normalizeTileURL(h,y,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=ne(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${y||A&&D.authority!=="raster"&&A===512?"@2x":""}${i.k.supported?".webp":"$1"}`),D.authority==="raster"?D.path=`/${i.e.RASTER_URL_PREFIX}${D.path}`:D.authority==="rasterarrays"?D.path=`/${i.e.RASTERARRAYS_URL_PREFIX}${D.path}`:D.authority==="3dtiles"?D.path=`/${i.e.TILES3D_URL_PREFIX}${D.path}`:(D.path=D.path.replace(/^.+\/v4\//,"/"),D.path=`/${i.e.TILE_URL_VERSION}${D.path}`);const F=this._customAccessToken||function(z){for(const G of z){const J=G.match(/^access_token=(.*)$/);if(J)return J[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,y){const A=ne(h);if(!A.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!A.path.match(/\.[\w]+$/))return h;let D="mapbox://";A.path.match(/^\/raster\/v1\//)?D+=`raster/${A.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:A.path.match(/^\/rasterarrays\/v1\//)?D+=`rasterarrays/${A.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:D+=`tiles/${A.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let F=A.params;return y&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,y){const A=!!y&&i.h(y),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,y){const A="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",D=ne(i.e.API_URL);if(h.protocol=D.protocol,h.authority=D.authority,h.protocol==="http"){const F=h.params.indexOf("secure");F>=0&&h.params.splice(F,1)}if(D.path!=="/"&&(h.path=`${D.path}${h.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return re(h);if(y=y||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!y)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(y[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${A}`)}return h.params=h.params.filter(F=>F.indexOf("access_token")===-1),h.params.push(`access_token=${y||""}`),re(h)}}const ce=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ne(T){const h=T.match(ce);if(!h)throw new Error("Unable to parse URL object");return{protocol:h[1],authority:h[2],path:h[3]||"/",params:h[4]?h[4].split("&"):[]}}function re(T){const h=T.params.length?`?${T.params.join("&")}`:"";return`${T.protocol}://${T.authority}${T.path}${h}`}const oe="mapbox.eventData";function fe(T){if(!T)return null;const h=T.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class ge{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const y=fe(i.e.ACCESS_TOKEN);let A="";return A=y&&y.u?i.f(y.u):i.e.ACCESS_TOKEN||"",h?`${oe}.${h}:${A}`:`${oe}:${A}`}fetchEventData(){const h=i.s("localStorage"),y=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(y);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(A);z&&(this.anonId=z);const G=localStorage.getItem(D);G&&(this.anonIdTimestamp=Number(G));const J=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(y,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,y,A,D){if(!i.e.EVENTS_URL)return;const F=ne(i.e.EVENTS_URL);F.params.push(`access_token=${D||i.e.ACCESS_TOKEN||""}`);const z={event:this.type,created:new Date(h).toISOString()},G=y?Object.assign(z,y):z,J={url:re(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([G])};this.pendingRequest=i.p(J,ae=>{this.pendingRequest=null,A(ae),this.saveEventData(),this.processRequests(D)})}queueRequest(h,y){this.queue.push(h),this.processRequests(y)}}class ue extends ge{constructor(h){super("metrics"),h&&(this.data=h)}postMetricsEvent(h){if(!i.e.EVENTS_URL||!h&&!i.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const y=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:y},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:y,payload:A}=this.queue.shift();this.postEvent(y,A,()=>{},h)}}const xe=new class extends ge{constructor(T){super("appUserTurnstile"),this._customAccessToken=T}postTurnstileEvent(T,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(T)&&T.some(y=>i.h(y)||i.j(y))&&this.queueRequest(Date.now(),h)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=fe(i.e.ACCESS_TOKEN),y=h?h.u:i.e.ACCESS_TOKEN;let A=y!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),A=!0);const D=this.queue.shift();if(this.eventData.lastSuccess){const F=new Date(this.eventData.lastSuccess),z=new Date(D),G=(D-this.eventData.lastSuccess)/864e5;A=A||G>=1||G<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Y,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=y)},T):this.processRequests()}},_e=xe.postTurnstileEvent.bind(xe),$e=new class extends ge{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(y,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:Y,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T))}remove(){this.errorCb=null}},Me=$e.postMapLoadEvent.bind($e),Ie=new class extends ge{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(T){let h=this.mapInstanceIdMap.get(T);return h||(h=i.u(),this.mapInstanceIdMap.set(T,h)),h}getEventId(T){const h=this.eventIdPerMapInstanceMap.get(T)||0;return this.eventIdPerMapInstanceMap.set(T,h+1),h}postStyleLoadEvent(T,h){const{map:y,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!T&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(y),z={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:y}=this.queue.shift();this.postEvent(h,y,()=>{},T)}},ke=Ie.postStyleLoadEvent.bind(Ie),pe=new ue({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),we=pe.postMetricsEvent.bind(pe),Le=new ue({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Qe=Le.postMetricsEvent.bind(Le),Te=new class extends ge{constructor(){super("gljs.performance")}postPerformanceEvent(T,h){i.e.EVENTS_URL&&(T||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},T)}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:y}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),G=function(Ne){const De={};if(Ne){for(const Pe in Ne)if(Pe!=="other")for(const We of Ne[Pe]){const Ve=`${Pe}ResolveRangeMin`,nt=`${Pe}ResolveRangeMax`,ut=`${Pe}RequestCount`,ot=`${Pe}RequestCachedCount`;De[Ve]=Math.min(De[Ve]||1/0,We.startTime),De[nt]=Math.max(De[nt]||-1/0,We.responseEnd);const Et=Nt=>{De[Nt]===void 0&&(De[Nt]=0),++De[Nt]};We.transferSize!==void 0&&We.transferSize===0&&Et(ot),Et(ut)}}return De}(function(Ne,De){const Pe={};if(Ne)for(const We of Ne){const Ve=De(We);Pe[Ve]===void 0&&(Pe[Ve]=[]),Pe[Ve].push(We)}return Pe}(F,f)),J=window.devicePixelRatio,ae=navigator.connection||navigator.mozConnection||navigator.webkitConnection,le=ae?ae.effectiveType:void 0,je={counters:[],metadata:[],attributes:[]},ve=(Ne,De,Pe)=>{Pe!=null&&Ne.push({name:De,value:Pe.toString()})};for(const Ne in G)ve(je.counters,Ne,G[Ne]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(ve(je.counters,"interactionRangeMin",D.interactionRange[0]),ve(je.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const Ne of Object.values(u)){const De=z.find(Pe=>Pe.name===Ne);De&&ve(je.counters,Ne,De.startTime)}return ve(je.counters,"visibilityHidden",D.visibilityHidden),ve(je.attributes,"style",function(Ne){if(Ne)for(const De of Ne){const Pe=De.name.split("?")[0];if(i.i(Pe)){const We=Pe.split("/").slice(-2);if(We.length===2)return`mapbox://styles/${We[0]}/${We[1]}`}}}(F)),ve(je.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),ve(je.attributes,"fogEnabled",D.fogEnabled?"true":"false"),ve(je.attributes,"projection",D.projection),ve(je.attributes,"zoom",D.zoom),ve(je.metadata,"devicePixelRatio",J),ve(je.metadata,"connectionEffectiveType",le),ve(je.metadata,"navigatorUserAgent",navigator.userAgent),ve(je.metadata,"screenWidth",window.screen.width),ve(je.metadata,"screenHeight",window.screen.height),ve(je.metadata,"windowWidth",window.innerWidth),ve(je.metadata,"windowHeight",window.innerHeight),ve(je.metadata,"mapWidth",D.width/J),ve(je.metadata,"mapHeight",D.height/J),ve(je.metadata,"webglRenderer",D.renderer),ve(je.metadata,"webglVendor",D.vendor),ve(je.metadata,"sdkVersion",c),ve(je.metadata,"sdkIdentifier","mapbox-gl-js"),je}(y);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},T)}},pt=Te.postPerformanceEvent.bind(Te),ye=new class extends ge{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(T,h,y,A){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const D=ne(i.e.API_URL+i.e.SESSION_PATH);D.params.push(`sku=${h||""}`),D.params.push(`access_token=${A||i.e.ACCESS_TOKEN||""}`);const F={url:re(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,y(z),this.saveEventData(),this.processRequests(A)})}getSessionAPI(T,h,y,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(y||i.e.ACCESS_TOKEN?this.queueRequest({id:T,timestamp:Date.now()},y):this.errorCb(new Error(ee)))}processRequests(T){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:y}=this.queue.shift();h&&this.success[h]||this.getSession(y,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T)}remove(){this.errorCb=null}},qe=ye.getSessionAPI.bind(ye),at=new Set;function tt(T,h){h?at.add(T):at.delete(T)}class Ae{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(h,y){this._updatedSourceCaches[h]=y,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const y=h.scope;this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._updatedLayers[y].add(h.id),this.setDirty()}removeLayer(h){const y=h.scope;this._removedLayers[y]=this._removedLayers[y]||{},this._updatedLayers[y]=this._updatedLayers[y]||new Set,this._removedLayers[y][h.id]=h,this._updatedLayers[y].delete(h.id),this._updatedPaintProps.delete(h.fqid),this.setDirty()}getRemovedLayer(h){return this._removedLayers[h.scope]?this._removedLayers[h.scope][h.id]:null}discardLayerRemoval(h){this._removedLayers[h.scope]&&delete this._removedLayers[h.scope][h.id]}getLayerUpdatesByScope(){const h={};for(const y in this._updatedLayers)h[y]=h[y]||{},h[y].updatedIds=Array.from(this._updatedLayers[y].values());for(const y in this._removedLayers)h[y]=h[y]||{},h[y].removedIds=Object.keys(this._removedLayers[y]);return h}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(h){this._updatedPaintProps.add(h.fqid),this.setDirty()}getUpdatedImages(h){return this._updatedImages[h]?Array.from(this._updatedImages[h].values()):[]}updateImage(h,y){this._updatedImages[y]=this._updatedImages[y]||new Set,this._updatedImages[y].add(i.I.toString(h)),this.setDirty()}resetUpdatedImages(h){this._updatedImages[h]&&this._updatedImages[h].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function rt(T){const{userImage:h}=T;return!!(h&&h.render&&h.render())&&(T.data.replace(new Uint8Array(h.data.buffer)),!0)}class He extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const y=this.atlasTexture.get(h);y&&(y.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,y){this.imageProviders.has(y)||this.imageProviders.set(y,new Map),this.imageProviders.get(y).set(h.id,h)}removeImageProvider(h,y){this.imageProviders.has(y)&&this.imageProviders.get(y).delete(h)}getPendingImageProviders(){const h=[];for(const y of this.imageProviders.values())for(const A of y.values())A.hasPendingRequests()&&h.push(A);return h}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new i.x),this._imageRasterizer}isLoaded(){for(const h of this.loaded.keys())if(!this.loaded.get(h))return!1;return!0}setLoaded(h,y){if(this.loaded.get(y)!==h&&(this.loaded.set(y,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,y,D);this.requestors=[]}}hasImage(h,y){return!!this.getImage(h,y)}getImage(h,y){return this.images.get(y).get(h.toString())}addImage(h,y,A){this._validate(h,A)&&this.images.get(y).set(h.toString(),A)}_validate(h,y){let A=!0;return this._validateStretch(y.stretchX,y.data&&y.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(y.stretchY,y.data&&y.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(y.content,y)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,y){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(y))}getImages(h,y,A){const D=[],F=[],z=this.imageProviders.get(y);for(const le of h){if(!le.iconsetId){D.push(le);continue}const je=z.get(le.iconsetId);je&&(this.getImage(le,y)?F.push(le):je.addPendingRequest(le))}if(D.length===0)return void this._notify(F,y,A);let G=!0;const J=!!this.loaded.get(y),ae=this.images.get(y);if(!J)for(const le of D)ae.has(le.toString())||(G=!1);J||G?this._notify(D,y,A):this.requestors.push({ids:D,scope:y,callback:A})}rasterizeImages(h,y){const A=new Map,{tasks:D,scope:F}=h;for(const[z,G]of D.entries()){const J=this.getImage(G.id,F);J&&A.set(z,{image:J,imageVariant:G})}this._rasterizeImages(F,A,y)}_rasterizeImages(h,y,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:y,scope:h},A);else{const D=new Map;for(const[F,{image:z,imageVariant:G}]of y.entries())D.set(F,this.imageRasterizer.rasterize(G,z,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,y,A){const D=this.images.get(y),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const G=D.get(z.toString());if(!G){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const J={data:G.usvg?null:G.data.clone(),pixelRatio:G.pixelRatio,sdf:G.sdf,usvg:G.usvg,version:G.version,stretchX:G.stretchX,stretchY:G.stretchY,content:G.content,hasRenderCallback:!!(G.userImage&&G.userImage.render)};G.usvg&&Object.assign(J,{width:G.icon.usvg_tree.width,height:G.icon.usvg_tree.height}),F.set(i.I.toString(z),J)}A(null,F)}getPixelSize(h){const{width:y,height:A}=this.atlasImage.get(h);return{width:y,height:A}}getPattern(h,y,A){const D=h.toString(),F=this.patterns.get(y),z=F.get(D),G=this.getImage(h,y);if(!G)return null;if(z){if(z.position.version===G.version)return z.position;z.position.version=G.version}else{if(G.usvg&&!G.data){const J=this.getPatternInFlightId(D,y);if(this.patternsInFlight.has(J))return null;this.patternsInFlight.add(J);const ae=new i.A(h).scaleSelf(i.o.devicePixelRatio),le=new Map([[ae.toString(),{image:G,imageVariant:ae}]]);return this._rasterizeImages(y,le,(je,ve)=>this.storePatternImage(ae,y,G,A,ve)),null}this.storePattern(h,y,G)}return this._updatePatternAtlas(y,A),F.get(D).position}getPatternInFlightId(h,y){return i.B(h,y)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,y,A,D,F){const z=h.toString(),G=F?F.get(z):void 0;G&&(A.data=G,this.storePattern(h.id,y,A),this._updatePatternAtlas(y,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),y)))}storePattern(h,y,A){const D={w:A.data.width+2*i.C,h:A.data.height+2*i.C,x:0,y:0},F=new i.F(D,A,i.C);this.patterns.get(y).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,y){const A=h.gl;let D=this.atlasTexture.get(y);D?this.dirty&&(D.update(this.atlasImage.get(y)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(y),A.RGBA8),this.atlasTexture.set(y,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,y){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ae})=>ae),{w:F,h:z}=i.G(D),G=this.atlasImage.get(h);G.resize({width:F||1,height:z||1});const J=this.images.get(h);for(const[ae,{bin:le,position:je}]of A.entries()){let ve=je.padding;const Ne=le.x+ve,De=le.y+ve,Pe=J.get(ae).data,We=Pe.width,Ve=Pe.height;ve=ve>1?ve-1:ve,i.q.copy(Pe,G,{x:0,y:0},{x:Ne,y:De},{width:We,height:Ve},y),i.q.copy(Pe,G,{x:0,y:Ve-ve},{x:Ne,y:De-ve},{width:We,height:ve},y),i.q.copy(Pe,G,{x:0,y:0},{x:Ne,y:De+Ve},{width:We,height:ve},y),i.q.copy(Pe,G,{x:We-ve,y:0},{x:Ne-ve,y:De},{width:ve,height:Ve},y),i.q.copy(Pe,G,{x:0,y:0},{x:Ne+We,y:De},{width:ve,height:Ve},y),i.q.copy(Pe,G,{x:We-ve,y:Ve-ve},{x:Ne-ve,y:De-ve},{width:ve,height:ve},y),i.q.copy(Pe,G,{x:0,y:Ve-ve},{x:Ne+We,y:De-ve},{width:ve,height:ve},y),i.q.copy(Pe,G,{x:0,y:0},{x:Ne+We,y:De+Ve},{width:ve,height:ve},y),i.q.copy(Pe,G,{x:We-ve,y:0},{x:Ne-ve,y:De+Ve},{width:ve,height:ve},y)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,y){const A=this.images.get(y);for(const D of h){if(this.callbackDispatchedThisFrame.get(y).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(y).add(D.toString());const F=A.get(D.toString());rt(F)&&this.updateImage(D,y,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ct(T){const h=T.value,y=T.valueSpec,A=T.style,D=T.styleSpec,F=T.key,z=T.arrayElementValidator||ur;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(y.length&&h.length!==y.length)return[new i.V(F,h,`array length ${y.length} expected, length ${h.length} found`)];if(y["min-length"]&&h.lengthD)return[new i.V(h,y,`${y} is greater than the maximum value ${D}`)]}return[]}function Ze(T){const h=T.key,y=T.value;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];const A=T.valueSpec,D=i.J(y.type);let F,z,G,J={};const ae=D!=="categorical"&&y.property===void 0,le=!ae,je=function(Pe){const We=Pe.stops;return Array.isArray(We)&&Array.isArray(We[0])&&i.H(We[0][0])}(y),ve=Jr({key:T.key,value:T.value,valueSpec:T.styleSpec.function,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{stops:function(Pe){if(D==="identity")return[new i.V(Pe.key,Pe.value,'identity function may not have a "stops" property')];let We=[];const Ve=Pe.value;return We=We.concat(ct({key:Pe.key,value:Ve,valueSpec:Pe.valueSpec,style:Pe.style,styleSpec:Pe.styleSpec,arrayElementValidator:Ne})),Array.isArray(Ve)&&Ve.length===0&&We.push(new i.V(Pe.key,Ve,"array must have at least one stop")),We},default:function(Pe){return ur({key:Pe.key,value:Pe.value,valueSpec:A,style:Pe.style,styleSpec:Pe.styleSpec})}}});return D==="identity"&&ae&&ve.push(new i.V(T.key,T.value,'missing required property "property"')),D==="identity"||y.stops||ve.push(new i.V(T.key,T.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&ve.push(new i.V(T.key,T.value,"exponential functions not supported")),T.styleSpec.$version>=8&&(le&&!i.N(A)?ve.push(new i.V(T.key,T.value,"property functions not supported")):ae&&!i.O(A)&&ve.push(new i.V(T.key,T.value,"zoom functions not supported"))),D!=="categorical"&&!je||y.property!==void 0||ve.push(new i.V(T.key,T.value,'"property" property is required')),ve;function Ne(Pe){let We=[];const Ve=Pe.value,nt=Pe.key;if(!Array.isArray(Ve))return[new i.V(nt,Ve,`array expected, ${i.K(Ve)} found`)];if(Ve.length!==2)return[new i.V(nt,Ve,`array length 2 expected, length ${Ve.length} found`)];if(je){if(!i.H(Ve[0]))return[new i.V(nt,Ve,`object expected, ${i.K(Ve[0])} found`)];const ut=Ve[0];if(ut.zoom===void 0)return[new i.V(nt,Ve,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(nt,Ve,"object stop key must have value")];const ot=i.J(ut.zoom);if(typeof ot!="number")return[new i.V(nt,ut.zoom,"stop zoom values must be numbers")];if(G&&G>ot)return[new i.V(nt,ut.zoom,"stop zoom values must appear in ascending order")];ot!==G&&(G=ot,z=void 0,J={}),We=We.concat(Jr({key:`${nt}[0]`,value:Ve[0],valueSpec:{zoom:{}},style:Pe.style,styleSpec:Pe.styleSpec,objectElementValidators:{zoom:Ue,value:De}}))}else We=We.concat(De({key:`${nt}[0]`,value:Ve[0],style:Pe.style,styleSpec:Pe.styleSpec},Ve));return i.Q(i.S(Ve[1]))?We.concat([new i.V(`${nt}[1]`,Ve[1],"expressions are not allowed in function stops.")]):We.concat(ur({key:`${nt}[1]`,value:Ve[1],valueSpec:A,style:Pe.style,styleSpec:Pe.styleSpec}))}function De(Pe,We){const Ve=i.K(Pe.value),nt=i.J(Pe.value),ut=Pe.value!==null?Pe.value:We;if(F){if(Ve!==F)return[new i.V(Pe.key,ut,`${Ve} stop domain type must match previous stop domain type ${F}`)]}else F=Ve;if(Ve!=="number"&&Ve!=="string"&&Ve!=="boolean"&&typeof nt!="number"&&typeof nt!="string"&&typeof nt!="boolean")return[new i.V(Pe.key,ut,"stop domain value must be a number, string, or boolean")];if(Ve!=="number"&&D!=="categorical"){let ot=`number expected, ${Ve} found`;return i.N(A)&&D===void 0&&(ot+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Pe.key,ut,ot)]}return D!=="categorical"||Ve!=="number"||typeof nt=="number"&&isFinite(nt)&&Math.floor(nt)===nt?D!=="categorical"&&Ve==="number"&&typeof nt=="number"&&typeof z=="number"&&z!==void 0&&ntnew i.V(`${T.key}${A.key}`,T.value,A.message));const y=h.value.expression||h.value._styleExpression.expression;if(T.expressionContext==="property"&&T.propertyKey==="text-font"&&!y.outputDefined())return[new i.V(T.key,T.value,`Invalid data expression for "${T.propertyKey}". Output values must be contained as literals within the expression.`)];if(T.expressionContext==="property"&&T.propertyType==="layout"&&!i.Z(y))return[new i.V(T.key,T.value,'"feature-state" data expressions are not supported with layout properties.')];if(T.expressionContext==="filter")return Ge(y,T);if(T.expressionContext==="appearance")return et(y,T);if(T.expressionContext&&T.expressionContext.indexOf("cluster")===0){if(!i.X(y,["zoom","feature-state"]))return[new i.V(T.key,T.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(T.expressionContext==="cluster-initial"&&!i.Y(y))return[new i.V(T.key,T.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ge(T,h){const y=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.delete(D);if(y.size===0)return[];const A=[];return T instanceof i._&&y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(T.eachChild(D=>{A.push(...Ge(D,h))}),A)}function et(T,h){const y=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)y.add(D);if(y.size===0)return[];const A=[];return T instanceof i._&&!y.has(T.name)?[new i.V(h.key,h.value,`["${T.name}"] is not an allowed parameter`)]:(T.eachChild(D=>{A.push(...et(D,h))}),A)}function it(T){const h=T.key,y=T.value,A=T.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${A.values.join(", ")}], ${JSON.stringify(y)} found`)):Object.keys(A.values).indexOf(i.J(y))===-1&&D.push(new i.V(h,y,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(y)} found`)),D}function Dt(T){return i.a2(i.S(T.value))?Je(Object.assign({},T,{expressionContext:"filter",valueSpec:T.styleSpec[`filter_${T.layerType||"fill"}`]})):Vt(T)}function Vt(T){const h=T.value,y=T.key;if(!Array.isArray(h))return[new i.V(y,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(y,h,"filter array must have at least 1 element")];const A=T.styleSpec;let D=it({key:`${y}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${y}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let z=2;z":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(y,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(y,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{ae in y&&h.push(new i.V(A,y[ae],`"${ae}" is prohibited for ref layers`))}),D.layers.forEach(ae=>{i.J(ae.id)===G&&(J=ae)}),J?J.ref?h.push(new i.V(A,y.ref,"ref cannot reference another ref layer")):z=i.J(J.type):typeof G=="string"&&h.push(new i.V(A,y.ref,`ref layer "${G}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(y.source)if(i.a0(y.source)){const J=D.sources&&D.sources[y.source],ae=J&&i.J(J.type);J?ae==="vector"&&z==="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a raster source`)):ae==="raster"&&z!=="raster"?h.push(new i.V(A,y.source,`layer "${y.id}" requires a vector source`)):ae!=="vector"||y["source-layer"]?ae==="raster-dem"&&z!=="hillshade"?h.push(new i.V(A,y.source,"raster-dem source can only be used with layer type 'hillshade'.")):ae!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&y.paint&&(y.paint["line-gradient"]||y.paint["line-trim-offset"])&&ae==="geojson"&&!J.lineMetrics?h.push(new i.V(A,y,`layer "${y.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&ae!=="raster-array"&&h.push(new i.V(A,y.source,`layer "${y.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,y.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,y,`layer "${y.id}" must specify a "source-layer"`)):h.push(new i.V(A,y.source,`source "${y.source}" not found`))}else h.push(new i.V(`${A}.source`,y.source,'"source" must be a string'));else h.push(new i.V(A,y,'missing required property "source"'));return h=h.concat(Jr({key:A,value:y,valueSpec:F.layer,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ur({key:`${A}.type`,value:y.type,valueSpec:F.layer.type,style:T.style,styleSpec:T.styleSpec,object:y,objectKey:"type"}),filter:J=>Dt(Object.assign({layerType:z},J)),layout:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ae=>Ms(Object.assign({layerType:z},ae))}}),paint:J=>Jr({layer:y,key:J.key,value:J.value,valueSpec:{},style:J.style,styleSpec:J.styleSpec,objectElementValidators:{"*":ae=>As(Object.assign({layerType:z,layer:y},ae))}}),appearances(J){const ae=ct({key:J.key,value:J.value,valueSpec:J.valueSpec,style:J.style,styleSpec:J.styleSpec,arrayElementValidator:ve=>function(Ne){const{key:De,layer:Pe,layerType:We}=Ne,Ve=i.J(Ne.value),nt=i.J(Ve.name),ut=i.J(Ve.condition),ot=Jr({key:De,value:Ve,valueSpec:Ne.styleSpec.appearance,style:Ne.style,styleSpec:Ne.styleSpec,objectElementValidators:{condition:Et=>function(Nt){const Tt=[];return Tt.push(...Je({key:Nt.key,value:Nt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),Tt}(Object.assign({layer:Pe,layerType:We},Et)),properties:Et=>function(Nt){const Tt=[],{styleSpec:jt,layer:yt,layerType:Ot}=Nt,Gt=jt[`paint_${Ot}`],Ht=jt[`layout_${Ot}`],es=Nt.object[Nt.objectKey];for(const ts in es){const gs=ts in Gt?"paint":ts in Ht?"layout":void 0;if(!gs){Tt.push(new i.V(Nt.key,ts,`unknown property "${ts}" for layer type "${Ot}"`));continue}const Us=Object.assign({},Nt,{key:`${Nt.key}.${ts}`,object:es,objectKey:ts,layer:yt,layerType:Ot,value:es[ts],valueSpec:gs==="paint"?Gt[ts]:Ht[ts]});Tt.push(...hs(Us,gs))}return Tt}(Object.assign({layer:Pe,layerType:We},Et))}});return nt!=="hidden"&&ut===void 0&&ot.push(new i.V(Ne.key,"name",'Appearance with name different than "hidden" must have a condition')),ot}(Object.assign({layerType:z,layer:y},ve))}),le=Array.isArray(J.value)?J.value:[],je=new Set;return le.forEach((ve,Ne)=>{const De=i.J(ve.name);if(De)if(je.has(De)){const Pe=i.J(y.id);ae.push(new i.V(J.key,De,`Duplicated appearance name "${De}" for layer "${Pe}"`))}else je.add(De)}),ae}}})),h}function er({key:T,value:h}){return i.a0(h)?[]:[new i.V(T,h,`string expected, ${i.K(h)} found`)]}const xt={promoteId:function T({key:h,value:y}){if(i.a0(y))return er({key:h,value:y});if(Array.isArray(y)){const D=[],F=i.S(y),z=i.U(F);return z.result==="error"&&z.value.forEach(G=>{D.push(new i.V(`${h}${G.key}`,null,`${G.message}`))}),i.X(z.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${h}`,null,"promoteId expression should be only feature dependent")),D}if(!i.H(y))return[new i.V(h,y,`string, expression or object expected, "${i.K(y)}" found`)];const A=[];for(const D in y)A.push(...T({key:`${h}.${D}`,value:y[D]}));return A}};function Ps(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(y,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(Jr({key:y,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:T.style,styleSpec:A,objectElementValidators:xt})),z;case"geojson":if(z=Jr({key:y,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:xt}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${y}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const G in h.clusterProperties){const J=h.clusterProperties[G];if(!Array.isArray(J))return[new i.V(`${y}.clusterProperties.${G}`,J,"array expected")];const[ae,le]=J,je=typeof ae=="string"?[ae,["accumulated"],["get",G]]:ae;z.push(...Je({key:`${y}.${G}.map`,value:le,expressionContext:"cluster-map"})),z.push(...Je({key:`${y}.${G}.reduce`,value:je,expressionContext:"cluster-reduce"}))}}return z;case"video":return Jr({key:y,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Jr({key:y,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(y,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return it({key:`${y}.type`,value:h.type,valueSpec:{values:mr(A)}})}}function mr(T){return T.source.reduce((h,y)=>{const A=T[y];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function Tr(T){const h=T.value,y=T.styleSpec,A=y.light,D=T.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const G=z.match(/^(.*)-transition$/),J=z.match(/^(.*)-use-theme$/);F=F.concat(J&&A[J[1]]?ur({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:y}):G&&A[G[1]]&&A[G[1]].transition?ur({key:z,value:h[z],valueSpec:y.transition,style:D,styleSpec:y}):A[z]?ur({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function Dr(T){const h=T.value;if(!h)return[];const y=T.key;if(!i.H(h))return[new i.V(y,h,`object expected, ${i.K(h)} found`)];let A=[];const D=T.styleSpec,F=D["light-3d"],z=T.style,G=T.style.lights;for(const le of["type","id"])if(!(le in h))return A=A.concat([new i.V(y,h,`missing property "${le}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${y}.type`,h.type,"string expected")]),A;if(G)for(let le=0;le[],array:ct,boolean:function(T){const h=T.value,y=T.key;return i.$(h)?[]:[new i.V(y,h,`boolean expected, ${i.K(h)} found`)]},number:Ue,color:function({key:T,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(T,h,`color expected, "${h}" found`)]:[]:[new i.V(T,h,`color expected, ${i.K(h)} found`)]},enum:it,filter:Dt,function:Ze,layer:cs,object:Jr,source:Ps,model:i.a7,light:Tr,"light-3d":Dr,terrain:xn,fog:Si,string:er,formatted:function(T){return er(T).length===0?[]:Je(T)},resolvedImage:function(T){return er(T).length===0?[]:Je(T)},projection:function(T){const h=T.value,y=T.styleSpec,A=y.projection,D=T.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(ur({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(T){const h=T.key,{value:y,styleSpec:A}=T;if(!i.H(y))return[new i.V(h,y,"import must be an object")];const{data:D,...F}=y;Object.defineProperty(F,"__line__",{value:y.__line__,enumerable:!1});let z=Jr(Object.assign({},T,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&z.push(new i.V(`${T.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(mn(D,A,{key:`${T.key}.data`}))),z},iconset:function(T){const h=T.value,y=T.key,A=T.styleSpec,D=T.style;if(!i.H(h))return[new i.V(y,h,"object expected")];if(!h.type)return[new i.V(y,h,'"type" is required')];const F=i.J(h.type);let z=[];if(z=z.concat(Jr({key:y,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(G,J){return!(G!=="source"||!J.source)}(F,h)){const G=D.sources&&D.sources[h.source],J=G&&i.J(G.type);G?J!=="raster-array"&&z.push(new i.V(y,h.source,`iconset cannot be used with a source of type ${String(J)}, it only be used with a "raster-array" source type`)):z.push(new i.V(y,h.source,`source "${h.source}" not found`))}return z}};function ur(T,h=!1){const y=T.value,A=T.valueSpec,D=T.styleSpec;if(A.expression){if(i.a4(i.J(y)))return Ze(T);if(i.Q(i.S(y)))return Je(T)}if(A.type&&Ia[A.type]){const F=Ia[A.type](T);return h===!0&&F.length>0&&Array.isArray(T.value)?Je(T):F}return Jr(Object.assign({},T,{valueSpec:A.type?D[A.type]:A}))}function Jr(T){const h=T.key,y=T.value,A=T.valueSpec||{},D=T.objectElementValidators||{},F=T.style,z=T.styleSpec;if(!i.H(y))return[new i.V(h,y,`object expected, ${i.K(y)} found`)];let G=[];for(const J in y){const ae=J.split(".")[0];let le;D[ae]?le=D[ae]:A[ae]?le=ur:D["*"]?le=D["*"]:A["*"]&&(le=ur),le?G=G.concat(le({key:(h&&`${h}.`)+J,value:y[J],valueSpec:A[ae]||A["*"],style:F,styleSpec:z,object:y,objectKey:J},y)):G.push(new i.a3(h,y[J],`unknown property "${J}"`))}for(const J in A){if(D[J])continue;const ae=A[J];ae.required&&ae.default===void 0&&y[J]===void 0&&G.push(new i.V(h,y,`missing required property "${J}"`))}return G}function Gr({key:T,value:h}){const y=er({key:T,value:h});if(y.length)return y;const A=h;return A.indexOf("{fontstack}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&y.push(new i.V(T,h,'"glyphs" url must include a "{range}" token')),y}function mn(T,h=i.a6,y={}){return Jr({key:y.key||"",value:T,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:T,objectElementValidators:{glyphs:Gr}})}function Yr(T,h=i.a6){return Be(mn(T,h))}const bi=T=>Be(Ps(T)),ft=T=>Be(Tr(T)),or=T=>Be(Dr(T)),Vn=T=>Be(xn(T)),Sr=T=>Be(Si(T)),jr=T=>Be(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(y===void 0)return[];if(!i.H(y))return[new i.V("snow",y,`object expected, ${i.K(y)} found`)];let z=[];for(const G in y){const J=G.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?ur({key:G,value:y[G],valueSpec:D.transition,style:A,styleSpec:D}):F[G]?ur({key:G,value:y[G],valueSpec:F[G],style:A,styleSpec:D}):[new i.a3(G,y[G],`unknown property "${G}"`)])}return z}(T)),ea=T=>Be(function(h){const y=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(y===void 0)return[];if(!i.H(y))return[new i.V("rain",y,`object expected, ${i.K(y)} found`)];let z=[];for(const G in y){const J=G.match(/^(.*)-transition$/);z=z.concat(J&&F[J[1]]&&F[J[1]].transition?ur({key:G,value:y[G],valueSpec:D.transition,style:A,styleSpec:D}):F[G]?ur({key:G,value:y[G],valueSpec:F[G],style:A,styleSpec:D}):[new i.a3(G,y[G],`unknown property "${G}"`)])}return z}(T)),La=T=>Be(cs(T)),Ii=T=>Be(Dt(T)),Fo=T=>Be(As(T)),$t=T=>Be(Ms(T)),Se=T=>Be(i.a7(T));function Be(T){return T.slice().sort((h,y)=>h.line&&y.line?h.line-y.line:0)}function Ye(T,h){let y=!1;if(h&&h.length)for(const A of h)A instanceof i.a3?i.w(A.message):(T.fire(new i.y(new Error(A.message))),y=!0);return y}const bt=i.a6.light;let gt;class Ft extends i.E{constructor(h,y="flat"){super(),this._transitionable=new i.a8(gt||(gt=new i.a9({anchor:new i.aa(bt.anchor),position:new i.ab(bt.position),color:new i.aa(bt.color),intensity:new i.aa(bt.intensity)}))),this.setLight(h,y),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,y,A={}){this._validate(ft,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=y)}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Ut=class extends i.E{constructor(T,h,y,A,D){super(),this.scope=y,this._transitionable=new i.a8(new i.a9({source:new i.aa(Zt.source),exaggeration:new i.aa(Zt.exaggeration)}),y,A),this._transitionable.setTransitionOrValue(T,A),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(T,h){this._transitionable.setTransitionOrValue(T,h)}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}getExaggeration(T){return this._transitioning.possiblyEvaluate(new i.ac(T,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const T=this._transitionable._values.exaggeration;if(!T)return null;const h=T.value.expression;if(!h)return null;let y=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(y=F,A=-1):A=F;return D<.01&&y>0&&A>y?[y,A]:null}isZoomDependent(){const T=this._transitionable._values.exaggeration;return T!=null&&T.value!=null&&T.value.expression!=null&&T.value.expression instanceof i.ad}};const Qt=45,Is=65,ys=.05;function vr(T,h,y,A){const D=i.ah(Qt,Is,y),[F,z]=Hr(T,A);let G=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return G*=G*G,G=Math.min(1,1.00747*G),G*D*T.alpha}function Hr(T,h){const y=.5/Math.tan(.5*h);return[T.range[0]+y,T.range[1]+y]}function xr(T,h,y,A,D){const F=i.af([],[h,y,A],D.mercatorFogMatrix);return vr(T,i.ag(F),D.pitch,D._fov)}function On(T,h,y,A,D,F,z){const G=[[y,A,0],[D,A,0],[D,F,0],[y,F,0]];let J=Number.MAX_VALUE,ae=-Number.MAX_VALUE;for(const le of G){const je=i.af([],le,h),ve=i.ag(je);J=Math.min(J,ve),ae=Math.max(ae,ve)}return[vr(T,J,z.pitch,z._fov),vr(T,ae,z.pitch,z._fov)]}const Rn=i.a6.fog;class Pn extends i.E{constructor(h,y,A,D){super();const F=new i.a9({range:new i.aa(Rn.range),color:new i.aa(Rn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Rn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Rn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Rn["horizon-blend"]),"star-intensity":new i.aa(Rn["star-intensity"]),"vertical-range":new i.aa(Rn["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=y,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,y=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:y?[i.ak(F[0],D[0],A),i.ak(F[1],D[1],A)]:D,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(h,y,A={}){if(this._validate(Sr,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(Rn))D[F]===void 0&&(D[F]=Rn[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,y)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const y=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Qt,Is,h))*y.a}getOpacityAtLatLng(h,y){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),G=F.elevation?F.elevation.getAtPointOrZero(z):0;return xr(A,z.x,z.y,G,F)}(this.state,h,y):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const y=this._transform.calculateFogTileMatrix(h.toUnwrapped());return On(this.state,y,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,y,A,D,F){return this._transform.projection.supportsFog?On(this.state,h,y,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Hr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const y=[4,5,6,7];for(const A of y){const D=h.points[A];let F;if(D[2]>=0)F=D;else{const z=h.points[A-4];F=i.am(z,D,z[2]/(z[2]-D[2]))}if(xr(this.state,F[0],F[1],0,this._transform)>=ys)return!0}return!1}updateConfig(h){this._transitionable.setTransitionOrValue(this._options,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,y,A){return(!A||A.validate!==!1)&&Ye(this,h.call(Yr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let wa,_o,cl,ni,pl=class extends i.E{constructor(T,h,y,A){super();const D=wa||(wa=new i.a9({density:new i.aa(i.a6.snow.density),intensity:new i.aa(i.a6.snow.intensity),color:new i.aa(i.a6.snow.color),opacity:new i.aa(i.a6.snow.opacity),vignette:new i.aa(i.a6.snow.vignette),"vignette-color":new i.aa(i.a6.snow["vignette-color"]),"center-thinning":new i.aa(i.a6.snow["center-thinning"]),direction:new i.aa(i.a6.snow.direction),"flake-size":new i.aa(i.a6.snow["flake-size"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),G=this.properties.get("vignette-color");return G.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:G}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(jr,T,y))return;const A=Object.assign({},T),D=i.a6.snow;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},co=class extends i.E{constructor(T,h,y,A){super();const D=_o||(_o=new i.a9({density:new i.aa(i.a6.rain.density),intensity:new i.aa(i.a6.rain.intensity),color:new i.aa(i.a6.rain.color),opacity:new i.aa(i.a6.rain.opacity),vignette:new i.aa(i.a6.rain.vignette),"vignette-color":new i.aa(i.a6.rain["vignette-color"]),"center-thinning":new i.aa(i.a6.rain["center-thinning"]),direction:new i.aa(i.a6.rain.direction),"droplet-size":new i.aa(i.a6.rain["droplet-size"]),"distortion-strength":new i.aa(i.a6.rain["distortion-strength"])}));this._transitionable=new i.a8(D,y,new Map(A)),this.set(T,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=y}get state(){const T=this.properties.get("opacity"),h=this.properties.get("color"),y=this.properties.get("direction"),A=i.an(y[0]),D=-Math.max(i.an(y[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette-color");return z.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*T),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(T,h,y={}){if(this._validate(ea,T,y))return;const A=Object.assign({},T),D=i.a6.rain;for(const F of Object.keys(D))A[F]===void 0&&(A[F]=D[F].default);this._options=A,this._transitionable.setTransitionOrValue(this._options,h)}updateConfig(T){this._transitionable.setTransitionOrValue(this._options,new Map(T))}updateTransitions(T){this._transitioning=this._transitionable.transitioned(T,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(T){this.properties=this._transitioning.possiblyEvaluate(T)}_validate(T,h,y){return(!y||y.validate!==!1)&&Ye(this,T.call(Yr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class Da extends i.E{constructor(h,y,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(y),this._transitionable=new i.a8(y,A,new Map(D)),this._transitionable.setTransitionOrValue(h.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(h){this._transitionable.setTransitionOrValue(this._options.properties,new Map(h))}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(h,y){this._options=h,this._transitionable.setTransitionOrValue(h.properties,y)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class uo{constructor(h,y,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,y){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=y.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),G=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(J=>y.isPointAboveHorizon(J))&&y.isPointAboveHorizon(G)}return new uo(A,D,y)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(h){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],h)}bufferedCameraGeometry(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>y.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=y.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const y=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(y,A,h),F=this.cameraPoint.clone();switch(3*((F.y>y.y)+(F.y>A.y))+((F.x>y.x)+(F.x>A.x))){case 0:D[0]=F,D[4]=F.clone();break;case 1:D.splice(1,0,F);break;case 2:D[1]=F;break;case 3:D.splice(4,0,F);break;case 5:D.splice(2,0,F);break;case 6:D[3]=F;break;case 7:D.splice(3,0,F);break;case 8:D[2]=F}return D}containsTile(h,y,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/y._pixelsPerMercatorPixel+1,z=A?this._bufferedCameraMercator(F,y):this._bufferedScreenMercator(F,y);let G=h.tileID.wrap+(z.unwrapped?D:0);const J=z.polygon.map(We=>i.as(h.tileTransform,We,G));if(!i.at(J,0,0,i.al,i.al))return;G=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ae=this.screenGeometryMercator.polygon.map(We=>i.au(h.tileTransform,We,G)),le=ae.map(We=>new i.P(We[0],We[1])),je=y.getFreeCameraOptions().position||new i.ae(0,0,0),ve=i.au(h.tileTransform,je,G),Ne=ae.map(We=>{const Ve=i.av(We,We,ve);return i.aw(Ve,Ve),new i.ax(ve,Ve)}),De=i.ay(h,1,y.zoom)*y._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:le,tilespaceRays:Ne,bufferedTilespaceGeometry:J,bufferedTilespaceBounds:(Pe=i.az(J),Pe.min.x=i.aA(Pe.min.x,0,i.al),Pe.min.y=i.aA(Pe.min.y,0,i.al),Pe.max.x=i.aA(Pe.max.x,0,i.al),Pe.max.y=i.aA(Pe.max.y,0,i.al),Pe),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:De};var Pe}_bufferedScreenMercator(h,y){const A=ho(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),y):{polygon:this.bufferedScreenGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,y){const A=ho(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=y.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),y):{polygon:this.bufferedCameraGeometry(h).map(F=>y.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,y){const A=function(F,z){const G=i.aB([],z.pixelMatrix,z.globeMatrix),J=[0,-i.aD,0,1],ae=[0,i.aD,0,1],le=[0,0,0,1];i.aC(J,J,G),i.aC(ae,ae,G),i.aC(le,le,G);const je=new i.P(J[0]/J[3],J[1]/J[3]),ve=new i.P(ae[0]/ae[3],ae[1]/ae[3]),Ne=i.aE(F,je)&&J[3]1?Ai(F.slice(0,We),z):[],ut=Wenew i.P(ha(Tt.x),Tt.y)),ut=ut.map(Tt=>new i.P(ha(Tt.x),Tt.y));const ot=[...nt];ot.length===0&&ot.push(ut[ut.length-1]);const Et=i.ak(ot[ot.length-1].y,(ut.length===0?nt[0]:ut[0]).y,Ve);let Nt;return Nt=Ne?[new i.P(0,Et),new i.P(0,0),new i.P(1,0),new i.P(1,Et)]:[new i.P(1,Et),new i.P(1,1),new i.P(0,1),new i.P(0,Et)],ot.push(...Nt),ut.length===0?ot.push(nt[0]):ot.push(...ut),{polygon:ot.map(Tt=>new i.ae(Tt.x,Tt.y)),unwrapped:!1}}(h,y);if(A)return A;const D=function(F,z){let G=!1,J=-1/0,ae=0;for(let je=0;jeJ&&(J=F[je].x,ae=je);for(let je=0;je.5&&(Ne.x{je.x-=1}),{polygon:F,unwrapped:G}}(Ai(h,y).map(F=>new i.P(ha(F.x),F.y)),y);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Ai(T,h){return i.aG(T,y=>{const A=h.pointCoordinate3D(y);y.x=A.x,y.y=A.y},1/256)}function ha(T){return T<0?1+T%1:T%1}function ho(T){return 100*T|0}function Tc(T,h,y,A,D){const F=function(G,J){if(G)return D(G);if(J){if(T.url&&J.tiles&&T.tiles&&delete T.tiles,J.variants){if(!Array.isArray(J.variants))return D(new Error("variants must be an array"));for(const le of J.variants){if(le==null||typeof le!="object"||le.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(le.capabilities))return D(new Error("capabilities must be an array"));if(le.capabilities.length===1&&le.capabilities[0]==="meshopt"){J=Object.assign(J,le);break}}}const ae=i.aH(Object.assign({},J,T),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ae.tiles=h.canonicalizeTileset(ae,T.url),D(null,ae)}},z=function(G,J,ae){if(!G)return null;if(!J&&!ae)return G;ae=ae||G.worldview_default;const le=Object.values(G.language||{});if(le.length===0)return null;const je=Object.values(G.worldview||{});if(je.length===0)return null;const ve=le.every(De=>De===J),Ne=je.every(De=>De===ae);return ve&&Ne?G:J in(G.language_options||{})||ae in(G.worldview_options||{})?null:G.language_options&&G.worldview_options?G:null}(T.data,y,A);return z?i.o.frame(()=>F(null,z)):T.url?i.m(h.transformRequest(h.normalizeSourceURL(T.url,null,y,A),i.R.Source),F):i.o.frame(()=>{const{data:G,...J}=T;F(null,J)})}function Wc(T,h){const y=Math.pow(2,h.z),A=Math.floor(i.aF(T.getWest())*y),D=Math.floor(i.aJ(T.getNorth())*y),F=Math.ceil(i.aF(T.getEast())*y),z=Math.ceil(i.aJ(T.getSouth())*y);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)y&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${y}`),A&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${A}`),this.fire(new i.y(D));else if(F){if(Object.assign(this,F),this.hasWorldviews=!!F.worldview_options,F.worldview_default&&(this.worldviewDefault=F.worldview_default),F.vector_layers){this.vectorLayers=F.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const z of F.vector_layers)this.vectorLayerIds.push(z.id),F.worldview&&F.worldview[z.source]&&this.localizableLayerIds.add(z.id)}this.tileBounds=cu.fromTileJSON(F),_e(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,y){const A=h.tileID.canonical.url(this.tiles,this.scheme),D=this.map._requestManager.normalizeTileURL(A),F=this.map._requestManager.transformRequest(D,i.R.Tile),z=this.map.style?this.map.style.getLut(this.scope):null,G=z?{image:z.image.clone()}:null,J={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:G,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:h.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:h.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&i.h(A)&&(J.localizableLayerIds=this.localizableLayerIds),J.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=y:h.request=h.actor.send("reloadTile",J,ae.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",J,ae.bind(this),void 0,!0);else{const le=i.aL.call({deduped:this._deduped},J,(je,ve)=>{if(je||!ve)ae.call(this,je);else{const Ne=i.aM(ve.responseHeaders);J.data={rawData:ve.rawData.slice(0),expires:Ne.expires,cacheControl:Ne.cacheControl},h.actor&&h.actor.send("loadTile",J,ae.bind(this),void 0,!0)}},!0);h.request={cancel:le}}function ae(le,je){return delete h.request,h.aborted?y(null):le&&le instanceof i.aN&&le.status!==404?y(le):(je&&je.resourceTiming&&(h.resourceTiming=je.resourceTiming),this.map._refreshExpiredTiles&&je&&h.setExpiryData(je),h.loadVectorData(je,this.map.painter),i.aO(this.dispatcher),y(null,je),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class ql extends i.E{constructor(h,y,A,D){super(),this.id=h,this.dispatcher=A,this.setEventedParent(D),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},y),Object.assign(this,i.aH(y,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const y=this.map.getWorldview();this._tileJSONRequest=Tc(this._options,this.map._requestManager,null,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?this.fire(new i.y(A)):D&&(Object.assign(this,D),D.raster_layers&&(this.rasterLayers=D.raster_layers,this.rasterLayerIds=this.rasterLayers.map(F=>F.id)),this.tileBounds=cu.fromTileJSON(D),_e(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(A)})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,y){const A=i.o.devicePixelRatio>=2,D=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),A,this.tileSize);h.request=i.n(this.map._requestManager.transformRequest(D,i.R.Tile),(F,z,G)=>{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(F)return h.state="errored",y(F);if(!z)return y(null);const J=i.aM(G);this.map._refreshExpiredTiles&&h.setExpiryData(J),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),y(null)})}abortTile(h,y){h.request&&(h.request.cancel(),delete h.request),y&&y()}unloadTile(h,y){h.texture&&h.texture instanceof i.T?(h.destroy(!1),h.texture&&h.texture instanceof i.T&&this.map.painter.saveTileTexture(h.texture)):h.destroy(),y&&y()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function uh([T,h],y,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:G,y:J,z:ae}=y;if(!isFinite(G)||!isFinite(J)||!isFinite(ae))throw new Error("Invalid MRT header");const le=2**ae,je=le*i.aF(T),ve=le*i.aJ(h);return function([Ne,De],Pe,{scaled:We=!0}={}){if(!Pe)throw new Error("bandView is undefined");const{data:Ve,tileSize:nt,buffer:ut,offset:ot,scale:Et,dimension:Nt}=Pe;if(Ne<-ut||Ne>nt+ut||De<-ut||De>nt+ut)throw new Error(`Point (${Ne}, ${De}) out of bounds for tileSize=${nt}, buffer=${ut}`);const Tt=(De+ut)*(nt+2*ut)+(Ne+ut);if(new Uint32Array(Ve.buffer)[Tt]===4294967295)return null;let jt=[];jt=We?[]:new Pe.data.constructor(Nt);for(let yt=0;yt{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(G)return G.name==="AbortError"?void 0:(h.state="errored",y(G));if(this.map._refreshExpiredTiles&&J){const le=i.aM(ae);h.setExpiryData(le)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!J)return y(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=J}y(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,y){const A=h.texturePerLayer;if(h.flushAllQueues(),A.size){h.destroy(!1);for(const D of A.values())this.map.painter.saveTileTexture(D)}else h.destroy()}prepareTile(h,y,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(y,A,D,(F,z)=>{if(F)return h.state="errored",this.fire(new i.y(F)),void this.triggerRepaint(h);z&&(h._isHeaderLoaded=!0,h.setTexturePerLayer(A,z,this.map.painter),h.state="loaded",this.triggerRepaint(h))}))}getInitialBand(h){if(!this.rasterLayers)return 0;const y=this.rasterLayers.find(({id:F})=>F===h),A=y&&y.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,y,A){if(!h)return;const D=y.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;y instanceof i.aR?F=y.paint.get("raster-array-band"):y instanceof i.aS&&(F=y.paint.get("raster-particle-array-band"));const z=F||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(y.id))return void this.prepareTile(h,D,y.id,z);if(h.updateNeeded(y.id,z)&&!A)return;const G=h.textureDescriptorPerLayer.get(y.id);return Object.assign({},G,{texture:h.texturePerLayer.get(y.id)})}getImages(h,y){const A=new Map;for(const D of h)for(const F of y){const[z,G]=F.split("/"),J=D.getLayer(z);if(!J||!J.hasBand(G)||!J.hasDataForBand(G))continue;const{bytes:ae,tileSize:le,buffer:je}=J.getBandView(G),ve=le+2*je,Ne={data:new i.q({width:ve,height:ve},ae),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,Ne)}return A}queryRasterArrayValueByBandId(h,y,A){const D=y._mrt;return new Promise(F=>{const z={},G=new Set;for(const[J,ae]of Object.entries(D.layers)){if(A.layerName&&J!==A.layerName)continue;const le={};z[J]=le;for(const{bands:je}of ae.dataIndex)for(const ve of je)A.bands&&!A.bands.includes(ve)||(G.add(i.B(J,ve)),y.fetchBand(J,null,ve,Ne=>{i.o.frame(()=>{le[ve]=Ne?null:uh([h.lng,h.lat],D,ae.getBandView(ve)),G.delete(i.B(J,ve)),G.size===0&&F(z)})},!1))}G.size===0&&F(z)})}_loadTileForQuery(h,y){if(this._loadTileLoaded[h.uid])return void y(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(y);this._loadTilePending[h.uid]=[y];const A=this.map._requestManager.normalizeTileURL(h.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),D=this.map._requestManager.transformRequest(A,i.R.Tile);h.actor.send("loadTile",{request:D,uid:h.uid,tileID:h.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(F,z,G)=>{if(F)return this._loadTilePending[h.uid].forEach(J=>J(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(J=>J(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const J=i.aM(G);h.setExpiryData(J)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(J=>J(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,y,A){return new Promise((D,F)=>{this._loadTileForQuery(y,(z,G)=>{z?F(z):D(G?this.queryRasterArrayValueByBandId(h,y,A):null)})})}queryRasterArrayValue(h,y){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?y.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,y):this.queryRasterArrayValueByAllBands(A,D,y):Promise.resolve(null)}findLoadedParent(h){const y=i.ae.fromLngLat(h,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(G[new i.aQ(T.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},G[new i.aQ(T.overscaledZ,T.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},G[new i.aQ(T.overscaledZ,z,h.z,F,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,A)this.fire(new i.y(A));else{const F={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&D&&D.resourceTiming&&D.resourceTiming[this.id]&&(F.resourceTiming=D.resourceTiming[this.id]),T&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(T),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T),this._updateWorkerData()}loadTile(T,h){const y=T.actor?"reloadTile":"loadTile";T.actor=this.actor;const A=this.map.style?this.map.style.getLut(this.scope):null,D=A?{image:A.image.clone()}:null,F=this._partialReload,z={type:this.type,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:T.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};T.request=this.actor.send(y,z,(G,J)=>F&&!J?(T.state="loaded",h(null)):(delete T.request,T.destroy(!1),T.aborted?h(null):G?h(G):(T.loadVectorData(J,this.map.painter,y==="reloadTile"),h(null))),void 0,y==="loadTile")}abortTile(T){T.request&&(T.request.cancel(),delete T.request),T.aborted=!0}unloadTile(T,h){this.actor.send("removeTile",{uid:T.uid,type:this.type,source:this.id,scope:this.scope}),T.destroy()}onRemove(T){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends i.aU{constructor(T,h,y,A){super(T,h,y,A),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const T=this.options;this.urls=[];for(const h of T.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,y)=>{this._loaded=!0,h?this.fire(new i.y(h)):y&&(this.video=y,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(T){if(this.video){const h=this.video.seekable;Th.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${h.start(0)} and ${h.end(0)}-second mark.`))):this.video.currentTime=T}}getVideo(){return this.video}onAdd(T){this.map||(this.map=T,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const T=this.map.painter.context,h=T.gl;this.texture?this.video.paused||(this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.texSubImage2D(h.TEXTURE_2D,0,0,0,h.RGBA,h.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(T,this.video,h.RGBA8),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(T)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:i.aU,model:i.aX,"batched-model":class extends i.E{constructor(T,h,y,A){super(),this.type="batched-model",this.id=T,this.tileSize=512,this._options=h,this.tiles=this._options.tiles,this.maxzoom=h.maxzoom||19,this.minzoom=h.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=y,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(A)}onAdd(T){this.map=T,this.load()}reload(){this.cancelTileJSONRequest();const T=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(T))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(T){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const h=Array.isArray(this.map._language)?this.map._language.join():this.map._language,y=this.map.getWorldview();this._tileJSONRequest=Tc(this._options,this.map._requestManager,h,y,(A,D)=>{this._tileJSONRequest=null,this._loaded=!0,A?(h&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${h}`),y&&y.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${y}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new cu(D.bounds,this.minzoom,this.maxzoom)),_e(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),T&&T(A)})}hasTransition(){return!1}hasTile(T){return!this.tileBounds||this.tileBounds.contains(T.canonical)}loaded(){return this._loaded}loadTile(T,h){const y=this.map._requestManager.normalizeTileURL(T.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(y,i.R.Tile),data:void 0,uid:T.uid,tileID:T.tileID,tileZoom:T.tileZoom,zoom:T.tileID.overscaledZ,tileSize:this.tileSize*T.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:T.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(T.actor&&T.state!=="expired")if(T.state==="loading")T.reloadCallback=h;else{if(T.buckets){const F=Object.values(T.buckets);for(const z of F)z.dirty=!0;return void(T.state="loaded")}T.request=T.actor.send("reloadTile",A,D.bind(this))}else T.actor=this.dispatcher.getActor(),T.request=T.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(F,z){return T.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&T.setExpiryData(z),T.loadModelData(z,this.map.painter),T.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(T,h,y,A){super(T,h,y,A),h.coordinates?Array.isArray(h.coordinates)&&h.coordinates.length===4&&!h.coordinates.some(D=>!Array.isArray(D)||D.length!==2||D.some(F=>typeof F!="number"))||this.fire(new i.y(new i.V(`sources.${T}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${T}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${T}`,null,'optional "animate" property must be a boolean value'))),h.canvas?typeof h.canvas=="string"||h.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${T}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.y(new i.V(`sources.${T}`,null,'missing required property "canvas"'))),this.options=h,this.animate=h.animate===void 0||h.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(T){this.map=T,this.load(),this.canvas&&this.animate&&this.play()}onRemove(T){this.pause()}prepare(){let T=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,T=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,T=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!T&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(h,this.canvas,h.gl.RGBA8,{premultiply:!0}),this._prepareData(h)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const T of[this.canvas.width,this.canvas.height])if(isNaN(T)||T<=0)return!0;return!1}},custom:class extends i.E{constructor(T,h,y,A){super(),this.id=T,this.type="custom",this._dataType="raster",this._dispatcher=y,this._implementation=h,this.setEventedParent(A),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new cu(this._implementation.bounds,this.minzoom,this.maxzoom)),h.update=this._update.bind(this),h.clearTiles=this._clearTiles.bind(this),h.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(h,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(T){this.map=T,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(T),this.load()}onRemove(T){this._implementation.onRemove&&this._implementation.onRemove(T)}hasTile(T){if(this._implementation.hasTile){const{x:h,y,z:A}=T.canonical;return this._implementation.hasTile({x:h,y,z:A})}return!this.tileBounds||this.tileBounds.contains(T.canonical)}loadTile(T,h){const{x:y,y:A,z:D}=T.tileID.canonical,F=new AbortController;T.request=Promise.resolve(this._implementation.loadTile({x:y,y:A,z:D},{signal:F.signal})).then((function(z){return delete T.request,T.aborted?(T.state="unloaded",h(null)):z===void 0?(T.state="errored",h(null)):z===null?(this.loadTileData(T,{width:this.tileSize,height:this.tileSize,data:null}),T.state="loaded",h(null)):function(G){return G instanceof ImageData||G instanceof HTMLCanvasElement||G instanceof ImageBitmap||G instanceof HTMLImageElement}(z)?(this.loadTileData(T,z),T.state="loaded",void h(null)):(T.state="errored",h(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(z=>{z.name!=="AbortError"&&(T.state="errored",h(z))}),T.request.cancel=()=>F.abort()}loadTileData(T,h){T.setTexture(h,this.map.painter)}unloadTile(T,h){if(T.texture&&T.texture instanceof i.T?(T.destroy(!1),T.texture&&T.texture instanceof i.T&&this.map.painter.saveTileTexture(T.texture)):T.destroy(),this._implementation.unloadTile){const{x:y,y:A,z:D}=T.tileID.canonical;this._implementation.unloadTile({x:y,y:A,z:D})}h&&h()}abortTile(T,h){T.request&&T.request.cancel&&(T.request.cancel(),delete T.request),h&&h()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(T=>({x:T.canonical.x,y:T.canonical.y,z:T.canonical.z}))}_clearTiles(){const T=i.B(this.id,this.scope);this.map.style.clearSource(T)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},Ul=function(T,h,y,A){const D=new Km[h.type](T,h,y,A);if(D.id!==T)throw new Error(`Expected Source id to be ${T} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function Xx(T,h,y=""){return`${y}:${h.id||""}:${h.layer.id}:${function(A){if("layerId"in A)return`layer:${A.layerId}`;{const{featuresetId:D,importId:F}=A;return`featureset:${D}${F?`:import:${F}`:""}`}}(T.target)}`}function by(T,h,y,A=""){if(T.uniqueFeatureID){const D=Xx(T,h,A);if(y.has(D))return!0;y.add(D)}return!1}function Q1(T,h,y,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(T,h.has3DLayers,D);z.sort(Dp);const G=[];for(const J of z){const ae=J.tile.queryRenderedFeatures(h,J,y,A,F,D);Object.keys(ae).length&&G.push({wrappedTileID:J.tile.tileID.wrapped().key,queryResults:ae})}for(const J in h.layers){const ae=h.layers[J];if(ae.styleLayer){const le=ae.styleLayer.queryRenderedFeatures(T,h.sourceCache,A);Object.keys(le).length&&G.push({wrappedTileID:0,queryResults:le})}}return G.length===0?{}:function(J){const ae={},le={};for(const je of J){const ve=je.queryResults,Ne=je.wrappedTileID,De=le[Ne]=le[Ne]||{};for(const Pe in ve){const We=ve[Pe],Ve=De[Pe]=De[Pe]||{},nt=ae[Pe]=ae[Pe]||[];for(const ut of We)Ve[ut.featureIndex]||(Ve[ut.featureIndex]=!0,nt.push(ut))}}return ae}(G)}function X1(T,h,y,A,D,F){const z={},G=A.queryRenderedSymbols(T),J=[];for(const ae of Object.keys(G).map(Number))J.push(D[ae]);J.sort(Dp);for(const ae of J){const le=ae.featureIndex.lookupSymbolFeatures(G[ae.bucketInstanceId],ae.bucketIndex,ae.sourceLayerIndex,h,y,F);for(const je in le){const ve=z[je]=z[je]||[],Ne=le[je];Ne.sort((De,Pe)=>{const We=ae.featureSortOrder;if(We){const Ve=We.indexOf(De.featureIndex);return We.indexOf(Pe.featureIndex)-Ve}return Pe.featureIndex-De.featureIndex});for(const De of Ne)ve.push(De)}}return z}function J1(T,h){const y=T.getRenderableIds().map(F=>T.getTileByID(F)),A=[],D={};for(let F=0;Fh.getLayer(F)).filter(Boolean);if(D.length!==0){A.layers=D,A.stateDependentLayerIds&&(A.stateDependentLayers=A.stateDependentLayerIds.map(F=>D.filter(z=>z.id===F)[0]));for(const F of D)y[F.fqid]=A}}return y}const du=32,om=33,$d=new Uint16Array(8184);for(let T=0;T<2046;T++){let h=T+2,y=0,A=0,D=0,F=0,z=0,G=0;for(1&h?D=F=z=du:y=A=G=du;(h>>=1)>1;){const ae=y+D>>1,le=A+F>>1;1&h?(D=y,F=A,y=z,A=G):(y=D,A=F,D=z,F=G),z=ae,G=le}const J=4*T;$d[J+0]=y,$d[J+1]=A,$d[J+2]=D,$d[J+3]=F}const Cd=new Uint16Array(2178),uu=new Uint8Array(1089),Ff=new Uint16Array(1089);function zf(T){return T===0?-.03125:T===32?.03125:0}const Zm={type:2,extent:i.al,loadGeometry:()=>[[new i.P(0,0),new i.P(i.al+1,0),new i.P(i.al+1,i.al+1),new i.P(0,i.al+1),new i.P(0,0)]]};class Ym{constructor(h,y,A,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=y,this.tileZoom=A,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=F,D&&D.style&&(this._lastUpdatedBrightness=D.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",D&&D.transform&&(this.projection=D.transform.projection),this.worldview=z,this._hasAppearances=null}registerFadeDuration(h){const y=h+this.timeAdded;yA)D=!1;else if(y)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,y){if(!this.latestFeatureIndex||!h.style)return;const A=h.style.listImages(),D=h.style.getBrightness();for(const F in this.buckets){if(!h.style.hasLayer(F))continue;const z=this.buckets[F],G=z.layers[0],J=G.sourceLayer||"_geojsonTileLayer",ae=h.style.getLayerSourceCache(G);let le={};ae&&(le=ae._state.getState(J,void 0));const je=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},ve=Object.keys(le).length>0&&!y;z.hasAppearances=z.layers.some(Pe=>Pe.appearances&&Pe.appearances.length>0);const Ne=ve?z.stateDependentLayers:z.layers;if(ve&&z.stateDependentLayers.length!==0||y){const Pe=this.latestFeatureIndex.loadVTLayers();z.update(le,Pe[J],A,je,Ne,y,D)}if(ve&&z.stateDependentLayers.length!==0||y||z.hasAppearances){const Pe={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,le,A,Pe)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ae&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ae.id,this.tileID);const De=h&&h.style&&h.style.getOwnLayer(F);De&&(this.queryPadding=Math.max(this.queryPadding,De.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;We--){const Ve=4*We,nt=$d[Ve+0],ut=$d[Ve+1],ot=$d[Ve+2],Et=$d[Ve+3],Nt=nt+ot>>1,Tt=ut+Et>>1,jt=Nt+Tt-ut,yt=Tt+nt-Nt,Ot=ut*om+nt,Gt=Et*om+ot,Ht=Tt*om+Nt,es=Math.hypot((Cd[2*Ot+0]+Cd[2*Gt+0])/2-Cd[2*Ht+0],(Cd[2*Ot+1]+Cd[2*Gt+1])/2-Cd[2*Ht+1])>=16;uu[Ht]=uu[Ht]||(es?1:0),We<1022&&(uu[Ht]=uu[Ht]||uu[(ut+yt>>1)*om+(nt+jt>>1)]||uu[(Et+yt>>1)*om+(ot+jt>>1)])}const je=new i.b1,ve=new i.b0;let Ne=0;function De(We,Ve){const nt=Ve*om+We;return Ff[nt]===0&&(je.emplaceBack(Cd[2*nt+0],Cd[2*nt+1],We*i.al/du,Ve*i.al/du),Ff[nt]=++Ne),Ff[nt]-1}function Pe(We,Ve,nt,ut,ot,Et){const Nt=We+nt>>1,Tt=Ve+ut>>1;if(Math.abs(We-ot)+Math.abs(Ve-Et)>1&&uu[Tt*om+Nt])Pe(ot,Et,We,Ve,Nt,Tt),Pe(nt,ut,ot,Et,Nt,Tt);else{const jt=De(We,Ve),yt=De(nt,ut),Ot=De(ot,Et);ve.emplaceBack(jt,yt,Ot)}}return Pe(0,0,du,du,du,0),Pe(du,du,0,0,0,du),{vertices:je,indices:ve}}(this.tileID.canonical,y);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:G,y:J}of A)D.emplaceBack(G,J,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let G=0;G0&&(J=i.bl(new Float64Array(16),y.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,y,z,J,G),this._makeGlobeTileDebugTextBuffer(h,D,y,z,J,G)}_globePoint(h,y,A,D,F,z,G){let J=i.bm(h,y,A);if(z){const ae=1<.5?Ne=-1:ve<-.5&&(Ne=1);let De=(h/i.al+A.x)/ae+Ne,Pe=(y/i.al+A.y)/ae;De=(De-le)*D._pixelsPerMercatorPixel+le,Pe=(Pe-je)*D._pixelsPerMercatorPixel+je;const We=[De*D.worldSize,Pe*D.worldSize,0];i.af(We,We,z),J=i.bn(J,We,G)}return i.af(J,J,F)}_makeGlobeTileDebugBorderBuffer(h,y,A,D,F,z){const G=new i.bd,J=new i.be,ae=new i.bo,le=(ve,Ne,De,Pe,We)=>{const Ve=(De-ve)/(We-1),nt=(Pe-Ne)/(We-1),ut=G.length;for(let ot=0;otje*Ne+De;for(let Ne=0;Ne{if(F)y(F);else try{const J=A.getHeaderLength(z);if(J>h)return void(this.request=this.fetchHeader(J,y));A.parseHeader(z),this._isHeaderLoaded=!0;let ae=0;for(const le of Object.values(A.layers))ae=Math.max(ae,le.dataIndex[le.dataIndex.length-1].lastByte);z.byteLength>=ae&&(this.entireBuffer=z),y(null,this.entireBuffer||z,G)}catch(J){y(J)}}),this.request}fetchBandForRender(h,y,A,D){this.fetchBand(h,y,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,y,A);const z=this.textureDescriptorPerLayer.get(y);D(null,z?z.img:null)})}fetchBand(h,y,A,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const G=this.actor;if(!G)return void D(new Error("Can't fetch tile band without an actor"));let J;const ae=i.B(String(A),i.B(this.tileID.key,h));let le=this._taskQueue.get(ae);le?le.add(D):(le=new Set,le.add(D),this._taskQueue.set(ae,le));const je=(Pe,We)=>{J.complete(Pe,We),Pe?D(Pe):(le.forEach(Ve=>Ve(null,We)),this._taskQueue.delete(ae))},ve=(Pe,We)=>{if(Pe)return D(Pe);const Ve=G.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:We,task:J},je,void 0,!0);if(y!==null){const nt=this._workQueuePerLayer.get(y)||[];nt.push(()=>{Ve&&Ve.cancel(),J.cancel()}),this._workQueuePerLayer.has(y)||this._workQueuePerLayer.set(y,nt)}};let Ne;try{Ne=z.getLayer(h)}catch(Pe){if(this.state==="reloading")return;throw Pe}if(!Ne)return void D(new Error(`Unknown sourceLayer "${h}"`));if(Ne.hasDataForBand(A))return le.forEach(Pe=>Pe(null,null)),void this._taskQueue.delete(ae);const De=Ne.getDataRange([A]);if(J=z.createDecodingTask(De),!J||J.tasks.length)if(y!==null&&this.flushQueues(y),this.entireBuffer)ve(null,this.entireBuffer.slice(De.firstByte,De.lastByte+1));else{const Pe=Object.assign({},this.requestParams,{headers:{Range:`bytes=${De.firstByte}-${De.lastByte}`}}),We=i.bu(Pe,ve);if(y!==null){const Ve=this._fetchQueuePerLayer.get(y)||[];Ve.push(()=>{We.cancel(),J.cancel()}),this._fetchQueuePerLayer.has(y)||this._fetchQueuePerLayer.set(y,Ve)}}}updateNeeded(h,y){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==y||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,y,A){if(!this._mrt)return;const D=this._mrt.getLayer(h);if(!D||!D.hasBand(A)||!D.hasDataForBand(A))return;const{bytes:F,tileSize:z,buffer:G,offset:J,scale:ae}=D.getBandView(A),le=z+2*G,je=new i.q({width:le,height:le},F),ve=this.texturePerLayer.get(y);ve&&ve instanceof i.T&&ve.update(je,{premultiply:!1}),this.textureDescriptorPerLayer.set(y,{layer:h,band:A,img:je,buffer:G,offset:J,tileSize:z,format:D.pixelFormat,mix:[ae,256*ae,65536*ae,16777216*ae]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const y of this.texturePerLayer.values())y&&y instanceof i.T&&y.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class J0{constructor(h,y){this.max=h,this.onRemove=y,this.reset()}reset(){for(const h in this.data)for(const y of this.data[h])y.timeout&&clearTimeout(y.timeout),this.onRemove(y.value);return this.data={},this.order=[],this}add(h,y,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:y,timeout:void 0};if(A!==void 0&&(F.timeout=setTimeout(()=>{this.remove(h,F)},A)),this.data[D].push(F),this.order.push(D),this.order.length>this.max){const z=this._getAndRemoveByKey(this.order[0]);z&&this.onRemove(z)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const y=this.data[h].shift();return y.timeout&&clearTimeout(y.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),y.value}getByKey(h){const y=this.data[h];return y?y[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,y){if(!this.has(h))return this;const A=h.wrapped().key,D=y===void 0?0:this.data[A].indexOf(y),F=this.data[A][D];return this.data[A].splice(D,1),F.timeout&&clearTimeout(F.timeout),this.data[A].length===0&&delete this.data[A],this.onRemove(F.value),this.order.splice(this.order.indexOf(A),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const y=this._getAndRemoveByKey(this.order[0]);y&&this.onRemove(y)}return this}filter(h){const y=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||y.push(D);for(const A of y)this.remove(A.value.tileID,A)}}class Jx{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,y,A){const D=String(y);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],A),this.deletedStates[h]===null){this.deletedStates[h]={};for(const F in this.state[h])F!==D&&(this.deletedStates[h][F]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][D]===null){this.deletedStates[h][D]={};for(const F in this.state[h][D])A[F]||(this.deletedStates[h][D][F]=null)}else for(const F in A)this.deletedStates[h]&&this.deletedStates[h][D]&&this.deletedStates[h][D][F]===null&&delete this.deletedStates[h][D][F]}removeFeatureState(h,y,A){if(this.deletedStates[h]===null)return;const D=String(y);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&y!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(y!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][D])for(A in this.deletedStates[h][D]={},this.stateChanges[h][D])this.deletedStates[h][D][A]=null;else this.deletedStates[h][D]=null;else this.deletedStates[h]=null}getState(h,y){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(y!==void 0){const G=String(y),J=Object.assign({},A[G],D[G]);if(F){const ae=F[y];if(ae===null)return{};for(const le in ae)delete J[le]}return J}const z=Object.assign({},A,D);if(F)for(const G in F)delete z[G];return z}initializeTileState(h,y){h.refreshFeatureState(y)}coalesceChanges(h,y){const A={};for(const D in this.stateChanges){this.state[D]=this.state[D]||{};const F={};for(const z in this.stateChanges[D])this.state[D][z]||(this.state[D][z]={}),Object.assign(this.state[D][z],this.stateChanges[D][z]),F[z]=this.state[D][z];A[D]=F}for(const D in this.deletedStates){this.state[D]=this.state[D]||{};const F={};if(this.deletedStates[D]===null)for(const z in this.state[D])F[z]={},this.state[D][z]={};else for(const z in this.deletedStates[D]){if(this.deletedStates[D][z]===null)this.state[D][z]={};else if(this.state[D][z])for(const G of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][G];F[z]=this.state[D][z]}A[D]=A[D]||{},Object.assign(A[D],F)}if(this.stateChanges={},this.deletedStates={},Object.keys(A).length!==0)for(const D in h)h[D].refreshFeatureState(y)}}class Pl extends i.E{constructor(h,y,A){super(),this.id=h,this._onlySymbols=A,y.on("data",D=>{D.dataType==="source"&&D.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&D.dataType==="source"&&D.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),y.on("error",()=>{this._sourceErrored=!0}),this._source=y,this._tiles={},this._cache=new J0(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=y.minTileCacheSize,this._maxTileCacheSize=y.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Jx,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(h){this.map=h,this._minTileCacheSize=this._minTileCacheSize===void 0&&h?h._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&h?h._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles)if(!this._tiles[h].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(h,y){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,y)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h)}_abortTile(h){if(this._source.abortTile)return this._source.abortTile(h)}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const y in this._tiles){const A=this._tiles[y];A.upload(h,this.map?this.map.painter:void 0),A.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(eb).map(h=>h.key)}getRenderableIds(h,y){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,y)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const z=D.tileID,G=F.tileID,J=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ae=new i.P(G.canonical.x,G.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-G.overscaledZ||ae.y-J.y||ae.x-J.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(eb).map(D=>D.key)}hasRenderableParent(h){const y=this.findLoadedParent(h,0);return!!y&&this._isIdRenderable(y.tileID.key)}_isIdRenderable(h,y,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(y||!this._tiles[h].holdingForFade())&&(A||!this._shadowCasterTiles[h])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(+h,"reloading")}}_reloadTile(h,y){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=y),this._loadTile(A,this._tileLoaded.bind(this,A,h,y)))}_tileLoaded(h,y,A,D,F){if(D){if(h.state="errored",D.status!==404)this._source.fire(new i.y(D,{tile:h}));else{if(this._source.fire(new i.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:h})),!(h.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const G=this.map.painter.terrain;this.update(this.transform,G.getScaledDemTileSize(),!0),G.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),A==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(y,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let z=new Map;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const y=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+J)===1?z+=J:Math.abs(z-J)===1&&(z-=J)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,G),D.neighboringTiles&&D.neighboringTiles[ae]&&(D.neighboringTiles[ae].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,y,A,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=y||z.tileID.overscaledZ>A)continue;let G=z.tileID;for(;z&&z.tileID.overscaledZ>y+1;){const ae=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[ae.key],z&&z.hasData()&&(G=ae)}let J=G;for(;J.overscaledZ>y;)if(J=J.scaledTo(J.overscaledZ-1),h[J.key]){D[G.key]=G;break}}}findLoadedParent(h,y){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=y?A:null}for(let A=h.overscaledZ-1;A>=y;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const y=this._tiles[h.key];return y&&y.hasData()?y:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,y){y=y||this._source.tileSize;const A=Math.ceil(h.width/y)+1,D=Math.ceil(h.height/y)+1,F=Math.floor(A*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,G=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(G)}handleWrapJump(h){const y=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,y){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+y),A[F.tileID.key]=F}this._tiles=A;for(const D in this._timers)clearTimeout(this._timers[D]),delete this._timers[D];for(const D in this._tiles)this._setTileReloadTimer(+D,this._tiles[D])}}update(h,y,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,y),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let G,J=this._source.maxzoom;const ae=this.map&&this.map.painter?this.map.painter._terrain:null;if(ae&&ae.sourceCache===this&&ae.attenuationRange()){const ve=ae.attenuationRange()[0],Ne=Math.floor(ve)-Math.log2(ae.getDemUpscale());J>Ne&&(J=Ne)}if(this.used||this.usedForTerrain){if(this._source.tileID)G=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ve=>new i.aQ(ve.canonical.z,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y));else if(this.tileCoverLift!==0){const ve=h.clone();ve.tileCoverLift=this.tileCoverLift,G=ve.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(G.push(new i.aQ(1,0,1,0,0)),G.push(new i.aQ(1,0,1,1,0)),G.push(new i.aQ(1,0,1,0,1)),G.push(new i.aQ(1,0,1,1,1)))}else if(G=h.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:J,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const ve=this._source.hasTile.bind(this._source);G=G.filter(Ne=>ve(Ne))}}else G=[];if(G.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!eg(this._source.type)){const ve=h.coveringZoomLevel({tileSize:y||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),Ne=Math.min(ve,this._source.maxzoom);if(z){const De=h.extendTileCover(G,Ne);for(const Pe of De)G.push(Pe)}else if(F){const De=h.extendTileCoverToNearPlane(G,this.transform.getFrustum(Ne),Ne);for(const Pe of De)G.push(Pe)}else if(this.castsShadows&&D){const De=h.extendTileCover(G,Ne,D,16);for(const Pe of De)this._shadowCasterTiles[Pe.key]=!0,G.push(Pe)}}const le=this._updateRetainedTiles(G);if(eg(this._source.type)&&G.length!==0){const ve={},Ne={},De=Object.keys(le);for(const We of De){const Ve=le[We],nt=this._tiles[We];if(!nt||nt.fadeEndTime&&nt.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Ve,Math.max(Ve.overscaledZ-Pl.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),ve[ut.tileID.key]=ut.tileID),Ne[We]=Ve}const Pe=G[G.length-1].overscaledZ;for(const We in this._tiles){const Ve=this._tiles[We];if(le[We]||!Ve.hasData())continue;let nt=Ve.tileID;for(;nt.overscaledZ>Pe;){nt=nt.scaledTo(nt.overscaledZ-1);const ut=this._tiles[nt.key];if(ut&&ut.hasData()&&Ne[nt.key]){le[We]=Ve.tileID;break}}}for(const We in ve)le[We]||(this._coveredTiles[We]=!0,le[We]=ve[We])}for(const ve in le)this._tiles[ve].clearFadeHold();const je=i.bv(this._tiles,le);for(const ve of je){const Ne=this._tiles[ve];Ne.hasSymbolBuckets&&!Ne.holdingForFade()?Ne.setHoldDuration(this.map._fadeDuration):Ne.hasSymbolBuckets&&!Ne.symbolFadeFinished()||this._removeTile(+ve)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(+h)}_updateRetainedTiles(h){const y={};if(h.length===0)return y;const A={},D=h.reduce((ae,le)=>Math.min(ae,le.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-Pl.maxOverzooming,this._source.minzoom),G=Math.max(F+Pl.maxUnderzooming,this._source.minzoom),J={};for(const ae of h){const le=this._addTile(ae);y[ae.key]=ae,le.hasData()||D=this._source.maxzoom){const ve=ae.children(this._source.maxzoom)[0],Ne=this.getTile(ve);if(Ne&&Ne.hasData()){y[ve.key]=ve;continue}}else{const ve=ae.children(this._source.maxzoom);if(y[ve[0].key]&&y[ve[1].key]&&y[ve[2].key]&&y[ve[3].key])continue}let je=le.wasRequested();for(let ve=ae.overscaledZ-1;ve>=z;--ve){const Ne=ae.scaledTo(ve);if(A[Ne.key]||(A[Ne.key]=!0,le=this.getTile(Ne),!le&&je&&(le=this._addTile(Ne)),le&&(y[Ne.key]=Ne,je=le.wasRequested(),le.hasData())))break}}return y}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const y=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}y.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of y)this._loadedParentTiles[F]=A}}_addTile(h){let y=this._tiles[h.key];if(y)return y.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),y;y=this._cache.getAndRemove(h),y&&(this._setTileReloadTimer(h.key,y),y.tileID=h,this._state.initializeTileState(y,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,y)));const A=!!y;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();y=this._source.type==="raster-array"?new Md(h,F,this.transform.tileZoom,D,this._isRaster):new Ym(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(y,this._tileLoaded.bind(this,y,h.key,y.state))}return y.uses++,this._tiles[h.key]=y,A||this._source.fire(new i.z("dataloading",{tile:y,coord:y.tileID,dataType:"source"})),y}_setTileReloadTimer(h,y){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=y.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const y=this._tiles[h];y&&(y.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),y.uses>0||(y.hasData()&&y.state!=="reloading"||y.state==="empty"?this._cache.add(y.tileID,y,y.getExpiryTimeout()):(y.aborted=!0,this._abortTile(y),this._unloadTile(y))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(+h);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(h,y,A){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",G=i.aF(F.center.lng);for(const J in this._tiles){const ae=this._tiles[J];if(A&&ae.clearQueryDebugViz(),ae.holdingForFade())continue;let le;if(z){const je=ae.tileID.canonical;if(je.z===0){const ve=[Math.abs(i.aA(G,...Oh(je,-1))-G),Math.abs(i.aA(G,...Oh(je,1))-G)];le=[0,2*ve.indexOf(Math.min(...ve))-1]}else{const ve=[Math.abs(i.aA(G,...Oh(je,-1))-G),Math.abs(i.aA(G,...Oh(je,0))-G),Math.abs(i.aA(G,...Oh(je,1))-G)];le=[ve.indexOf(Math.min(...ve))-1]}}else le=[0];for(const je of le){const ve=h.containsTile(ae,F,y,je);ve&&D.push(ve)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,y){const A=this.getRenderableIds(h,y).map(F=>this._tiles[F].tileID),D=this.transform.projection.name==="globe";for(const F of A)F.projMatrix=this.transform.calculateProjMatrix(F.toUnwrapped()),F.expandedProjMatrix=D?this.transform.calculateProjMatrix(F.toUnwrapped(),!1,!0):F.projMatrix;return A}sortCoordinatesByDistance(h){const y=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of y){const G=1/(1<F[z.key]-F[G.key]),y}hasTransition(){if(this._source.hasTransition())return!0;if(eg(this._source.type))for(const h in this._tiles){const y=this._tiles[h];if(y.fadeEndTime!==void 0&&y.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,y,A){this._state.updateState(h=h||"_geojsonTileLayer",y,A)}removeFeatureState(h,y,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",y,A)}getFeatureState(h,y){return this._state.getState(h=h||"_geojsonTileLayer",y)}setDependencies(h,y,A){const D=this._tiles[h];D&&D.setDependencies(y,A)}reloadTilesForDependencies(h,y){for(const A in this._tiles)this._tiles[A].hasDependency(h,y)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,y))}_preloadTiles(h,y){if(!this._sourceLoaded){const J=()=>{this._sourceLoaded&&(this._source.off("data",J),this._preloadTiles(h,y))};return void this._source.on("data",J)}const A=new Map,D=Array.isArray(h)?h:[h],F=this.map.painter.terrain,z=this.usedForTerrain&&F?F.getScaledDemTileSize():this._source.tileSize;for(const J of D){const ae=J.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const le of ae)A.set(le.key,le);this.usedForTerrain&&J.updateElevation(!1)}const G=Array.from(A.values());i.bw(G,(J,ae)=>{const le=new Ym(J,this._source.tileSize*J.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(le,je=>{this._source.type==="raster-dem"&&le.dem&&this._backfillDEM(le),ae(je,le)})},y)}}function eb(T,h){const y=Math.abs(2*T.wrap)-+(T.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return T.overscaledZ-h.overscaledZ||A-y||h.canonical.y-T.canonical.y||h.canonical.x-T.canonical.x}function eg(T){return T==="raster"||T==="image"||T==="video"||T==="custom"}function Oh(T,h){const y=1<0:A.type==="building"?D=!A.isHidden(h)&&A.paint.get("building-opacity")>0:A.type==="model"&&(D=!A.isHidden(h)&&A.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!D&&y.visible,y.visible=D}}updateZOffset(h,y){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,z=this.style.getLayerSourceCache(F);let G=1;F.type==="fill-extrusion"?G=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(G=D.visible?F.paint.get("building-vertical-scale"):0);let J=z?z.getTile(y):null;if(!J&&z)for(const ae in z._tiles){const le=z._tiles[ae];if(y.canonical.isChildOf(le.tileID.canonical)){J=le;break}}this.currentBuildingBuckets.push({bucket:J?J.getBucket(F):null,tileID:J?J.tileID:y,verticalScale:G})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(y[A]=h[A])}),y}function ev(T){T=T.slice();const h=Object.create(null);for(let y=0;y0?(D-z)/G:0;return this.points[F].mult(1-J).add(this.points[y].mult(J))}}class e2{constructor(h,y,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(y/A);for(let z=0;zthis.width||D<0||y>this.height)return!F&&[];const G=[];if(h<=0&&y<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let J=0;J0:G}_queryCircle(h,y,A,D,F){const z=h-A,G=h+A,J=y-A,ae=y+A;if(G<0||z>this.width||ae<0||J>this.height)return!D&&[];const le=[];return this._forEachCell(z,J,G,ae,this._queryCellCircle,le,{hitTest:D,circle:{x:h,y,radius:A},seenUids:{box:{},circle:{}}},F),D?le.length>0:le}query(h,y,A,D,F){return this._query(h,y,A,D,!1,F)}hitTest(h,y,A,D,F){return this._query(h,y,A,D,!0,F)}hitTestCircle(h,y,A,D){return this._queryCircle(h,y,A,!0,D)}_queryCell(h,y,A,D,F,z,G,J){const ae=G.seenUids,le=this.boxCells[F];if(le!==null){const ve=this.bboxes;for(const Ne of le)if(!ae.box[Ne]){ae.box[Ne]=!0;const De=4*Ne;if(h<=ve[De+2]&&y<=ve[De+3]&&A>=ve[De+0]&&D>=ve[De+1]&&(!J||J(this.boxKeys[Ne]))){if(G.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[Ne],x1:ve[De],y1:ve[De+1],x2:ve[De+2],y2:ve[De+3]})}}}const je=this.circleCells[F];if(je!==null){const ve=this.circles;for(const Ne of je)if(!ae.circle[Ne]){ae.circle[Ne]=!0;const De=3*Ne;if(this._circleAndRectCollide(ve[De],ve[De+1],ve[De+2],h,y,A,D)&&(!J||J(this.circleKeys[Ne]))){if(G.hitTest)return z.push(!0),!0;{const Pe=ve[De],We=ve[De+1],Ve=ve[De+2];z.push({key:this.circleKeys[Ne],x1:Pe-Ve,y1:We-Ve,x2:Pe+Ve,y2:We+Ve})}}}}}_queryCellCircle(h,y,A,D,F,z,G,J){const ae=G.circle,le=G.seenUids,je=this.boxCells[F];if(je!==null){const Ne=this.bboxes;for(const De of je)if(!le.box[De]){le.box[De]=!0;const Pe=4*De;if(this._circleAndRectCollide(ae.x,ae.y,ae.radius,Ne[Pe+0],Ne[Pe+1],Ne[Pe+2],Ne[Pe+3])&&(!J||J(this.boxKeys[De])))return z.push(!0),!0}}const ve=this.circleCells[F];if(ve!==null){const Ne=this.circles;for(const De of ve)if(!le.circle[De]){le.circle[De]=!0;const Pe=3*De;if(this._circlesCollide(Ne[Pe],Ne[Pe+1],Ne[Pe+2],ae.x,ae.y,ae.radius)&&(!J||J(this.circleKeys[De])))return z.push(!0),!0}}}_forEachCell(h,y,A,D,F,z,G,J){const ae=this._convertToXCellCoord(h),le=this._convertToYCellCoord(y),je=this._convertToXCellCoord(A),ve=this._convertToYCellCoord(D);for(let Ne=ae;Ne<=je;Ne++)for(let De=le;De<=ve;De++)if(F.call(this,h,y,A,D,this.xCellCount*De+Ne,z,G,J))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,y,A,D,F,z){const G=D-h,J=F-y,ae=A+z;return ae*ae>G*G+J*J}_circleAndRectCollide(h,y,A,D,F,z,G){const J=(z-D)/2,ae=Math.abs(h-(D+J));if(ae>J+A)return!1;const le=(G-F)/2,je=Math.abs(y-(F+le));if(je>le+A)return!1;if(ae<=J||je<=le)return!0;const ve=ae-J,Ne=je-le;return ve*ve+Ne*Ne<=A*A}}const wt={unknown:0,flipRequired:1,flipNotRequired:2},Es=Math.tan(85*Math.PI/180);function Xs(T,h,y,A,D,F,z){const G=i.bC();if(y)if(F.name==="globe"){const J=i.bD(D,h);i.aB(G,G,J)}else{const J=i.bE([],z);G[0]=J[0],G[1]=J[1],G[4]=J[2],G[5]=J[3],A||i.bB(G,G,D.angle)}else i.aB(G,D.labelPlaneMatrix,T);return G}function gn(T,h,y,A,D,F,z){const G=Xs(T,h,y,A,D,F,z);return F.name==="globe"&&y||(G[2]=G[6]=G[10]=G[14]=0),G}function yn(T,h,y,A,D,F,z){if(y){if(F.name==="globe"){const G=Xs(T,h,y,A,D,F,z);return i.bl(G,G),i.aB(G,T,G),G}{const G=i.bz(T),J=i.bA([]);return J[0]=z[0],J[1]=z[1],J[4]=z[2],J[5]=z[3],i.aB(G,G,J),A||i.bB(G,G,-D.angle),G}}return D.glCoordMatrix}function ua(T,h,y,A){const D=[T,h,y,1];y?i.aC(D,D,A):$r(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Ur(T,h){return Math.min(.5+T/h*.5,1.5)}function mo(T,h){const y=T[0]/T[3],A=T[1]/T[3];return y>=-h[0]&&y<=h[0]&&A>=-h[1]&&A<=h[1]}function tg(T,h,y,A,D,F,z,G,J,ae,le=1){const je=y.transform,ve=A?T.textSizeData:T.iconSizeData,Ne=i.bK(ve,y.transform.zoom,le),De=je.projection.name==="globe",Pe=[256/y.width*2+1,256/y.height*2+1],We=A?T.text.dynamicLayoutVertexArray:T.icon.dynamicLayoutVertexArray;We.clear();let Ve=null;De&&(Ve=A?T.text.globeExtVertexArray:T.icon.globeExtVertexArray);const nt=T.lineVertexArray,ut=A?T.text.placedSymbolArray:T.icon.placedSymbolArray,ot=y.transform.width/y.transform.height;let Et,Nt=!1;for(let Tt=0;TtMath.abs(y)?{useVertical:!0}:T===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==wt.unknown&&function(D,F){return D===0||Math.abs(F/D)>Es}(y,A)?h===wt.flipRequired?{needsFlipping:!0}:null:y<0?{needsFlipping:!0}:null}function rv(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve,nt,ut){const ot=h/24,Et=T.lineOffsetX*ot,Nt=T.lineOffsetY*ot,{lineStartIndex:Tt,glyphStartIndex:jt,numGlyphs:yt,segment:Ot,writingMode:Gt,flipState:Ht}=T,es=Tt+T.lineLength,ts=gs=>{if(le){const[as,Jt,Ls]=gs.up,rr=ae.length;i.bN(le,rr+0,as,Jt,Ls),i.bN(le,rr+1,as,Jt,Ls),i.bN(le,rr+2,as,Jt,Ls),i.bN(le,rr+3,as,Jt,Ls)}const[Us,Yt,Bt]=gs.point;i.bO(ae,Us,Yt,Bt,gs.angle)};if(yt>1){const gs=Op(ot,G,Et,Nt,y,je,ve,T,J,F,Ne,Pe,!1,We,Ve,nt,ut);if(!gs)return{notEnoughRoom:!0};if(A&&!y){let[Us,Yt,Bt]=gs.first.point,[as,Jt,Ls]=gs.last.point;[Us,Yt]=ua(Us,Yt,Bt,z),[as,Jt]=ua(as,Jt,Ls,z);const rr=Zr(Gt,Ht,(as-Us)*De,Jt-Yt);if(T.flipState=rr&&rr.needsFlipping?wt.flipRequired:wt.flipNotRequired,rr)return rr}ts(gs.first);for(let Us=jt+1;Us0?as:Xm(ve,Bt,Us,1,D,void 0,We,Ve.canonical),Ls=Zr(Gt,Ht,(Jt[0]-Us[0])*De,Jt[1]-Us[1]);if(T.flipState=Ls&&Ls.needsFlipping?wt.flipRequired:wt.flipNotRequired,Ls)return Ls}const gs=sb(ot*G.getoffsetX(jt),Et,Nt,y,je,ve,Ot,Tt,es,J,F,Ne,Pe,!1,!1,We,Ve,nt,ut);if(!gs)return{notEnoughRoom:!0};ts(gs)}return{}}function nv(T,h,y,A,D){const{x:F,y:z,z:G}=A.projectTilePoint(T.x,T.y,h);if(!D)return ua(F,z,G,y);const[J,ae,le]=D.getElevation(T,D.elevation,D.elevationFeature);return ua(F+J,z+ae,G+le,y)}function Xm(T,h,y,A,D,F,z,G){const J=nv(T.sub(h)._unit()._add(T),G,D,z,F);return i.av(J,y,J),i.aw(J,J),i.bH(J,y,J,A)}function sb(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve,nt){const ut=A?T-h:T+h;let ot=ut>0?1:-1,Et=0;A&&(ot*=-1,Et=Math.PI),ot<0&&(Et+=Math.PI);let Nt=G+z+(ot>0?0:1)|0,Tt=D,jt=D,yt=0,Ot=0;const Gt=Math.abs(ut),Ht=[],es=[];let ts=F,gs=ts,Us=i.bF([]);const Yt=()=>Xm(gs,ts,jt,Gt-yt+1,le,ve,Pe,We.canonical);for(;yt+Ot<=Gt;){if(Nt+=ot,Nt=J)return null;if(jt=Tt,gs=ts,Ht.push(jt),Ne&&es.push(gs),ts=new i.P(ae.getx(Nt),ae.gety(Nt)),Tt=je[Nt],!Tt){const Cr=nv(ts,We.canonical,le,Pe,ve);Tt=Cr[3]>0?je[Nt]=Cr:Yt()}yt+=Ot;const Vs=i.av([],Tt,jt),Ir=i.bG(jt,Tt);if(y&&Ir>0&&Ot>0&&i.bJ(Us,Vs)/(Ot*Ir)0,ut),Tt=ae*Nt.perspectiveRatio,jt=(A.x1*y+G.x-A.padding)*Tt+Nt.point.x,yt=(A.y1*y+G.y-A.padding)*Tt+Nt.point.y,Ot=(A.x2*y+G.x+A.padding)*Tt+Nt.point.x,Gt=(A.y2*y+G.y+A.padding)*Tt+Nt.point.y,Ht=Nt.perspectiveRatio<=.55||Nt.occluded;return!this.isInsideGrid(jt,yt,Ot,Gt)||!J&&this.grid.hitTest(jt,yt,Ot,Gt,je)||Ht?{box:[],offscreen:!1,occluded:Nt.occluded}:{box:[jt,yt,Ot,Gt],offscreen:this.isOffscreen(jt,yt,Ot,Gt),occluded:!1}}placeCollisionCircles(h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We){const Ve=[],nt=this.transform.elevation,ut=h.getProjection(),ot=h.elevationType==="road",Et=!!nt||ot,Nt=i.bV.getAtTileOffsetFunc(We,this.transform.center.lat,this.transform.worldSize,ut),Tt=new i.P(A.tileAnchorX,A.tileAnchorY),jt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:yt,y:Ot,z:Gt}=ut.projectTilePoint(jt.x,jt.y,We.canonical),Ht=null;if(Et){const Ir=ot?h.getElevationFeatureForText(D):null;Ht={getElevation:Nt,elevation:nt,elevationFeature:Ir};const[Cr,pr,br]=Nt(Tt,nt,Ir);yt+=Cr,Ot+=pr,Gt+=br}const es=ut.name==="globe",ts=this.projectAndGetPerspectiveRatio(J,yt,Ot,Gt,We,es||!!nt||this.transform.pitch>0,ut),{perspectiveRatio:gs}=ts,Us=(ve?G/gs:G*gs)/i.bY,Yt=ua(yt,Ot,Gt,ae),Bt=A.lineOffsetX*Us,as=A.lineOffsetY*Us,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Ls=Math.cos(Jt),rr=ts.signedDistanceFromCamera>0?Op(Us,z,Bt,as,ot&&A.flipState===1,Yt,jt,A,F,ae,{},Et&&!ve?Ht:null,ve&&Et,ut,We,ve,Ls):null;let yr=!1,Js=!1,Vs=!0;if(rr&&!ts.occluded){const Ir=.5*De*gs+Pe,Cr=new i.P(-100,-100),pr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),br=new wy,{first:Kr,last:In}=rr,ja=Kr.path.length;let ai=[];for(let Tn=ja-1;Tn>=1;Tn--)ai.push(Kr.path[Tn]);for(let Tn=1;Tn(Et&&!es&&(Mi=Nt(_iTn[3]<=0)&&(ai=[]));let Xa=[];if(ai.length>0){let Tn=1/0,ui=-1/0,Mi=1/0,_i=-1/0;for(const Za of ai)Tn=Math.min(Tn,Za[0]),Mi=Math.min(Mi,Za[1]),ui=Math.max(ui,Za[0]),_i=Math.max(_i,Za[1]);ui>=Cr.x&&Tn<=pr.x&&_i>=Cr.y&&Mi<=pr.y&&(Xa=[ai.map(Za=>new i.P(Za[0],Za[1]))],(Tnpr.x||Mipr.y)&&(Xa=i.bW(Xa,Cr.x,Cr.y,pr.x,pr.y)))}for(const Tn of Xa){br.reset(Tn,.25*Ir);let ui=0;ui=br.length<=.5*Ir?1:Math.ceil(br.paddedLength/Rr)+1;for(let Mi=0;Mi0?(i.aC(J,J,h),this.fogState&&F&&G.name!=="globe"&&(ae=function(ve,Ne,De,Pe,We,Ve){const nt=Ve.calculateFogTileMatrix(We),ut=[Ne,De,Pe];return i.af(ut,ut,nt),vr(ve,i.ag(ut),Ve.pitch,Ve._fov)}(this.fogState,y,A,D,F.toUnwrapped(),this.transform)>.9)):$r(J,J,h);const le=J[3];return{point:new i.P((J[0]/le+1)/2*this.transform.width+Ra,(-J[1]/le+1)/2*this.transform.height+Ra),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(G)/le*.5,1.5),signedDistanceFromCamera:le,occluded:z&&J[2]>le||ae}}isOffscreen(h,y,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,y,A,D){return A>=0&&h=0&&yA.collisionGroupID===y}}return this.collisionGroups[h]}}function qd(T,h,y,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(T),G=-(F-.5)*h,J=-(z-.5)*y,ae=i.c2(T,A);return new i.P(G+ae[0]*D,J+ae[1]*D)}function jl(T,h,y,A,D){const F=new i.P(T,h);return y&&F._rotate(A?D:-D),F}class Ome{constructor(h,y,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new Ci(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=y,this.retainedQueryData={},this.collisionGroups=new s2(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,y,A,D,F=1){const z=A.getBucket(y),G=A.latestFeatureIndex;if(!z||!G||y.fqid!==z.layerIds[0])return;const J=z.layers[0].layout,ae=z.layers[0].paint,le=A.collisionBoxArray,je=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),ve=A.tileSize/i.al,Ne=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const De=(Pe=A.tileID,We=z.getProjection(),Ve=this.transform,We.name===this.projection?Ve.calculateProjMatrix(Pe.toUnwrapped()):Jw(Ve,We,Pe));var Pe,We,Ve;const nt=J.get("text-pitch-alignment")==="map",ut=J.get("text-rotation-alignment")==="map";y.compileFilter(y.options);const ot=y.dynamicFilter(),Et=y.dynamicFilterNeedsFeature(),Nt=this.transform.calculatePixelsToTileUnitsMatrix(A),Tt=gn(De,A.tileID.canonical,nt,ut,this.transform,z.getProjection(),Nt);let jt=null;const yt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(nt){const Bt=yn(De,A.tileID.canonical,nt,ut,this.transform,z.getProjection(),Nt);jt=i.aB([],this.transform.labelPlaneMatrix,Bt)}let Ot=null;ot&&A.latestFeatureIndex&&(Ot={unwrappedTileID:Ne,dynamicFilter:ot,dynamicFilterNeedsFeature:Et}),this.retainedQueryData[z.bucketInstanceId]=new t2(z.bucketInstanceId,G,z.sourceLayerIndex,z.index,A.tileID);const[Gt,Ht]=z.layers[0].layout.get("text-size-scale-range"),es=i.aA(F,Gt,Ht),[ts,gs]=J.get("icon-size-scale-range"),Us=i.aA(F,ts,gs),Yt={bucket:z,layout:J,paint:ae,posMatrix:De,invMatrix:yt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:Tt,labelToScreenMatrix:jt,clippingData:Ot,scale:je,textPixelRatio:ve,holdingForFade:A.holdingForFade(),collisionBoxArray:le,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,es),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,Us),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const Bt of z.sortKeyRanges){const{sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Ls}=Bt;h.push({sortKey:as,symbolInstanceStart:Jt,symbolInstanceEnd:Ls,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve,nt,ut,ot,Et){const{textOffset0:Nt,textOffset1:Tt,crossTileID:jt}=Pe,yt=[Nt,Tt],Ot=qd(h,z,G,yt,J),Gt=this.collisionIndex.placeCollisionBox(Ve,J,y,A,D,F,jl(Ot.x,Ot.y,ae,le,this.transform.angle),De,je,ve,Ne.predicate);if(ut){const Ht=Ve.getSymbolInstanceIconSize(Et,this.transform.zoom,Pe.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Ve,Ht,ut,A,D,F,jl(Ot.x,Ot.y,ae,le,this.transform.angle),De,je,ve,Ne.predicate).box.length===0)return}if(Gt.box.length>0){let Ht;return this.prevPlacement&&this.prevPlacement.variableOffsets[jt]&&this.prevPlacement.placements[jt]&&this.prevPlacement.placements[jt].text&&(Ht=this.prevPlacement.variableOffsets[jt].anchor),this.variableOffsets[jt]={textOffset:yt,width:z,height:G,anchor:h,textScale:J,prevAnchor:Ht},this.markUsedJustification(Ve,h,Pe,nt),Ve.allowVerticalPlacement&&(this.markUsedOrientation(Ve,nt,Pe),this.placedOrientations[jt]=nt),{shift:Ot,placedGlyphBoxes:Gt}}}placeLayerBucketPart(h,y,A,D,F=1){const{bucket:z,layout:G,paint:J,posMatrix:ae,textLabelPlaneMatrix:le,labelToScreenMatrix:je,clippingData:ve,textPixelRatio:Ne,mercatorCenter:De,invMatrix:Pe,holdingForFade:We,collisionBoxArray:Ve,partiallyEvaluatedTextSize:nt,partiallyEvaluatedIconSize:ut,collisionGroup:ot,latestFeatureIndex:Et}=h.parameters,Nt=G.get("text-optional"),Tt=G.get("icon-optional"),jt=G.get("text-allow-overlap"),yt=G.get("icon-allow-overlap"),Ot=G.get("text-rotation-alignment")==="map",Gt=G.get("icon-rotation-alignment")==="map",Ht=G.get("text-pitch-alignment")==="map",es=J.get("symbol-z-offset"),ts=G.get("symbol-elevation-reference")==="sea",gs=G.get("symbol-placement"),[Us,Yt]=G.get("text-size-scale-range"),[Bt,as]=G.get("icon-size-scale-range"),Jt=i.aA(F,Us,Yt),Ls=i.aA(F,Bt,as),rr=G.get("text-variable-anchor"),yr=Ot&&gs!=="point",Js=Gt&&gs!=="point",Vs=rr&&z.hasTextData(),Ir=z.hasIconTextFit()&&Vs&&z.hasIconData();this.transform.setProjection(z.projection);const Cr=Vs||yr,pr=Js||Ir;let br=jt&&(yt||!z.hasIconData()||Tt),Kr=yt&&(jt||!z.hasTextData()||Nt);const In=!es.isConstant();!z.collisionArrays&&Ve&&z.deserializeCollisionBoxes(Ve),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Ve,Jt,Ls);const ja=(Rr,Xa,Tn)=>{const{crossTileID:ui,numVerticalGlyphVertices:Mi}=Rr;let _i=null;if(ve&&ve.dynamicFilterNeedsFeature||In){const Lo=this.retainedQueryData[z.bucketInstanceId];_i=Et.loadFeature({featureIndex:Rr.featureIndex,bucketIndex:Lo.bucketIndex,sourceLayerIndex:Lo.sourceLayerIndex,layoutVertexArrayOffset:0});const tl=_i.properties?_i.properties.worldview:null;if(z.localizable&&z.worldview&&typeof tl=="string")if(tl==="all")_i.properties.$localized=!0;else{if(!tl.split(",").includes(z.worldview))return;_i.properties.$localized=!0,_i.properties.worldview=z.worldview}}if(ve&&!(0,ve.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},_i,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Rr.tileAnchorX,Rr.tileAnchorY),this.transform.calculateDistanceTileData(ve.unwrappedTileID)))return this.placements[ui]=new fi(!1,!1,!1,!0),void y.add(ui);const Za=es.evaluate(_i,{});if(y.has(ui))return;if(We)return void(this.placements[ui]=new fi(!1,!1,!1));let Gn=!1,li=!1,Co=!0,no=!1,hi=!1,$a=null,Wn={box:null,offscreen:null,occluded:null},Xi={box:null},Ho=null,jo=null,Di=null,qu=0,Td=0,Gl=0;Tn.textFeatureIndex?qu=Tn.textFeatureIndex:Rr.useRuntimeCollisionCircles&&(qu=Rr.featureIndex),Tn.verticalTextFeatureIndex&&(Td=Tn.verticalTextFeatureIndex);const Vd=z.elevationFeatures?z.elevationFeatures[Rr.elevationFeatureIndex]:void 0,Hd=Lo=>{Lo.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const tl=this.transform.elevation;Lo.elevation=ts?Za:Za+i.bV.getAtTileOffset(Lo.tileID,new i.P(Lo.tileAnchorX,Lo.tileAnchorY),tl,Vd),Lo.elevation+=Rr.zOffset},ld=Tn.textBox;if(ld){Hd(ld);const Lo=Oi=>{let fl=i.bL.horizontal;if(z.allowVerticalPlacement&&!Oi&&this.prevPlacement){const Mo=this.prevPlacement.placedOrientations[ui];Mo&&(this.placedOrientations[ui]=Mo,fl=Mo,this.markUsedOrientation(z,fl,Rr))}return fl},tl=(Oi,fl)=>{if(z.allowVerticalPlacement&&Mi>0&&Tn.verticalTextBox){for(const Mo of z.writingModes)if(Mo===i.bL.vertical?(Wn=fl(),Xi=Wn):Wn=Oi(),Wn&&Wn.box&&Wn.box.length)break}else Wn=Oi()};if(rr){let Oi=rr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[ui]){const No=this.prevPlacement.variableOffsets[ui];Oi.indexOf(No.anchor)>0&&(Oi=Oi.filter(ip=>ip!==No.anchor),Oi.unshift(No.anchor))}const fl=(No,ip,A2)=>{const Up=z.getSymbolInstanceTextSize(nt,Rr,this.transform.zoom,Xa),E2=(No.x2-No.x1)*Up+2*No.padding,Sb=(No.y2-No.y1)*Up+2*No.padding,Zf=Rr.hasIconTextFit&&!yt?ip:null;Zf&&Hd(Zf);let fg={box:[],offscreen:!1,occluded:!1};const Cb=jt?2*Oi.length:Oi.length;for(let Fy=0;Fy=Oi.length,Rr,Xa,z,A2,Zf,nt,ut);if(xg&&(fg=xg.placedGlyphBoxes,fg&&fg.box&&fg.box.length)){Gn=!0,$a=xg.shift;break}}return fg};tl(()=>fl(ld,Tn.iconBox,i.bL.horizontal),()=>{const No=Tn.verticalTextBox;return No&&Hd(No),z.allowVerticalPlacement&&!(Wn&&Wn.box&&Wn.box.length)&&Mi>0&&No?fl(No,Tn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Wn&&(Gn=Wn.box,Co=Wn.offscreen,no=Wn.occluded);const Mo=Lo(!(!Wn||!Wn.box));if(!Gn&&this.prevPlacement){const No=this.prevPlacement.variableOffsets[ui];No&&(this.variableOffsets[ui]=No,this.markUsedJustification(z,No.anchor,Rr,Mo))}}else{const Oi=(fl,Mo)=>{const No=z.getSymbolInstanceTextSize(nt,Rr,this.transform.zoom,Xa),ip=this.collisionIndex.placeCollisionBox(z,No,fl,De,Pe,Cr,new i.P(0,0),jt,Ne,ae,ot.predicate);return ip&&ip.box&&ip.box.length&&(this.markUsedOrientation(z,Mo,Rr),this.placedOrientations[ui]=Mo),ip};tl(()=>Oi(ld,i.bL.horizontal),()=>{const fl=Tn.verticalTextBox;return z.allowVerticalPlacement&&Mi>0&&fl?(Hd(fl),Oi(fl,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),Lo(!!(Wn&&Wn.box&&Wn.box.length))}}if(Ho=Wn,Gn=Ho&&Ho.box&&Ho.box.length>0,Co=Ho&&Ho.offscreen,no=Ho&&Ho.occluded,Rr.useRuntimeCollisionCircles){const Lo=Rr.centerJustifiedTextSymbolIndex>=0?Rr.centerJustifiedTextSymbolIndex:Rr.verticalPlacedTextSymbolIndex,tl=z.text.placedSymbolArray.get(Lo),Oi=i.bM(z.textSizeData,nt,tl),fl=G.get("text-padding");jo=this.collisionIndex.placeCollisionCircles(z,jt,tl,Lo,z.lineVertexArray,z.glyphOffsetArray,Oi,ae,le,je,A,Ht,ot.predicate,Rr.collisionCircleDiameter*Oi/i.bY,fl,this.retainedQueryData[z.bucketInstanceId].tileID),Gn=jt||jo.circles.length>0&&!jo.collisionDetected,Co=Co&&jo.offscreen,no=jo.occluded}if(Tn.iconFeatureIndex&&(Gl=Tn.iconFeatureIndex),Tn.iconBox){const Lo=tl=>{Hd(tl);const Oi=Rr.hasIconTextFit&&$a?jl($a.x,$a.y,Ot,Ht,this.transform.angle):new i.P(0,0),fl=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Rr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,fl,tl,De,Pe,pr,Oi,yt,Ne,ae,ot.predicate)};Xi&&Xi.box&&Xi.box.length&&Tn.verticalIconBox?(Di=Lo(Tn.verticalIconBox),li=Di.box.length>0):(Di=Lo(Tn.iconBox),li=Di.box.length>0),Co=Co&&Di.offscreen,hi=Di.occluded}const mm=Nt||Rr.numHorizontalGlyphVertices===0&&Mi===0,ap=Tt||Rr.numIconVertices===0;if(mm||ap?ap?mm||(li=li&&Gn):Gn=li&&Gn:li=Gn=li&&Gn,Gn&&Ho&&Ho.box&&this.collisionIndex.insertCollisionBox(Ho.box,G.get("text-ignore-placement"),z.bucketInstanceId,Xi&&Xi.box&&Td?Td:qu,ot.ID),li&&Di&&this.collisionIndex.insertCollisionBox(Di.box,G.get("icon-ignore-placement"),z.bucketInstanceId,Gl,ot.ID),jo&&(Gn&&this.collisionIndex.insertCollisionCircles(jo.circles,G.get("text-ignore-placement"),z.bucketInstanceId,qu,ot.ID),A)){const Lo=z.bucketInstanceId;let tl=this.collisionCircleArrays[Lo];tl===void 0&&(tl=this.collisionCircleArrays[Lo]=new q3);for(let Oi=0;Oi=0;--Xa){const Tn=Rr[Xa];ja(z.symbolInstances.get(Tn),Tn,z.collisionArrays[Tn])}z.hasAnyZOffset&&i.w(`${z.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(z.hasAnyZOffset){const Rr=z.getSortedIndexesByZOffset();for(let Xa=0;Xa=0&&(h.text.placedSymbolArray.get(F).crossTileID=je>=0&&F!==je?0:ae),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=je>=0&&z!==je?0:ae),G>=0&&(h.text.placedSymbolArray.get(G).crossTileID=je>=0&&G!==je?0:ae),J>=0&&(h.text.placedSymbolArray.get(J).crossTileID=je>=0&&J!==je?0:ae)}markUsedOrientation(h,y,A){const D=y===i.bL.horizontal||y===i.bL.horizontalOnly?y:0,F=y===i.bL.vertical?y:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:G,rightJustifiedTextSymbolIndex:J,verticalPlacedTextSymbolIndex:ae}=A,le=h.text.placedSymbolArray;z>=0&&(le.get(z).placedOrientation=D),G>=0&&(le.get(G).placedOrientation=D),J>=0&&(le.get(J).placedOrientation=D),ae>=0&&(le.get(ae).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const y=this.prevPlacement;let A=!1;this.prevZoomAdjustment=y?y.zoomAdjustment(this.transform.zoom):0;const D=y?y.symbolFadeChange(h):1,F=y?y.opacities:{},z=y?y.variableOffsets:{},G=y?y.placedOrientations:{};for(const J in this.placements){const ae=this.placements[J],le=F[J];le?(this.opacities[J]=new Bf(le,D,ae.text,ae.icon,null,ae.clipped),A=A||ae.text!==le.text.placed||ae.icon!==le.icon.placed):(this.opacities[J]=new Bf(null,D,ae.text,ae.icon,ae.skipFade,ae.clipped),A=A||ae.text||ae.icon)}for(const J in F){const ae=F[J];if(!this.opacities[J]){const le=new Bf(ae,D,!1,!1);le.isHidden()||(this.opacities[J]=le,A=A||ae.text.placed||ae.icon.placed)}}for(const J in z)this.variableOffsets[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.variableOffsets[J]=z[J]);for(const J in G)this.placedOrientations[J]||!this.opacities[J]||this.opacities[J].isHidden()||(this.placedOrientations[J]=G[J]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=y?y.lastPlacementChangeTime:h)}updateLayerOpacities(h,y,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of y){const G=z.getBucket(h);G&&z.latestFeatureIndex&&h.fqid===G.layerIds[0]&&(this.updateBucketOpacities(G,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),G.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(G,z.tileID),G.elevationType==="road"&&G.updateRoadElevation(z.tileID.canonical),G.updateZOffset())}}updateBucketOpacities(h,y,A,D,F,z,G,J){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const ae=h.layers[0].layout,le=h.layers[0].paint,je=!!h.layers[0].dynamicFilter(),ve=new Bf(null,0,!1,!1,!0),Ne=ae.get("text-allow-overlap"),De=ae.get("icon-allow-overlap"),Pe=ae.get("text-variable-anchor"),We=ae.get("text-rotation-alignment")==="map",Ve=ae.get("text-pitch-alignment")==="map",nt=le.get("symbol-z-offset"),ut=ae.get("symbol-elevation-reference")==="sea",ot=!nt.isConstant(),Et=new Bf(null,0,Ne&&(De||!h.hasIconData()||ae.get("icon-optional")),De&&(Ne||!h.hasTextData()||ae.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const Nt=(jt,yt,Ot)=>{for(let Gt=0;Gt0||Gt>0,rr=es>0,yr=this.placedOrientations[Ht],Js=yr===i.bL.vertical,Vs=yr===i.bL.horizontal||yr===i.bL.horizontalOnly;!Ls&&!rr||Jt.isHidden()||Tt++;let Ir=!1;if((Ls||rr)&&z)for(const Cr of h.activeReplacements){if(i.bZ(Cr,F,i.b_.Symbol,J)||Cr.min.x>ts||ts>Cr.max.x||Cr.min.y>gs||gs>Cr.max.y)continue;const pr=i.b$(ts,gs,G.canonical,Cr.footprintTileId.canonical);if(Ir=i.c0(pr,Cr.footprint),Ir)break}if(Ls){const Cr=Ir?av:Fu(Jt.text);Nt(h.text,Ot,Js?av:Cr),Nt(h.text,Gt,Vs?av:Cr);const pr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:br,centerJustifiedTextSymbolIndex:Kr,rightJustifiedTextSymbolIndex:In,verticalPlacedTextSymbolIndex:ja}=yt,ai=h.text.placedSymbolArray,Rr=pr||Js?1:0;br>=0&&(ai.get(br).hidden=Rr),Kr>=0&&(ai.get(Kr).hidden=Rr),In>=0&&(ai.get(In).hidden=Rr),ja>=0&&(ai.get(ja).hidden=pr||Vs?1:0);const Xa=this.variableOffsets[Ht];Xa&&this.markUsedJustification(h,Xa.anchor,yt,yr);const Tn=this.placedOrientations[Ht];Tn&&(this.markUsedJustification(h,"left",yt,Tn),this.markUsedOrientation(h,Tn,yt))}if(rr){const Cr=Ir?av:Fu(Jt.icon),{placedIconSymbolIndex:pr,verticalPlacedIconSymbolIndex:br}=yt,Kr=h.icon.placedSymbolArray,In=Jt.icon.isHidden()?1:0;pr>=0&&(Nt(h.icon,es,Js?av:Cr),Kr.get(pr).hidden=In),br>=0&&(Nt(h.icon,yt.numVerticalIconVertices,Vs?av:Cr),Kr.get(br).hidden=In)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Cr=h.collisionArrays[jt];if(Cr){let pr=new i.P(0,0),br=!0;if(Cr.textBox||Cr.verticalTextBox){if(Pe){const In=this.variableOffsets[Ht];In?(pr=qd(In.anchor,In.width,In.height,In.textOffset,In.textScale),We&&pr._rotate(Ve?this.transform.angle:-this.transform.angle)):br=!1}je&&(br=!Jt.clipped),Cr.textBox&&jy(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Js,Bt,ut,pr.x,pr.y),Cr.verticalTextBox&&jy(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Vs,Bt,ut,pr.x,pr.y)}const Kr=br&&!!(!Vs&&Cr.verticalIconBox);Cr.iconBox&&jy(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Kr,Bt,ut,yt.hasIconTextFit?pr.x:0,yt.hasIconTextFit?pr.y:0),Cr.verticalIconBox&&jy(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Kr,Bt,ut,yt.hasIconTextFit?pr.x:0,yt.hasIconTextFit?pr.y:0)}}}if(h.fullyClipped=Tt===0,h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.bucketInstanceId in this.collisionCircleArrays){const jt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=jt.invProjMatrix,h.placementViewportMatrix=jt.viewportMatrix,h.collisionCircleArray=jt.circles,delete this.collisionCircleArrays[h.bucketInstanceId]}}symbolFadeChange(h){return this.fadeDuration===0?1:(h-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(h){return Math.max(0,(this.transform.zoom-h)/1.5)}hasTransitions(h){return this.stale||h-this.lastPlacementChangeTimeh}isStale(){return this.stale}setStale(){this.stale=!0}}function jy(T,h,y,A,D,F,z){T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0),T.emplaceBack(h?1:0,y?1:0,F||0,z||0,A,D?1:0)}const YE=Math.pow(2,25),r2=Math.pow(2,24),U3=Math.pow(2,17),QE=Math.pow(2,16),V3=Math.pow(2,9),Ru=Math.pow(2,8),sg=Math.pow(2,1);function Fu(T){if(T.opacity===0&&!T.placed)return 0;if(T.opacity===1&&T.placed)return 4294967295;const h=T.placed?1:0,y=Math.floor(127*T.opacity);return y*YE+h*r2+y*U3+h*QE+y*V3+h*Ru+y*sg+h}const av=0;class rb{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&h.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(h,y,A,D,F,z){const G=this._bucketParts;for(;this._currentTileIndexJ.sortKey-ae.sortKey));this._currentPartIndex{const J=i.o.now()-z;return!this._forceFullPlacement&&J>2};for(;this._currentPlacementIndex>=0;){const J=y[h[this._currentPlacementIndex]],ae=this.placement.collisionIndex.transform.zoom;if(J.type==="symbol"&&J.visibility!=="none"&&(!J.minzoom||J.minzoom<=ae)&&(!J.maxzoom||J.maxzoom>ae)){const le=J,je=le.layout.get("symbol-z-elevate"),ve=le.layout.get("symbol-sort-key").constantOr(1)!==void 0,Ne=le.layout.get("symbol-z-order"),De=Ne==="viewport-y"||Ne==="auto"&&!(Ne!=="viewport-y"&&ve),Pe=le.layout.get("text-allow-overlap")||le.layout.get("icon-allow-overlap")||le.layout.get("text-ignore-placement")||le.layout.get("icon-ignore-placement"),We=De&&Pe,Ve=this._inProgressLayer=this._inProgressLayer||new rb(le),nt=i.B(J.source,J.scope);if(Ve.continuePlacement(je||We?D[nt]:A[nt],this.placement,this._showCollisionBoxes,J,G,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const Jm=512/i.al/2;class rg{constructor(h,y,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(y.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let z=0;zWe-Ve);for(const We of Pe){const Ve=this.crossTileIDs[We];if(this.keys[We]===le&&!A.has(Ve)){A.add(Ve),ae.crossTileID=Ve;break}}}}}class mc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class XE{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const y=Math.round((h-this.lng)/360);if(y!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const z in D){const G=D[z];G.tileID=G.tileID.unwrapTo(G.tileID.wrap+y),F[G.tileID.key]=G}this.indexes[A]=F}this.lng=h}addBucket(h,y,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===y.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const G in z){const J=z[G];J.tileID.isChildOf(h)&&J.findMatches(y.symbolInstances,h,D)}else{const G=z[h.scaledTo(Number(F)).key];G&&G.findMatches(y.symbolInstances,h,D)}}for(let F=0;F{y[A]=!0});for(const A in this.layerIndexes)y[A]||delete this.layerIndexes[A]}}const $f=771;class Hn{constructor(h,y,A,D){this.blendFunction=h,this.blendColor=y.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}Hn.Replace=[1,0,1,0],Hn.disabled=new Hn(Hn.Replace,i.ao.transparent,[!1,!1,!1,!1]),Hn.unblended=new Hn(Hn.Replace,i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlended=new Hn([1,$f,1,$f],i.ao.transparent,[!0,!0,!0,!0]),Hn.alphaBlendedNonPremultiplied=new Hn([770,$f,770,$f],i.ao.transparent,[!0,!0,!0,!0]),Hn.multiply=new Hn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),Hn.additive=new Hn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Fr{constructor(h,y,A){this.func=h,this.mask=y,this.range=A}}Fr.ReadOnly=!1,Fr.ReadWrite=!0,Fr.disabled=new Fr(519,Fr.ReadOnly,[0,1]);const H3=7680;class vn{constructor(h,y,A,D,F,z){this.test=h,this.ref=y,this.mask=A,this.fail=D,this.depthFail=F,this.pass=z}}vn.disabled=new vn({func:519,mask:0},0,0,H3,H3,H3);const nb=1029,G3=2305;class pn{constructor(h,y,A){this.enable=h,this.mode=y,this.frontFace=A}}function qf(T,h){const y=i.ca(T,3);i.cc(T,h),i.cg(T,3,y)}function JE(T,h){const y=i.c7([]);return i.c8(y,y,-h),i.c9(y,y,-T),y}function W3(T,h){const y=[T[0],T[1],0],A=[h[0],h[1],0];if(i.ag(y)>=1e-15){const z=i.aw([],y);i.c5(A,z,i.bJ(A,z)),h[0]=A[0],h[1]=A[1]}const D=i.bI([],h,T);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return JE(Math.atan2(Math.sqrt(T[0]*T[0]+T[1]*T[1]),-T[2]),F)}pn.disabled=new pn(!1,nb,G3),pn.backCCW=new pn(!0,nb,G3),pn.backCW=new pn(!0,nb,2304),pn.frontCW=new pn(!0,1028,2304),pn.frontCCW=new pn(!0,1028,G3);class zu{constructor(h,y){this.position=h,this.orientation=y}get position(){return this._position}set position(h){if(h){const y=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(y.x=i.bT(y.x,0,1)),this._position=y}else this._position=null}lookAtPoint(h,y,A){if(this.orientation=null,!this.position)return;const D=this.position,F=A||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(h)):0),z=i.ae.fromLngLat(h,F),G=[z.x-D.x,z.y-D.y,z.z-D.z];y||(y=[0,0,1]),y[2]=Math.abs(y[2]),this.orientation=W3(G,y)}setPitchBearing(h,y){this.orientation=JE(i.an(h),i.an(-y))}}class K3{constructor(h,y){this._transform=i.bA([]),this.orientation=y,this.position=h}get mercatorPosition(){const h=this.position;return new i.ae(h[0],h[1],h[2])}get position(){const h=i.ca(this._transform,3);return[h[0],h[1],h[2]]}set position(h){var y;h&&i.cg(this._transform,3,[(y=h)[0],y[1],y[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&qf(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),y=this.right();return{bearing:Math.atan2(-y[1],y[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,y){this._orientation=JE(h,y),qf(this._transform,this._orientation)}forward(){const h=i.ca(this._transform,2);return[-h[0],-h[1],-h[2]]}up(){const h=i.ca(this._transform,1);return[-h[0],-h[1],-h[2]]}right(){const h=i.ca(this._transform,0);return[h[0],h[1],h[2]]}getCameraToWorld(h,y){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,y)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,y,A){const D=this.position;i.c5(D,D,-h);const F=new Float64Array(16);return i.bq(F,[A,A,A]),i.br(F,F,D),F[10]*=y,F}getWorldToCamera(h,y){const A=new Float64Array(16),D=new Float64Array(4),F=this.position;return i.cb(D,this._orientation),i.c5(F,F,-h),i.cc(A,D),i.br(A,A,F),A[1]*=-1,A[5]*=-1,A[9]*=-1,A[13]*=-1,A[8]*=y,A[9]*=y,A[10]*=y,A[11]*=y,A}getCameraToClipPerspective(h,y,A,D){const F=new Float64Array(16);return i.cd(F,h,y,A,D),F}getCameraToClipOrthographic(h,y,A,D,F,z){const G=new Float64Array(16);return i.ce(G,h,y,A,D,F,z),G}getDistanceToElevation(h,y=!1){const A=h===0?0:i.cf(h,y?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new K3([...this.position],[...this.orientation])}}const Kc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class Z3{constructor(h=0,y=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(y)||y<0||isNaN(A)||A<0||isNaN(D)||D<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=y,this.left=A,this.right=D}interpolate(h,y,A){return y.top!=null&&h.top!=null&&(this.top=i.ak(h.top,y.top,A)),y.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,y.bottom,A)),y.left!=null&&h.left!=null&&(this.left=i.ak(h.left,y.left,A)),y.right!=null&&h.right!=null&&(this.right=i.ak(h.right,y.right,A)),this}getCenter(h,y){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+y-this.bottom)/2,0,y);return new i.P(A,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new Z3(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const zp=15;class e6{constructor(h,y,A,D,F,z,G){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=y||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(G),this.width=0,this.height=0,this._center=new i.aT(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Z3,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new K3,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const h=new e6(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return h._elevation=this._elevation,h._centerAltitude=this._centerAltitude,h._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,h.tileSize=this.tileSize,h.mercatorFromTransition=this.mercatorFromTransition,h.width=this.width,h.height=this.height,h.cameraElevationReference=this.cameraElevationReference,h._center=this._center,h._setZoom(this.zoom),h._seaLevelZoom=this._seaLevelZoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._nearZ=this._nearZ,h._farZ=this._farZ,h._averageElevation=this._averageElevation,h._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._camera=this._camera.clone(),h._calcMatrices(),h.freezeTileCoverage=this.freezeTileCoverage,h.frustumCorners=this.frustumCorners,h._allowWorldUnderZoom=this._allowWorldUnderZoom,h}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!y||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;y||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&A.exaggeration()&&this._centerAltitudeValidForExaggeration!==A.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*A.exaggeration(),this._centerAltitudeValidForExaggeration=A.exaggeration()):(this._centerAltitude=h||0,this._centerAltitudeValidForExaggeration=A.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const h=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(h)}sampleAverageElevation(){if(!this._elevation)return 0;const h=this._elevation,y=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const We=i.cY(ve,je,Ne,De,Pe);J.has(We)||(F.push(new i.aQ(je,ve,Ne,De,Pe)),J.add(We))};for(let je=0;jeve.canonical.z)continue;const Ne=ve.canonical,De=ve.overscaledZ,Pe=ve.wrap,We=1<0,ut=Ne.y+10,Et=ve.wrap-(nt?0:1),Nt=ve.wrap+(Ve?0:1),Tt=nt?Ne.x-1:We-1,jt=Ve?Ne.x+1:0;if(z)A[0]<0?(ae(De,Nt,Ne.z,jt,Ne.y),A[1]<0&&ut&&(ae(De,Pe,Ne.z,Ne.x,Ne.y+1),ae(De,Nt,Ne.z,jt,Ne.y+1)),A[1]>0&&ot&&(ae(De,Pe,Ne.z,Ne.x,Ne.y-1),ae(De,Nt,Ne.z,jt,Ne.y-1))):A[0]>0?(ae(De,Et,Ne.z,Tt,Ne.y),A[1]<0&&ut&&(ae(De,Pe,Ne.z,Ne.x,Ne.y+1),ae(De,Et,Ne.z,Tt,Ne.y+1)),A[1]>0&&ot&&(ae(De,Pe,Ne.z,Ne.x,Ne.y-1),ae(De,Et,Ne.z,Tt,Ne.y-1))):A[1]<0&&ut?ae(De,Pe,Ne.z,Ne.x,Ne.y+1):ot&&ae(De,Pe,Ne.z,Ne.x,Ne.y-1);else{const yt=ve.visibleQuadrants;1&yt&&(ae(De,Et,Ne.z,Tt,Ne.y),ot&&(ae(De,Pe,Ne.z,Ne.x,Ne.y-1),ae(De,Et,Ne.z,Tt,Ne.y-1))),2&yt&&(ae(De,Nt,Ne.z,jt,Ne.y),ot&&(ae(De,Pe,Ne.z,Ne.x,Ne.y-1),ae(De,Nt,Ne.z,jt,Ne.y-1))),4&yt&&(ae(De,Et,Ne.z,Tt,Ne.y),ut&&(ae(De,Pe,Ne.z,Ne.x,Ne.y+1),ae(De,Et,Ne.z,Tt,Ne.y+1))),8&yt&&(ae(De,Nt,Ne.z,jt,Ne.y),ut&&(ae(De,Pe,Ne.z,Ne.x,Ne.y+1),ae(De,Nt,Ne.z,jt,Ne.y+1)))}}const le=[];for(const je of F)F.some(ve=>je.isChildOf(ve))||le.push(je);if(F=le.filter(je=>!h.some(ve=>!!(je.overscaledZ{const Ve=We.canonical.x+.5-Ne[0],nt=We.canonical.y+.5-Ne[1];return Ve*Ve+nt*nt{const Tt=i.cY(ut,nt,ot,Et,Nt);F.has(Tt)||(D.push(new i.aQ(nt,ut,ot,Et,Nt)),F.add(Tt))},G=h.reduce((nt,ut)=>Math.max(nt,ut.overscaledZ),A),J=1<{const ot=Math.floor(nt[0]),Et=Math.floor(nt[1]),Nt=(nt[0]-ot)*i.al,Tt=(nt[1]-Et)*i.al,jt=Math.floor(ut[0]),yt=Math.floor(ut[1]),Ot=(ut[0]-jt)*i.al,Gt=(ut[1]-yt)*i.al;for(let Ht=-1;Ht<=1;Ht++){const es=ot+Ht;if(!(es<0||es>=J)){le.x=Nt-Ht*i.al,je.x=Ot-(es-jt)*i.al;for(let ts=-1;ts<=1;ts++){const gs=Et+ts;le.y=Tt-ts*i.al,je.y=Gt-(gs-yt)*i.al,i.cZ(le,je,ae)&&z(G,0,A,es,gs)}}}},Ne=y.points,De=Ne[i.cv],Pe=Ne[i.cw],We=this._projectToGround(De,Ne[i.cx]),Ve=this._projectToGround(Pe,Ne[i.cy]);return ve(De,We),ve(Pe,Ve),D}_projectToGround(h,y){return i.cz(i.cA(),h,y,h[2]/(h[2]-y[2]))}coveringTiles(h){let y=this.coveringZoomLevel(h);const A=y,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&yh.maxzoom&&(y=h.maxzoom);const G=this.locationCoordinate(this.center),J=this.center.lat,ae=1<{const Jt=new i.ae(Bt.x+25e-6,Bt.y,Bt.z),Ls=new i.ae(Bt.x,Bt.y+25e-6,Bt.z),rr=Bt.toLngLat(),yr=Jt.toLngLat(),Js=Ls.toLngLat(),Vs=this.locationCoordinate(rr),Ir=this.locationCoordinate(yr),Cr=this.locationCoordinate(Js),pr=Math.hypot(Ir.x-Vs.x,Ir.y-Vs.y),br=Math.hypot(Cr.x-Vs.x,Cr.y-Vs.y);return Math.sqrt(pr*br)*Tt/25e-6},yt=Bt=>{const as=Et,Jt=Nt;return{aabb:i.cF(this,ae,0,0,0,Bt,Jt,as,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:as,wrap:Bt,fullyVisible:!1}},Ot=[];let Gt=[];const Ht=y,es=h.reparseOverscaled?A:y,ts=(We-this._centerAltitude)*Pe,gs=Bt=>{if(!this._elevation||!Bt.tileID||!z)return;const as=this._elevation.getMinMaxForTile(Bt.tileID),Jt=Bt.aabb;as?(Jt.min[2]=as.min,Jt.max[2]=as.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Bt.shouldSplit=Yt(Bt),Bt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},Us=(Bt,as)=>{if(.707*as{if(Bt.zoom=.9)return!0}else if(F&&(Ls=Bt.aabb.distanceZ(Ve)*Pe),this.projection.isReprojectedInTileSpace&&A<=5){const br=Math.pow(2,Bt.zoom),Kr=jt(new i.ae((Bt.x+.5)/br,(Bt.y+.5)/br));rr=Kr>.85?1:Kr}if(!z&&!je){const br=Math.sqrt(as*as+Jt*Jt+Ls*Ls);let Kr=(1<0;){const Bt=Ot.pop(),as=Bt.x,Jt=Bt.y;let Ls=Bt.fullyVisible;const rr=()=>this.projection.name==="globe"&&(Bt.y===0||Bt.y===(1<>1),Ir={aabb:z?Bt.aabb.quadrant(yr):i.cF(this,ae,Bt.zoom+1,Js,Vs,Bt.wrap,Bt.minZ,Bt.maxZ,this.projection),zoom:Bt.zoom+1,x:Js,y:Vs,wrap:Bt.wrap,fullyVisible:Ls,tileID:void 0,shouldSplit:void 0,minZ:Bt.minZ,maxZ:Bt.maxZ};F&&!je&&(Ir.tileID=new i.aQ(Bt.zoom+1===Ht?es:Bt.zoom+1,Bt.wrap,Bt.zoom+1,Js,Vs),gs(Ir)),Ot.push(Ir)}else{const yr=Bt.zoom===Ht?es:Bt.zoom;if(h.minzoom&&h.minzoom>yr)continue;let Js=0;if(!Ls){let pr=nt?Bt.aabb.intersectsPrecise(Ne):Bt.aabb.intersectsPreciseFlat(Ne);if(pr===0&&rr()){const br=new i.cD(Bt.zoom,as,Jt);pr=i.cE(this,ae,br,!0).intersectsPrecise(Ne)}if(pr===0)continue;if(h.calculateQuadrantVisibility)if(Ne.containsPoint(Bt.aabb.center))Js=15;else for(let br=0;br<4;br++)Bt.aabb.quadrant(br).intersects(Ne)!==0&&(Js|=1<{const Ls=[0,0,0,1],rr=[i.al,i.al,0,1],yr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Ls,Ls,yr),i.aC(rr,rr,yr);const Js=i.cG([],Ls,rr),Vs=i.cH([],Ls,rr),Ir=i.c$(Js,Vs);if(Ir===0)return!0;let Cr=!1;const pr=this._elevation;if(pr&&Ir>Bt&&as!==0){const br=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Kr;h.isTerrainDEM||(Kr=pr.getMinMaxForTile(Jt.tileID)),Kr||(Kr={min:Nt,max:Et});const In=i.cI(this.rotation),ja=[In[0]*i.al,In[1]*i.al,Kr.max];i.af(ja,ja,br),Cr=(1-ja[1])*this.height*.5Bt.distanceSq-as.distanceSq).map(Bt=>Bt.tileID)}resize(h,y){this.width=h,this.height=y,this.pixelsToGLUnits=[2/h,-2/y],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log2(h)}project(h){const y=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,y);return new i.P(A.x*this.worldSize,A.y*this.worldSize)}unproject(h){return this.projection.unproject(h.x/this.worldSize,h.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.cf(1,this.center.lat)/this.worldSize}setLocationAtPoint(h,y){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const G=this.worldSize;A=(y.x-F.x)/G,D=(y.y-F.y)/G}else{const G=this.pointCoordinate(y),J=this.pointCoordinate(F);A=G.x-J.x,D=G.y-J.y}const z=this.locationCoordinate(h);this.setLocation(new i.ae(z.x-A,z.y-D))}setLocation(h){this.center=this.coordinateLocation(h),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(h,y){return this.projection.locationPoint(this,h,y)}locationPoint3D(h,y){return this.projection.locationPoint(this,h,y,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,y){return this.coordinateLocation(this.pointCoordinate3D(h,y))}locationCoordinate(h,y){const A=y?i.cf(y,h.lat):void 0,D=this.projection.project(h.lng,h.lat);return new i.ae(D.x,D.y,A)}coordinateLocation(h){return this.projection.unproject(h.x,h.y)}pointRayIntersection(h,y){const A=y??this._centerAltitude,D=[h.x,h.y,0,1],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const G=D[2],J=F[2];return{p0:D,p1:F,t:G===J?0:(A-G)/(J-G)}}screenPointToMercatorRay(h){const y=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(y,y,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(y,y,1/y[3]),i.cK(A,A,1/A[3]),y[2]=i.cf(y[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(y,y,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([y[0],y[1],y[2]],i.aw([],i.av([],A,y)))}rayIntersectionCoordinate(h){const{p0:y,p1:A,t:D}=h,F=i.cf(y[2],this._center.lat),z=i.cf(A[2],this._center.lat);return new i.ae(i.ak(y[0],A[0],D)/this.worldSize,i.ak(y[1],A[1],D)/this.worldSize,i.ak(F,z,D))}pointCoordinate(h,y=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,y)}pointCoordinate3D(h,y){if(!this.elevation)return this.pointCoordinate(h,y);let A=this.projection.pointCoordinate3D(this,h.x,h.y);if(A)return new i.ae(A[0],A[1],A[2]);let D=0,F=this.horizonLineFromTop();if(h.y>F)return this.pointCoordinate(h,y);const z=.02*F,G=h.clone();for(let J=0;J<10&&F-D>z;J++){G.y=i.ak(D,F,.66);const ae=this.projection.pointCoordinate3D(this,G.x,G.y);ae?(F=G.y,A=ae):D=G.y}return A?new i.ae(A[0],A[1],A[2]):this.pointCoordinate(h)}isPointAboveHorizon(h){return this.projection.isPointAboveHorizon(this,h)}isPointOnSurface(h){if(h.y<0||h.y>this.height||h.x<0||h.x>this.width)return!1;if(this.elevation||this.zoom>=i.cL)return!this.isPointAboveHorizon(h);const y=this.pointCoordinate(h);return y.y>=0&&y.y<=1}_coordinatePoint(h,y){const A=y&&this.elevation?this.elevation.getAtPointOrZero(h,this._centerAltitude):this._centerAltitude,D=[h.x*this.worldSize,h.y*this.worldSize,A+h.toAltitude(),1];return i.aC(D,D,this.pixelMatrix),D[3]>0?new i.P(D[0]/D[3],D[1]/D[3]):new i.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:h,left:y}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(y,h)),z=this.pointLocation3D(new i.P(D,h)),G=this.pointLocation3D(new i.P(D,A)),J=this.pointLocation3D(new i.P(y,A));let ae=Math.min(F.lng,z.lng,G.lng,J.lng),le=Math.max(F.lng,z.lng,G.lng,J.lng),je=Math.min(F.lat,z.lat,G.lat,J.lat),ve=Math.max(F.lat,z.lat,G.lat,J.lat);const Ne=Math.pow(2,-this.zoom)/16*270,De=this.projection.name==="globe"?1:4,Pe=(We,Ve,nt,ut,ot)=>{const Et=(We+nt)/2,Nt=(Ve+ut)/2,Tt=new i.P(Et,Nt),{lng:jt,lat:yt}=this.pointLocation3D(Tt),Ot=Math.max(0,ae-jt,je-yt,jt-le,yt-ve);ae=Math.min(ae,jt),le=Math.max(le,jt),je=Math.min(je,yt),ve=Math.max(ve,yt),(otNe)&&(Pe(We,Ve,Et,Nt,ot+1),Pe(Et,Nt,nt,ut,ot+1))};if(Pe(y,h,D,h,1),Pe(D,h,D,A,1),Pe(D,A,y,A,1),Pe(y,A,y,h,1),this.projection.name==="globe"){const[We,Ve]=i.cM(this);We?(ve=90,le=180,ae=-180):Ve&&(je=-90,le=180,ae=-180)}return new i.aI(new i.aT(ae,je),new i.aT(le,ve))}_getBoundsRectangular(h,y){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,G=new i.P(D,A),J=new i.P(z,A),ae=new i.P(z,F),le=new i.P(D,F);let je=this.pointCoordinate(G,h),ve=this.pointCoordinate(J,h);const Ne=this.pointCoordinate(ae,y),De=this.pointCoordinate(le,y),Pe=(We,Ve)=>(Ve.y-We.y)/(Ve.x-We.x);return je.y>1&&ve.y>=0?je=new i.ae((1-De.y)/Pe(De,je)+De.x,1):je.y<0&&ve.y<=1&&(je=new i.ae(-De.y/Pe(De,je)+De.x,0)),ve.y>1&&je.y>=0?ve=new i.ae((1-Ne.y)/Pe(Ne,ve)+Ne.x,1):ve.y<0&&je.y<=1&&(ve=new i.ae(-Ne.y/Pe(Ne,ve)+Ne.x,0)),new i.aI().extend(this.coordinateLocation(je)).extend(this.coordinateLocation(ve)).extend(this.coordinateLocation(De)).extend(this.coordinateLocation(Ne))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const y=h.visibleDemTiles.reduce((A,D)=>{if(D.dem){const F=D.dem.tree;A.min=Math.min(A.min,F.minimums[0]),A.max=Math.max(A.max,F.maximums[0])}return A},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(y.min*h.exaggeration(),y.max*h.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(h=!0){const y=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-y*(1-this._horizonShift);return h?Math.max(0,A):A}getMaxBounds(){return this.maxBounds}setMaxBounds(h){this.maxBounds=h,this.minLat=-i.cJ,this.maxLat=i.cJ,this.minLng=-180,this.maxLng=180,h&&(this.minLat=h.getSouth(),this.maxLat=h.getNorth(),this.minLng=h.getWest(),this.maxLng=h.getEast(),this.maxLngje&&(G=je-ae),je-leNe&&(z=Ne-J),Ne-ve{for(let Yt=0;Yt<16;Yt++)es[Yt]=i.ak(ts[Yt],gs[Yt],Us)})(G,G,J,i.d0(this.pitch>=zp?1:this.pitch/zp))}else G=J;const ae=i.cP([],J,z);let le=i.cP([],G,z);if(this.projection.isReprojectedInTileSpace){const yt=this.locationCoordinate(this.center),Ot=i.bA([]);i.br(Ot,Ot,[yt.x*this.worldSize,yt.y*this.worldSize,0]),i.aB(Ot,Ot,i.cQ(this)),i.br(Ot,Ot,[-yt.x*this.worldSize,-yt.y*this.worldSize,0]),i.aB(le,le,Ot),i.aB(ae,ae,Ot),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],le,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=le,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),y){const yt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);yt[8]=2*-h.x/this.width,yt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],yt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const je=i.bl([],G);this.frustumCorners=i.cT.fromInvProjectionMatrix(je,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!y);const ve=new Float32Array(16);i.bA(ve),i.cS(ve,ve,[1,-1,1]),i.cU(ve,ve,this._pitch),i.bB(ve,ve,this.angle);const Ne=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(Ne);const De=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Ne[8]=2*-h.x/this.width,Ne[9]=2*(h.y+De)/this.height,this.skyboxMatrix=i.aB(ve,Ne,ve);const Pe=this.point,We=Pe.x,Ve=Pe.y,nt=this.width%2/2,ut=this.height%2/2,ot=Math.cos(this.angle),Et=Math.sin(this.angle),Nt=We-Math.round(We)+ot*nt+Et*ut,Tt=Ve-Math.round(Ve)+ot*ut+Et*nt,jt=new Float64Array(le);if(i.br(jt,jt,[Nt>.5?Nt-1:Nt,Tt>.5?Tt-1:Tt,0]),this.alignedProjMatrix=jt,le=i.bC(),i.cS(le,le,[this.width/2,-this.height/2,1]),i.br(le,le,[1,-1,0]),this.labelPlaneMatrix=le,le=i.bC(),i.cS(le,le,[1,-1,1]),i.br(le,le,[-1,-1,0]),i.cS(le,le,[2/this.width,2/this.height,1]),this.glCoordMatrix=le,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ae),this._calcFogMatrices(),this._distanceTileDataCache={},le=i.bl(new Float64Array(16),this.pixelMatrix),!le)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=le,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const yt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(yt,yt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=le;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,y=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,y];i.c5(F,F,D),i.c5(A,A,-1),i.cW(A,A,F);const z=i.bC();i.br(z,z,A),i.cS(z,z,F),this.mercatorFogMatrix=z,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(h,y,D)}_computeCameraPosition(h){const y=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*y-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-A[0]*F,D.y/this.worldSize-A[1]*F,h/this.worldSize*this._centerAltitude-A[2]*F]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(h){const y=this._maxCameraBoundsDistance()*Math.cos(this._pitch),A=this._camera.position[2],D=h[2];let F=1;this.projection.wrap&&(this.center=this.center.wrap()),D>0&&(F=Math.min((y-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,y=this._camera.forward(),{pitch:A,bearing:D}=this._camera.getPitchBearing(),F=i.cf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,z=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.an(this._maxPitch)),G=Math.max((h[2]-F)/Math.cos(A),z),J=this._zoomFromMercatorZ(G);i.bH(h,h,y,G),this._pitch=i.aA(A,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(D,-Math.PI,Math.PI),this._setZoom(i.aA(J,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let y=0,A=i.cL,D=0,F=1/0;for(;A-y>1e-6&&A>y;){const z=y+.5*(A-y),G=this.tileSize*Math.pow(2,z),J=this.getCameraToCenterDistance(this.projection,z,G),ae=this.scaleZoom(J/(Math.max(0,h)*this.tileSize)),le=Math.abs(z-ae);leae||ve.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(h,y){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+y;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([y,A,D],F){const z=[y,A,D,1];i.aC(z,z,F);const G=z[3]=Math.max(z[3],1e-6);return z[0]/=G,z[1]/=G,z[2]/=G,z}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(h[0],h[1])}{const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,h))}}getCameraToCenterDistance(h,y=this.zoom,A=this.worldSize){const D=i.cO(h,y,this.width,this.height,1024),F=h.pixelSpaceConversion(this.center.lat,A,D);let z=.5/Math.tan(.5*this._fov)*this.height*F;return this.isOrthographic&&(z=i.ak(1,z,i.d0(this.pitch>=zp?1:this.pitch/zp))),z}getWorldToCameraMatrix(){const h=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.aB(h,h,this.globeMatrix),h}getFrustum(h){return i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,h,this.projection.zAxisUnit==="meters")}}const Ny=(T,h)=>{if(h>0&&T.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||T.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const y=T.transform,A=Math.max(Math.abs(y._zoom-(T.minCutoffZoom-1)),1),D=y.isLODDisabled(!1)?i.ah(60,45,y.pitch):i.ah(30,15,y.pitch),F=y._farZ-y._nearZ,z=h*y.height,G=((1-(J=D))*y.cameraToCenterDistance+J*(y._farZ+z))*A;var J;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[y._nearZ,y._farZ,(G-y._nearZ)/F,(G-z-y._nearZ)/F]}}},ep=2048;class n2{constructor(h,y){this.aabb=h,this.lastCascade=y}}class Rme{add(h,y){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],y.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],y.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],y.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],y.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],y.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],y.max[2])):this.receivers[h.key]=new n2(y,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,y,A){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const G=this.receivers[z];if(!G||!D.intersectsAabb(G.aabb))continue;G.aabb.min=D.closestPoint(G.aabb.min),G.aabb.max=D.closestPoint(G.aabb.max);const J=G.aabb.getCorners();for(let ae=0;ae1||ve[1]<-1||ve[1]>1){le=!1;break}}if(G.lastCascade=ae,F=Math.max(F,ae),le)break}}return F+1}}class ab{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Rme,this._depthMode=new Fr(h.context.gl.LEQUAL,Fr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const h of this._cascades)h.texture.destroy(),h.framebuffer.destroy();this._cascades=[]}updateShadowParameters(h,y){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!y||!y.properties)return;const D=y.properties.get("shadow-intensity");if(!y.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((De,Pe)=>{const We=A.style._mergedLayers[Pe];return De+(We.hasShadowPass()&&!We.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=ep,G=ep;if(this._cascades.length===0||ep!==this._cascades[0].texture.size[0]){this._cascades=[];for(let De=0;De<2;++De){const Pe=A._shadowMapDebug,We=F.gl,Ve=F.createFramebuffer(z,G,Pe?1:0,"texture"),nt=new i.T(F,{width:z,height:G,data:null},We.DEPTH_COMPONENT16);if(Ve.depthAttachment.set(nt.texture),Pe){const ut=new i.T(F,{width:z,height:G,data:null},We.RGBA8);Ve.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Ve,texture:nt,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=i2(y);let J=0;if(h.elevation){const De=h.elevation,Pe=[1e4,-1e4];De.visibleDemTiles.filter(We=>We.dem).forEach(We=>{const Ve=We.dem.tree;Pe[0]=Math.min(Pe[0],Ve.minimums[0]),Pe[1]=Math.max(Pe[1],Ve.maximums[0])}),Pe[0]!==1e4&&(J=(Pe[1]-Pe[0])*De.exaggeration())}const ae=1.5*h.cameraToCenterDistance,le=3*ae,je=new Float64Array(16);for(let De=0;De=0)return{};const F=function(J,ae,le){const je=le/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const G={};return G.vertices=F,G.planes=[a2(F[1],F[0],F[4]),a2(F[2],F[1],F[5]),a2(F[3],F[2],F[6]),a2(F[0],F[3],F[7])],G}addShadowReceiver(h,y,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,y,A))}getMaxCascadeForTile(h){const y=this._receivers.get(h);return y&&y.lastCascade?y.lastCascade:0}}function a2(T,h,y){const A=i.av([],y,h),D=i.av([],T,h),F=i.bI([],A,D),z=i.ag(F);return z===0?[0,0,1,0]:(i.c5(F,F,1/z),[F[0],F[1],F[2],-i.bJ(F,h)])}function i2(T){const h=T.properties.get("direction"),y=i.d4(h.x,h.y,h.z);y[2]=i.aA(y[2],0,75);const A=i.d6([y[0],y[1],y[2]]);return i.d5(A.x,A.y,A.z)}function ng(T,h,y){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),G=[z.x,z.y,z.z],J=y.properties.get("color-use-theme")==="none",ae=y.properties.get("color"),le=y.properties.get("intensity"),je=Math.max(i.bJ([0,0,1],G),0),ve=[0,0,0];i.c5(ve,ae.toPremultipliedRenderColor(J?null:T.getLut(h.scope)).toArray01Linear().slice(0,3),le);const Ne=[0,0,0];return i.c5(Ne,D.toPremultipliedRenderColor(A?null:T.getLut(y.scope)).toArray01Linear().slice(0,3),je*F),i.db([ve[0]>0?ve[0]/(ve[0]+Ne[0]):0,ve[1]>0?ve[1]/(ve[1]+Ne[1]):0,ve[2]>0?ve[2]/(ve[2]+Ne[2]):0])}function ky(T,h,y,A,D,F){const z=T.zoom,G=T.scale,J=T.worldSize,ae=1/J,le=T.aspect,je=Math.sqrt(1+le*le)*Math.tan(.5*T.fovX),ve=je*je,Ne=A-y,De=A+y;let Pe,We;ve>Ne/De?(Pe=A,We=A*je):(Pe=.5*De*(1+ve),We=.5*Math.sqrt(Ne*Ne+2*(A*A+y*y)*ve+De*De*ve*ve));const Ve=T.projection.pixelsPerMeter(T.center.lat,J),nt=T._camera.getCameraToWorldMercator(),ut=[0,0,-Pe*ae];i.af(ut,ut,nt);let ot=We*ae;const Et=T._edgeInsets;if(!(Et.left===0&&Et.top===0&&Et.right===0&&Et.bottom===0||Et.left===Et.right&&Et.top===Et.bottom)){const Ls=T._camera.getWorldToCamera(T.worldSize,T.projection.zAxisUnit==="meters"?Ve:1),rr=T._camera.getCameraToClipPerspective(T._fov,T.width/T.height,y,A);rr[8]=2*-T.centerOffset.x/T.width,rr[9]=2*T.centerOffset.y/T.height;const yr=new Float64Array(16);i.cP(yr,rr,Ls);const Js=new Float64Array(16);i.bl(Js,yr);const Vs=i.cB.fromInvProjectionMatrix(Js,J,z,!0);for(const Ir of Vs.points){const Cr=((Nt=Ir)[0]/=G,Nt[1]/=G,Nt[2]=i.cf(Nt[2],T._center.lat),Nt);ot=Math.max(ot,i.c6(i.da([],ut,Cr)))}}var Nt;ot*=D/(D-1);const Tt=Math.acos(h[2]),jt=Math.atan2(-h[0],-h[1]),yt=new K3;yt.position=ut,yt.setPitchBearing(Tt,jt);const Ot=yt.getWorldToCamera(J,Ve),Gt=ot*J,Ht=Math.min(T._mercatorZfromZoom(17)*J*-2,-2*Gt),es=yt.getCameraToClipOrthographic(-Gt,Gt,-Gt,Gt,Ht,(Gt+F*Ve)/h[2]),ts=new Float64Array(16);i.aB(ts,es,Ot);const gs=i.d5(Math.floor(1e6*ut[0])/1e6*J,Math.floor(1e6*ut[1])/1e6*J,0),Us=.5*D,Yt=[0,0,0];i.af(Yt,gs,ts),i.c5(Yt,Yt,Us);const Bt=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],as=[0,0,0];i.av(as,Yt,Bt),i.c5(as,as,-1/Us);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,as),i.aB(ts,Jt,ts),[ts,Gt]}class Fme extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,y){return i.dc(this.requestManager.transformRequest(y,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,y,void 0,void 0,D);return F.computeBoundsAndApplyParent(),F}).catch(A=>{if(A&&A.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${h} from ${y}: ${A.message}`)))})}load(h,y,A={forceReload:!1}){this.models[y]||(this.models[y]={});const D=Object.keys(h),F=[],z=[];for(const G of D){const J=h[G];this.hasURLBeenRequested(J)&&!A.forceReload||(this.modelByURL[J]={modelId:G,scope:y},F.push(this.loadModel(G,J)),z.push(G)),this.models[y][G]||(this.models[y][G]={model:null,numReferences:1})}this.numModelsLoading[y]=(this.numModelsLoading[y]||0)+z.length,Promise.allSettled(F).then(G=>{for(let J=0;J{this.fire(new i.y(new Error(`Could not load models: ${G.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,y,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,y):this.getModelByURL(this.modelUris[y][h]))}getModel(h,y){return this.models[y]||(this.models[y]={}),this.models[y][h]?this.models[y][h].model:void 0}getModelByURL(h){if(!h)return null;const y=this.modelByURL[h];return y?this.models[y.scope][y.modelId].model:null}hasModelBeenAdded(h,y){return this.models[y]&&this.models[y][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,y,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(y);if((this.hasModel(h,A,{exactIdMatch:!0})||this.hasModelBeenAdded(h,A))&&this.modelUris[A][h]===D)this.models[A][h].numReferences++;else if(this.hasURLBeenRequested(D)){const{scope:F,modelId:z}=this.modelByURL[D];this.models[F][z].numReferences++}else this.modelUris[A][h]=D,this.load({[h]:this.modelUris[A][h]},A)}addModelURLs(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A=this.modelUris[y];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,y){this.models[y]||(this.models[y]={}),this.modelUris[y]||(this.modelUris[y]={});const A={};for(const D of h)this.hasModel(D,y,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[y][D].numReferences++:this.modelUris[y][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[y][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[y][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[y][D]);this.load(A,y)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,y,A=!1,D=!1){if(this.models[y]&&this.models[y][h]&&(this.models[y][h].numReferences--,this.models[y][h].numReferences===0||D)){const F=this.modelUris[y][h];A||delete this.modelUris[y][h],delete this.modelByURL[F];const z=this.models[y][h].model;if(!z)return;delete this.models[y][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const y of Object.keys(this.models[h])){const A=this.models[h][y].model;delete this.models[h][y],A&&A.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(h){return this.models[h]||(this.models[h]={}),Object.keys(this.models[h])}upload(h,y){this.models[y]||(this.models[y]={});for(const A in this.models[y])this.models[y][A].model&&this.models[y][A].model.upload(h.context)}}const t6=i.a6.colorTheme,zme=new i.a9({data:new i.aa(t6.data)});function BR(T){if(!T.metadata||!T.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:y,top:A,width:D,height:F}=T.metadata.content_area,z=y*h,G=A*h;return[z,G,z+D*h,G+F*h]}function $R(T){if(T)return T.map(([h,y])=>[h*i.o.devicePixelRatio,y*i.o.devicePixelRatio])}class s6{constructor(h,y,A){this.id=h,this.scope=y,this.sourceCache=A,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(h){this.missingRequests.has(h.name)||this.pendingRequests.has(h.name)||this.pendingRequests.add(h.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const h=new Map;if(!this.sourceCache.loaded())return h;const y=this.sourceCache.getVisibleCoordinates();if(y.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof Sd))return h;const D=y.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,G]of F)h.set(i.I.from({name:z,iconsetId:this.id}),G),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const Sy=(T,h)=>Ye(T,h&&h.filter(y=>y.identifier!=="source.canvas")),qR=i.aH(Oa,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),UR=i.aH(Oa,["setCenter","setZoom","setBearing","setPitch"]),Y3=new Set(["background","sky","slot","custom"]),Cy={version:8,layers:[],sources:{}},o2={duration:300,delay:0};class tp extends i.E{constructor(h,y={}){super(),this.map=h,this.scope=y.scope||"",this.globalId=null,this.fragments=[],this.importDepth=y.importDepth||0,this.importsCache=y.importsCache||new Map,this.resolvedImports=y.resolvedImports||new Set,this.transition=Object.assign({},o2),this._buildingIndex=new Qw(this),this.crossTileSymbolIndex=new Fp,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=y.styleChanges||new Ae,this._hasDataDrivenEmissive=!1,this.dispatcher=y.dispatcher?y.dispatcher:new i.D(i.dh(),this),y.imageManager?this.imageManager=y.imageManager:(this.imageManager=new He(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=y.glyphManager?y.glyphManager:new i.di(h._requestManager,y.localFontFamily?i.dj.all:y.localIdeographFontFamily?i.dj.ideographs:i.dj.none,y.localFontFamily||y.localIdeographFontFamily),y.modelManager?this.modelManager=y.modelManager:(this.modelManager=new Fme(h._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=y.configOptions?y.configOptions:new Map,this._configDependentLayers=y.configDependentLayers?y.configDependentLayers:new Set,this._indoorDependentLayers=y.indoorDependentLayers?y.indoorDependentLayers:new Set,this._config=y.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:y.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=y.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=tp.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(G=>G))for(const G in A._sourceCaches){const J=A._sourceCaches[G],ae=J.getSource().type;ae!=="vector"&&ae!=="geojson"||J.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const G=this._layers[z];G.source===F.id&&this._validateLayer(G)}})}load(h){return h?(typeof h=="string"?this.loadURL(h):this.loadJSON(h),this):this}_getGlobalId(h){if(!h)return null;if(typeof h=="string"){if(i.h(h))return h;const y=i.dm(h);if(!y.startsWith("http"))try{return new URL(y,location.href).toString()}catch{return y}return y}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,y,A){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,A))}catch(G){z(G,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(G,J)=>{G?this.fire(new i.y(G)):J&&D(J,y)})}else typeof h=="object"&&D(h,y)}loadURL(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof y.validate=="boolean"?y.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,y.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,A);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,G)=>{if(this._request=null,z)this.fire(new i.y(z));else if(G)return this.importsCache.set(h,G),this._load(G,A)})}loadJSON(h,y={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,y.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(Cy,!1)}_loadImports(h,y,A){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const D=[];for(const F of h){const z=this._createFragmentStyle(F),G=new Promise(le=>{z.once("style.import.load",le),z.once("error",le)}).then(()=>this.mergeAll());if(D.push(G),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const J=F.data||this.importsCache.get(F.url);J?(z.loadJSON(J,{validate:y}),this._isInternalStyle(J)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:y}):z.loadEmpty();const ae={style:z,id:F.id,config:F.config};if(A){const le=this.fragments.findIndex(({id:je})=>je===A);this.fragments=this.fragments.slice(0,le).concat(ae).concat(this.fragments.slice(le))}else this.fragments.push(ae)}return Promise.allSettled(D)}getImportGlobalIds(h=this,y=new Set){for(const A of h.fragments)A.style.globalId&&y.add(A.style.globalId),this.getImportGlobalIds(A.style,y);return[...y.values()]}_createFragmentStyle(h){const y=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[y];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new tp(this.map,{scope:y,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:A,configOptions:this.options,colorThemeOverride:h["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return F.setEventedParent(this.map,{style:F}),F}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(h){return this.isRootStyle()&&(h.fragment||!!h.schema&&h.fragment!==!1)}_load(h,y){if(this._isInternalStyle(h)){const F=Object.assign({},Cy,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,y)}if(this.updateConfig(this._config,h.schema),y&&Sy(this,Yr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const J in h.sources)this.addSource(J,h.sources[J],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const J in h.iconsets)this.addIconset(J,h.iconsets[J]);h.sprite?this._loadIconset(h.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&h.glyphs&&this.glyphManager.setURL(h.glyphs);const F=ev(this.stylesheet.layers);if(this._order=F.map(J=>J.id),this.stylesheet.light&&i.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const J=this.stylesheet.lights[0];this.light=new Ft(J.properties,J.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ft(this.stylesheet.light)),this._layers={};for(const J of F){const ae=i.du(J,this.scope,this._styleColorTheme.lut,this.options);ae.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ae.fqid),ae.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ae.fqid),this._hasAppearances=this._hasAppearances||ae.getAppearances().length!==0,ae.setEventedParent(this,{layer:{id:ae.id}}),this._layers[ae.id]=ae;const le=this.getOwnLayerSourceCache(ae),je=!!this.directionalLight&&this.directionalLight.shadowsEnabled();le&&ae.canCastShadows()&&je&&(le.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const G=this.isRootStyle();h.imports?this._loadImports(h.imports,y).then(()=>{this._reloadImports(),this.fire(new i.z(G?"style.load":"style.import.load"))}).catch(J=>{this.fire(new i.y(new Error("Failed to load imports",J))),this.fire(new i.z(G?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(G?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{A()}).catch(z=>{i.w(`Couldn't load color theme from the stylesheet: ${z}`),A()})}else this._styleColorTheme.lut=null,A()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(h=>h.style.hasAppearances())}mergeAll(){let h,y,A,D,F,z,G,J,ae,le;const je={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(ve=>{if(ve.stylesheet){if(ve.light!=null&&(h=ve.light),ve.stylesheet.lights)for(const Ne of ve.stylesheet.lights)Ne.type==="ambient"&&ve.ambientLight!=null&&(y=ve.ambientLight),Ne.type==="directional"&&ve.directionalLight!=null&&(A=ve.directionalLight);D=this._prioritizeTerrain(D,ve.terrain,ve.stylesheet.terrain),ve.stylesheet.fog&&ve.fog!=null&&(F=ve.fog),ve.stylesheet.snow&&ve.snow!=null&&(z=ve.snow),ve.stylesheet.rain&&ve.rain!=null&&(G=ve.rain),ve.stylesheet.camera!=null&&(le=ve.stylesheet.camera),ve.stylesheet.projection!=null&&(J=ve.stylesheet.projection),ve.stylesheet.transition!=null&&(ae=ve.stylesheet.transition),je[ve.scope]=ve._styleColorTheme}}),this.light=h,this.ambientLight=y,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=G,this._styleColorThemeForScope=je,D===null?delete this.terrain:this.terrain=D,this.camera=le||{"camera-projection":"perspective"},this.projection=J||{name:"mercator"},this.transition=Object.assign({},o2,ae),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const y=A=>{for(const D of A.fragments)y(D.style);h(A)};y(this)}_prioritizeTerrain(h,y,A){const D=h&&h.drapeRenderMode===0;return A===null?y&&y.drapeRenderMode===0?y:D?h:null:y!=null&&(!h||D||y&&y.drapeRenderMode===1)?y:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(y=>{h=this._prioritizeTerrain(h,y.terrain,y.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(y=>{y.stylesheet.projection!=null&&(h=y.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},y={},A={};this.forEachFragmentStyle(D=>{for(const F in D._sourceCaches){const z=i.B(F,D.scope);h[z]=D._sourceCaches[F]}for(const F in D._otherSourceCaches){const z=i.B(F,D.scope);y[z]=D._otherSourceCaches[F]}for(const F in D._symbolSourceCaches){const z=i.B(F,D.scope);A[z]=D._symbolSourceCaches[F]}}),this._mergedSourceCaches=h,this._mergedOtherSourceCaches=y,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const y of Object.values(h.stylesheet.indoor)){const A=y,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},y=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const G of z._order){const J=z._layers[G];if(J.type==="slot"){const ae=i.dq(G);if(h[ae])continue;h[ae]=[]}J.slot&&h[J.slot]?h[J.slot].push(J):y.push(J)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const G of z)if(G.type==="slot"){const J=i.dq(G.id);h[J]&&F(h[J]),this._mergedSlots.push(J)}else{const J=i.B(G.id,G.scope);this._mergedOrder.push(J),A[J]=G,G.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),G.type==="circle"&&(this._hasCircleLayers=!0),G.type==="symbol"&&(this._hasSymbolLayers=!0),G.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(y),this._has3DLayers){const z={};for(let G=0;Gz[G]-z[J])}this._mergedLayers=A,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(h){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,h),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(h){return h.data?function(y,A,D,F){const z=Object.assign({},A);for(const J of Object.keys(t6))z[J]===void 0&&(z[J]=t6[J].default);const G=new i.a8(zme,y,new Map(D));return G.setTransitionOrValue(z,D),G.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,h,this.options).get("data"):null}_loadColorTheme(h){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const y=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((A,D)=>{const F="data:image/png;base64,";if(!h||h.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void A();let z=h;z.startsWith(F)||(z=F+z);const G=i.I.from("mapbox-reserved-lut"),J=new Image;J.src=z,J.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},J.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==y)return void A();this._styleColorTheme.lutLoading=!1;const{width:ae,height:le,data:je}=i.o.getImageData(J);if(le>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ae!==le*le)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(G)&&this.removeImage(G),this.addImage(G,{data:new i.q({width:ae,height:le},je),pixelRatio:1,sdf:!1,usvg:!1,version:0});const ve=this.imageManager.getImage(G,this.scope);ve?(this._styleColorTheme.lut={image:ve.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const y=this._styleColorThemeForScope[h];return y?y.lut:null}setProjection(h){h?this.stylesheet.projection=h:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(h){this._spriteRequest=function(y,A,D){let F,z,G;const J=i.o.devicePixelRatio>1?"@2x":"";let ae=i.m(A.transformRequest(A.normalizeSpriteURL(y,J,".json"),i.R.SpriteJSON),(ve,Ne)=>{ae=null,G||(G=ve,F=Ne,je())}),le=i.n(A.transformRequest(A.normalizeSpriteURL(y,J,".png"),i.R.SpriteImage),(ve,Ne)=>{le=null,G||(G=ve,z=Ne,je())});function je(){if(G)D(G);else if(F&&z){const ve=i.o.getImageData(z),Ne={};for(const De in F){const{width:Pe,height:We,x:Ve,y:nt,sdf:ut,pixelRatio:ot,stretchX:Et,stretchY:Nt,content:Tt}=F[De],jt=new i.q({width:Pe,height:We});i.q.copy(ve,jt,{x:Ve,y:nt},{x:0,y:0},{width:Pe,height:We},null),Ne[De]={data:jt,pixelRatio:ot!==void 0?ot:1,sdf:ut!==void 0&&ut,stretchX:Et,stretchY:Nt,content:Tt,usvg:!1,version:0}}D(null,Ne)}}return{cancel(){ae&&(ae.cancel(),ae=null),le&&(le.cancel(),le=null)}}}(h,this.map._requestManager,(y,A)=>{if(this._spriteRequest=null,y)this.fire(new i.y(y));else if(A){const D=new Map;for(const F in A)D.set(i.I.from(F),A[F]);this.addImages(D)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))})}addIconset(h,y){if(y.type==="sprite")return void this._loadSprite(y.url);const A=this.getOwnSourceCache(y.source);if(!A)return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=A.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${y.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const F=new s6(h,this.scope,A);this.imageManager.addImageProvider(F,this.scope)}removeIconset(h){this.imageManager.removeImageProvider(h,this.scope)}_loadIconset(h){if(!i.h(h)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(h);const y=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)y?this._loadSprite(h):this.fire(new i.y(F));else if(z){const G=new Map;for(const J in z)G.set(i.I.from(J),z[J]);this.addImages(G)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))},i.bu((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const G={},J=i.dg(new i.bt(z));for(const ae of J.icons){const le={version:1,pixelRatio:i.o.devicePixelRatio,content:BR(ae),stretchX:ae.metadata?$R(ae.metadata.stretch_x_areas):void 0,stretchY:ae.metadata?$R(ae.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ae};G[ae.name]=le}D(null,G)}))}_validateLayer(h){const y=this.getOwnSource(h.source);if(!y)return;const A=h.sourceLayer;A&&(y.type==="geojson"||y.vectorLayerIds&&y.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${y.id}" as specified by style layer "${h.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const h in this._sourceCaches)if(!this._sourceCaches[h].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:h}of this.fragments)if(!h.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((h,y)=>{const A=this.fragments[y];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const y in this._sourceCaches){const A=this._sourceCaches[y].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const y=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&y.push(D.serialize())}return y}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const h in this._sourceCaches)if(this._sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];if(y._transitionablePaint&&y._transitionablePaint._values){const A=y._transitionablePaint._values["line-emissive-strength"];if(A&&A.value&&A.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(h){return h?this.order:this._mergedOrder}isLayerDraped(h){return!!this.terrain&&h.isDraped(this.getLayerSourceCache(h))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(h){const y=this.getOwnLayer(h);if(y)return y;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const y=this.getOwnSource(h);if(y)return y;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,y){const A=this.map.painter;if(A)for(let D=h.minzoom||0;D<(h.maxzoom||25.5);D++){const F=h.getProgramIds();if(F)for(const z of F){const G=h.getDefaultProgramParams(z,y.zoom,this._styleColorTheme.lut);G&&(A.style=this,this.fog&&(A._fogVisible=!0,G.overrideFog=!0,A.getOrCreateProgram(z,G)),A._fogVisible=!1,G.overrideFog=!1,A.getOrCreateProgram(z,G),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(G.overrideRtt=!0,A.getOrCreateProgram(z,G)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const y=this.calculateLightsBrightness();h.brightness=y||0,y!==this._brightness&&(this._brightness=y,this.dispatcher.broadcast("setBrightness",y)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const G=this._changes.getLayerUpdatesByScope();for(const J in G){const{updatedIds:ae,removedIds:le}=G[J];(ae||le)&&(this._updateWorkerLayers(J,ae,le),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const G in this._mergedSourceCaches){const J=this._mergedSourceCaches[G];F[G]=J.used,J.used=!1,J.tileCoverLift=0}for(const G of this._mergedOrder){const J=this._mergedLayers[G];if(J.visibility!=="none"&&J.recalculate(h,this._availableImages),!J.isHidden(h.zoom)){const ae=this.getLayerSourceCache(J);ae&&(ae.used=!0,ae.tileCoverLift=Math.max(ae.tileCoverLift,J.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(J,h)}):this.precompilePrograms(J,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const G of z)G.sourceCache.used=!0;for(const G in F){const J=this._mergedSourceCaches[G];F[G]!==J.used&&J.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:J.getSource().id}))}this.light&&this.light.recalculate(h),this.terrain&&this.terrain.recalculate(h),this.fog&&this.fog.recalculate(h),this.snow&&this.snow.recalculate(h),this.rain&&this.rain.recalculate(h),this.z=h.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),A&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const h=this.imageManager.getPendingImageProviders();for(const y of h){const A=y.resolvePendingRequests(),D=this.getFragmentStyle(y.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const y in this._mergedSourceCaches){const A=this._mergedSourceCaches[y].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[y].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const y in h)this._changes.resetUpdatedImages(y)}_updateWorkerLayers(h,y,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:y?D._serializeLayers(y):[],scope:h,removedIds:A||[],options:D.options})}setState(h,y){if(this._checkLoaded(),Sy(this,Yr(h)))return!1;(h=i.dp(h)).layers=ev(h.layers);const A=function(z,G){if(!z)return[{command:Oa.setStyle,args:[G]}];let J=[];try{if(!i.by(z.version,G.version))return[{command:Oa.setStyle,args:[G]}];if(i.by(z.center,G.center)||J.push({command:Oa.setCenter,args:[G.center]}),i.by(z.zoom,G.zoom)||J.push({command:Oa.setZoom,args:[G.zoom]}),i.by(z.bearing,G.bearing)||J.push({command:Oa.setBearing,args:[G.bearing]}),i.by(z.pitch,G.pitch)||J.push({command:Oa.setPitch,args:[G.pitch]}),i.by(z.sprite,G.sprite)||J.push({command:Oa.setSprite,args:[G.sprite]}),i.by(z.glyphs,G.glyphs)||J.push({command:Oa.setGlyphs,args:[G.glyphs]}),i.by(z.imports,G.imports)||function(Ne=[],De=[],Pe){De=De||[];const We=(Ne=Ne||[]).map(tv),Ve=De.map(tv),nt=Ne.reduce(sv,{}),ut=De.reduce(sv,{}),ot=We.slice();let Et,Nt,Tt,jt;for(Et=0,Nt=0;Et{Ne.source&&ae[Ne.source]?J.push({command:Oa.removeLayer,args:[Ne.id]}):je.push(Ne)});let ve=z.terrain;ve&&ae[ve.source]&&(J.push({command:Oa.setTerrain,args:[void 0]}),ve=void 0),J=J.concat(le),i.by(ve,G.terrain)||J.push({command:Oa.setTerrain,args:[G.terrain]}),function(Ne,De,Pe){De=De||[];const We=(Ne=Ne||[]).map(tv),Ve=De.map(tv),nt=Ne.reduce(sv,{}),ut=De.reduce(sv,{}),ot=We.slice(),Et=Object.create(null);let Nt,Tt,jt,yt,Ot,Gt,Ht;for(Nt=0,Tt=0;Nt!(z.command in UR));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in qR));if(D.length>0)throw new Error(`Unimplemented: ${D.map(z=>z.command).join(", ")}.`);const F=[];return A.forEach(z=>{F.push(this[z.command](...z.args))}),y&&Promise.all(F).then(y).catch(y),this.stylesheet=h,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(h){if(h.size===0)return this;for(const[y,A]of h.entries()){if(this.getImage(y))return this.fire(new i.y(new Error(`An image with the name "${y.name}" already exists.`)));this.imageManager.addImage(y,this.scope,A),this._changes.updateImage(y,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,y){return this.getImage(h)?this.fire(new i.y(new Error(`An image with the name "${h.name}" already exists.`))):(this.imageManager.addImage(h,this.scope,y),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,y,A=!1){this.imageManager.updateImage(h,this.scope,y),A&&(this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})))}getImage(h){return this.imageManager.getImage(h,this.scope)}removeImage(h){return this.getImage(h)?(this.imageManager.removeImage(h,this.scope),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(h){return this.modelManager.addModelURLs(h,this.getActualScope()),this._updateWorkerModels(),this.fire(new i.z("data",{dataType:"style"})),this}addModel(h,y,A={}){return this._checkLoaded(),this._validate(Se,`models.${h}`,y,null,A)||(this.modelManager.addModel(h,y,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(h){return this.modelManager.hasModel(h,this.getActualScope())}removeModel(h){return this.hasModel(h)?(this.modelManager.removeModel(h,this.getActualScope(),!1,!0),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(h,y,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!y.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(y).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(y.type)>=0&&this._validate(bi,`sources.${h}`,y,null,A))return;this.map&&this.map._collectResourceTiming&&(y.collectResourceTiming=!0);const D=Ul(h,y,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const G=(z?"symbol:":"other:")+D.id,J=i.B(G,this.scope),ae=this._sourceCaches[G]=new Pl(J,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ae,ae.onAdd(this.map)};F(!1),y.type!=="vector"&&y.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const y=this.getOwnSource(h);if(!y)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const A=this.getOwnSourceCaches(h);for(const D of A){const F=i.dq(D.id);delete this._sourceCaches[F],this._changes.discardSourceCacheUpdate(D.id),D.fire(new i.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:D.getSource().id})),D.setEventedParent(null),D.clearTiles()}return delete this._otherSourceCaches[h],delete this._symbolSourceCaches[h],this.mergeSources(),y.setEventedParent(null),y.onRemove&&y.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,y){this._checkLoaded(),this.getOwnSource(h).setData(y),this._changes.setDirty()}getOwnSource(h){const y=this.getOwnSourceCache(h);return y&&y.getSource()}getOwnSources(){const h=[];for(const y in this._otherSourceCaches){const A=this.getOwnSourceCache(y);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const y in h){const A=h[y]._tiles;for(const D in A){const F=A[D];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}setLights(h){if(this._checkLoaded(),!h)return delete this.ambientLight,void delete this.directionalLight;const y=this._getTransitionParameters();for(const F of h){if(this._validate(or,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(y)}else this.ambientLight=new Da(F,cl||(cl=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(y)}else this.directionalLight=new Da(F,ni||(ni=new i.a9({direction:new i.ap(i.a6.properties_light_directional.direction),color:new i.aa(i.a6.properties_light_directional.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_directional.intensity),"cast-shadows":new i.aa(i.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new i.aa(i.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new i.aa(i.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const A=Object.assign(y,{worldview:this.map.getWorldview()}),D=new i.ac(this.z||0,A);this.ambientLight&&this.ambientLight.recalculate(D),this.directionalLight&&this.directionalLight.recalculate(D),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const h=this.directionalLight,y=this.ambientLight;if(!h||!y)return;const A=ve=>.2126*(ve[0]<=.03928?ve[0]/12.92:Math.pow((ve[0]+.055)/1.055,2.4))+.7152*(ve[1]<=.03928?ve[1]/12.92:Math.pow((ve[1]+.055)/1.055,2.4))+.0722*(ve[2]<=.03928?ve[2]/12.92:Math.pow((ve[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),G=1-i.d4(z.x,z.y,z.z)[2]/90,J=A(D)*F*G,ae=y.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),le=y.properties.get("intensity"),je=A(ae)*le;return Number(((J+je)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const h=[];return this.directionalLight&&h.push(this.directionalLight.get()),this.ambientLight&&h.push(this.ambientLight.get()),h}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(h){if(h==null||h===""&&this.isRootStyle())return this;if(i.dr(h)){const y=i.ds(h),A=this.fragments.find(({id:F})=>F===y);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const y=this.fragments.find(({id:A})=>A===h);return y?y.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const y={},A=(D,F="")=>`${D}::${F}`;this._featuresetSelectors={};for(const D in h){const F=this._featuresetSelectors[D]=[];for(const z of h[D].selectors){if(z.featureNamespace){const J=this.getOwnLayer(z.layer);if(!J){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ae=A(J.source,J.sourceLayer);if(ae in y&&y[ae]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}y[ae]=z.featureNamespace}let G;if(z.properties)for(const J in z.properties){const ae=i.U(z.properties[J]);ae.result==="success"&&(G=G||{},G[J]=ae.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:G,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const y=this.getFragmentStyle(h);if(!y||!y.stylesheet.featuresets)return[];const A=[];for(const D in y.stylesheet.featuresets)A.push({featuresetId:D,importId:y.scope?y.scope:void 0});return A}getFeaturesetLayers(h,y){const A=this.getFragmentStyle(y),D=A.stylesheet.featuresets;if(!D||!D[h])return this.fire(new i.y(new Error(`The featureset '${h}' does not exist in the map's style and cannot be queried.`))),[];const F=[];for(const z of D[h].selectors){const G=A.getOwnLayer(z.layer);G&&F.push(G)}return F}getConfigProperty(h,y){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(y,A.scope),F=A.options.get(D),z=F?F.value||F.default:null;return z?z.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(h,y){const A=i.B(h,y);return this._mergedIndoor[A]}setIndoorData(h,y){this.map.indoor.setIndoorData(y)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,y,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[y])return;const z=i.U(A);if(z.result!=="success")return void Sy(this,z.value);const G=z.value.expression,J=i.B(y,D.scope),ae=D.options.get(J);if(!ae)return;let le;const{minValue:je,maxValue:ve,stepValue:Ne,type:De,values:Pe}=F[y],We=i.U(F[y].default);We.result==="success"&&(le=We.value.expression),le?(this.options.set(J,Object.assign({},ae,{value:G,default:le,minValue:je,maxValue:ve,stepValue:Ne,type:De,values:Pe})),this.updateConfigDependencies(y)):this.fire(new i.y(new Error(`No schema defined for the config option "${y}" in the "${h}" fragment.`)))}getConfig(h){const y=this.getFragmentStyle(h);if(!y)return null;const A=y.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const z=i.B(F,y.scope),G=y.options.get(z),J=G?G.value||G.default:null;D[F]=J?J.serialize():null}return D}setConfig(h,y){const A=this.getFragmentStyle(h);A&&(A.updateConfig(y,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const y=this.getFragmentStyle(h);return y?y.stylesheet.schema:null}setSchema(h,y){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=y,A.updateConfig(A._config,y),this.updateConfigDependencies())}updateConfig(h,y){if(this._config=h,h||y)if(y)for(const A in y){let D,F;const z=i.U(y[A].default);if(z.result==="success"&&(D=z.value.expression),h&&h[A]!==void 0){const ve=i.U(h[A]);ve.result==="success"&&(F=ve.value.expression)}const{minValue:G,maxValue:J,stepValue:ae,type:le,values:je}=y[A];if(D){const ve=i.B(A,this.scope);this.options.set(ve,{default:D,value:F,minValue:G,maxValue:J,stepValue:ae,type:le,values:je})}else this.fire(new i.y(new Error(`No schema defined for config option "${A}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(h,y=()=>!0){for(const A of h){const D=this.getLayer(A);D&&y(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,y=>!h||y.expressionDependencies.configDependencies.has(h)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(y=>{const A=y._styleColorTheme.colorThemeOverride?y._styleColorTheme.colorThemeOverride:y._styleColorTheme.colorTheme;if(A){const D=y._evaluateColorThemeData(A);(!y._styleColorTheme.lut&&D!==""||y._styleColorTheme.lut&&D!==y._styleColorTheme.lut.data)&&y.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,y,A={}){this._checkLoaded();const D=h.id;if(this._layers[D])return void this.fire(new i.y(new Error(`Layer with id "${D}" already exists on this map`)));let F;if(h.type==="custom"){if(Sy(this,i.dt(h)))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof h.source=="object"&&(this.addSource(D,h.source),h=i.dp(h),h=Object.assign(h,{source:D})),this._validate(La,`layers.${D}`,h,{arrayIndex:-1},A))return;F=i.du(h,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(F),F.setEventedParent(this,{layer:{id:D}})}const z=i.B(F.source,F.scope);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(z),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(z);let G=this._order.length;if(y){const je=this._order.indexOf(y);if(je===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));F.slot===this._layers[y].slot?G=je:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(G,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const J=this.getOwnLayerSourceCache(F),ae=!!this.directionalLight&&this.directionalLight.shadowsEnabled();J&&F.canCastShadows()&&ae&&(J.castsShadows=!0);const le=this._changes.getRemovedLayer(F);if(le&&F.source&&J&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const je=i.B(F.source,F.scope);le.type!==F.type?this._changes.updateSourceCache(je,"clear"):(this._changes.updateSourceCache(je,"reload"),J.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,y){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===y)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(y){const z=this._order.indexOf(y);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${y}" does not exist on this map.`)));A.slot===this._layers[y].slot?F=z:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const y=this._checkLayer(h);if(!y)return;y.setEventedParent(null);const A=this._order.indexOf(h);this._order.splice(A,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(y.fqid),this._indoorDependentLayers.delete(y.fqid),this._changes.removeLayer(y);const D=this.getOwnLayerSourceCache(y);if(D&&D.castsShadows){let F=!1;for(const z in this._layers)if(this._layers[z].source===y.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}y.onRemove&&y.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const y in this._layers)if(this._layers[y].type===h)return!0;return!1}setLayerZoomRange(h,y,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===y&&D.maxzoom===A||(y!=null&&(D.minzoom=y),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,y){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==y&&(A.slot=y,this._updateLayer(A))}setFilter(h,y,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,y))return y==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Ii,`layers.${D.id}.filter`,y,{layerType:D.type},A)||(D.filter=i.dp(y),this._updateLayer(D)))}getFilter(h){const y=this._checkLayer(h);if(y)return i.dp(y.filter)}setLayoutProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(y),A)){if(A!=null&&(!D||D.validate!==!1)&&Sy(F,$t.call(Yr,{key:`layers.${h}.layout.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(y,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(y==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(y)?this.setPaintProperty(h,y,A,D):this.setLayoutProperty(h,y,A,D))}getLayoutProperty(h,y){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(y)}setPaintProperty(h,y,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(y),A)||A!=null&&(!D||D.validate!==!1)&&Sy(F,Fo.call(Yr,{key:`layers.${h}.paint.${y}`,layerType:F.type,objectKey:y,value:A,styleSpec:i.a6})))return;const z=F.setPaintProperty(y,A);F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),z&&this._updateLayer(F),this._changes.updatePaintProperties(F)}getPaintProperty(h,y){const A=this._checkLayer(h);if(A)return A.getPaintProperty(y)}setFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ae}=h.target,le=this.getFragmentStyle(ae),je=le.getFeaturesetLayers(J);for(const{source:ve,sourceLayer:Ne}of je)le.setFeatureState({id:h.id,source:ve,sourceLayer:Ne},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ae=this.getLayer(J);this.setFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},y)}return}const A=h.source,D=h.sourceLayer,F=this._checkSource(A);if(!F)return;const z=F.type;if(z==="geojson"&&D)return void this.fire(new i.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(z==="vector"&&!D)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided.")));const G=this.getOwnSourceCaches(A);for(const J of G)J.setFeatureState(D,h.id,y)}removeFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:J,importId:ae}=h.target,le=this.getFragmentStyle(ae),je=le.getFeaturesetLayers(J);for(const{source:ve,sourceLayer:Ne}of je)le.removeFeatureState({id:h.id,source:ve,sourceLayer:Ne},y)}else if("layerId"in h.target){const{layerId:J}=h.target,ae=this.getLayer(J);this.removeFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},y)}return}const A=h.source,D=this._checkSource(A);if(!D)return;const F=D.type,z=F==="vector"?h.sourceLayer:void 0;if(F==="vector"&&!z)return void this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(y&&typeof h.id!="string"&&typeof h.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const G=this.getOwnSourceCaches(A);for(const J of G)J.removeFeatureState(z,h.id,y)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:G}=h.target,J=this.getFragmentStyle(G),ae=J.getFeaturesetLayers(z);for(const{source:le,sourceLayer:je}of ae){const ve=J.getFeatureState({id:h.id,source:le,sourceLayer:je});if(ve&&!F)F=ve;else if(!i.by(F,ve))return void this.fire(new i.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in h.target){const{layerId:z}=h.target,G=this.getLayer(z);F=this.getFeatureState({id:h.id,source:G.source,sourceLayer:G.sourceLayer})}return F}const y=h.source,A=h.sourceLayer,D=this._checkSource(y);if(D){if(D.type!=="vector"||A)return h.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(y)[0].getFeatureState(A,h.id);this.fire(new i.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(h){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,h),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const h=this.getTerrain(),y=h&&this.terrain&&this.terrain.scope===this.scope?h:this.stylesheet.terrain;return i.dv({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:y,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},A=>A!==void 0)}_updateFilteredLayers(h){for(const y of Object.values(this._mergedLayers))h(y)&&this._updateLayer(y)}_updateLayer(h){this._changes.updateLayer(h);const y=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&y&&y.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),y.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const y=G=>this._mergedLayers[G].is3D(!!this.terrain),A=this.order,D={},F=[];for(let G=A.length-1;G>=0;G--){const J=A[G];if(y(J)){D[J]=G;for(const ae of h){const le=ae[J];if(le)for(const je of le)F.push(je)}}}F.sort((G,J)=>J.intersectionZ-G.intersectionZ);const z=[];for(let G=A.length-1;G>=0;G--){const J=A[G];if(y(J))for(let ae=F.length-1;ae>=0;ae--){const le=F[ae].feature;if(le.layer&&D[le.layer.id]{if(Y3.has(le.type))return;const je=this.getOwnLayerSourceCache(le),ve=F[je.id]=F[je.id]||{sourceCache:je,layers:{},has3DLayers:!1};le.is3D(!!this.terrain)&&(ve.has3DLayers=!0),ve.layers[le.fqid]=ve.layers[le.fqid]||{styleLayer:le,targets:[]},ve.layers[le.fqid].targets.push({filter:D})};if(y&&y.layers){if(!Array.isArray(y.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const le of y.layers){const je=this._layers[le];if(!je)return this.fire(new i.y(new Error(`The layer '${le}' does not exist in the map's style and cannot be queried for features.`))),[];z(je)}}else for(const le in this._layers)z(this._layers[le]);const G=this._queryRenderedFeatures(h,F,A),J=this._flattenAndSortRenderedFeatures(G),ae=[];for(const le of J)i.dw(le.layer.id)===this.scope&&ae.push(le);return ae}queryRenderedFeatureset(h,y,A){let D;y&&!Array.isArray(y)&&y.filter&&(this._validate(Ii,"queryRenderedFeatures.filter",y.filter,null,y),D=i.b6(y.filter));const F="mock",z=[];if(y&&y.target)z.push(Object.assign({},y,{targetId:F,filter:D}));else{const le=this.getFeaturesetDescriptors();for(const je of le)z.push({targetId:F,filter:D,target:je});for(const{style:je}of this.fragments){const ve=je.getFeaturesetDescriptors();for(const Ne of ve)z.push({targetId:F,filter:D,target:Ne})}}const G=this.queryRenderedTargets(h,z,A),J=[],ae=new Set;for(const le of G)for(const je of le.variants[F])by(je,le,ae)||J.push(new i.dx(le,je));return J}queryRenderedTargets(h,y,A){const D={},F=(G,J,ae,le)=>{const je=D[J.id]=D[J.id]||{sourceCache:J,layers:{},has3DLayers:!1};if(je.layers[G.fqid]=je.layers[G.fqid]||{styleLayer:G,targets:[]},G.is3D(!!this.terrain)&&(je.has3DLayers=!0),!le)return ae.uniqueFeatureID=!1,void je.layers[G.fqid].targets.push(ae);je.layers[G.fqid].targets.push(Object.assign({},ae,{namespace:le.namespace,properties:le.properties,uniqueFeatureID:le.uniqueFeatureID}))};for(const G of y)if("featuresetId"in G.target){const{featuresetId:J,importId:ae}=G.target,le=this.getFragmentStyle(ae);if(!le||!le._featuresetSelectors)continue;const je=le._featuresetSelectors[J];if(!je){this.fire(new i.y(new Error(`The featureset '${J}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const ve of je){const Ne=le.getOwnLayer(ve.layerId);Ne&&!Y3.has(Ne.type)&&F(Ne,le.getOwnLayerSourceCache(Ne),G,ve)}}else if("layerId"in G.target){const{layerId:J}=G.target,ae=this.getLayer(J);if(!ae||Y3.has(ae.type))continue;F(ae,this.getLayerSourceCache(ae),G)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,y,A){const D=[],F=!!this.map._showQueryGeometry,z=uo.createFromScreenPoints(h,A);for(const G in y){const J=Q1(z,y[G],this._availableImages,A,F);Object.keys(J).length&&D.push(J)}if(this.placement)for(const G in y){if(!y[G].sourceCache._onlySymbols)continue;const J=X1(z.screenGeometry,y[G],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(J).length&&D.push(J)}return D}querySourceFeatures(h,y){const A=y&&y.filter;A&&this._validate(Ii,"querySourceFeatures.filter",A,null,y);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(J1(z,y));return D}addSourceType(h,y,A){return tp.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(tp.setSourceType(h,y),y.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:y.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,y,A={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const G in h)if(!i.by(h[G],D[G])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,y,A),this.light.updateTransitions(z)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=i.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&i.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(h,y=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),y===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let A=h;const D=!("source"in h)||h.source==null;if(y===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const G="terrain-dem-src";this.addSource(G,A.source),A=i.dp(A),A=Object.assign(A,{source:G})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const G=this.terrain?this.getFragmentStyle(this.terrain.scope):null;G&&(z.style=G.serialize())}if(this._validate(Vn,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&y!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,y),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const G of Object.keys(i.a6.terrain))!A.hasOwnProperty(G)&&i.a6.terrain[G].default&&(A[G]=i.a6.terrain[G].default);for(const G in h)if(!i.by(h[G],z[G])){F.set(h,this.options),this.stylesheet.terrain=h;const J=this._getTransitionParameters({duration:0});F.updateTransitions(J),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const y=this.fog=new Pn(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createSnow(h){const y=this.snow=new pl(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_createRain(h){const y=this.rain=new co(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const h of this.map._markers)h._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(h){if(this._checkLoaded(),!h)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const y=this.fog;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.fog=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createFog(h);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(h){if(this._checkLoaded(),!h)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const y=this.snow;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.snow=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createSnow(h);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(h){if(this._checkLoaded(),!h)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const y=this.rain;if(!i.by(y.get(),h)){y.set(h,this.options),this.stylesheet.rain=y.get();const A=this._getTransitionParameters({duration:0});y.updateTransitions(A)}}else this._createRain(h);this._markersNeedUpdate=!0}_reloadColorTheme(){const h=()=>{for(const D in this._layers)this._layers[D].lut=this._styleColorTheme.lut;for(const D in this._sourceCaches)this._sourceCaches[D].clearTiles()},y=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!y)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(y);this._loadColorTheme(A).then(()=>{this.fire(new i.z("colorthemeset")),h()}).catch(D=>{i.w(`Couldn't set color theme: ${D}`)})}setColorTheme(h){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&i.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=h,this._reloadColorTheme()}setImportColorTheme(h,y){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=y,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],y=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):y.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...y)}_createTerrain(h,y){const A=this.terrain=new Ut(h,y,this.scope,this.options,this.map.getWorldview());y===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});A.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="fill-extrusion"&&this._updateLayer(y)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const y=this._layers[h];y.type==="symbol"&&this._updateLayer(y)}}_validate(h,y,A,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return Sy(this,h.call(Yr,Object.assign({key:y,style:z,value:A,styleSpec:i.a6},D)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.dy.off("pluginStateChange",this._rtlTextPluginCallback);for(const h in this._mergedLayers)this._mergedLayers[h].setEventedParent(null);for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles(),this._mergedSourceCaches[h].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(h){const y=this.getSourceCaches(h);for(const A of y)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const y=this._mergedLayers[h];y._clear&&y._clear()}}reloadSource(h){const y=this.getSourceCaches(h);for(const A of y)A.resume(),A.reload()}reloadSources(){for(const h of this.getSources())h.reload&&h.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(h=>{h.modelManager.reloadModels(h.scope)})}updateSources(h){let y;this.directionalLight&&(y=i2(this.directionalLight));const A=new Set,D=new Set;for(const F in this._mergedLayers){const z=this._mergedLayers[F];z.type==="building"&&A.add(z.source),z.hasElevation()&&!D.has(z.source)&&D.add(z.source)}for(const F in this._mergedSourceCaches){const z=this._mergedSourceCaches[F],G=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,y,G)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const y=this._sourceCaches[h];y.resume(),y.reload()}}_updatePlacement(h,y,A,D,F,z,G=!1){let J=!1,ae=!1;const le={},je={};for(const Pe of this._mergedOrder){const We=this._mergedLayers[Pe];if(We.type!=="symbol")continue;const Ve=i.B(We.source,We.scope);let nt=le[Ve];if(!nt){const ot=this.getLayerSourceCache(We);if(!ot)continue;const Et=ot.getRenderableIds(!0).map(Nt=>ot.getTileByID(Nt));je[Ve]=Et.slice(),nt=le[Ve]=Et.sort((Nt,Tt)=>Tt.tileID.overscaledZ-Nt.tileID.overscaledZ||(Nt.tileID.isLessThan(Tt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(We,nt,y.center.lng,y.projection);J=J||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),G=G||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const ve=!!(this.placement&&!y.equals(this.placement.transform)),Ne=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),De=(ve||Ne||J||this.placement&&this.placement.isStale())&&D===0;if((G||!this.pauseablePlacement||De||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),y.zoom))&&(this.pauseablePlacement=new Ac(y,this._mergedOrder,G||D===0,A,D,F,this.placement,this.fog&&y.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,le,je,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ae=!0),J&&this.pauseablePlacement.placement.setStale()),ae||J){this._buildingIndex.onNewFrame(y.zoom);for(let Pe=0;PeF===h.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${h.id}' already exists in the map's style.`)));if(!y)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===y);return D===-1&&this.fire(new i.y(new Error(`Import with id "${y}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,y)}updateImport(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof y=="string"?(this.setImportUrl(h,y),this):(y.url&&y.url!==A[D].url&&this.setImportUrl(h,y.url),i.by(y.config,A[D].config)||this.setImportConfig(h,y.config,y.data.schema),i.by(y.data,A[D].data)||this.setImportData(h,y.data),this)}moveImport(h,y){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(y);if(F===-1)return this;const z=A[D],G=this.fragments[D];return A=A.filter(({id:J})=>J!==h),this.fragments=this.fragments.filter(({id:J})=>J!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(G).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,y){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=y;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(y),this}setImportData(h,y){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:y?(this.fragments[A].style.setState(y),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,y,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;y?F[D].config=y:delete F[D].config;const z=this.fragments[D];A&&z.style.stylesheet&&(z.style.stylesheet.schema=A);const G=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=y,z.style.updateConfig(y,G),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const y=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(y.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const y=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return y===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),y}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const y in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[y];A&&h.push(A.getSource())}return h}getSource(h,y){const A=this.getSourceCache(h,y);return A&&A.getSource()}getLayerSource(h){const y=this.getLayerSourceCache(h);return y&&y.getSource()}getSourceCache(h,y){const A=i.B(h,y);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const y=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[y]:this._mergedOtherSourceCaches[y]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const y=[];return this._mergedOtherSourceCaches[h]&&y.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&y.push(this._mergedSymbolSourceCaches[h]),y}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const y in h){const A=h[y];A==="reload"?this.reloadSource(y):A==="clear"&&this.clearSource(y)}}updateLayers(h){const y=this._changes.getUpdatedPaintProperties();for(const A of y){const D=this.getLayer(A);D&&D.updateTransitions(h)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(h){this.stylesheet.glyphs=h,this.glyphManager.setURL(h)}getImages(h,y,A){this.imageManager.getImages(y.images,y.scope,A),this._updateTilesForChangedImages();const D=z=>{if(z){const G=y.images.map(J=>i.I.toString(J));z.setDependencies(y.tileID.key,y.type,G)}},F=i.B(y.source,y.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),y.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,y,A){this.imageManager.rasterizeImages(y,A)}getGlyphs(h,y,A){this.glyphManager.getGlyphs(y.stacks,A)}getResource(h,y,A){return i.dz(y,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const y=[];return this._otherSourceCaches[h]&&y.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&y.push(this._symbolSourceCaches[h]),y}_isSourceCacheLoaded(h){const y=this.getOwnSourceCaches(h);return y.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):y.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,y){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const A=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(A||D||y&&y.type==="batched-model"||h.type==="model")return!0}else if(h.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(h=>{h.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}tp.getSourceType=function(T){return Km[T]},tp.setSourceType=function(T,h){Km[T]=h},tp.registerForPluginStateChange=i.dA;class VR extends i.E{constructor(h){super(),this._style=h,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},i.aY(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(h){h===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=h,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(h){this._activeFloorsVisible=h,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(h){for(const[y,A]of Object.entries(h.buildings))if(this._buildings[y])for(const D of A.floorIds)this._buildings[y].floors[D]||(this._buildings[y].floors[D]=A.floors[D]);else this._buildings[y]=A;for(const y of h.activeFloors)this._activeFloors.add(y);this._updateIndoorSelector()}getIndoorTileOptions(h,y){const A=this._style.getIndoorSourceLayers(h,y);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,y,A){const D=function(F,z,G,J){let ae=null,le=Number.MAX_SAFE_INTEGER;if(J<16)return null;for(const[je,ve]of Object.entries(F)){const Ne=ve.center;if(Ne){const De=z.distanceTo(i.aT.convert(Ne));De({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,G)=>G.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var ib=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #ifdef RENDER_CUTOFF float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);} #endif`,ob=` #ifdef DUAL_SOURCE_BLENDING layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1; #else layout(location=0) out vec4 glFragColor; #endif #ifdef USE_MRT1 layout(location=1) out vec4 out_Target1; #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} #ifdef INDICATOR_CUTOUT uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params; #endif vec4 applyCutout(vec4 color,float height) { #ifdef INDICATOR_CUTOUT float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0); #else return color; #endif } #ifdef DEBUG_WIREFRAME #define HANDLE_WIREFRAME_DEBUG \\ glFragColor=vec4(0.7,0.0,0.0,0.7); \\ gl_FragDepth=gl_FragCoord.z-0.0001; #else #define HANDLE_WIREFRAME_DEBUG #endif #ifdef RENDER_CUTOFF uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity; #endif vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,r6=` #define EXTENT 8192.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0 float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);} #ifdef RENDER_CUTOFF uniform vec4 u_cutoff_params;out float v_cutoff_opacity; #endif const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt) {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib #define DECLARE_MATERIAL_TABLE_INFO #endif`,Q3="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",cm=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif #ifdef TERRAIN uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; } #endif #ifdef DEPTH_OCCLUSION uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset; #ifdef DEPTH_D24 float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);} #else highp float unpack_depth_rgba(vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif #ifdef DEPTH_D24 float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r); #else float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5)); #endif return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5; #ifdef DEPTH_D24 highp vec4 depth=vec4( texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r );depth=unpack_depth4(depth); #else highp vec4 depth=vec4( unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy)) ); #endif return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) { #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r); #else highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y))); #endif res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w; #ifdef CLIP_ZERO_TO_ONE coord.z=-1.0+2.0*coord.z; #endif highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));} #else bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; } #endif`,X3=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,tr=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`,n6=`#ifdef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0) );}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0) );}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);} #endif`,J3=`#ifdef RASTER_ARRAY uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;} #endif uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`,eC=`#ifdef RENDER_SHADOWS uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];} #endif`,a6=`#ifdef RENDER_SHADOWS precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) { #ifdef CLIP_ZERO_TO_ONE highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias); #else highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias); #endif return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w; #ifdef SHADOWS_SINGLE_CASCADE vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias); #else light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0); #endif }highp float calculate_shadow_bias(float NDotL) { #ifdef NORMAL_OFFSET return 0.5*u_shadow_bias.x; #else return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z)); #endif }float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy) {highp vec2 biasUV=vec2( pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);} #endif`;const l2=/#include\s+"([^"]+)"/g,Uf=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,i6=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,iv=new Set(["ifdef","ifndef","elif","if","defined"]),ov=new Set;Ty(ib,ov),Ty(r6,ov),Ty(ob,ov);const My={"_prelude_fog.vertex.glsl":X3,"_prelude_terrain.vertex.glsl":cm,"_prelude_shadow.vertex.glsl":eC,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer #define MATERIAL_TABLE_DEBUG 0 uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset; #if MATERIAL_TABLE_DEBUG vec4 colorDebug; #endif };uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; }uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info; #if MATERIAL_TABLE_DEBUG const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green; #endif uint offset=0u; #if MATERIAL_TABLE_DEBUG bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;} #endif offset++; #if MATERIAL_TABLE_DEBUG uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;} #endif offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++); #if MATERIAL_TABLE_DEBUG if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;} #endif uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset); #if MATERIAL_TABLE_DEBUG if(keepFinding) {uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}} #endif offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup; #if MATERIAL_TABLE_DEBUG if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}} #endif info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes) {uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);} #define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset) #define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset) #define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); #define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug; #endif`,"_prelude_fog.fragment.glsl":tr,"_prelude_shadow.fragment.glsl":a6,"_prelude_lighting.glsl":` #ifdef LIGHTING_3D_MODE uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);} #endif`,"_prelude_raster_array.glsl":n6,"_prelude_raster_particle.glsl":J3},tC={};Ba("",cm),Ba(tr,X3),Ba(a6,eC),Ba(n6,""),Ba(J3,"");const HR=Ba(ob,r6),sC=ib,Bme=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",sC,HR.fragmentSource].join(` `),GR=["precision highp float;",sC,HR.vertexSource].join(` `);var o6={background:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE in vec4 v_color; #endif void main() {vec4 out_color; #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_lighting.glsl" in vec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength; #ifdef LIGHTING_3D_MODE uniform mediump vec4 u_color;out vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef LIGHTING_3D_MODE v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength); #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*u_opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),building:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos; #ifdef BUILDING_FAUX_FACADE in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity; #endif #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT in highp float v_flood_radius;in float v_has_flood_light; #endif uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));} #ifdef BUILDING_FAUX_FACADE float hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y; #if 0 if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0; #else if (x_major) {out_normal=sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao; #endif return out_color;} #endif vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a; #ifdef BUILDING_FAUX_FACADE if (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);} #endif vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0; #ifdef RENDER_SHADOWS #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif #else shadowed_lighting_factor=dot(xy_flipped_normal,u_lighting_directional_dir); #endif color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb); #ifdef FLOOD_LIGHT float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance); #endif color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive); #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z)); #endif color*=u_opacity; #ifdef INDICATOR_CUTOUT color=applyCutout(color,v_pos.z); #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord); #endif glFragColor=color; #ifdef DEBUG_SHOW_NORMALS color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color; #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos; #ifdef BUILDING_FAUX_FACADE out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #ifdef FLOOD_LIGHT out highp float v_flood_radius;out float v_has_flood_light; #endif const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #ifdef BUILDING_FAUX_FACADE mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);} #endif #pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive #pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive void main() { #pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive #pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive #ifdef FLOOD_LIGHT v_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius); #endif vec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0; #ifdef BUILDING_FAUX_FACADE v_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);float height=a_centroid_3.z;depth_offset=min(1000.0,height)*0.0000002;} #endif v_pos=a_pos_3f; #ifdef RENDER_CUTOFF vec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity; #endif #ifdef RENDER_SHADOWS vec3 shadow_pos=v_pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0); #endif #ifdef FOG v_fog_pos=fog_position(v_pos); #endif gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;}`),buildingBloom:Ba(`in vec4 v_color_emissive; #pragma mapbox: define-attribute highp vec4 bloom_attenuation #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0; #ifdef HAS_ATTRIBUTE_a_bloom_attenuation float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance); #endif #ifdef RENDER_CUTOFF opacity*=v_cutoff_opacity; #endif glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f; #pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive #pragma mapbox: define-attribute highp vec4 bloom_attenuation out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive #pragma mapbox: initialize-attribute highp vec4 bloom_attenuation #ifdef HAS_ATTRIBUTE_a_part_color_emissive vec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive); #else v_color_emissive=vec4(1.0); #endif gl_Position=u_matrix*vec4(a_pos_3f,1.0); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),buildingDepth:Ba(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,"in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" in vec3 v_data;in float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity uniform float u_emissive_strength;void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif glFragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif #ifdef ELEVATED_ROADS in float a_circle_z_offset; #endif out vec3 v_data;out float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1); #endif #ifdef ELEVATED_ROADS world_center.z+=a_circle_z_offset+ELEVATION_BIAS; #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Ba("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Ba(`#include "_prelude_fog.fragment.glsl" uniform highp float u_intensity;in vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif out vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Ba(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(0.0); #endif HANDLE_WIREFRAME_DEBUG;}`,"in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Ba("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl" in vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition; #endif out float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation); #ifdef PROJECTION_GLOBE_VIEW #ifndef PROJECTED_POS_ON_VIEWPORT vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition); #endif #endif vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Ba("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Ba("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl" in vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3; #endif out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),elevatedStructuresDepth:Ba(`void main() { #ifndef DEPTH_TEXTURE glFragColor=vec4(0.); #endif }`,"in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:Ba(`#ifdef DEPTH_RECONSTRUCTION in float v_height; #endif void main() { #ifdef DEPTH_RECONSTRUCTION if (v_height >=0.0) discard; #else #ifdef FEATURE_CUTOUT apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord); #endif #endif glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth; #ifdef DEPTH_RECONSTRUCTION out float v_height; #endif void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale); #ifdef DEPTH_RECONSTRUCTION if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height; #endif gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in vec3 v_normal;in float v_height; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth; #endif vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color) {color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength; #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color vec3 color=structure_color.xyz; #ifdef LIGHTING_3D_MODE vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz); #ifdef RENDER_SHADOWS float shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor); #else color=apply_lighting(color,transformed_normal); #endif color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);} #endif #ifdef FOG color=fog_apply(color,v_fog_pos); #endif vec4 out_color=vec4(color,1.0); #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_height); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth; #endif #pragma mapbox: define highp vec4 structure_color void main() { #pragma mapbox: initialize highp vec4 structure_color v_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1); #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fill:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=opacity; #ifdef INDICATOR_CUTOUT if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);} #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=z_offset; #endif }`),fillOutline:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp float z_offset #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden); #ifdef FLIP_Y v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif uniform float u_emissive_strength; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif in highp vec2 v_pos;in highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*(alpha*opacity); #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos;out highp vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw; #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef FLIP_Y v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world; #else v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #endif #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in highp vec2 v_pos;uniform float u_emissive_strength; #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif glFragColor=out_color*opacity; #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos; #ifdef ELEVATED_ROADS in float a_road_z_offset;out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif out highp vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define highp float z_offset void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize highp float z_offset #ifdef FILL_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio; #ifdef ELEVATED_ROADS z_offset+=a_road_z_offset;v_road_z_offset=z_offset; #endif float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef RENDER_SHADOWS vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset); #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" in vec4 v_color;in vec4 v_flat; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1; #endif uniform lowp float u_opacity; #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec2 v_ao; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) in vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) in highp vec3 v_normal; #endif uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor; #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) in float v_flood_radius;in float v_has_floodlight; #endif in float v_height; #pragma mapbox: define highp float emissive_strength void main() { #pragma mapbox: initialize highp float emissive_strength #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) vec3 normal=normalize(v_normal); #endif float z;vec4 color=v_color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001); #ifdef LIGHTING_3D_MODE normal=mix(normal,vec3(0.0,0.0,1.0),z); #else color=mix(v_color,v_roof_color,z); #endif #endif float h=max(0.0,v_height);float ao_shade=1.0; #ifdef FAUX_AO float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave); #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT color.rgb*=mix(ao_shade,1.0,v_has_floodlight); #else color.rgb*=ao_shade; #endif #else color.rgb*=ao_shade; #endif #endif #ifdef LIGHTING_3D_MODE float flood_radiance=0.0; #ifdef FLOOD_LIGHT flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight; #endif #ifdef RENDER_SHADOWS #ifdef FLOOD_LIGHT float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance); #else float shadowed_lighting_factor; #ifdef RENDER_CUTOFF shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;} #else shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w); #endif color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor); #endif #else color.rgb=apply_lighting(color.rgb,normal); #ifdef FLOOD_LIGHT color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance); #endif #endif color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity; #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h)); #endif #ifdef INDICATOR_CUTOUT color=applyCutout(color,h); #endif #ifdef FEATURE_CUTOUT color=apply_feature_cutout(color,gl_FragCoord); #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif uniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) out vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) out highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec2 v_ao; #endif #if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT) out float v_flood_radius;out float v_has_floodlight; #endif out float v_height;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));} #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define highp float flood_light_wall_radius #pragma mapbox: define highp float line_width #pragma mapbox: define highp float emissive_strength void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize highp float flood_light_wall_radius #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp float emissive_strength base*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE) v_normal=normal; #endif base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); #else h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float cutoff=1.0;vec3 scaled_pos=pos; #ifdef RENDER_CUTOFF vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0); #ifdef CLIP_ZERO_TO_ONE cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w); #else cutoff=cutoff_opacity(u_cutoff_params,ground.z); #endif if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale); #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0)); #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h; #ifdef RENDER_SHADOWS vec3 shd_pos0=pos;vec3 shd_pos1=pos; #ifdef NORMAL_OFFSET vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1); #endif float NdotL=0.0;float colorvalue=0.0; #ifndef LIGHTING_3D_MODE colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #endif #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE #ifdef FLOOD_LIGHT float is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale; #endif v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0); #else v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity; #endif #if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE) float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionDepth:Ba(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale; #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp float line_width #pragma mapbox: define highp vec4 color out highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp float line_width #pragma mapbox: initialize highp vec4 color base*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif vec3 pos; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h); #else pos=vec3(pos_nx.xy,t > 0.0 ? height : base); #endif #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}`),fillExtrusionPattern:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FILL_EXTRUSION_PATTERN_TRANSITION uniform float u_pattern_transition; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;in vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE in vec3 v_normal; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef FILL_EXTRUSION_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,height); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #include "_prelude_lighting.glsl" #include "_prelude_material_table.vertex.glsl" uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos; #ifdef RENDER_WALL_MODE in vec3 a_join_normal_inside; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif #ifdef TERRAIN uniform int u_height_type;uniform int u_base_type; #endif out highp vec2 v_pos;out vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;out vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE out vec3 v_normal; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define highp float pixel_ratio #pragma mapbox: define highp float line_width void main() {DECLARE_MATERIAL_TABLE_INFO #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump vec4 pattern #ifdef FILL_EXTRUSION_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize highp float pixel_ratio #pragma mapbox: initialize highp float line_width vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif #ifdef RENDER_WALL_MODE vec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5; #endif float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_normal=normal; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),groundShadow:Ba(`#include "_prelude_shadow.fragment.glsl" precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #ifdef FOG in float v_fog_opacity; #endif void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light); #ifdef RENDER_CUTOFF shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w)); #endif #ifdef FOG shadow=mix(shadow,vec3(1.0),v_fog_opacity); #endif #ifdef INDICATOR_CUTOUT shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r); #endif glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #ifdef FOG out float v_fog_opacity; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0); #ifdef FOG v_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos); #endif }`),fillExtrusionGroundEffect:Ba(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size; #ifdef SDF_SUBPASS in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);} #ifdef FOG in highp float v_fog; #endif #endif void main() { #ifdef CLEAR_SUBPASS vec4 color=vec4(1.0); #ifdef CLEAR_FROM_TEXTURE color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)); #endif glFragColor=color; #else #ifdef SDF_SUBPASS highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0; #ifdef FOG fog=v_fog; #endif #ifdef RENDER_CUTOFF fog*=v_cutoff_opacity; #endif glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog)); #else #ifdef USE_MRT1 out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0); #else vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass); #ifdef OVERDRAW_INSPECTOR color=vec4(1.0); #endif glFragColor=color; #endif #endif HANDLE_WIREFRAME_DEBUG; #endif }`,`#include "_prelude_fog.vertex.glsl" in highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark; #ifdef SDF_SUBPASS out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao; #ifdef FOG out highp float v_fog; #endif #endif uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao; #pragma mapbox: define highp float flood_light_ground_radius const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() { #pragma mapbox: initialize highp float flood_light_ground_radius vec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp; #ifdef SDF_SUBPASS v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius); #ifdef FOG v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos); #endif #endif float hidden_by_landmark=0.0; #ifdef HAS_CENTROID hidden_by_landmark=a_hidden_by_landmark; #endif float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0)); #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif }`),hillshadePrepare:Ba(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength); #endif #ifdef FOG glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos)); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv; #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;in vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha; #ifdef RENDER_LINE_DASH float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture(u_gradient_image,v_uv.xy); #ifdef MULTIPLY_LINE_GRADIENT_COLOR out_color*=color; #endif #else out_color=color; #endif float trim_alpha=1.0; #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=1.0-transition_factor;} #endif if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}} #ifdef RENDER_LINE_BORDER float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}} #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif out_color*=(alpha*opacity); #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define EXTRUDE_SCALE 0.015873016 in vec2 a_pos_normal;in vec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) in vec3 a_z_offset_width; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) in highp vec3 a_packed; #endif #ifdef RENDER_LINE_DASH in float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform highp float u_floor_width_scale; #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec3 v_uv; #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define mediump float side_z_offset #pragma mapbox: define lowp float border_width #pragma mapbox: define lowp vec4 border_color #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float side_z_offset #pragma mapbox: initialize lowp float border_width #pragma mapbox: initialize lowp vec4 border_color #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth; #ifdef VARIABLE_LINE_WIDTH bool left=normal.y==1.0;halfwidth=(u_width_scale*(left ? a_z_offset_width.y : a_z_offset_width.z))/2.0;a_z_offset+=left ? side_z_offset : 0.0;v_normal=side_z_offset > 0.0 && left ? vec2(0.0) : v_normal; #else halfwidth=(u_width_scale*width)/2.0; #endif offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude; #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0; #ifdef CROSS_SLOPE_VERTICAL float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress); #else v_uv=vec3(a_uv_x,0.0,line_progress); #endif #endif #ifdef RENDER_LINE_DASH float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),linePattern:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image; #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef LINE_PATTERN_TRANSITION uniform float u_pattern_transition; #endif in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width; #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS in highp float v_road_z_offset; #endif #ifdef LINE_JOIN_NONE in vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #pragma mapbox: define mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize lowp float emissive_strength vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif #ifdef LINE_PATTERN_TRANSITION vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);} #endif #ifdef LINE_JOIN_NONE highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);} #endif #ifdef LIGHTING_3D_MODE color=apply_lighting_with_emission_ground(color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef ELEVATED_ROADS color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #else color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}} #ifdef INDICATOR_CUTOUT color=applyCutout(color,v_z_offset); #endif glFragColor=color; #ifdef DUAL_SOURCE_BLENDING glFragColorSrc1=vec4(vec3(0.0),emissive_strength); #else #ifdef USE_MRT1 out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #include "_prelude_terrain.vertex.glsl" #define scale 0.015873016 in vec2 a_pos_normal;in vec4 a_data; #if defined(ELEVATED) || defined(ELEVATED_ROADS) in vec3 a_z_offset_width; #endif #ifdef RENDER_LINE_TRIM_OFFSET in highp vec3 a_packed; #endif in highp float a_linesofar; #ifdef LINE_JOIN_NONE in highp vec3 a_pattern_data;out vec2 v_pattern_data; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #endif uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale; #ifdef ELEVATED uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) { #ifdef ELEVATION_REFERENCE_SEA return 0.0; #else return elevation(apos); #endif } #endif out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width; #ifdef RENDER_LINE_TRIM_OFFSET out highp vec3 v_uv; #endif #ifdef ELEVATED_ROADS out highp float v_road_z_offset; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define mediump float blur #pragma mapbox: define mediump float opacity #pragma mapbox: define mediump float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define mediump float floorwidth #pragma mapbox: define mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: define mediump vec4 pattern_b #endif #pragma mapbox: define mediump float pixel_ratio #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize mediump float blur #pragma mapbox: initialize mediump float opacity #pragma mapbox: initialize mediump float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize mediump float floorwidth #pragma mapbox: initialize mediump vec4 pattern #ifdef LINE_PATTERN_TRANSITION #pragma mapbox: initialize mediump vec4 pattern_b #endif #pragma mapbox: initialize mediump float pixel_ratio #pragma mapbox: initialize lowp float emissive_strength float a_z_offset; #if defined(ELEVATED) || defined(ELEVATED_ROADS) a_z_offset=a_z_offset_width.x; #endif float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy; #ifdef ELEVATED_ROADS v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude; #else #ifdef ELEVATED vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0; #ifdef CROSS_SLOPE_VERTICAL float top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0); #else #ifdef CROSS_SLOPE_HORIZONTAL float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset; #else float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset; #endif #endif gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden); #else gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden); #endif #endif #ifdef ELEVATED_ROADS #ifdef RENDER_SHADOWS vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #endif #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur)); #else v_gamma_scale=1.0; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress); #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale); #ifdef LINE_JOIN_NONE v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y); #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif #ifdef INDICATOR_CUTOUT v_z_offset=a_z_offset; #endif }`),raster:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" #include "_prelude_raster_array.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth; #ifdef PROJECTION_GLOBE_VIEW in float v_split_fade; #endif uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength; #ifndef RASTER_ARRAY uniform highp sampler2D u_image0;uniform sampler2D u_image1; #endif #ifdef RASTER_COLOR uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res; #endif void main() {vec4 color0,color1,color;vec2 value; #ifdef RASTER_COLOR #ifdef RASTER_ARRAY #ifdef RASTER_ARRAY_LINEAR value=mix( raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #else value=mix( raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t ); #endif if (value.y > 0.0) value.x/=value.y; #else color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a); #endif color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y; #else color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t); #endif color.a*=u_opacity; #ifdef GLOBE_POLES color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition); #endif vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef PROJECTION_GLOBE_VIEW glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade)); #endif #ifdef RENDER_CUTOFF glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth); #endif #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif #ifdef USE_MRT1 out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in vec2 a_pos;in vec2 a_texture_pos; #endif out vec2 v_pos0;out vec2 v_pos1;out float v_depth; #ifdef PROJECTION_GLOBE_VIEW out float v_split_fade; #endif void main() {vec2 uv; #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz); #endif #else float w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1; #ifdef RENDER_CUTOFF v_depth=gl_Position.z; #endif }`),rasterParticle:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb; #endif #ifdef FOG highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit)); #endif glFragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center; #define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8 in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv; #ifdef PROJECTION_GLOBE_VIEW vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif #else uv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif #endif v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Ba("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl" in float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2( mod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Ba("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Ba(`#include "_prelude_raster_particle.glsl" uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow( linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4) );highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Ba(`#include "_prelude_lighting.glsl" #include "_prelude_shadow.fragment.glsl" #define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor; #ifdef ICON_TRANSITION uniform float u_icon_transition; #endif #ifdef COLOR_ADJUSTMENT uniform mat4 u_color_adj_mat; #endif #ifdef INDICATOR_CUTOUT in highp float v_z_offset; #else #ifdef RENDER_SHADOWS in highp float v_z_offset; #endif #endif in vec2 v_tex_a; #ifdef ICON_TRANSITION in vec2 v_tex_b; #endif in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL in float is_sdf;in vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2]; #ifdef RENDER_TEXT_AND_SYMBOL if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif return;} #endif #ifdef RENDER_SDF float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha; #else #ifdef ICON_TRANSITION vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b); #else out_color=texture(u_texture,v_tex_a); #endif #ifdef APPLY_LUT_ON_GPU out_color=applyLUT(u_lutTexture,out_color); #endif #ifdef COLOR_ADJUSTMENT out_color=u_color_adj_mat*out_color; #endif #endif out_color*=opacity*fade_opacity; #ifdef LIGHTING_3D_MODE out_color=apply_lighting_with_emission_ground(out_color,emissive_strength); #ifdef RENDER_SHADOWS float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth); #ifdef TERRAIN out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light); #else out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light); #endif #endif #endif #ifdef INDICATOR_CUTOUT out_color=applyCutout(out_color,v_z_offset); #endif #ifdef FEATURE_CUTOUT out_color=apply_feature_cutout(out_color,gl_FragCoord); #endif glFragColor=out_color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl" #include "_prelude_shadow.vertex.glsl" #define APPEARANCE_ICON 1.0 in vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity; #ifdef Z_OFFSET in float a_auto_z_offset; #endif #ifdef PROJECTION_GLOBE_VIEW in vec3 a_globe_anchor;in vec3 a_globe_normal; #endif #ifdef ICON_TRANSITION in vec2 a_texb; #endif #ifdef OCCLUSION_QUERIES in float a_occlusion_query_opacity; #endif #ifdef ELEVATED_ROADS in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale; #endif #ifdef INDICATOR_CUTOUT out highp float v_z_offset; #else #ifdef RENDER_SHADOWS out highp float v_z_offset; #endif #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif out vec2 v_tex_a; #ifdef ICON_TRANSITION out vec2 v_tex_b; #endif out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity; #ifdef RENDER_TEXT_AND_SYMBOL out float is_sdf;out vec2 v_tex_a_icon; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth; #endif #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur #pragma mapbox: define lowp float emissive_strength #pragma mapbox: define lowp float occlusion_opacity #pragma mapbox: define lowp float z_offset void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur #pragma mapbox: initialize lowp float emissive_strength #pragma mapbox: initialize lowp float occlusion_opacity #pragma mapbox: initialize lowp float z_offset vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor); #ifdef Z_OFFSET e+=a_auto_z_offset; #endif vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w; #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w; #endif vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW #ifdef PROJECTED_POS_ON_VIEWPORT projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0); #else vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #endif #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif #ifdef Z_OFFSET z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0; #else z+=u_pitch_with_map ? z_offset : 0.0; #endif float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change)); #ifdef DEPTH_OCCLUSION float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier; #endif #ifdef OCCLUSION_QUERIES float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier; #endif #ifdef Z_TEST_OCCLUSION out_fade_opacity*=occlusion_opacity; #endif float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else #ifdef ELEVATED_ROADS vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y; #else pos=vec3(projected_pos.xy/projected_pos.w+offset,z); #endif #endif gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize; #ifdef RENDER_TEXT_AND_SYMBOL is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon; #endif #ifdef ICON_TRANSITION v_tex_b=a_texb/u_texsize; #endif #ifdef RENDER_SHADOWS vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz; #ifdef NORMAL_OFFSET vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1(); #endif v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w; #endif #ifdef INDICATOR_CUTOUT v_z_offset=e; #else #ifdef RENDER_SHADOWS v_z_offset=e; #endif #endif }`),terrainRaster:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif in vec2 v_pos0; #ifdef FOG in float v_fog_opacity; #endif #ifdef RENDER_SHADOWS in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1; #endif uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color; #ifdef LIGHTING_3D_MODE const vec3 normal=vec3(0.0,0.0,1.0); #ifdef RENDER_SHADOWS float cutoffOpacity=1.0; #ifdef RENDER_CUTOFF cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w); #endif #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0; #else float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity)); #endif #else float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor); #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0; #endif #endif #else color=image_color; #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0; #ifdef FOG out float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1; #endif void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.); #endif }`),terrainDepth:Ba("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl" uniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Ba(`#include "_prelude_fog.fragment.glsl" in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,Q3),skyboxGradient:Ba(`#include "_prelude_fog.fragment.glsl" in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif }`,Q3),skyboxCapture:Ba(` in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float; #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_lighting.glsl" uniform sampler2D u_image0; #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS uniform sampler2D u_image1;uniform float u_emissive_texture_available; #endif uniform float u_far_z_cutoff;in vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING highp vec2 uv=gl_FragCoord.xy/u_viewport; #ifdef FLIP_Y uv.y=1.0-uv.y; #endif highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias); #else raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=vec4(raster.rgb*antialias,raster.a*antialias); #endif #else color=texture(u_image0,v_pos0); #ifdef LIGHTING_3D_MODE #ifdef LIGHTING_3D_ALPHA_EMISSIVENESS float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0; #else color=apply_lighting_ground(color); #endif #endif #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_terrain.vertex.glsl" uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES in vec3 a_globe_pos;in vec2 a_uv; #else in vec2 a_pos; #endif out vec2 v_pos0;void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos);globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Ba(`#include "_prelude_fog.fragment.glsl" uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) { #ifdef ALPHA_PASS glFragColor=vec4(0,0,0,0);return; #else #ifdef NATIVE glFragColor=vec4(1,1,1,1); #else glFragColor=vec4(0,0,0,1); #endif return; #endif } #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb; #ifdef ALPHA_PASS float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a); #else vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t); #endif }`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:Ba(`#include "_prelude_fog.fragment.glsl" #include "_prelude_shadow.fragment.glsl" #include "_prelude_lighting.glsl" uniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix; #ifdef RENDER_SHADOWS in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows; #endif #ifdef OCCLUSION_TEXTURE_TRANSFORM uniform vec4 u_occlusionTextureTransform; #endif #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute highp vec2 uv_2f #ifdef HAS_ATTRIBUTE_a_pbr in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params; #endif #ifdef HAS_TEXTURE_u_baseColorTexture uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff; #endif #ifdef HAS_TEXTURE_u_metallicRoughnessTexture uniform sampler2D u_metallicRoughnessTexture; #endif #ifdef HAS_TEXTURE_u_occlusionTexture uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity; #endif #ifdef HAS_TEXTURE_u_normalTexture uniform sampler2D u_normalTexture; #endif #ifdef HAS_TEXTURE_u_emissionTexture uniform sampler2D u_emissionTexture; #endif #ifdef APPLY_LUT_ON_GPU uniform highp sampler3D u_lutTexture; #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack; #ifdef DEPTH_D24 highp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;} #else highp float unpack_depth_rgba(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;} #endif bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size; #ifdef FLIP_Y coord.y=1.0-coord.y; #endif #ifdef DEPTH_D24 highp float depth=unpack_depth(texture(u_depthTexture,coord).r); #else highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord)); #endif return v_depth > depth+0.0005;} #endif #define saturate(_x) clamp(_x,0.,1.) vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor) { #ifdef LIGHTING_3D_MODE vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir)); #endif return apply_lighting(albedo,transformed_normal,lighting_factor); #else vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3; #endif }vec4 getBaseColor() {vec4 albedo=u_baseColorFactor; #ifdef HAS_ATTRIBUTE_a_color_3f albedo*=vec4(color_3f,1.0); #endif #ifdef HAS_ATTRIBUTE_a_pbr #else #ifdef HAS_ATTRIBUTE_a_color_4f albedo*=color_4f; #endif #endif #if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f) vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}} #ifdef UNPREMULT_TEXTURE_IN_SHADER if(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0; #endif if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;} #endif vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a); #ifdef APPLY_LUT_ON_GPU color=applyLUT(u_lutTexture,color); #endif return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) { #ifdef HAS_TEXTURE_u_normalTexture highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y; #ifdef FLIP_Y T=-T;B=-B; #endif highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res; #else return mat3(1.0); #endif }highp vec3 getNormal(){highp vec3 n; #ifdef HAS_ATTRIBUTE_a_normal_3f n=normalize(normal_3f); #else highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z)); #ifdef FLIP_Y n=normalize(cross(fdx,fdy)); #else n=normalize(cross(fdx,fdy))*-1.0; #endif #endif #if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap); #endif return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor; #ifdef HAS_ATTRIBUTE_a_pbr mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w; #endif #if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b; #endif const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness) {float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH) {return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH) {float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness) {highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV) {float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat) { #ifdef LIGHTING_3D_MODE return mat.diffuseColor; #else return mat.diffuseColor/PI; #endif }vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV) {vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal) {vec3 env_light=vec3(0.65,0.65,0.65); #ifdef LIGHTING_3D_MODE float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor; #endif vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor) {highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor; #ifdef RENDER_SHADOWS lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows); #else lighting_factor=NdotL; #endif vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0; #if !defined(LIGHTING_3D_MODE) const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL); #endif color*=intensityFactor;return color;}void main() { #ifdef TERRAIN_FRAGMENT_OCCLUSION if (isOccluded()) {discard;} #endif vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor; #ifdef LIGHTING_3D_MODE lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color; #endif vec4 finalColor; #ifdef DIFFUSE_SHADED vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor); #ifdef HAS_TEXTURE_u_occlusionTexture float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao; #endif finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity; #else Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0; #if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) #ifdef OCCLUSION_TEXTURE_TRANSFORM vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy; #else vec2 uv=uv_2f; #endif ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao; #endif vec4 emissive=u_emissiveFactor; #if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb); #endif #ifdef APPLY_LUT_ON_GPU float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength; #endif color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity; #ifdef HAS_ATTRIBUTE_a_pbr float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb; #ifdef APPLY_LUT_ON_GPU color_mix=applyLUT(u_lutTexture,color_mix); #endif color=mix(color,color_mix,min(1.0,resEmission)); #ifdef HAS_ATTRIBUTE_a_color_4f float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance); #endif #endif vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity); #endif #ifdef FOG finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w)); #endif #ifdef RENDER_CUTOFF finalColor*=v_cutoff_opacity; #endif #ifdef INDICATOR_CUTOUT finalColor=applyCutout(finalColor,v_position_height.w); #endif #ifdef FEATURE_CUTOUT finalColor=apply_feature_cutout(finalColor,gl_FragCoord); #endif glFragColor=finalColor; #ifdef OVERDRAW_INSPECTOR glFragColor=vec4(1.0); #endif HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl" #include "_prelude_shadow.vertex.glsl" in vec3 a_pos_3f; #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec2 uv_2f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f #pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr #pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix; #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_normal_matrix; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows; #endif out vec4 v_position_height;out lowp vec4 v_color_mix; #ifdef TERRAIN_FRAGMENT_OCCLUSION out highp float v_depth; #endif #ifdef HAS_ATTRIBUTE_a_pbr out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params; #endif vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() { #pragma mapbox: initialize-attribute highp vec3 normal_3f #pragma mapbox: initialize-attribute highp vec2 uv_2f #pragma mapbox: initialize-attribute highp vec3 color_3f #pragma mapbox: initialize-attribute highp vec4 color_4f #pragma mapbox: initialize-attribute-custom highp vec4 pbr #pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength highp mat4 normal_matrix; #ifdef INSTANCED_ARRAYS normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else normal_matrix=u_normal_matrix; #endif vec3 local_pos;mat3 rs; #ifdef MODEL_POSITION_ON_GPU vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos; #else local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a); #endif v_position_height.w=a_pos_3f.z; #ifdef HAS_ATTRIBUTE_a_pbr vec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x; #endif #ifdef FOG v_fog_pos=fog_position(local_pos); #endif #ifdef RENDER_CUTOFF v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z); #endif #ifdef TERRAIN_FRAGMENT_OCCLUSION v_depth=gl_Position.z/gl_Position.w; #ifdef CLIP_ZERO_TO_ONE v_depth=-1.0+2.0*v_depth; #endif #endif #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f); #else normal_3f=vec3(normal_matrix*vec4(normal_3f,0)); #endif #endif #ifdef HAS_ATTRIBUTE_a_pbr #ifdef HAS_ATTRIBUTE_a_color_4f v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0); #endif #endif #ifdef RENDER_SHADOWS vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0); #ifdef NORMAL_OFFSET #ifdef HAS_ATTRIBUTE_a_normal_3f #ifdef MODEL_POSITION_ON_GPU vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #else vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0(); #endif #endif #endif v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w; #endif }`),modelDepth:Ba(`in highp float v_depth;void main() { #ifndef DEPTH_TEXTURE glFragColor=pack_depth(v_depth); #endif }`,`in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth; #ifdef MODEL_POSITION_ON_GPU #ifdef INSTANCED_ARRAYS in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3; #else uniform highp mat4 u_instance; #endif uniform highp mat4 u_node_matrix; #endif void main() { #ifdef MODEL_POSITION_ON_GPU highp mat4 instance; #ifdef INSTANCED_ARRAYS instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3); #else instance=u_instance; #endif vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden); #else gl_Position=u_matrix*vec4(a_pos_3f,1); #endif v_depth=gl_Position.z/gl_Position.w;}`),stars:Ba(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv) {float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,` in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),snowParticle:Ba("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; uniform float u_horizontalOscillationRate; uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Ba("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",` in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; uniform float u_velocity; uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+ localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Ba("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:Ba("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl" in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos; #ifdef TERRAIN float e=elevation(world_pos.xy);world_pos.z+=e; #endif vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function Ty(T,h){const y=T.split(` `);for(let A of y){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(i6);if(D)for(const F of D)iv.has(F)||h.add(F)}}function Ba(T,h){const y=new Set,A=[],D=[];T=T.replace(l2,(z,G)=>(D.push(G),"")),h=h.replace(l2,(z,G)=>(A.push(G),""));let F=new Set(ov);Ty(T,F),Ty(h,F);for(const z of[...A,...D])tC[z]||(tC[z]=new Set,Ty(My[z],tC[z])),F=new Set([...F,...tC[z]]);return{fragmentSource:T=T.replace(Uf,(z,G,J,ae,le)=>(y.add(le),G==="define"?` #ifndef HAS_UNIFORM_u_${le} in ${J} ${ae} ${le}; #else uniform ${J} ${ae} u_${le}; #endif `:G==="initialize"?` #ifdef HAS_UNIFORM_u_${le} ${J} ${ae} ${le} = u_${le}; #endif `:G==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ae} ${le}; #endif `:G==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(Uf,(z,G,J,ae,le)=>{const je=`MATERIAL_ATTRIBUTE_OFFSET_${le}`,ve=ae==="float"?"vec2":ae,Ne=`GET_ATTRIBUTE_${ve}(a_${le}, materialInfo, ${je})`,De=le.match(/color/)?"color":ve;return G==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ae} a_${le}; #endif `:y.has(le)?G==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${je}) in ${J} ${ve} a_${le}; #endif out ${J} ${ae} ${le}; #else uniform ${J} ${ae} u_${le}; #endif `:G==="initialize"?De==="vec4"?` #ifndef HAS_UNIFORM_u_${le} ${le} = a_${le}; #else ${J} ${ae} ${le} = u_${le}; #endif `:` #if !defined(HAS_UNIFORM_u_${le}) #ifdef ${je} ${le} = unpack_mix_${De}(${Ne}, u_${le}_t); #else ${le} = unpack_mix_${De}(a_${le}, u_${le}_t); #endif #else ${J} ${ae} ${le} = u_${le}; #endif `:G==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} in ${J} ${ae} a_${le}; out ${J} ${ae} ${le}; #endif `:G==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${le} ${le} = a_${le}; #endif `:void 0:G==="define"?` #ifndef HAS_UNIFORM_u_${le} uniform lowp float u_${le}_t; #if !defined(${je}) in ${J} ${ve} a_${le}; #endif #else uniform ${J} ${ae} u_${le}; #endif `:G==="define-instanced"?De==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${le}0; in vec4 a_${le}1; in vec4 a_${le}2; in vec4 a_${le}3; #else uniform ${J} ${ae} u_${le}; #endif `:` #ifdef INSTANCED_ARRAYS in ${J} ${ve} a_${le}; #else uniform ${J} ${ae} u_${le}; #endif `:G==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${le} ${J} ${ae} ${le} = a_${le}; #endif `:De==="vec4"?` #ifndef HAS_UNIFORM_u_${le} #ifdef ${je} ${J} ${ae} ${le} = ${Ne}; #else ${J} ${ae} ${le} = a_${le}; #endif #else ${J} ${ae} ${le} = u_${le}; #endif `:` #ifndef HAS_UNIFORM_u_${le} #ifdef ${je} ${J} ${ae} ${le} = unpack_mix_${De}(${Ne}, u_${le}_t); #else ${J} ${ae} ${le} = unpack_mix_${De}(a_${le}, u_${le}_t); #endif #else ${J} ${ae} ${le} = u_${le}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class $me{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,y,A,D,F,z,G,J){this.context=h;let ae=this.boundPaintVertexBuffers.length!==D.length;for(let je=0;!ae&&je{const Et=ut.paint.get("hillshade-shadow-color"),Nt=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Tt=ut.paint.get("hillshade-highlight-color"),jt=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",yt=ut.paint.get("hillshade-accent-color"),Ot=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Gt=ut.paint.get("hillshade-emissive-strength");let Ht=i.an(ut.paint.get("hillshade-illumination-direction"));if(ut.paint.get("hillshade-illumination-anchor")==="viewport")Ht-=Ve.transform.angle;else if(Ve.style&&Ve.style.enable3dLights()&&Ve.style.directionalLight){const ts=Ve.style.directionalLight.properties.get("direction"),gs=i.d4(ts.x,ts.y,ts.z);Ht=i.an(gs[1])}const es=!Ve.options.moving;return{u_matrix:ot||Ve.transform.calculateProjMatrix(nt.tileID.toUnwrapped(),es),u_image:0,u_latrange:qme(0,nt.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Ht],u_shadow:Et.toPremultipliedRenderColor(Nt?null:ut.lut),u_highlight:Tt.toPremultipliedRenderColor(jt?null:ut.lut),u_emissive_strength:Gt,u_accent:yt.toPremultipliedRenderColor(Ot?null:ut.lut)}})(T,y,A,T.terrain?h.projMatrix:null);T.uploadCommonUniforms(G,ve,h.toUnwrapped());const{tileBoundsBuffer:De,tileBoundsIndexBuffer:Pe,tileBoundsSegments:We}=T.getTileBoundsBuffers(y);ve.draw(T,J.TRIANGLES,D,F,z,pn.disabled,Ne,A.id,De,Pe,We)}function l6(T,h,y){if(!h.needsDEMTextureUpload)return;const A=T.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||T.getTileTexture(y.stride);const F=y.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function Vme(T,h,y){const A=T.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),l6(T,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;A.activeTexture.set(D.TEXTURE0);let G=h.hillshadeFBO;if(!G){const ve=new i.T(A,{width:z,height:z,data:null},D.RGBA8);ve.bind(D.LINEAR,D.CLAMP_TO_EDGE),G=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),G.colorAttachment0.set(ve.texture)}A.bindFramebuffer.set(G.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:J,tileBoundsIndexBuffer:ae,tileBoundsSegments:le}=T.getMercatorTileBoundsBuffers(),je=[];T.linearFloatFilteringSupported()&&je.push("TERRAIN_DEM_FLOAT_FORMAT"),T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&je.push("USE_MRT1"),T.getOrCreateProgram("hillshadePrepare",{defines:je}).draw(T,D.TRIANGLES,Fr.disabled,vn.disabled,Hn.unblended,pn.disabled,((ve,Ne)=>{const De=Ne.stride,Pe=i.bC();return i.ce(Pe,0,i.al,-i.al,0,0,1),i.br(Pe,Pe,[0,-i.al,0]),{u_matrix:Pe,u_image:1,u_dimension:[De,De],u_zoom:ve.overscaledZ}})(h.tileID,F),y.id,J,ae,le),h.needsHillshadePrepare=!1}class po{constructor(h){this.gl=h.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(h){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Hme extends po{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class WR extends po{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class c6 extends po{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class rC extends po{getDefault(){return[!0,!0,!0,!0]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class d6 extends po{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class lv extends po{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class lb extends po{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const y=this.current;(h.func!==y.func||h.ref!==y.ref||h.mask!==y.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class c2 extends po{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class cb extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.STENCIL_TEST):y.disable(y.STENCIL_TEST),this.current=h,this.dirty=!1}}class KR extends po{getDefault(){return[0,1]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class u6 extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.DEPTH_TEST):y.disable(y.DEPTH_TEST),this.current=h,this.dirty=!1}}class ZR extends po{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class db extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.BLEND):y.disable(y.BLEND),this.current=h,this.dirty=!1}}class nC extends po{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class aC extends po{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const y=this.current;(h.r!==y.r||h.g!==y.g||h.b!==y.b||h.a!==y.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class h6 extends po{getDefault(){return this.gl.FUNC_ADD}set(h){(h!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(h,h),this.current=h,this.dirty=!1)}}class iC extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;h?y.enable(y.CULL_FACE):y.disable(y.CULL_FACE),this.current=h,this.dirty=!1}}class d2 extends po{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class YR extends po{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let QR=class extends po{getDefault(){return null}set(T){(T!==this.current||this.dirty)&&(this.gl.useProgram(T),this.current=T,this.dirty=!1)}};class XR extends po{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class ub extends po{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const y=this.current;(h[0]!==y[0]||h[1]!==y[1]||h[2]!==y[2]||h[3]!==y[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class JR extends po{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindFramebuffer(y.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class Gme extends po{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindRenderbuffer(y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class Wme extends po{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindTexture(y.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Kme extends po{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.bindBuffer(y.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class m6 extends po{getDefault(){return null}set(h){const y=this.gl;y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class p6 extends po{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class f6 extends po{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class x6 extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class eF extends po{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const y=this.gl;y.pixelStorei(y.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class oC extends po{constructor(h,y){super(h),this.context=h,this.parent=y}getDefault(){return null}}class lC extends oC{constructor(h,y,A=0){super(h,y),this.attachmentPoint=h.gl.COLOR_ATTACHMENT0+A}setDirty(){this.dirty=!0}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachmentPoint,y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class hb extends oC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferRenderbuffer(y.FRAMEBUFFER,this.attachment(),y.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class u2 extends oC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const y=this.gl;y.framebufferTexture2D(y.FRAMEBUFFER,this.attachment(),y.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class tF extends hb{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const dm=(T,h,y,A)=>({u_matrix:T,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:y,u_emissive_texture_available:A}),cC=(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We)=>({u_proj_matrix:Float32Array.from(T),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:y,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:G,u_frustum_br:J,u_frustum_bl:ae,u_globe_pos:le,u_globe_radius:je,u_viewport:ve,u_grid_matrix:We?Float32Array.from(We):new Float32Array(9),u_skirt_height:Ne,u_far_z_cutoff:De,u_emissive_texture_available:Pe});function h2(T,h){return T!=null&&h!=null&&!(!T.hasData()||!h.hasData())&&T.demTexture!=null&&h.demTexture!=null&&T.tileID.key!==h.tileID.key}const ag=new class{constructor(){this.operations={}}newMorphing(T,h,y,A,D){if(T in this.operations){const F=this.operations[T];F.to.tileID.key!==y.tileID.key&&(F.queued=y)}else this.operations[T]={startTime:A,phase:0,duration:D,from:h,to:y,queued:null}}getMorphValuesForProxy(T){if(!(T in this.operations))return null;const h=this.operations[T];return{from:h.from,to:h.to,phase:h.phase}}update(T){for(const h in this.operations){const y=this.operations[h];for(y.phase=(T-y.startTime)/y.duration;y.phase>=1||!this._validOp(y);)if(!this._nextOp(y,T)){delete this.operations[h];break}}}_nextOp(T,h){return!!T.queued&&(T.from=T.to,T.to=T.queued,T.queued=null,T.phase=0,T.startTime=h,!0)}_validOp(T){return T.from.hasData()&&T.to.hasData()}},dC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function uC(T,h,y){if(h===0)return 0;const A=h<1&&y===514?.25/h:1;return 6*Math.pow(1.5,22-T)*Math.max(h,1)*A}function g6(T,h){const y=1<({u_matrix:T});function p2(T,h,y,A,D){if(D>0){const F=i.o.now(),z=(F-T.timeAdded)/D,G=h?(F-h.timeAdded)/D:-1,J=y.getSource(),ae=A.coveringZoomLevel({tileSize:J.tileSize,roundZoom:J.roundZoom}),le=!h||Math.abs(h.tileID.overscaledZ-ae)>Math.abs(T.tileID.overscaledZ-ae),je=le&&T.refreshedUponExpiration?1:i.aA(le?z:1-G,0,1);return h?{opacity:1,mix:1-je,isFading:z<1}:{opacity:je,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class hC extends Pl{constructor(h){const y=Ul("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",y,!1),y.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,y){h.state="loaded",y(null)}}class y6 extends Pl{constructor(h){const y=Ul("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",y,!1),y.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,y,A){if(h.freezeTileCoverage)return;this.transform=h;const D=h.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((F,z)=>{if(F[z.key]="",!this._tiles[z.key]){const G=new Ym(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);G.state="loaded",this._tiles[z.key]=G}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const y=this.proxyCachedFBO[h];if(y!==void 0){const A=Object.values(y);this.renderCachePool.push(...A),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class v6 extends i.aQ{constructor(h,y,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=y,this.projMatrix=A}}class b6 extends i.bV{constructor(h,y){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(J){const ae=new i.bd,le=new i.b0,je=131;ae.reserve(17161),le.reserve(33800);const ve=i.al/128,Ne=i.al+ve/2,De=Ne+ve;for(let We=-ve;WeNe||We<0||We>Ne?24575:0,ut=i.aA(Math.round(Ve),0,i.al),ot=i.aA(Math.round(We),0,i.al);ae.emplaceBack(ut+nt,ot)}const Pe=(We,Ve)=>{const nt=Ve*je+We;le.emplaceBack(nt+1,nt,nt+je),le.emplaceBack(nt+je,nt+je+1,nt+1)};for(let We=1;We<129;We++)for(let Ve=1;Ve<129;Ve++)Pe(Ve,We);return[0,129].forEach(We=>{for(let Ve=0;Ve<130;Ve++)Pe(Ve,We),Pe(We,Ve)}),[ae,le,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,A.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new y6(y.map),this.orthoMatrix=i.bC(),i.ce(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.al,0,i.al,0,1);const G=z.gl;this._overlapStencilMode=new vn({func:G.GEQUAL,mask:255},0,255,G.KEEP,G.KEEP,G.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=y,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new hC(y.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(h){h.on("data",this._onStyleDataEvent.bind(this)),this._style=h,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(h,y,A){if(h&&h.terrain){this._style!==h&&(this.style=h,this._evaluationZoom=void 0);const D=h.terrain.properties,F=h.terrain.drapeRenderMode===0,z=h.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=i.o.now();const G=h.terrain&&h.terrain.scope,J=D.get("source"),ae=F?this._mockSourceCache:h.getSourceCache(J,G);if(!ae)return void i.w(`Couldn't find terrain source "${J}".`);if(this.sourceCache=ae,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(y):D.get("exaggeration"),!y.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const le=()=>{this.sourceCache.used&&i.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const je=this.getScaledDemTileSize();this.sourceCache.update(y,je,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,le(),this._initializing=!0),le(),y.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(y),this._emptyDEMTextureDirty=!0,this._previousZoom=y.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const y=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=y!=null?A-y:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let G=F-this._previousZoom;const J=this._previousUpdateTimestamp;let ae=F;this._evaluationZoom!=null&&(ae=this._evaluationZoom,Math.abs(F-ae)>.5&&(G=.5*(F-ae+G)),G*D<0&&(ae+=G)),this._evaluationZoom=ae;const le=z.getExaggeration(ae),je=le===z.getExaggeration(Math.max(0,ae-.1));if(je&&Math.abs(le-this._exaggeration)<.01)return le;let ve=Math.min(.1,.00375*(this._updateTimestamp-J));return(je||le<.1||Math.abs(G)<1e-4)&&(ve=Math.min(.2,4*ve)),i.ak(this._exaggeration,le,ve)}resetTileLookupCache(h){this._findCoveringTileCache[h]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(h){h.dataType==="source"&&h.coord?this._clearRenderCacheForTile(h.sourceCacheId,h.coord):h.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const h in this._style._mergedSourceCaches)this._style._mergedSourceCaches[h].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(h=>h.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const h=2*this.proxySourceCache.getSource().tileSize;return[h,h]}set useVertexMorphing(h){this._useVertexMorphing=h}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const y=this.proxySourceCache,A=this.painter.transform;this._initializing&&(this._initializing=A._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(A.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const D=this.proxyCoords=y.getIds().map(J=>{const ae=y.getTileByID(J).tileID;return ae.projMatrix=A.calculateProjMatrix(ae.toUnwrapped()),ae});(function(J,ae){const le=ae.transform.pointCoordinate(ae.transform.getCameraPoint()),je=new i.P(le.x,le.y);J.sort((ve,Ne)=>{if(Ne.overscaledZ-ve.overscaledZ)return Ne.overscaledZ-ve.overscaledZ;const De=new i.P(ve.canonical.x+(1<{this.proxyToSource[J.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const J in z){const ae=z[J];if(!ae.used||(ae!==this.sourceCache&&this.resetTileLookupCache(ae.id),this._setupProxiedCoordsForOrtho(ae,h[J],F),ae.usedForTerrain))continue;const le=h[J];ae.getSource().reparseOverscaled&&this._assignTerrainTiles(le)}this.proxiedCoords[y.id]=D.map(J=>new v6(J,J.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const G={};this._visibleDemTiles=[];for(const J of this.proxyCoords){const ae=this.terrainTileForTile[J.key];if(!ae)continue;const le=ae.tileID.key;le in G||(this._visibleDemTiles.push(ae),G[le]=le)}}_assignTerrainTiles(h){this._initializing||h.forEach(y=>{if(this.terrainTileForTile[y.key])return;const A=this._findTileCoveringTileID(y,this.sourceCache);A&&(this.terrainTileForTile[y.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,y=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(y.TEXTURE1),l6(this.painter,D,F))}}_prepareDemTileUniforms(h,y,A,D){if(!y||y.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,y.tileID.canonical.z-F.z),G=D||"";return A[`u_dem_tl${G}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${G}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const y=this._visibleDemTiles.reduce((A,D)=>{if(!D.dem)return A;const F=D.dem.tree.minimums[0];return F>0&&h++,A+F},0);return h?y/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,y=h.gl;h.activeTexture.set(y.TEXTURE2);const A=this._getLoadedAreaMinimum(),D=new i.dL({width:1,height:1},new Float32Array([A]));this._emptyDEMTextureDirty=!1;let F=this._emptyDEMTexture;return F?F.update(D,{premultiply:!1}):F=this._emptyDEMTexture=new i.T(h,D,y.R32F,{premultiply:!1}),F}setupElevationDraw(h,y,A){const D=this.painter.context,F=D.gl,z={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};z.u_exaggeration=this.exaggeration();let G=null,J=null,ae=1;if(A&&A.morphing&&this._useVertexMorphing){const Ne=A.morphing.srcDemTile,De=A.morphing.dstDemTile;ae=A.morphing.phase,Ne&&De&&(this._prepareDemTileUniforms(h,Ne,z,"_prev")&&(J=Ne),this._prepareDemTileUniforms(h,De,z)&&(G=De))}const le=Ne=>Ne&&Ne.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let je=null;var ve;if(this.enabled?J&&G?(je=G.demTexture,D.activeTexture.set(F.TEXTURE4),J.demTexture.bind(le(J),F.CLAMP_TO_EDGE),z.u_dem_lerp=ae):(G=this.terrainTileForTile[h.tileID.key],je=this._prepareDemTileUniforms(h,G,z)?G.demTexture:this.emptyDEMTexture):je=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),je&&(z.u_dem_size=(ve=je).size[0]===1?1:ve.size[0]-2,je.bind(le(G),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,y,z),A&&A.useMeterToDem&&G){const Ne=(1<{if(Ve===ts)return;const gs=[dC[ts],"PROJECTION_GLOBE_VIEW"];ut&&gs.push("CUSTOM_ANTIALIASING");const Us=ae.isTileAffectedByFog(es);We=ae.getOrCreateProgram("globeRaster",{defines:gs,overrideFog:Us}),Ve=ts},Et=ae.colorModeForRenderPass(),Nt=new Fr(Pe.LEQUAL,Fr.ReadWrite,ae.depthRangeFor3D);ag.update(Ne);const Tt=i.dF(nt),jt=[i.aF(nt.center.lng),i.aJ(nt.center.lat)],yt=ae.globeSharedBuffers,Ot=[nt.width*i.o.devicePixelRatio,nt.height*i.o.devicePixelRatio],Gt=Float32Array.from(nt.globeMatrix),Ht={useDenormalizedUpVectorScale:!0};{const es=ae.transform,ts=uC(es.zoom,le.exaggeration(),le.sourceCache._source.tileSize);Ve=-1;const gs=Pe.TRIANGLES;for(const Us of ve){const Yt=je.getTile(Us),Bt=vn.disabled,as=le.prevTerrainTileForTile[Us.key],Jt=le.terrainTileForTile[Us.key];h2(as,Jt)&&ag.newMorphing(Us.key,as,Jt,Ne,250),mb(ae,Yt.emissiveTexture),De.activeTexture.set(Pe.TEXTURE0),Yt.texture&&Yt.texture.bind(Pe.LINEAR,Pe.CLAMP_TO_EDGE);const Ls=ag.getMorphValuesForProxy(Us.key),rr=Ls?1:0;Ls&&Object.assign(Ht,{morphing:{srcDemTile:Ls.from,dstDemTile:Ls.to,phase:i.dD(Ls.phase)}});const yr=i.dG(Us.canonical),Js=i.dH(yr.getCenter().lat),Vs=i.dI(Us.canonical,yr,Js,es.worldSize/es._pixelsPerMercatorPixel),Ir=i.bk(i.dJ(Us.canonical)),Cr=ae.emissiveMode==="mrt-fallback"?1:0,pr=cC(es.expandedFarZProjMatrix,Gt,Tt,Ir,i.aj(es.zoom),jt,es.frustumCorners.TL,es.frustumCorners.TR,es.frustumCorners.BR,es.frustumCorners.BL,es.globeCenterInViewSpace,es.globeRadius,Ot,ts,es._farZ,Cr,Vs);if(ot(Us,rr),We&&(le.setupElevationDraw(Yt,We,Ht),ae.uploadCommonUniforms(De,We,Us.toUnwrapped()),yt)){const[br,Kr,In]=yt.getGridBuffers(Js,ts!==0);We.draw(ae,gs,Nt,Bt,Et,pn.backCCW,pr,"globe_raster",br,Kr,In)}}}if(yt&&(ae.renderDefaultNorthPole||ae.renderDefaultSouthPole)){const es=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&es.push("CUSTOM_ANTIALIASING"),We=ae.getOrCreateProgram("globeRaster",{defines:es});for(const ts of ve){const{x:gs,y:Us,z:Yt}=ts.canonical,Bt=Us===0,as=Us===(1<br.draw(ae,Pe.TRIANGLES,Nt,vn.disabled,Et,pn.disabled,cC(nt.expandedFarZProjMatrix,Vs,Vs,Ir,0,jt,nt.frustumCorners.TL,nt.frustumCorners.TR,nt.frustumCorners.BR,nt.frustumCorners.BL,nt.globeCenterInViewSpace,nt.globeRadius,Ot,0,nt._farZ,Cr),"globe_pole_raster",Kr,rr,yr);le.setupElevationDraw(Js,We,Ht),ae.uploadCommonUniforms(De,We,ts.toUnwrapped()),Bt&&ae.renderDefaultNorthPole&&pr(We,Jt),as&&ae.renderDefaultSouthPole&&(Vs=i.cS(i.bC(),Vs,[1,-1,1]),pr(We,Ls))}}}})(D,F,z,G,J);else{const ae=D.context,le=ae.gl;let je,ve;const Ne=D.shadowRenderer,De=Ny(D,D.longestCutoffRange),Pe=Et=>{if(ve===Et)return;const Nt=[];Nt.push(dC[Et]),De.shouldRenderCutoff&&Nt.push("RENDER_CUTOFF"),Ne&&(Nt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ne.useNormalOffset&&Nt.push("NORMAL_OFFSET")),je=D.getOrCreateProgram("terrainRaster",{defines:Nt}),ve=Et},We=D.colorModeForRenderPass(),Ve=new Fr(le.LEQUAL,Fr.ReadWrite,D.depthRangeFor3D);ag.update(J);const nt=D.transform,ut=uC(nt.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let ot=[0,0,0];if(Ne){const Et=D.style.directionalLight,Nt=D.style.ambientLight;Et&&Nt&&(ot=ng(D.style,Et,Nt))}{ve=-1;const Et=le.TRIANGLES,[Nt,Tt]=[F.gridIndexBuffer,F.gridSegments];for(const jt of G){const yt=z.getTile(jt),Ot=vn.disabled,Gt=F.prevTerrainTileForTile[jt.key],Ht=F.terrainTileForTile[jt.key];h2(Gt,Ht)&&ag.newMorphing(jt.key,Gt,Ht,J,250),mb(D,yt.emissiveTexture),ae.activeTexture.set(le.TEXTURE0),yt.texture&&yt.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const es=ag.getMorphValuesForProxy(jt.key),ts=es?1:0;let gs;es&&(gs={morphing:{srcDemTile:es.from,dstDemTile:es.to,phase:i.dD(es.phase)}});const Us=D.emissiveMode==="mrt-fallback"?1:0,Yt=dm(jt.projMatrix,g6(jt.canonical,nt.renderWorldCopies)?ut/10:ut,ot,Us);if(Pe(ts),!je)continue;F.setupElevationDraw(yt,je,gs);const Bt=jt.toUnwrapped();Ne&&Ne.setupShadows(Bt,je),D.uploadCommonUniforms(ae,je,Bt,null,De),je.draw(D,Et,Ve,Ot,We,pn.backCCW,Yt,"terrain_raster",F.gridBuffer,Nt,Tt)}}}}(y,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,y.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const y=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),G=y.style.order,J=[];this._updateFBOs(y.emissiveMode==="mrt-fallback");let ae=0;for(const le of F){const je=D.getTileByID(le.proxyTileKey),ve=D.proxyCachedFBO[le.key]?D.proxyCachedFBO[le.key][h]:void 0,Ne=ve!==void 0?D.renderCache[ve]:this.pool[ae++],De=ve!==void 0;if(je.texture=Ne.tex,je.emissiveTexture=Ne.emissiveTex,De&&!Ne.dirty){J.push(je.tileID);continue}A.bindFramebuffer.set(Ne.fb.framebuffer);const Pe=A.gl;let We;Pe.drawBuffers(y.emissiveMode==="mrt-fallback"?[Pe.COLOR_ATTACHMENT0,Pe.COLOR_ATTACHMENT1]:[Pe.COLOR_ATTACHMENT0]),this.renderedToTile=!1,Ne.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),Ne.dirty=!1);for(let Ve=z.start;Ve<=z.end;++Ve){const nt=y.style._mergedLayers[G[Ve]];if(nt.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(nt),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(Ne,ot,nt,ut),We=ut?ut.id:null),y.renderLayer(y,ut,nt,Et)}if(Pe.drawBuffers([Pe.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Ve of this._pendingGroundEffectLayers){const nt=y.style._mergedLayers[G[Ve]];if(nt.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(nt),ot=ut?this.proxyToSource[le.key][ut.id]:[le];if(!ot)continue;const Et=ot;A.viewport.set([0,0,Ne.fb.width,Ne.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(Ne,ot,nt,ut),We=ut?ut.id:null),y.renderLayer(y,ut,nt,Et)}this.renderedToTile?(Ne.dirty=!0,J.push(je.tileID)):De||--ae,ae===5&&(ae=0,this.renderToBackBuffer(J))}return this.renderToBackBuffer(J),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,y.width,y.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const y=h.order.length;let A=-1,D=y;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(y=>y.dem).forEach(y=>{h=Math.min(h,y.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,y,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,G=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,y,A);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,y=h.gl,A=this.drapeBufferSize;h.activeTexture.set(y.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},y.RGBA8);D.bind(y.LINEAR,y.CLAMP_TO_EDGE);const F=h.createFramebuffer(A[0],A[1],1,null);let z;return F.colorAttachment0.set(D.texture),this._emissiveTexture&&(z=new i.T(h,{width:A[0],height:A[1],data:null},y.R8),z.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.createColorAttachment(h,1),F.colorAttachment1.set(z.texture)),F.depthAttachment=new tF(h,F.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=h.createRenderbuffer(h.gl.DEPTH_STENCIL,A[0],A[1]),this._stencilRef=0,F.depthAttachment.set(this._sharedDepthStencil),h.clear({stencil:0})):F.depthAttachment.set(this._sharedDepthStencil),h.extTextureFilterAnisotropic&&y.texParameterf(y.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const y of this.pool)this._updateFBO(y,h);for(const y of this.proxySourceCache.renderCache)this._updateFBO(y,h);this._emissiveTexture=h}}_updateFBO(h,y){const A=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(y){const G=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);G.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=G,A.createColorAttachment(D,1),A.colorAttachment1.set(G.texture)}else h.emissiveTex=void 0,A.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const y=this._style._mergedLayers[h],A=y.isHidden(this.painter.transform.zoom);return y.type==="hillshade"||y.type==="custom"?!A&&y.shouldRedrape():!A&&y.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof Rf){h=!0;break}if(!h)return;const y={};for(let A=0;AJ>G.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(h){const y=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,y.renderCache.length>y.renderCachePool.length){const z=Object.values(y.proxyCachedFBO);y.proxyCachedFBO={};for(let G=0;G=0;z--){const G=A[z];if(y.getTileByID(G.key),y.proxyCachedFBO[G.key]!==void 0){const J=h[G.key],ae=this.proxyToSource[G.key];let le=0;for(const je in ae){const ve=ae[je],Ne=J[je];if(!Ne||Ne.length!==ve.length||ve.some((De,Pe)=>De!==Ne[Pe]||D[je]&&D[je].hasOwnProperty(De.key))){le=-1;break}++le}for(const je in y.proxyCachedFBO[G.key])y.renderCache[y.proxyCachedFBO[G.key][je]].dirty=le<0||le!==Object.values(J).length}}const F=[...this._drapedRenderBatches];F.sort((z,G)=>G.end-G.start-(z.end-z.start));for(const z of F)for(const G of A){if(y.proxyCachedFBO[G.key])continue;let J=y.renderCachePool.pop();J===void 0&&y.renderCache.length<50&&(J=y.renderCache.length,y.renderCache.push(this._createFBO())),J!==void 0&&(y.proxyCachedFBO[G.key]={},y.proxyCachedFBO[G.key][z.start]=J,y.renderCache[J].dirty=!0)}this._tilesDirty={}}_setupStencil(h,y,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(y.length<=1)return void(this._overlapStencilType=!1);let G;if(A.isTileClipped())G=y.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(y[0].overscaledZ>y[y.length-1].overscaledZ))return void(this._overlapStencilType=!1);G=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+G>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=G,this._overlapStencilMode.ref=this._stencilRef,A.isTileClipped()&&this._renderTileClippingMasks(y,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(h){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[h.key]),this._overlapStencilMode):vn.disabled}_renderTileClippingMasks(h,y){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const G of h){const J=A._tileClippingMaskIDs[G.key]=--y;z.draw(A,F.TRIANGLES,Fr.disabled,new vn({func:F.ALWAYS,mask:0},J,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,pn.disabled,m2(G.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const y=this.painter.transform;if(h.x<0||h.x>y.width||h.y<0||h.y>y.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,y.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=y.worldSize,A[1]/=y.worldSize;const D=y._camera.position,F=i.cf(1,y.center.lat),z=[D[0],D[1],D[2]/F,0],G=i.da([],A.slice(0,3),z);i.aw(G,G);const J=this.raycast(z,G,this._exaggeration);return J!==null&&J?(i.bH(z,z,G,J),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,y,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,y,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let J=0;Jle.overscaledZ-ae.overscaledZ)}_setupProxiedCoordsForImageSource(h,y,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),G=z.tileID;if(!G)return;const J=new i.P(G.x,G.y)._div(1<(je.min.x=Math.min(je.min.x,ve.x-J.x),je.min.y=Math.min(je.min.y,ve.y-J.y),je.max.x=Math.max(je.max.x,ve.x-J.x),je.max.y=Math.max(je.max.y,ve.y-J.y),je),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),le=(je,ve)=>{const Ne=je.wrap+je.canonical.x/(1<We+ae.max.x||De+PeVe+ae.max.y};for(let je=0;jez.key===y.tileID.key);if(F)return F}if(y.tileID.key!==h.key){const F=h.canonical.z-y.tileID.canonical.z;let z,G,J;D=i.bC();const ae=y.tileID.wrap-h.wrap<0?(z=i.al>>F,G=z*((y.tileID.canonical.x<=je){const ve=h.canonical.z-je;y.getSource().reparseOverscaled?(G=Math.max(h.canonical.z+2,y.transform.tileZoom),z=new i.aQ(G,h.wrap,je,h.canonical.x>>ve,h.canonical.y>>ve)):ve!==0&&(G=je,z=new i.aQ(G,h.wrap,je,h.canonical.x>>ve,h.canonical.y>>ve))}z.key!==h.key&&(ae.push(z.key),A=y.getTile(z))}const le=je=>{ae.forEach(ve=>{D[ve]=je}),ae.length=0};for(G-=1;G>=J&&(!A||!A.hasData());G--){A&&le(A.tileID.key);const je=z.calculateScaledKey(G);if(A=y.getTileByID(je),A&&A.hasData())break;const ve=D[je];if(ve===null)break;ve===void 0?ae.push(je):A=y.getTileByID(ve)}return le(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,y){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[y.key]=!0}}function pb(T,h,y){const A=function(G,J,ae){const le=i.bJ(J,G),je=i.bJ(ae,[.2126,.7152,.0722]),ve=(De,Pe,We)=>(1-We)*De+We*Pe,Ne=ve(1-.3*Math.min(je,1),1,Math.min(le+1,1));return ve(.92,1,Math.asin(i.aA(J[2],-1,1))/Math.PI+.5)*Ne}(T,[0,0,1],h),D=[0,0,0];i.c5(D,y.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),T[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const Zme=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Yme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class sF{static cacheKey(h,y,A,D){const F=[y];D&&F.push(D.cacheKey);for(const z of A)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,y,A,D,F,z){const G=h.gl;this.program=G.createProgram(),this.configuration=D,this.name=y,this.fixedDefines=[...z];const J=`#version 300 es ${(D?D.defines():[]).concat(z.map(Pe=>`#define ${Pe}`)).join(` `)}`,ae=[J,Bme];for(const Pe of A.fragmentIncludes)ae.push(My[Pe]);ae.push(A.fragmentSource);const le=ae.join(` `),je=[J,GR];for(const Pe of A.vertexIncludes)je.push(My[Pe]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&je.push("uniform int u_instanceID;"),je.push(A.vertexSource);let ve=je.join(` `);this.forceManualRenderingForInstanceIDShaders&&(ve=ve.replaceAll("gl_InstanceID","u_instanceID"));const Ne=G.createShader(G.FRAGMENT_SHADER);if(G.isContextLost())return void(this.failedToCreate=!0);G.shaderSource(Ne,le),G.compileShader(Ne),G.attachShader(this.program,Ne);const De=G.createShader(G.VERTEX_SHADER);G.isContextLost()?this.failedToCreate=!0:(G.shaderSource(De,ve),G.compileShader(De),G.attachShader(this.program,De),this.attributes={},G.linkProgram(this.program),G.deleteShader(De),G.deleteShader(Ne),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Pe=>({u_instanceID:new i.ch(Pe)}))(h)),(z.includes("TERRAIN")||y.includes("symbol")||y.includes("circle"))&&(this.terrainUniforms=(Pe=>({u_dem:new i.ch(Pe),u_dem_prev:new i.ch(Pe),u_dem_tl:new i.ck(Pe),u_dem_scale:new i.cj(Pe),u_dem_tl_prev:new i.ck(Pe),u_dem_scale_prev:new i.cj(Pe),u_dem_size:new i.cj(Pe),u_dem_lerp:new i.cj(Pe),u_exaggeration:new i.cj(Pe),u_depth:new i.ch(Pe),u_depth_size_inv:new i.ck(Pe),u_depth_range_unpack:new i.ck(Pe),u_occluder_half_size:new i.cj(Pe),u_occlusion_depth_offset:new i.cj(Pe),u_meter_to_dem:new i.cj(Pe),u_label_plane_matrix_inv:new i.cl(Pe)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Pe=>({u_tile_tl_up:new i.ci(Pe),u_tile_tr_up:new i.ci(Pe),u_tile_br_up:new i.ci(Pe),u_tile_bl_up:new i.ci(Pe),u_tile_up_scale:new i.cj(Pe)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Pe=>({u_fog_matrix:new i.cl(Pe),u_fog_range:new i.ck(Pe),u_fog_color:new i.d3(Pe),u_fog_horizon_blend:new i.cj(Pe),u_fog_vertical_limit:new i.ck(Pe),u_fog_temporal_offset:new i.cj(Pe),u_frustum_tl:new i.ci(Pe),u_frustum_tr:new i.ci(Pe),u_frustum_br:new i.ci(Pe),u_frustum_bl:new i.ci(Pe),u_globe_pos:new i.ci(Pe),u_globe_radius:new i.cj(Pe),u_globe_transition:new i.cj(Pe),u_is_globe:new i.ch(Pe),u_viewport:new i.ck(Pe)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Pe=>({u_cutoff_params:new i.d3(Pe)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Pe=>({u_lighting_ambient_color:new i.ci(Pe),u_lighting_directional_dir:new i.ci(Pe),u_lighting_directional_color:new i.ci(Pe),u_ground_radiance:new i.ci(Pe)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Pe=>({u_light_matrix_0:new i.cl(Pe),u_light_matrix_1:new i.cl(Pe),u_fade_range:new i.ck(Pe),u_shadow_normal_offset:new i.ci(Pe),u_shadow_intensity:new i.cj(Pe),u_shadow_texel_size:new i.cj(Pe),u_shadow_map_resolution:new i.cj(Pe),u_shadow_direction:new i.ci(Pe),u_shadow_bias:new i.ci(Pe),u_shadowmap_0:new i.ch(Pe),u_shadowmap_1:new i.ch(Pe)}))(h)))}getAttributeLocation(h,y){let A=this.attributes[y];return A===void 0&&(A=this.attributes[y]=h.getAttribLocation(this.program,y)),A}setTerrainUniformValues(h,y){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setGlobeUniformValues(h,y){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D]&&A[D].set(this.program,D,y[D])}}setFogUniformValues(h,y){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setCutoffUniformValues(h,y){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setLightsUniformValues(h,y){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}}setShadowUniformValues(h,y){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in y)A[D].set(this.program,D,y[D])}_drawDebugWireframe(h,y,A,D,F,z,G,J,ae,le){const je=h.options.wireframe;if(je.terrain===!1&&je.layers2D===!1&&je.layers3D===!1)return;const ve=h.context;if(!(!(!je.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!je.layers2D||h._terrain&&h._terrain.renderingToTexture||!Zme.includes(this.name))||!(!je.layers3D||!Yme.includes(this.name))))return;const Ne=ve.gl,De=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,ve);if(!De)return;const Pe=[...this.fixedDefines,"DEBUG_WIREFRAME"],We=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Pe});ve.program.set(We.program);const Ve=(ot,Et,Nt)=>{if(Et[ot]&&Nt[ot])for(const Tt in Et[ot])Nt[ot][Tt]&&Nt[ot][Tt].set(Nt.program,Tt,Et[ot][Tt].current)};ae&&ae.setUniforms(We.program,ve,We.binderUniforms,G,{zoom:J}),Ve("fixedUniforms",this,We),Ve("terrainUniforms",this,We),Ve("globeUniforms",this,We),Ve("fogUniforms",this,We),Ve("lightsUniforms",this,We),Ve("shadowUniforms",this,We),De.bind(),ve.setColorMode(new Hn([Ne.ONE,Ne.ONE_MINUS_SRC_ALPHA,Ne.ZERO,Ne.ONE],i.ao.transparent,[!0,!0,!0,!1])),ve.setDepthMode(new Fr(y.func===Ne.LESS?Ne.LEQUAL:y.func,Fr.ReadOnly,y.range)),ve.setStencilMode(vn.disabled);const nt=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const ot=le||1;for(let Et=0;Et1?Ne.drawElementsInstanced(Ne.LINES,nt,Ne.UNSIGNED_SHORT,ut,le):Ne.drawElements(Ne.LINES,nt,Ne.UNSIGNED_SHORT,ut);F.bind(),ve.program.set(this.program),ve.setDepthMode(y),ve.setStencilMode(A),ve.setColorMode(D)}checkUniforms(h,y,A){if(this.fixedDefines.includes(y)){for(const D of Object.keys(A))if(!A[D].initialized)throw new Error(`Program '${this.name}', from draw '${h}': uniform ${D} not set but required by ${y} being defined`)}}draw(h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We){const Ve=h.context,nt=Ve.gl;if(this.failedToCreate)return;Ve.program.set(this.program),Ve.setDepthMode(A),Ve.setStencilMode(D),Ve.setColorMode(F),Ve.setCullFace(z);for(const[jt,yt]of this.fixedUniformsEntries)yt.set(this.program,jt,G[jt]);De&&De.setUniforms(this.program,Ve,this.binderUniforms,ve,{zoom:Ne});const ut={[nt.POINTS]:1,[nt.LINES]:2,[nt.TRIANGLES]:3,[nt.LINE_STRIP]:1}[y];this.checkUniforms(J,"RENDER_SHADOWS",this.shadowUniforms);const ot=Pe||[],Et=De?De.getPaintVertexBuffers():[],Nt=y===nt.TRIANGLES&&le,Tt=We&&We>0?1:void 0;for(const jt of je.get()){const yt=jt.vaos||(jt.vaos={});if((yt[J]||(yt[J]=new $me)).bind(Ve,this,ae,Et,le,jt.vertexOffset,ot,Tt),this.forceManualRenderingForInstanceIDShaders){const Ot=We||1;for(let Gt=0;Gt1?nt.drawElementsInstanced(y,jt.primitiveLength*ut,nt.UNSIGNED_SHORT,jt.primitiveOffset*ut*2,We):le?nt.drawElements(y,jt.primitiveLength*ut,nt.UNSIGNED_SHORT,jt.primitiveOffset*ut*2):nt.drawArrays(y,jt.vertexOffset,jt.vertexLength);Nt&&this._drawDebugWireframe(h,A,D,F,le,jt,ve,Ne,De,We)}}}function rF(T,h,y=0){const A=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,T.transform.tileZoom)/A,F=D*(h.tileID.canonical.x+h.tileID.wrap*A),z=D*h.tileID.canonical.y;return{u_image:0,u_texsize:h.imageAtlasTexture?h.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/i.ay(h,1,T.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:y}}const mC={terrain:0,flat:1},Qme=i.bC(),pC=(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve)=>{const nt=h.style.light,ut=nt.properties.get("position"),ot=[ut.x,ut.y,ut.z],Et=i.dO();nt.properties.get("anchor")==="viewport"&&(i.dP(Et,-h.transform.angle),i.dQ(ot,ot,Et));const Nt=nt.properties.get("color").toPremultipliedRenderColor(null),Tt=h.transform,jt={u_matrix:T,u_lightpos:ot,u_lightintensity:nt.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_vertical_gradient:+y,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Qme,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:mC[ae],u_base_type:mC[le],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:De,u_vertical_scale:Pe,u_flood_light_intensity:We,u_ground_shadow_factor:Ve};return Tt.projection.name==="globe"&&(jt.u_tile_id=[G.canonical.x,G.canonical.y,1<({u_matrix:T,u_edge_radius:h,u_width_scale:y,u_vertical_scale:A,u_height_type:mC[D],u_base_type:mC[F]}),nF=(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve)=>{const nt=pC(T,h,y,A,D,F,z,G,ae,le,je,ve,Ne,De,Pe,We,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,G.overscaledZ)/J.tileSize/8};return Object.assign(nt,rF(h,J,Ve),ut)},fb=(T,h,y,A,D,F,z,G,J,ae,le)=>({u_matrix:h,u_opacity:y,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:G,u_attenuation:J,u_edge_radius:ae,u_fb:0,u_fb_size:le,u_dynamic_offset:1}),w6=(T,h,y)=>({u_matrix:T,u_emissive_strength:h,u_ground_shadow_factor:y}),j6=(T,h,y,A,D,F=0)=>Object.assign(w6(T,h,D),rF(y,A,F)),aF=(T,h,y,A)=>({u_matrix:T,u_world:y,u_emissive_strength:h,u_ground_shadow_factor:A}),N6=(T,h,y,A,D,F,z=0)=>Object.assign(j6(T,h,y,A,F,z),{u_world:D}),Ay=(T,h)=>({u_matrix:T,u_ground_shadow_factor:h}),cv=(T,h,y,A,D)=>({u_matrix:T,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:y,u_height_scale:A,u_reset_depth:D}),fC=(T,h,y,A,D,F,z,G,J)=>({u_matrix:T,u_normal_matrix:h,u_opacity:y,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:G,u_flood_light_intensity:J}),iF=T=>({u_matrix:T}),Ey=T=>({u_matrix:T}),k6=(T,h,y,A,D,F,z,G)=>{const J=i.al/F.tileSize;return{u_matrix:T,u_inv_rot_matrix:h,u_camera_to_center_distance:y.getCameraToCenterDistance(G),u_extrude_scale:[y.pixelsToGLUnits[0]/J,y.pixelsToGLUnits[1]/J],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},f2=(T,h,y=1)=>({u_matrix:T,u_color:h,u_overlay:0,u_overlay_scale:y}),oF=i.bC(),lF=(T,h,y,A,D,F,z)=>{const G=T.transform,J=G.projection.name==="globe",ae=J?i.dR(G.zoom,h.canonical)*G._pixelsPerMercatorPixel:i.ay(y,1,F),le={u_matrix:h.projMatrix,u_extrude_scale:ae,u_intensity:z,u_inv_rot_matrix:oF,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(J){le.u_inv_rot_matrix=A,le.u_merc_center=D,le.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:le.mix,u_opacity:le.opacity*je.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:je.paint.get("raster-brightness-min"),u_brightness_high:je.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(je.paint.get("raster-saturation")),u_contrast_factor:i.dS(je.paint.get("raster-contrast")),u_spin_weights:dF(je.paint.get("raster-hue-rotate")),u_perspective_transform:ve,u_raster_elevation:Ne,u_zoom_transition:z,u_merc_center:G,u_cutoff_params:J,u_colorization_mix:xC(i.dU,Pe,Ve),u_colorization_offset:gC(i.dU,We,Ve),u_color_ramp:De,u_texture_offset:[ut/(nt+2*ut),nt/(nt+2*ut)],u_texture_res:[nt+2*ut,nt+2*ut],u_emissive_strength:ot});function dF(T){T*=Math.PI/180;const h=Math.sin(T),y=Math.cos(T);return[(2*y+1)/3,(-Math.sqrt(3)*h-y+1)/3,(Math.sqrt(3)*h-y+1)/3]}const Vf=.05,Xme=(T,h,y,A,D,F,z,G,J,ae,le,je)=>({u_matrix:T,u_normalize_matrix:h,u_globe_matrix:y,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:le.mix,u_opacity:le.opacity,u_image0:0,u_image1:1,u_raster_elevation:je,u_zoom_transition:z,u_merc_center:G,u_cutoff_params:J}),Jme=(T,h,y,A,D,F,z,G,J,ae)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_tile_offset:y,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:G,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Vf,Vf]}),uF=(T,h,y,A,D,F,z,G,J,ae)=>({u_particle_texture:T,u_particle_texture_side_len:h,u_velocity:y,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:G,u_data_scale:[255*J[0],255*J[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Vf,Vf]}),hF=i.bC(),yC=(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve,nt,ut,ot,Et,Nt,Tt)=>{const jt=D.transform,yt={u_is_size_zoom_constant:+(T==="constant"||T==="source"),u_is_size_feature_constant:+(T==="constant"||T==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:jt.getCameraToCenterDistance(nt),u_rotate_symbol:+y,u_aspect_ratio:jt.width/jt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:G,u_is_text:+ae,u_elevation_from_sea:J?1:0,u_pitch_with_map:+A,u_texsize:le,u_texsize_icon:je,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:hF,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:hF,u_up_vector:[0,-1,0],u_color_adj_mat:Et,u_icon_transition:Nt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(nt)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:Tt||1,u_ground_shadow_factor:ut,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:ot,u_lutTexture:Kc.LUT};return nt.name==="globe"&&(yt.u_tile_id=[Ne.canonical.x,Ne.canonical.y,1<({u_matrix:T,u_emissive_strength:h,u_opacity:y,u_color:A}),Py=(T,h,y,A,D,F,z,G,J)=>Object.assign(function(ae,le,je,ve,Ne,De){const{width:Pe,height:We}=ve.imageManager.getPixelSize(le),Ve=Math.pow(2,De.tileID.overscaledZ),nt=De.tileSize*Math.pow(2,ve.transform.tileZoom)/Ve,ut=nt*(De.tileID.canonical.x+De.tileID.wrap*Ve),ot=nt*De.tileID.canonical.y;return{u_image:0,u_pattern_tl:je.tl,u_pattern_br:je.br,u_texsize:[Pe,We],u_pattern_size:je.displaySize,u_pattern_units_to_pixels:Ne?[ve.transform.width,-1*ve.transform.height]:[1/i.ay(De,1,ve.transform.tileZoom),1/i.ay(De,1,ve.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,ot>>16],u_pixel_coord_lower:[65535&ut,65535&ot]}}(0,F,z,A,G,J),{u_matrix:T,u_emissive_strength:h,u_opacity:y}),xb=new Float32Array(i.bA([])),dv=(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne=[0,0,0],De,Pe,We)=>{const Ve=D.style.light,nt=Ve.properties.get("position"),ut=[-nt.x,-nt.y,nt.z],ot=i.dO();Ve.properties.get("anchor")==="viewport"&&(i.dP(ot,-D.transform.angle),i.dQ(ut,ut,ot));const Et=le.alphaMode==="MASK",Nt=Ve.properties.get("color").toNonPremultipliedRenderColor(null),Tt=ve.paint.get("model-ambient-occlusion-intensity"),jt=ve.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return jt.a=ve.paint.get("model-color-mix-intensity").constantOr(0),We&&(jt.r=We[0],jt.g=We[1],jt.b=We[2],jt.a=We[3]),Pe&&(jt.r=Pe.color.r,jt.g=Pe.color.g,jt.b=Pe.color.b,jt.a=Pe.colorMix,je=Pe.emissionStrength,F*=Pe.opacity),{u_matrix:T,u_lighting_matrix:h,u_normal_matrix:y,u_node_matrix:A||xb,u_lightpos:ut,u_lightintensity:Ve.properties.get("intensity"),u_lightcolor:[Nt.r,Nt.g,Nt.b],u_camera_pos:Ne,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Et,u_alphaCutoff:le.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:G.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:J,u_roughnessFactor:ae,u_baseColorTexture:Kc.BaseColor,u_metallicRoughnessTexture:Kc.MetallicRoughness,u_normalTexture:Kc.Normal,u_occlusionTexture:Kc.Occlusion,u_emissionTexture:Kc.Emission,u_lutTexture:Kc.LUT,u_color_mix:jt.toArray01(),u_aoIntensity:Tt,u_emissive_strength:je,u_occlusionTextureTransform:De||[0,0,0,0]}},S6=(T,h=xb,y=xb)=>({u_matrix:T,u_instance:h,u_node_matrix:y}),vC={fillExtrusion:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_opacity:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_flood_light_color:new i.ci(T),u_vertical_scale:new i.cj(T),u_flood_light_intensity:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillExtrusionDepth:T=>({u_matrix:new i.cl(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_vertical_scale:new i.cj(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T)}),fillExtrusionPattern:T=>({u_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_vertical_gradient:new i.cj(T),u_height_factor:new i.cj(T),u_edge_radius:new i.cj(T),u_width_scale:new i.cj(T),u_ao:new i.ck(T),u_height_type:new i.ch(T),u_base_type:new i.ch(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_up_dir:new i.ci(T),u_height_lift:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_opacity:new i.cj(T),u_pattern_transition:new i.cj(T)}),fillExtrusionGroundEffect:T=>({u_matrix:new i.cl(T),u_opacity:new i.cj(T),u_ao_pass:new i.cj(T),u_meter_to_tile:new i.cj(T),u_ao:new i.ck(T),u_flood_light_intensity:new i.cj(T),u_flood_light_color:new i.ci(T),u_attenuation:new i.cj(T),u_edge_radius:new i.cj(T),u_fb:new i.ch(T),u_fb_size:new i.cj(T),u_dynamic_offset:new i.cj(T)}),fill:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_ground_shadow_factor:new i.ci(T)}),fillPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),fillOutline:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_ground_shadow_factor:new i.ci(T)}),fillOutlinePattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_world:new i.ck(T),u_image:new i.ch(T),u_texsize:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_tile_units_to_pixels:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_pattern_transition:new i.cj(T)}),building:T=>({u_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_opacity:new i.cj(T),u_faux_facade_ao_intensity:new i.cj(T),u_camera_pos:new i.ci(T),u_tile_to_meter:new i.cj(T),u_facade_emissive_chance:new i.cj(T),u_flood_light_color:new i.ci(T),u_flood_light_intensity:new i.cj(T)}),buildingBloom:T=>({u_matrix:new i.cl(T)}),buildingDepth:T=>({u_matrix:new i.cl(T)}),elevatedStructuresDepth:T=>({u_matrix:new i.cl(T),u_depth_bias:new i.cj(T)}),elevatedStructures:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),elevatedStructuresDepthReconstruct:T=>({u_matrix:new i.cl(T),u_camera_pos:new i.ci(T),u_depth_bias:new i.cj(T),u_height_scale:new i.cj(T),u_reset_depth:new i.cj(T)}),circle:i.dY,collisionBox:T=>({u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_extrude_scale:new i.ck(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T)}),collisionCircle:T=>({u_matrix:new i.cl(T),u_inv_matrix:new i.cl(T),u_camera_to_center_distance:new i.cj(T),u_viewport_size:new i.ck(T)}),debug:T=>({u_color:new i.dB(T),u_matrix:new i.cl(T),u_overlay:new i.ch(T),u_overlay_scale:new i.cj(T)}),clippingMask:T=>({u_matrix:new i.cl(T)}),heatmap:T=>({u_extrude_scale:new i.cj(T),u_intensity:new i.cj(T),u_matrix:new i.cl(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_up_dir:new i.ci(T)}),heatmapTexture:T=>({u_image:new i.ch(T),u_color_ramp:new i.ch(T),u_opacity:new i.cj(T)}),hillshade:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_latrange:new i.ck(T),u_light:new i.ck(T),u_shadow:new i.dB(T),u_highlight:new i.dB(T),u_emissive_strength:new i.cj(T),u_accent:new i.dB(T)}),hillshadePrepare:T=>({u_matrix:new i.cl(T),u_image:new i.ch(T),u_dimension:new i.ck(T),u_zoom:new i.cj(T)}),line:i.dX,linePattern:i.dW,raster:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_brightness_low:new i.cj(T),u_brightness_high:new i.cj(T),u_saturation_factor:new i.cj(T),u_contrast_factor:new i.cj(T),u_spin_weights:new i.ci(T),u_perspective_transform:new i.ck(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T),u_colorization_mix:new i.d3(T),u_colorization_offset:new i.cj(T),u_color_ramp:new i.ch(T),u_texture_offset:new i.ck(T),u_texture_res:new i.ck(T),u_emissive_strength:new i.cj(T)}),rasterParticle:T=>({u_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_grid_matrix:new i.dC(T),u_tl_parent:new i.ck(T),u_scale_parent:new i.cj(T),u_fade_t:new i.cj(T),u_opacity:new i.cj(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_raster_elevation:new i.cj(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_cutoff_params:new i.d3(T)}),rasterParticleTexture:T=>({u_texture:new i.ch(T),u_opacity:new i.cj(T)}),rasterParticleDraw:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_tile_offset:new i.ck(T),u_velocity:new i.ch(T),u_color_ramp:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),rasterParticleUpdate:T=>({u_particle_texture:new i.ch(T),u_particle_texture_side_len:new i.cj(T),u_velocity:new i.ch(T),u_velocity_res:new i.ck(T),u_max_speed:new i.cj(T),u_speed_factor:new i.cj(T),u_reset_rate:new i.cj(T),u_rand_seed:new i.cj(T),u_uv_offset:new i.ck(T),u_data_scale:new i.ck(T),u_data_offset:new i.cj(T),u_particle_pos_scale:new i.cj(T),u_particle_pos_offset:new i.ck(T)}),symbol:T=>({u_is_size_zoom_constant:new i.ch(T),u_is_size_feature_constant:new i.ch(T),u_size_t:new i.cj(T),u_size:new i.cj(T),u_camera_to_center_distance:new i.cj(T),u_rotate_symbol:new i.ch(T),u_aspect_ratio:new i.cj(T),u_fade_change:new i.cj(T),u_matrix:new i.cl(T),u_label_plane_matrix:new i.cl(T),u_coord_matrix:new i.cl(T),u_is_text:new i.ch(T),u_elevation_from_sea:new i.ch(T),u_pitch_with_map:new i.ch(T),u_texsize:new i.ck(T),u_texsize_icon:new i.ck(T),u_texture:new i.ch(T),u_texture_icon:new i.ch(T),u_gamma_scale:new i.cj(T),u_device_pixel_ratio:new i.cj(T),u_tile_id:new i.ci(T),u_zoom_transition:new i.cj(T),u_inv_rot_matrix:new i.cl(T),u_merc_center:new i.ck(T),u_camera_forward:new i.ci(T),u_tile_matrix:new i.cl(T),u_up_vector:new i.ci(T),u_ecef_origin:new i.ci(T),u_is_halo:new i.ch(T),u_icon_transition:new i.cj(T),u_color_adj_mat:new i.cl(T),u_scale_factor:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_inv_matrix:new i.cl(T),u_normal_scale:new i.cj(T),u_lutTexture:new i.ch(T)}),background:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_color:new i.dB(T)}),backgroundPattern:T=>({u_matrix:new i.cl(T),u_emissive_strength:new i.cj(T),u_opacity:new i.cj(T),u_image:new i.ch(T),u_pattern_tl:new i.ck(T),u_pattern_br:new i.ck(T),u_texsize:new i.ck(T),u_pattern_size:new i.ck(T),u_pixel_coord_upper:new i.ck(T),u_pixel_coord_lower:new i.ck(T),u_pattern_units_to_pixels:new i.ck(T)}),terrainRaster:T=>({u_matrix:new i.cl(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_skirt_height:new i.cj(T),u_ground_shadow_factor:new i.ci(T),u_emissive_texture_available:new i.cj(T)}),skybox:T=>({u_matrix:new i.cl(T),u_sun_direction:new i.ci(T),u_cubemap:new i.ch(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxGradient:T=>({u_matrix:new i.cl(T),u_color_ramp:new i.ch(T),u_center_direction:new i.ci(T),u_radius:new i.cj(T),u_opacity:new i.cj(T),u_temporal_offset:new i.cj(T)}),skyboxCapture:T=>({u_matrix_3f:new i.dC(T),u_sun_direction:new i.ci(T),u_sun_intensity:new i.cj(T),u_color_tint_r:new i.d3(T),u_color_tint_m:new i.d3(T),u_luminance:new i.cj(T)}),globeRaster:T=>({u_proj_matrix:new i.cl(T),u_globe_matrix:new i.cl(T),u_normalize_matrix:new i.cl(T),u_merc_matrix:new i.cl(T),u_zoom_transition:new i.cj(T),u_merc_center:new i.ck(T),u_image0:new i.ch(T),u_image1:new i.ch(T),u_grid_matrix:new i.dC(T),u_skirt_height:new i.cj(T),u_far_z_cutoff:new i.cj(T),u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_globe_pos:new i.ci(T),u_globe_radius:new i.cj(T),u_viewport:new i.ck(T),u_emissive_texture_available:new i.cj(T)}),globeAtmosphere:T=>({u_frustum_tl:new i.ci(T),u_frustum_tr:new i.ci(T),u_frustum_br:new i.ci(T),u_frustum_bl:new i.ci(T),u_horizon:new i.cj(T),u_transition:new i.cj(T),u_fadeout_range:new i.cj(T),u_atmosphere_fog_color:new i.d3(T),u_high_color:new i.d3(T),u_space_color:new i.d3(T),u_temporal_offset:new i.cj(T),u_horizon_angle:new i.cj(T)}),model:T=>({u_matrix:new i.cl(T),u_lighting_matrix:new i.cl(T),u_normal_matrix:new i.cl(T),u_node_matrix:new i.cl(T),u_lightpos:new i.ci(T),u_lightintensity:new i.cj(T),u_lightcolor:new i.ci(T),u_camera_pos:new i.ci(T),u_opacity:new i.cj(T),u_baseColorFactor:new i.d3(T),u_emissiveFactor:new i.d3(T),u_metallicFactor:new i.cj(T),u_roughnessFactor:new i.cj(T),u_baseTextureIsAlpha:new i.ch(T),u_alphaMask:new i.ch(T),u_alphaCutoff:new i.cj(T),u_baseColorTexture:new i.ch(T),u_metallicRoughnessTexture:new i.ch(T),u_normalTexture:new i.ch(T),u_occlusionTexture:new i.ch(T),u_emissionTexture:new i.ch(T),u_lutTexture:new i.ch(T),u_color_mix:new i.d3(T),u_aoIntensity:new i.cj(T),u_emissive_strength:new i.cj(T),u_occlusionTextureTransform:new i.d3(T)}),modelDepth:T=>({u_matrix:new i.cl(T),u_instance:new i.cl(T),u_node_matrix:new i.cl(T)}),groundShadow:T=>({u_matrix:new i.cl(T),u_ground_shadow_factor:new i.ci(T)}),stars:T=>({u_matrix:new i.cl(T),u_up:new i.ci(T),u_right:new i.ci(T),u_intensity_multiplier:new i.cj(T)}),snowParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_horizontalOscillationRadius:new i.cj(T),u_horizontalOscillationRate:new i.cj(T),u_boxSize:new i.cj(T),u_billboardSize:new i.cj(T),u_simpleShapeParameters:new i.ck(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_particleColor:new i.d3(T),u_direction:new i.ci(T)}),rainParticle:T=>({u_modelview:new i.cl(T),u_projection:new i.cl(T),u_time:new i.cj(T),u_cam_pos:new i.ci(T),u_texScreen:new i.ch(T),u_velocityConeAperture:new i.cj(T),u_velocity:new i.cj(T),u_boxSize:new i.cj(T),u_rainDropletSize:new i.ck(T),u_distortionStrength:new i.cj(T),u_rainDirection:new i.ci(T),u_color:new i.d3(T),u_screenSize:new i.ck(T),u_thinningCenterPos:new i.ck(T),u_thinningShape:new i.ci(T),u_thinningAffectedRatio:new i.cj(T),u_thinningParticleOffset:new i.cj(T),u_shapeDirectionalPower:new i.cj(T),u_shapeNormalPower:new i.cj(T),u_mode:new i.cj(T)}),vignette:T=>({u_vignetteShape:new i.ci(T),u_vignetteColor:new i.d3(T)}),occlusion:T=>({u_matrix:new i.cl(T),u_anchorPos:new i.ci(T),u_screenSizePx:new i.ck(T),u_occluderSizePx:new i.ck(T),u_color:new i.d3(T)})};class Bp{constructor(h,y,A,D){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++,this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=!!A,this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||y.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Bp.uniqueIdxCounter,Bp.uniqueIdxCounter++;const y=this.context.gl;this.context.unbindVAO(),this.bind(),y.bufferSubData(y.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Bp.uniqueIdxCounter=0;const C6={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class mF{constructor(h,y,A,D,F,z){this.length=y.length,this.attributes=A,this.itemSize=y.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const G=h.gl;this.buffer=G.createBuffer(),h.bindVertexBuffer.set(this.buffer),G.bufferData(G.ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?G.DYNAMIC_DRAW:G.STATIC_DRAW),this.dynamicDraw||F||y.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const y=this.context.gl;this.bind(),y.bufferSubData(y.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,y){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class pF{constructor(h,y,A,D,F){this.context=h,this.width=y,this.height=A;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new lC(h,z,0)),D>1&&(this.colorAttachment1=new lC(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new hb(h,z):new u2(h,z))}createColorAttachment(h,y){y===0?this.colorAttachment0=new lC(h,this.framebuffer,0):y===1&&(this.colorAttachment1=new lC(h,this.framebuffer,1))}removeColorAttachment(h,y){const A=this.context.gl;let D;y===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):y===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const y=this.colorAttachment0.get();y&&h.deleteTexture(y)}if(this.colorAttachment1){const y=this.colorAttachment1.get();y&&h.deleteTexture(y)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const y=this.depthAttachment.get();y&&h.deleteRenderbuffer(y)}else{const y=this.depthAttachment.get();y&&h.deleteTexture(y)}h.deleteFramebuffer(this.framebuffer)}}class gb{constructor(h,y){this.gl=h,this.clearColor=new Hme(this),this.clearDepth=new WR(this),this.clearStencil=new c6(this),this.colorMask=new rC(this),this.depthMask=new d6(this),this.stencilMask=new lv(this),this.stencilFunc=new lb(this),this.stencilOp=new c2(this),this.stencilTest=new cb(this),this.depthRange=new KR(this),this.depthTest=new u6(this),this.depthFunc=new ZR(this),this.blend=new db(this),this.blendFunc=new nC(this),this.blendColor=new aC(this),this.blendEquation=new h6(this),this.cullFace=new iC(this),this.cullFaceSide=new d2(this),this.frontFace=new YR(this),this.program=new QR(this),this.activeTexture=new XR(this),this.viewport=new ub(this),this.bindFramebuffer=new JR(this),this.bindRenderbuffer=new Gme(this),this.bindTexture=new Wme(this),this.bindVertexBuffer=new Kme(this),this.bindElementBuffer=new m6(this),this.bindVertexArrayOES=new p6(this),this.pixelStoreUnpack=new f6(this),this.pixelStoreUnpackPremultiplyAlpha=new x6(this),this.pixelStoreUnpackFlipY=new eF(this),this.options=y?Object.assign({},y):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=h.getExtension("EXT_texture_filter_anisotropic")||h.getExtension("MOZ_EXT_texture_filter_anisotropic")||h.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=h.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=h.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=h.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=h.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=y&&!!y.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=h.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=h.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=h.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=h.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(h,y,A){return new Bp(this,h,y,A)}createVertexBuffer(h,y,A,D,F){return new mF(this,h,y,A,D,F)}createRenderbuffer(h,y,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,y,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,y,A,D){return new pF(this,h,y,A,D)}clear({color:h,depth:y,stencil:A,colorMask:D}){const F=this.gl;let z=0;h&&(z|=F.COLOR_BUFFER_BIT,this.clearColor.set(h.toNonPremultipliedRenderColor(null)),this.colorMask.set(D||[!0,!0,!0,!0])),y!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(y),this.depthMask.set(!0)),A!==void 0&&(z|=F.STENCIL_BUFFER_BIT,this.clearStencil.set(A),this.stencilMask.set(255)),F.clear(z)}setCullFace(h){h.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(h.mode),this.frontFace.set(h.frontFace))}setDepthMode(h){h.func!==this.gl.ALWAYS||h.mask?(this.depthTest.set(!0),this.depthFunc.set(h.func),this.depthMask.set(h.mask),this.depthRange.set(h.range)):this.depthTest.set(!1)}setStencilMode(h){h.test.func!==this.gl.ALWAYS||h.mask?(this.stencilTest.set(!0),this.stencilMask.set(h.mask),this.stencilOp.set([h.fail,h.depthFail,h.pass]),this.stencilFunc.set({func:h.test.func,ref:h.ref,mask:h.test.mask})):this.stencilTest.set(!1)}setColorMode(h){i.by(h.blendFunction,Hn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(h.blendFunction),this.blendColor.set(h.blendColor),h.blendEquation?this.blendEquation.set(h.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(h.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let uv;function kr(T,h,y,A,D,F,z){const G=T.context,J=G.gl,ae=T.transform,le=[i.aF(ae.center.lng),i.aJ(ae.center.lat)],je=y.layout.get("symbol-placement"),ve=y.layout.get("text-variable-anchor"),Ne=y.layout.get("icon-rotation-alignment")==="map",De=y.layout.get("text-rotation-alignment")==="map",Pe=je!=="point",We=[];let Ve=0,nt=0;for(let yt=0;yt0){const pr=i.bC(),br=Js;i.cP(pr,Ht.placementInvProjMatrix,ae.glCoordMatrix),i.cP(pr,pr,Ht.placementViewportMatrix),We.push({circleArray:Ir,circleOffset:nt,transform:br,invTransform:pr,projection:Ht.getProjection()}),Ve+=Ir.length/4,nt=Ve}if(!Vs)continue;T.terrain&&T.terrain.setupElevationDraw(Gt,yr);const Cr=Ls?[Ot.canonical.x,Ot.canonical.y,1<=0&&(Ne[ut.associatedIconIndex]={x:Ht,y:es,z:ts,angle:as})}else Rp(Nt,je)}if(ae){ve.clear();const nt=T.icon.placedSymbolArray;for(let ut=0;ut{let $a=[0,0,0];if(hi){const Wn=T.style.directionalLight,Xi=T.style.ambientLight;Wn&&Xi&&($a=ng(T.style,Wn,Xi))}return $a},Xa=hi=>{yt.depthOcclusionForSymbolsAndCircles&&(y.hasOcclusionOpacityProperties||T.terrain)&&(hi.push("DEPTH_D24"),hi.push("DEPTH_OCCLUSION"))},Tn=hi=>{y.lut&&!Nt&&(y.lut.texture||(y.lut.texture=new i.d$(T.context,y.lut.image,[y.lut.image.height,y.lut.image.height,y.lut.image.height],Tt.gl.RGBA8)),Tt.activeTexture.set(Tt.gl.TEXTURE0+Kc.LUT),y.lut.texture&&y.lut.texture.bind(Tt.gl.LINEAR,Tt.gl.CLAMP_TO_EDGE),hi.push("APPLY_LUT_ON_GPU"))},ui=()=>{const hi=Ot&&y.layout.get("symbol-placement")!=="point",$a=[];Xa($a),Tn($a);const Wn=hi||In,Xi=Vs.elevationType==="road",Ho=T.shadowRenderer,jo=Xi&&Ht&&!!Ho&&Ho.enabled,Di=Rr(jo),qu=Xi&&Ht&&!T.terrain?Yt:Us,Td=y.paint.get("icon-image-cross-fade");T.terrainRenderModeElevated()&&Ht&&$a.push("PITCH_WITH_MAP_TERRAIN"),Ir&&($a.push("PROJECTION_GLOBE_VIEW"),Wn&&$a.push("PROJECTED_POS_ON_VIEWPORT")),Td>0&&Vs.hasAnySecondaryIcon&&$a.push("ICON_TRANSITION"),!Vs.icon.zOffsetVertexBuffer||Xi&&T.terrain||$a.push("Z_OFFSET"),Ve===0&&nt===0&&ut===0&&ot===1||$a.push("COLOR_ADJUSTMENT"),Vs.sdfIcons&&$a.push("RENDER_SDF"),jo&&$a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&Ht&&!T.terrain&&Vs.icon.orientationVertexBuffer&&$a.push("ELEVATED_ROADS");const Gl=Vs.icon.programConfigurations.get(y.id),Vd=T.getOrCreateProgram("symbol",{config:Gl,defines:$a}),Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],ld=Vs.iconSizeData,mm=i.bK(ld,yt.zoom),ap=Ht||!yt.isOrthographic,fh=Xs(pr,Js.tileID.canonical,Ht,Ot,yt,Vs.getProjection(),br),Lo=yn(pr,Js.tileID.canonical,Ht,Ot,yt,Vs.getProjection(),br),tl=T.translatePosMatrix(Lo,Js,G,ae,!0),Oi=T.translatePosMatrix(pr,Js,G,ae),fl=Wn?g2:fh,Mo=Ot&&!Ht&&!hi;let No=rr;!Jt&&!yt.mercatorFromTransition||Ot||(No=ig(yt));const ip=Ir?No:rr,A2=y.getColorAdjustmentMatrix(Ve,nt,ut,ot),Up=yC(ld.kind,mm,Mo,Ht,T,Oi,fl,tl,Et,!1,Hd,[0,0],0,yr,Cr,Bt,ja,ip,Vs.getProjection(),Di,ai,A2,Td,null),E2=Js.imageAtlasTexture?Js.imageAtlasTexture:null,Sb=y.layout.get("icon-size").constantOr(0)!==1||Vs.iconsNeedLinear,Zf=Vs.sdfIcons||T.options.rotating||T.options.zooming||Sb||ap?jt.LINEAR:jt.NEAREST,fg=Vs.sdfIcons&&y.paint.get("icon-halo-width").constantOr(1)!==0,Cb=T.terrain&&Ht&&hi?i.bl(i.bC(),fh):g2;if(hi&&Vs.icon){const Fy=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Vs.getProjection()),xg=gn(pr,Js.tileID.canonical,Ht,Ot,yt,Vs.getProjection(),br),Vp=y.layout.get("icon-size-scale-range"),gg=i.aA(T.scaleFactor,Vp[0],Vp[1]);tg(Vs,pr,T,!1,xg,Lo,Ht,Pe,Fy,yr,gg)}return{program:Vd,buffers:Vs.icon,uniformValues:Up,atlasTexture:E2,atlasTextureIcon:null,atlasInterpolation:Zf,atlasInterpolationIcon:null,isSDF:Vs.sdfIcons,hasHalo:fg,depthMode:qu,tile:Js,renderWithShadows:jo,labelPlaneMatrixInv:Cb}},Mi=()=>{const hi=Gt&&y.layout.get("symbol-placement")!=="point",$a=[],Wn=hi||as||In,Xi=Vs.elevationType==="road",Ho=T.shadowRenderer,jo=Xi&&es&&!!Ho&&Ho.enabled,Di=Rr(jo),qu=Xi&&es&&!T.terrain?Yt:Us;T.terrainRenderModeElevated()&&es&&$a.push("PITCH_WITH_MAP_TERRAIN"),Ir&&($a.push("PROJECTION_GLOBE_VIEW"),Wn&&$a.push("PROJECTED_POS_ON_VIEWPORT")),!Vs.text.zOffsetVertexBuffer||Xi&&T.terrain||$a.push("Z_OFFSET"),Vs.iconsInText&&$a.push("RENDER_TEXT_AND_SYMBOL"),$a.push("RENDER_SDF"),jo&&$a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&es&&!T.terrain&&Vs.text.orientationVertexBuffer&&$a.push("ELEVATED_ROADS"),Xa($a);const Td=Vs.text.programConfigurations.get(y.id),Gl=T.getOrCreateProgram("symbol",{config:Td,defines:$a});let Vd,Hd=[0,0],ld=null;const mm=Vs.textSizeData;Vs.iconsInText&&(Hd=Js.imageAtlasTexture?Js.imageAtlasTexture.size:[0,0],ld=Js.imageAtlasTexture?Js.imageAtlasTexture:null,Vd=es||!yt.isOrthographic||T.options.rotating||T.options.zooming||mm.kind==="composite"||mm.kind==="camera"?jt.LINEAR:jt.NEAREST);const ap=Js.glyphAtlasTexture?Js.glyphAtlasTexture.size:[0,0],fh=y.layout.get("text-size-scale-range"),Lo=i.aA(T.scaleFactor,fh[0],fh[1]),tl=i.bK(mm,yt.zoom,Lo),Oi=Xs(pr,Js.tileID.canonical,es,Gt,yt,Vs.getProjection(),br),fl=yn(pr,Js.tileID.canonical,es,Gt,yt,Vs.getProjection(),br),Mo=T.translatePosMatrix(fl,Js,J,le,!0),No=T.translatePosMatrix(pr,Js,J,le),ip=Wn?g2:Oi,A2=Gt&&!es&&!hi;let Up=rr;!Jt&&!yt.mercatorFromTransition||Gt||(Up=ig(yt));const E2=yC(mm.kind,tl,A2,es,T,No,ip,Mo,Et,!0,ap,Hd,0,yr,Cr,Bt,ja,Ir?Up:rr,Vs.getProjection(),Di,ai,null,null,Lo),Sb=Js.glyphAtlasTexture?Js.glyphAtlasTexture:null,Zf=jt.LINEAR,fg=y.paint.get("text-halo-width").constantOr(1)!==0,Cb=T.terrain&&es&&hi?i.bl(i.bC(),Oi):g2;if(hi&&Vs.text){const Fy=i.bV.getAtTileOffsetFunc(yr,yt.center.lat,yt.worldSize,Vs.getProjection()),xg=gn(pr,Js.tileID.canonical,es,Gt,yt,Vs.getProjection(),br);tg(Vs,pr,T,!0,xg,fl,es,We,Fy,yr,Lo)}return{program:Gl,buffers:Vs.text,uniformValues:E2,atlasTexture:Sb,atlasTextureIcon:ld,atlasInterpolation:Zf,atlasInterpolationIcon:Vd,isSDF:!0,hasHalo:fg,depthMode:qu,tile:Js,renderWithShadows:jo,labelPlaneMatrixInv:Cb}},_i=Vs.icon.segments.get().length,Za=Vs.text.segments.get().length,Gn=_i&&!z.onlyText?ui():null,li=Za&&!z.onlyIcons?Mi():null,Co=y.paint.get("icon-opacity").constantOr(1),no=y.paint.get("text-opacity").constantOr(1);if(ts&&Vs.canOverlap){gs=!0;const hi=Co&&!z.onlyText?Vs.icon.segments.get():[],$a=no&&!z.onlyIcons?Vs.text.segments.get():[];for(const Wn of hi)Ls.push({segments:new i.bg([Wn]),sortKey:Wn.sortKey,state:Gn});for(const Wn of $a)Ls.push({segments:new i.bg([Wn]),sortKey:Wn.sortKey,state:li})}else z.onlyText||Ls.push({segments:Co?Vs.icon.segments:new i.bg([]),sortKey:0,state:Gn}),z.onlyIcons||Ls.push({segments:no?Vs.text.segments:new i.bg([]),sortKey:0,state:li})}gs&&Ls.sort((yr,Js)=>yr.sortKey-Js.sortKey);for(const yr of Ls){const Js=yr.state;if(Js)if(T.terrain?T.terrain.setupElevationDraw(Js.tile,Js.program,{useDepthForOcclusion:yt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Js.labelPlaneMatrixInv}):T.setupDepthForOcclusion(yt.depthOcclusionForSymbolsAndCircles,Js.program),Tt.activeTexture.set(jt.TEXTURE0),Js.atlasTexture&&Js.atlasTexture.bind(Js.atlasInterpolation,jt.CLAMP_TO_EDGE,!0),Js.atlasTextureIcon&&(Tt.activeTexture.set(jt.TEXTURE1),Js.atlasTextureIcon&&Js.atlasTextureIcon.bind(Js.atlasInterpolationIcon,jt.CLAMP_TO_EDGE,!0)),Js.renderWithShadows&&T.shadowRenderer.setupShadows(Js.tile.tileID.toUnwrapped(),Js.program,"vector-tile"),T.uploadCommonLightUniforms(T.context,Js.program),Js.hasHalo){const Vs=Js.uniformValues;Vs.u_is_halo=1,M6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Vs,2),Vs.u_is_halo=0}else{if(Js.isSDF){const Vs=Js.uniformValues;Js.hasHalo&&(Vs.u_is_halo=1,M6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Vs,1)),Vs.u_is_halo=0}M6(Js.buffers,yr.segments,y,T,Js.program,Js.depthMode,D,F,Js.uniformValues,1)}}}function M6(T,h,y,A,D,F,z,G,J,ae){const le=[T.dynamicLayoutVertexBuffer,T.opacityVertexBuffer,T.iconTransitioningVertexBuffer,T.globeExtVertexBuffer,T.zOffsetVertexBuffer,T.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,G,pn.disabled,J,y.id,T.layoutVertexBuffer,T.indexBuffer,h,y.paint,A.transform.zoom,T.programConfigurations.get(y.id),le,ae)}function fF(T,h){const y=1<=zp?1:Ne.pitch/zp))),2*De}(T.transform),ae=T.transform.getFreeCameraOptions().position,le="elevatedStructuresDepthReconstruct",je=T.getOrCreateProgram(le,{defines:["DEPTH_RECONSTRUCTION"]}),ve=T.getOrCreateProgram(le);for(const Ne of A){const De=h.getTile(Ne),Pe=De.getBucket(y);if(!Pe)continue;const We=Pe.elevatedStructures;if(!We)continue;const Ve=Pe.elevationBufferData.heightRange,nt=fF(Ne.toUnwrapped(),ae),ut=T.translatePosMatrix(Ne.projMatrix,De,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor"));let ot,Et,Nt,Tt;if(D==="initialize"){if(!Ve||Ve.min>=1||We.depthSegments.segments[0].primitiveLength===0)continue;ot=cv(ut,nt,J,1,0),Et=z,Nt=We.depthSegments,Tt=je}else if(D==="reset"){if(!Ve||Ve.min>=0||We.maskSegments.segments[0].primitiveLength===0)continue;ot=cv(ut,nt,0,0,1),Et=G,Nt=We.maskSegments,Tt=je}else if(D==="geometry"){if(We.depthSegments.segments[0].primitiveLength===0)continue;ot=cv(ut,nt,J,1,0),Et=z,Nt=We.depthSegments,Tt=ve}Tt.draw(T,F.TRIANGLES,Et,vn.disabled,Hn.disabled,pn.disabled,ot,y.id,We.vertexBuffer,We.indexBuffer,Nt,y.paint,T.transform.zoom)}}function _C(T,h,y,A){const{painter:D,sourceCache:F,layer:z,coords:G,colorMode:J,elevationType:ae,terrainEnabled:le,pass:je}=T,ve=D.context.gl,Ne=z.paint.get("fill-pattern"),De=z.paint.get("fill-pattern-cross-fade"),Pe=Ne.constantOr(null);let We=ae;ae!=="road"||h&&!le||(We="none");const Ve=We==="road",nt=T.painter.shadowRenderer,ut=Ve&&!!nt&&nt.enabled,ot=new Fr(D.context.gl.LEQUAL,Fr.ReadOnly,D.depthRangeFor3D);let Et=[0,0,0];if(ut){const yt=D.style.directionalLight,Ot=D.style.ambientLight;yt&&Ot&&(Et=ng(D.style,yt,Ot))}const Nt=Ne&&Ne.constantOr(1),Tt=D.terrain&&D.terrain.renderingToTexture,jt=(yt,Ot)=>{let Gt,Ht,es,ts,gs;Ot?(Gt=Nt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",es=ve.LINES):(Gt=Nt?"fillPattern":"fill",es=ve.TRIANGLES);for(const Us of G){const Yt=F.getTile(Us);if(Nt&&!Yt.patternsLoaded())continue;const Bt=Yt.getBucket(z);if(!Bt)continue;const as=h?Bt.elevationBufferData:Bt.bufferData;if(as.isEmpty())continue;D.prepareDrawTile();const Jt=as.programConfigurations.get(z.id),Ls=D.isTileAffectedByFog(Us),rr=[],yr=[];Ve&&(rr.push("ELEVATED_ROADS"),yr.push(as.elevatedLayoutVertexBuffer)),ut&&rr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Tt&&y&&rr.push("USE_MRT1"),Nt&&(D.context.activeTexture.set(ve.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(ve.LINEAR,ve.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Js=!1;if(Pe&&Yt.imageAtlas){const br=Yt.imageAtlas,Kr=i.e3.from(Pe),In=Kr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ja=Kr.getSecondary(),ai=br.patternPositions.get(In),Rr=ja?br.patternPositions.get(ja.scaleSelf(i.o.devicePixelRatio).toString()):null;Js=!!ai&&!!Rr,ai&&Jt.setConstantPatternPositions(ai,Rr)}De>0&&(Js||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&rr.push("FILL_PATTERN_TRANSITION");const Vs=D.getOrCreateProgram(Gt,{config:Jt,overrideFog:Ls,defines:rr}),Ir=D.translatePosMatrix(Us.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&nt.setupShadows(Yt.tileID.toUnwrapped(),Vs,"vector-tile");const Cr=z.paint.get("fill-emissive-strength");if(Ot){ts=as.lineIndexBuffer,gs=as.lineSegments;const br=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[ve.drawingBufferWidth,ve.drawingBufferHeight];Ht=Gt==="fillOutlinePattern"&&Nt?N6(Ir,Cr,D,Yt,br,Et,De):aF(Ir,Cr,br,Et)}else ts=as.indexBuffer,gs=as.triangleSegments,Ht=Nt?j6(Ir,Cr,D,Yt,Et,De):w6(Ir,Cr,Et);D.uploadCommonUniforms(D.context,Vs,Us.toUnwrapped());let pr=yt;(ae==="road"&&!le||ae==="offset")&&(pr=ot),Vs.draw(D,es,pr,A||D.stencilModeForClipping(Us),J,pn.disabled,Ht,z.id,as.layoutVertexBuffer,ts,gs,z.paint,D.transform.zoom,Jt,yr)}};D.renderPass===je&&jt(D.depthModeForSublayer(1,D.renderPass==="opaque"?Fr.ReadWrite:Fr.ReadOnly),!1),We==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&jt(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Fr.ReadOnly),!0)}function wC(T,h,y,A,D,F,z,G){y.resetLayerRenderingStats(T);const J=T.context,ae=J.gl,le=T.transform,je=y.paint.get("fill-extrusion-pattern"),ve=y.paint.get("fill-extrusion-pattern-cross-fade"),Ne=je.constantOr(null),De=je.constantOr(1),Pe=y.paint.get("fill-extrusion-opacity"),We=T.style.enable3dLights(),Ve=y.paint.get(We&&!De?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),nt=[y.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ve],ut=y.layout.get("fill-extrusion-edge-radius"),ot=ut>0&&!y.paint.get("fill-extrusion-rounded-roof"),Et=ot?0:ut,Nt=le.projection.name==="globe"?i.eb():0,Tt=le.projection.name==="globe",jt=Tt?i.aj(le.zoom):0,yt=[i.aF(le.center.lng),i.aJ(le.center.lat)],Ot=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Gt=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ot?null:y.lut).toArray01().slice(0,3),Ht=y.paint.get("fill-extrusion-flood-light-intensity"),es=y.paint.get("fill-extrusion-vertical-scale"),ts=y.paint.get("fill-extrusion-line-width").constantOr(1)!==0,gs=y.paint.get("fill-extrusion-height-alignment"),Us=y.paint.get("fill-extrusion-base-alignment"),Yt=Ny(T,y.paint.get("fill-extrusion-cutoff-fade-range")),Bt=[];let as;Tt&&Bt.push("PROJECTION_GLOBE_VIEW"),nt[0]>0&&Bt.push("FAUX_AO"),ot&&Bt.push("ZERO_ROOF_RADIUS"),G&&Bt.push("HAS_CENTROID"),Ht>0&&Bt.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Bt.push("RENDER_CUTOFF"),ts&&Bt.push("RENDER_WALL_MODE");const Jt=T.renderPass==="shadow",Ls=T.shadowRenderer,rr=Jt&&!!Ls,yr=Jt?pn.disabled:pn.backCCW;T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0);let Js=[0,0,0];if(Ls){const Cr=T.style.directionalLight,pr=T.style.ambientLight;Cr&&pr&&(Js=ng(T.style,Cr,pr)),Jt||(Bt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ls.useNormalOffset&&Bt.push("NORMAL_OFFSET")),as=Bt.concat(["SHADOWS_SINGLE_CASCADE"])}const Vs=rr?"fillExtrusionDepth":De?"fillExtrusionPattern":"fillExtrusion",Ir=y.getLayerRenderingStats();for(const Cr of A){const pr=h.getTile(Cr),br=pr.getBucket(y);if(!br||br.projection.name!==le.projection.name)continue;let Kr=!1;Ls&&(Kr=Ls.getMaxCascadeForTile(Cr.toUnwrapped())===0);const In=T.isTileAffectedByFog(Cr),ja=br.programConfigurations.get(y.id);let ai=!1;if(Ne&&pr.imageAtlas){const Za=pr.imageAtlas,Gn=i.e3.from(Ne),li=Gn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),Co=Gn.getSecondary(),no=Za.patternPositions.get(li),hi=Co?Za.patternPositions.get(Co.scaleSelf(i.o.devicePixelRatio).toString()):null;ai=!!no&&!!hi,no&&ja.setConstantPatternPositions(no,hi)}ve>0&&(ai||ja.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Bt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Rr=T.getOrCreateProgram(Vs,{config:ja,defines:Kr?as:Bt,overrideFog:In});if(T.terrain&&T.terrain.setupElevationDraw(pr,Rr,{useMeterToDem:!0}),!br.centroidVertexBuffer){const Za=Rr.getAttributeLocation(ae,"a_centroid_pos");Za!==-1&&ae.vertexAttrib2f(Za,0,0)}!Jt&&Ls&&Ls.setupShadows(pr.tileID.toUnwrapped(),Rr,"vector-tile"),De&&(T.context.activeTexture.set(ae.TEXTURE0),pr.imageAtlasTexture&&pr.imageAtlasTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),ja.updatePaintBuffers());const Xa=y.paint.get("fill-extrusion-vertical-gradient"),Tn=1/br.tileToMeter;let ui;if(Jt&&Ls){if(lg(pr.tileID,br.maxHeight,T))continue;const Za=Ls.calculateShadowPassMatrixFromTile(pr.tileID.toUnwrapped());ui=_6(Za,Et,Tn,es,gs,Us)}else{const Za=T.translatePosMatrix(Cr.expandedProjMatrix,pr,y.paint.get("fill-extrusion-translate"),y.paint.get("fill-extrusion-translate-anchor")),Gn=le.projection.createInversionMatrix(le,Cr.canonical);ui=De?nF(Za,T,Xa,Pe,nt,Et,Tn,Cr,pr,Nt,gs,Us,jt,yt,Gn,Gt,es,ve):pC(Za,T,Xa,Pe,nt,Et,Tn,Cr,Nt,gs,Us,jt,yt,Gn,Gt,es,Ht,Js)}T.uploadCommonUniforms(J,Rr,Cr.toUnwrapped(),null,Yt);let Mi=br.segments;if(le.projection.name==="mercator"&&!Jt&&(Mi=br.getVisibleSegments(pr.tileID,T.terrain,T.transform.getFrustum(0)),!Mi.get().length))continue;if(Ir)if(Jt)for(const Za of Mi.get())Ir.numRenderedVerticesInShadowPass+=Za.primitiveLength;else for(const Za of Mi.get())Ir.numRenderedVerticesInTransparentPass+=Za.primitiveLength;const _i=[];(T.terrain||G)&&_i.push(br.centroidVertexBuffer),Tt&&_i.push(br.layoutVertexExtBuffer),ts&&_i.push(br.wallVertexBuffer),Rr.draw(T,J.gl.TRIANGLES,D,F,z,yr,ui,y.id,br.layoutVertexBuffer,br.indexBuffer,Mi,y.paint,T.transform.zoom,ja,_i)}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1)}class T6{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function og(T,h,y,A,D,F,z,G,J,ae,le,je,ve,Ne,De,Pe,We,Ve,nt,ut){const ot=h.context,Et=ot.gl,Nt=h.transform,Tt=h.transform.zoom,jt=[],yt=T.translate,Ot=T.translateAnchor,Gt=T.edgeRadius,Ht=Ny(h,T.cutoffFadeRange);le==="clear"?(jt.push("CLEAR_SUBPASS"),ut&&(jt.push("CLEAR_FROM_TEXTURE"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE))):le==="sdf"?jt.push("SDF_SUBPASS"):le==="emissive"&&(jt.push("USE_MRT1"),ot.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE)),Ve&&jt.push("HAS_CENTROID"),Ht.shouldRenderCutoff&&jt.push("RENDER_CUTOFF");const es=(ts,gs,Us,Yt,Bt)=>{let as=jt;gs.groundRadiusBuffer!=null&&(as=jt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=gs.programConfigurations.get(A.id),Ls=h.isTileAffectedByFog(ts),rr=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:as,overrideFog:Ls}),yr=fb(h,Yt,je,ae,Bt,[ve,Ne*Bt],De,Pe,We,Tt>=17?0:Gt*Bt,ut?ut.size[0]:0),Js=[];Ve&&Js.push(gs.hiddenByLandmarkVertexBuffer),gs.groundRadiusBuffer!=null&&Js.push(gs.groundRadiusBuffer),h.uploadCommonUniforms(ot,rr,ts.toUnwrapped(),null,Ht),rr.draw(h,ot.gl.TRIANGLES,F,z,G,J,yr,A.id,gs.vertexBuffer,gs.indexBuffer,Us,A.paint,Tt,Jt,Js)};for(const ts of D){const gs=y.getTile(ts),Us=gs.getBucket(A);if(!Us||Us.projection.name!==Nt.projection.name||!Us.groundEffect||Us.groundEffect&&!Us.groundEffect.hasData())continue;const Yt=Us.groundEffect,Bt=1/Us.tileToMeter;{const as=h.translatePosMatrix(ts.projMatrix,gs,yt,Ot),Jt=Yt.getDefaultSegment();es(ts,Yt,Jt,as,Bt)}if(nt)for(let as=0;as<4;as++){const Jt=i.e9[as](ts),Ls=y.getTile(Jt);if(!Ls)continue;const rr=Ls.getBucket(A);if(!rr||rr.projection.name!==Nt.projection.name||!rr.groundEffect||rr.groundEffect&&!rr.groundEffect.hasData())continue;const yr=rr.groundEffect;let Js,Vs;as===0?(Js=[-i.al,0,0],Vs=1):as===1?(Js=[i.al,0,0],Vs=0):as===2?(Js=[0,-i.al,0],Vs=3):(Js=[0,i.al,0],Vs=2);const Ir=yr.regionSegments[Vs];if(!Ir)continue;const Cr=new Float32Array(16);i.br(Cr,ts.projMatrix,Js),es(ts,yr,Ir,h.translatePosMatrix(Cr,gs,yt,Ot),Bt)}}}function epe(T,h,y,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const G=F?F.findDEMTileFor(y):null;if(!(G&&G.dem||z))return;F&&G&&G.dem&&A.selfDEMTileTimestamp!==G.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=G.dem._timestamp);const J=Ve=>new i.P(Math.ceil((Ve+i.ed)*i.ee),0),ae=Ve=>{const nt=h.getSource().minzoom,ut=Et=>{const Nt=h.getTileByID(Et);if(Nt&&Nt.hasData())return Nt.getBucket(D)},ot=[0,-1,1];for(const Et of ot){if(Ve.overscaledZ+Et(le[0]=Math.min(Ve.min.y,nt.min.y),le[1]=Math.max(Ve.max.y,nt.max.y),le[2]=i.al-nt.min.x>Ve.max.x?nt.min.x-i.al:Ve.max.x,le),ve=(Ve,nt)=>(le[0]=Math.min(Ve.min.x,nt.min.x),le[1]=Math.max(Ve.max.x,nt.max.x),le[2]=i.al-nt.min.y>Ve.max.y?nt.min.y-i.al:Ve.max.y,le),Ne=[(Ve,nt)=>je(Ve,nt),(Ve,nt)=>je(nt,Ve),(Ve,nt)=>ve(Ve,nt),(Ve,nt)=>ve(nt,Ve)],De=(Ve,nt,ut,ot,Et,Nt,Tt)=>{if(!F)return 0;const jt=[[Nt?ut:Ve,Nt?Ve:ut,0],[Nt?ut:nt,Nt?nt:ut,0]],yt=Tt<0?i.al+Tt:Tt,Ot=[Nt?yt:(Ve+nt)/2,Nt?(Ve+nt)/2:yt,0];return ut===0&&Tt<0||ut!==0&&Tt>0?F.getForTilePoints(Et,[Ot],!0,ot):jt.push(Ot),F.getForTilePoints(y,jt,!0,G),Math.max(jt[0][2],jt[1][2],Ot[2])/F.exaggeration()};for(let Ve=0;Ve<4;Ve++){const nt=A.borderFeatureIndices[Ve];if(nt.length===0)continue;const ut=i.e9[Ve](y),ot=ae(ut);if(!(ot&&ot instanceof i.ea))continue;const Et=F?F.findDEMTileFor(ut):null;if(!(Et&&Et.dem||z)||(F&&Et&&Et.dem&&A.borderDEMTileTimestamp[Ve]!==Et.dem._timestamp&&(A.borderDoneWithNeighborZ[Ve]=-1,A.borderDEMTileTimestamp[Ve]=Et.dem._timestamp),A.borderDoneWithNeighborZ[Ve]===ot.canonical.z))continue;ot.centroidVertexArray.length===0&&ot.createCentroidsBuffer();const Nt=(Ve<2?1:5)-Ve,Tt=ot.borderDoneWithNeighborZ[Nt]!==A.canonical.z,jt=ot.borderFeatureIndices[Nt];let yt=0;if(A.canonical.z!==ot.canonical.z){for(const Ot of nt)A.showCentroid(A.featuresOnBorder[Ot]);if(Tt)for(const Ot of jt)ot.showCentroid(ot.featuresOnBorder[Ot]);A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}for(const Ot of nt){const Gt=A.featuresOnBorder[Ot],Ht=A.centroidData[Gt.centroidDataIndex],es=Gt.borders[Ve];let ts;for(;ytes[0]+3||gs[0]>es[0]-3)break;ot.showCentroid(ts),yt++}if(ts&&ytes[1]-3)&&(Us++,++yt!==jt.length);)ts=ot.featuresOnBorder[jt[yt]];ts=ot.featuresOnBorder[jt[gs]];let Yt=!1;if(Us>=1){const Jt=ts.borders[Nt];Math.abs(es[0]-Jt[0])<3&&Math.abs(es[1]-Jt[1])<3&&(Us=1,Yt=!0,yt=gs+1)}else if(Us===0){A.showCentroid(Gt);continue}const Bt=ot.centroidData[ts.centroidDataIndex];z&&Yt&&(((Pe=Ht).flags|(We=Bt).flags)&i.ec?(Pe.flags|=i.ec,We.flags|=i.ec):(Pe.flags&=~i.ec,We.flags&=~i.ec));const as=Gt.intersectsCount()>1||ts.intersectsCount()>1;if(Us>1)yt=gs,Ht.centroidXY=Bt.centroidXY=new i.P(0,0);else if(Et&&Et.dem&&!as){const Jt=Ne[Ve](Ht,Bt),Ls=Ve%2?i.al-1:0,rr=De(Jt[0],Math.min(i.al-1,Jt[1]),Ls,Et,ut,Ve<2,Jt[2]);Ht.centroidXY=Bt.centroidXY=J(rr)}else as?Ht.centroidXY=Bt.centroidXY=new i.P(0,0):(Ht.centroidXY=A.encodeBorderCentroid(Gt),Bt.centroidXY=ot.encodeBorderCentroid(ts));A.writeCentroidToBuffer(Ht),ot.writeCentroidToBuffer(Bt)}else A.showCentroid(Gt)}A.borderDoneWithNeighborZ[Ve]=ot.canonical.z,ot.borderDoneWithNeighborZ[Nt]=A.canonical.z}var Pe,We;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(T)}const Rh=[1,0,0],A6=[0,1,0],Bu=[0,0,1];function lg(T,h,y){const A=y.transform,D=y.shadowRenderer;if(!D)return!0;const F=T.toUnwrapped(),z=A.tileSize*D._cascades[y.currentShadowCascade].scale;let G=h;if(A.elevation){const Pe=A.elevation.getMinMaxForTile(T);Pe&&(G+=Pe.max)}const J=[...D.shadowDirection];J[2]=-J[2];const ae=D.computeSimplifiedTileShadowVolume(F,G,z,J);if(!ae)return!1;const le=[Rh,A6,Bu,J,[J[0],0,J[2]],[0,J[1],J[2]]],je=A.projection.name==="globe",ve=A.scaleZoom(z),Ne=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,ve,!je),De=D.getCurrentCascadeFrustum();return Ne.intersectsPrecise(ae.vertices,ae.planes,le)===0||De.intersectsPrecise(ae.vertices,ae.planes,le)===0}function v2(T){const{painter:h,source:y,layer:A,coords:D}=T;let F=T.defines;const z=h.context,G=h.renderPass==="shadow",J=h.renderPass==="light-beam",ae=h.shadowRenderer,le=i.ef(h.transform.center.lat,h.transform.zoom),je=Ny(h,A.paint.get("building-cutoff-fade-range"));je.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),T.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const ve of D){const Ne=y.getTile(ve),De=Ne.getBucket(A);if(!De)continue;ae&&ae.getMaxCascadeForTile(ve.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Pe=De.programConfigurations.get(A.id);let We,Ve,nt,ut=h.translatePosMatrix(ve.expandedProjMatrix,Ne,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,T.verticalScale]),G&&ae){if(lg(Ne.tileID,De.maxHeight*le,h))continue;let Et=ae.calculateShadowPassMatrixFromTile(Ne.tileID.toUnwrapped());Et=i.cS(i.bC(),Et,[1,1,T.verticalScale]),nt=Ey(Et),We=Ve=h.getOrCreateProgram("buildingDepth",{config:Pe,defines:F,overrideFog:!1})}else if(J)We=Ve=h.getOrCreateProgram("buildingBloom",{config:Pe,defines:F,overrideFog:!1}),nt=iF(ut);else{const Et=h.transform.calculatePosMatrix(ve.toUnwrapped(),h.transform.worldSize);i.cS(Et,Et,[1,1,T.verticalScale]);const Nt=i.bC();i.cS(Nt,Et,[1,-1,1/le]),i.bl(Nt,Nt),i.eg(Nt,Nt);const Tt=h.transform.getFreeCameraOptions().position,jt=1<{if(J){const Tt=Et.entranceBloom;Nt.draw(h,z.gl.TRIANGLES,T.depthMode,vn.disabled,T.blendMode,pn.disabled,nt,A.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,A.paint,h.transform.zoom,Pe,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=Et.segmentsBucket;let jt=[Et.layoutNormalBuffer,Et.layoutCentroidBuffer,Et.layoutColorBuffer,Et.layoutFloodLightDataBuffer];Et.layoutFacadePaintBuffer&&(jt=jt.concat([Et.layoutFacadeDataBuffer,Et.layoutFacadeVerticalRangeBuffer,Et.layoutFacadePaintBuffer])),Nt.draw(h,z.gl.TRIANGLES,T.depthMode,vn.disabled,T.blendMode,G?pn.disabled:pn.backCW,nt,A.id,Et.layoutVertexBuffer,Et.indexBuffer,Tt,A.paint,h.transform.zoom,Pe,jt)}};h.uploadCommonUniforms(z,Ve,ve.toUnwrapped(),null,je),De.buildingWithoutFacade&&ot(De.buildingWithoutFacade,Ve),De.buildingWithFacade&&(We!==Ve&&h.uploadCommonUniforms(z,We,ve.toUnwrapped(),null,je),ot(De.buildingWithFacade,We))}}function jC(T,h,y,A,D,F,z,G,J,ae,le,je,ve){const Ne=T.context.gl,De=T.depthModeForSublayer(1,Fr.ReadOnly,Ne.LEQUAL,!0),Pe=.1*(1-(We=le))+3*We;var We;const Ve=T._showOverdrawInspector,nt=je,ut=new T6;Ve||og(ut,T,h,y,A,De,new vn({func:Ne.ALWAYS,mask:255},255,255,Ne.KEEP,Ne.KEEP,Ne.REPLACE),new Hn([Ne.ONE,Ne.ONE,Ne.ONE,Ne.ONE],i.ao.transparent,[!1,!1,!1,!0],Ne.MIN),pn.disabled,D,"sdf",F,z,G,J,ae,Pe,nt,!1);{const ot=Ve?vn.disabled:new vn({func:Ne.EQUAL,mask:255},255,255,Ne.KEEP,Ne.DECR,Ne.DECR),Et=Ve?T.colorModeForRenderPass():new Hn([Ne.ONE_MINUS_DST_ALPHA,Ne.DST_ALPHA,Ne.ONE,Ne.ONE],i.ao.transparent,[!0,!0,!0,!0]);og(ut,T,h,y,A,De,ot,Et,pn.disabled,D,"color",F,z,G,J,ae,Pe,nt,!1)}}function NC(T){return[T[0]*i.eh,T[1]*i.eh,T[2]*i.eh,0]}function b2(T,h,y,A,D,F,z,G,J){const ae=A.getSource(),le=y.globeSharedBuffers;if(!le)return;let je,ve,Ne;if(h&&(je=A.getTile(h)),ae instanceof i.aU?(ve=ae.texture,Ne=i.dK(0,0,y.transform)):je&&h&&(ve=je.texture,Ne=i.dK(h.canonical.z,h.canonical.x,y.transform)),!ve||!Ne)return;T||(Ne=i.cS(i.bC(),Ne,[1,-1,1]));const De=y.context,Pe=De.gl,We=D.paint.get("raster-resampling")==="nearest"?Pe.NEAREST:Pe.LINEAR,Ve=y.colorModeForDrapableLayerRenderPass(F),nt=z.defines;nt.push("GLOBE_POLES");const ut=new Fr(Pe.LEQUAL,Fr.ReadWrite,y.depthRangeFor3D),ot=Float32Array.from(y.transform.expandedFarZProjMatrix),Et=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));y.terrain&&y.terrain.prepareDrawTile(),De.activeTexture.set(Pe.TEXTURE0),ve.bind(We,Pe.CLAMP_TO_EDGE),De.activeTexture.set(Pe.TEXTURE1),ve.bind(We,Pe.CLAMP_TO_EDGE),"useMipmap"in ve&&De.extTextureFilterAnisotropic&&y.transform.pitch>20&&Pe.texParameterf(Pe.TEXTURE_2D,De.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,De.extTextureFilterAnisotropicMax);const[Nt,Tt,jt,yt]=h?le.getPoleBuffers(h.canonical.z,!1):le.getPoleBuffers(0,!0),Ot=D.paint.get("raster-elevation");let Gt;T?(Gt=Nt,y.renderDefaultNorthPole=Ot!==0):(Gt=Tt,y.renderDefaultSouthPole=Ot!==0);const Ht=NC(z.mix),es=((gs,Us,Yt,Bt,as,Jt,Ls,rr,yr,Js,Vs,Ir,Cr)=>cF(gs,Us,Yt,new Float32Array(16),new Float32Array(9),[0,0],Bt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],rr,2,Js,Vs,Ir,1,0,Cr))(ot,Et,Ne,i.aj(y.transform.zoom),0,D,0,Ot,0,Ht,z.offset,z.range,F),ts=y.getOrCreateProgram("raster",{defines:nt});y.uploadCommonUniforms(De,ts,null),ts.draw(y,Pe.TRIANGLES,ut,J,Ve,G,es,D.id,Gt,jt,yt)}function xF(T){const h=T._nearZ,y=T.projection.farthestPixelDistance(T),A=y-h,D=.2*T.height,F=h+D;return[h,y,(F-D-h)/A,(F-h)/A]}function cg(T,h,y,A){if(T)return h instanceof Sd&&T instanceof Md?h.getTextureDescriptor(T,y,!0):{texture:T.texture,mix:NC(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Zi=i.ei([{name:"a_index",type:"Int16",components:1}]);class kC{constructor(h,y,A,D){const F={width:A[0],height:A[1],data:null},z=h.gl;this.targetColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(h,F,z.RGBA8,{useMipmap:!1}),this.context=h,this.updateParticleTexture(y,D),this.lastInvalidatedAt=0}updateParticleTexture(h,y){if(this.particleTextureDimension===y.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const A=this.context.gl,D=y.width*y.height;this.particleTexture0=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,y,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Ht=i.bj(y.canonical,J),es=i.el(Ht);ve=i.aB(new Float32Array(16),J.globeMatrix,es),i.aB(ve,J.projMatrix,ve)}const Ne=i.bC();Ne[12]+=2*D/(i.o.devicePixelRatio*J.width),Ne[13]+=2*F/(i.o.devicePixelRatio*J.height),i.aB(ve,Ne,ve);const De=T.getOrCreateProgram("debug",{defines:je}),Pe=h.getTileByID(y.key);T.terrain&&T.terrain.setupElevationDraw(Pe,De);const We=Fr.disabled,Ve=vn.disabled,nt=T.colorModeForRenderPass(),ut="$debug";G.activeTexture.set(ae.TEXTURE0),T.emptyTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),le?Pe._makeGlobeTileDebugBuffers(T.context,J):Pe._makeDebugTileBoundsBuffers(T.context,J.projection);const ot=Pe._tileDebugBuffer||T.debugBuffer,Et=Pe._tileDebugIndexBuffer||T.debugIndexBuffer,Nt=Pe._tileDebugSegments||T.debugSegments;if(De.draw(T,ae.LINE_STRIP,We,Ve,nt,pn.disabled,f2(ve,A.toPremultipliedRenderColor(null)),ut,ot,Et,Nt,null,null,null,[Pe._globeTileDebugBorderBuffer]),z){const Ht=Pe.latestRawTileData,es=Math.floor((Ht&&Ht.byteLength||0)/1024);let ts=y.canonical.toString();y.overscaledZ!==y.canonical.z&&(ts+=` => ${y.overscaledZ}`),ts+=` ${Pe.state}`,ts+=` ${es}kb`,function(gs,Us){gs.initDebugOverlayCanvas();const Yt=gs.debugOverlayCanvas,Bt=gs.context.gl,as=gs.debugOverlayCanvas.getContext("2d");as.clearRect(0,0,Yt.width,Yt.height),as.shadowColor="white",as.shadowBlur=2,as.lineWidth=1.5,as.strokeStyle="white",as.textBaseline="top",as.font="bold 36px Open Sans, sans-serif",as.fillText(Us,5,5),as.strokeText(Us,5,5),gs.debugOverlayTexture.update(Yt),gs.debugOverlayTexture.bind(Bt.LINEAR,Bt.CLAMP_TO_EDGE)}(T,ts)}const Tt=h.getTile(y).tileSize,jt=512/Math.min(Tt,512)*(y.overscaledZ/J.zoom)*.5,yt=Pe._tileDebugTextBuffer||T.debugBuffer,Ot=Pe._tileDebugTextIndexBuffer||T.quadTriangleIndexBuffer,Gt=Pe._tileDebugTextSegments||T.debugSegments;De.draw(T,ae.TRIANGLES,We,Ve,Hn.alphaBlended,pn.disabled,f2(ve,i.ao.transparent.toPremultipliedRenderColor(null),jt),ut,yt,Ot,Gt,null,null,null,[Pe._globeTileDebugTextBuffer])}function pv(T,h,y,A){Kt(T,0,h+y/2,T.transform.width,y,A)}function Io(T,h,y,A){Kt(T,h-y/2,0,y,T.transform.height,A)}function Kt(T,h,y,A,D,F){const z=T.context,G=z.gl;G.enable(G.SCISSOR_TEST),G.scissor(h*i.o.devicePixelRatio,y*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),G.disable(G.SCISSOR_TEST)}const _F=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:SC}=_F;function Hf(T,h,y,A){T.emplaceBack(h,y,A)}class CC{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Hf(this.vertexArray,-1,-1,1),Hf(this.vertexArray,1,-1,1),Hf(this.vertexArray,-1,1,1),Hf(this.vertexArray,1,1,1),Hf(this.vertexArray,-1,-1,-1),Hf(this.vertexArray,1,-1,-1),Hf(this.vertexArray,-1,1,-1),Hf(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=h.createVertexBuffer(this.vertexArray,SC),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function fv(T,h,y,A,D,F){const z=T.context.gl,G=h.paint.get("sky-atmosphere-color"),J=h.paint.get("sky-atmosphere-halo-color"),ae=h.paint.get("sky-atmosphere-sun-intensity"),le=((je,ve,Ne,De,Pe)=>({u_matrix_3f:je,u_sun_direction:ve,u_sun_intensity:Ne,u_color_tint_r:[De.r,De.g,De.b,De.a],u_color_tint_m:[Pe.r,Pe.g,Pe.b,Pe.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ae,G.toPremultipliedRenderColor(null),J.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),y.draw(T,z.TRIANGLES,Fr.disabled,vn.disabled,Hn.unblended,pn.frontCW,le,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const wF=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class yb{constructor(h){const y=new i.ep;y.emplaceBack(-1,1,1,0,0),y.emplaceBack(1,1,1,1,0),y.emplaceBack(1,-1,1,1,1),y.emplaceBack(-1,-1,1,0,1);const A=new i.b0;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(y,wF.members),this.indexBuffer=h.createIndexBuffer(A),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const tpe=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class spe{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class jF{constructor(h){this.colorModeAlphaBlendedWriteRGB=new Hn([1,$f,1,$f],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Hn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new spe,this.updateNeeded=!0}update(h){const y=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new yb(y);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(le){const je=i.eq(30),ve=[];for(let Ne=0;Ne{const jt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Tt&&jt.push("ALPHA_PASS");const yt=h.getOrCreateProgram("globeAtmosphere",{defines:jt}),Ot=((Ht,es,ts,gs,Us,Yt,Bt,as,Jt,Ls,rr,yr)=>({u_frustum_tl:Ht,u_frustum_tr:es,u_frustum_br:ts,u_frustum_bl:gs,u_horizon:Us,u_transition:Yt,u_fadeout_range:Bt,u_atmosphere_fog_color:as.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Ls.toArray01(),u_temporal_offset:rr,u_horizon_angle:yr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,G,We,le,ve,De,nt,Et);h.uploadCommonUniforms(A,yt);const Gt=this.atmosphereBuffer;Gt&&yt.draw(h,D.TRIANGLES,z,vn.disabled,Tt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,pn.backCW,Ot,Tt?"atmosphere_glow_alpha":"atmosphere_glow",Gt.vertexBuffer,Gt.indexBuffer,Gt.segments)};Nt(!1),Nt(!0)}drawStars(h,y){const A=i.aA(y.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,z=h.transform,G=h.getOrCreateProgram("stars"),J=i.c7([]);i.c9(J,J,-z._pitch),i.c8(J,J,-z.angle),i.c9(J,J,i.an(z._center.lat)),i.et(J,J,-i.an(z._center.lng));const ae=i.cc(new Float32Array(16),J),le=i.aB([],z.starsProjMatrix,ae),je=i.eo([],ae),ve=i.eu([],je),Ne=[0,1,0];i.dQ(Ne,Ne,ve),i.c5(Ne,Ne,this.params.sizeMultiplier);const De=[1,0,0];i.dQ(De,De,ve),i.c5(De,De,this.params.sizeMultiplier);const Pe=(We=Ne,Ve=De,nt=A,{u_matrix:Float32Array.from(le),u_up:We,u_right:Ve,u_intensity_multiplier:nt});var We,Ve,nt;h.uploadCommonUniforms(D,G),this.starsVx&&this.starsIdx&&G.draw(h,F.TRIANGLES,Fr.disabled,vn.disabled,this.colorModeAlphaBlendedWriteRGB,pn.disabled,Pe,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class MC{constructor(){this.visibleTiles=[]}updateBorders(h,y){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const J of F){const ae=h.getTile(J);if(!ae.hasData())continue;const le=ae.getBucket(y);le&&(le.isEmpty()||(A.push(J.key),D.push({bucket:le,tileID:J.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let J=0;JJ.tileID.z-ae.tileID.z||J.tileID.x-ae.tileID.x||J.tileID.y-ae.tileID.y);for(const J of D){const ae=new Array,le=new Array,je=J.bucket;for(const ve of je.featuresOnBorder)G.has(ve.featureId)?le.push(ve.footprintIndex):(G.add(ve.featureId),ae.push(ve.footprintIndex));je.updateFootprintHiddenFlags(ae,i.ev,!1),je.updateFootprintHiddenFlags(le,i.ev,!0)}}}function TC(T,h){const y=[...T],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(y,D,y),i.aB(y,h.worldToFogMatrix,y),y}function AC(T,h,y,A,D){const F=y.material,z=A.context,{baseColorTexture:G,metallicRoughnessTexture:J}=F.pbrMetallicRoughness,{normalTexture:ae,occlusionTexture:le,emissionTexture:je}=F;function ve(De,Pe,We){if(De&&(T.push(Pe),z.activeTexture.set(z.gl.TEXTURE0+We),De.gfxTexture)){const{minFilter:Ve,magFilter:nt,wrapS:ut,wrapT:ot}=De.sampler;De.gfxTexture.bindExtraParam(Ve,nt,ut,ot)}}ve(G,"HAS_TEXTURE_u_baseColorTexture",Kc.BaseColor),ve(J,"HAS_TEXTURE_u_metallicRoughnessTexture",Kc.MetallicRoughness),ve(ae,"HAS_TEXTURE_u_normalTexture",Kc.Normal),ve(le,"HAS_TEXTURE_u_occlusionTexture",Kc.Occlusion),ve(je,"HAS_TEXTURE_u_emissionTexture",Kc.Emission),D&&(D.texture||(D.texture=new i.d$(A.context,D.image,[D.image.height,D.image.height,D.image.height],z.gl.RGBA8)),z.activeTexture.set(z.gl.TEXTURE0+Kc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),T.push("APPLY_LUT_ON_GPU")),y.texcoordBuffer&&(T.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(y.texcoordBuffer)),y.colorBuffer&&(T.push(y.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(y.colorBuffer)),y.normalBuffer&&(T.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(y.normalBuffer)),y.pbrBuffer&&(T.push("HAS_ATTRIBUTE_a_pbr"),T.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(y.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||T.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||T.push("DIFFUSE_SHADED");const Ne=A.shadowRenderer;Ne&&(T.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ne.useNormalOffset&&T.push("NORMAL_OFFSET"))}function EC(T,h,y,A,D,F){const z=T.modelOpacity,G=h.context,J=new Fr(h.context.gl.LEQUAL,T.isLightMesh?Fr.ReadOnly:Fr.ReadWrite,h.depthRangeFor3D),ae=h.transform,le=T.mesh,je=le.material,ve=je.pbrMetallicRoughness,Ne=h.style.fog;let De;De=h.transform.projection.zAxisUnit==="pixels"?[...T.nodeModelMatrix]:i.aB([],A.zScaleMatrix,T.nodeModelMatrix),i.aB(De,A.negCameraPosMatrix,De);const Pe=i.bl([],De);i.eg(Pe,Pe);const We=y.paint.get("model-color-use-theme").constantOr("default")==="none",Ve=y.paint.get("model-emissive-strength").constantOr(0),nt=dv(new Float32Array(T.worldViewProjection),new Float32Array(De),new Float32Array(Pe),null,h,z,ve.baseColorFactor,je.emissiveFactor,ve.metallicFactor,ve.roughnessFactor,je,Ve,y,void 0,void 0,T.materialOverride,T.modelColor),ut={defines:[]},ot=[],Et=h.shadowRenderer;Et&&(Et.useNormalOffset=!1),AC(ut.defines,ot,le,h,We?null:y.lut);let Nt=null;if(Ne){const yt=TC(T.nodeModelMatrix,h.transform);if(Nt=new Float32Array(yt),ae.projection.name!=="globe"){const Ot=le.aabb.min,Gt=le.aabb.max,[Ht,es]=Ne.getOpacityForBounds(yt,Ot[0],Ot[1],Gt[0],Gt[1]);ut.overrideFog=Ht>=ys||es>=ys}}const Tt=Ny(h,y.paint.get("model-cutoff-fade-range"));Tt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const jt=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(G,jt,null,Nt,Tt),h.renderPass!=="shadow"&&Et&&Et.setupShadowsFromMatrix(T.nodeModelMatrix,jt),jt.draw(h,G.gl.TRIANGLES,J,D,F,le.material.doubleSided?pn.disabled:pn.backCCW,nt,y.id,le.vertexBuffer,le.indexBuffer,le.segments,y.paint,h.transform.zoom,void 0,ot)}function _2(T,h){return T.style._importedAsBasemap?"basemap":h.scope}function xv(T,h,y,A,D,F,z,G,J,ae){const le=T.transform,je=!!h.isGeometryBloom&&h.isGeometryBloom;if(je&&T.renderPass==="shadow")return;const ve=le.projection.name==="globe"?i.eD(y,le):[...y];i.aB(ve,ve,h.globalMatrix);const Ne=i.aB([],A,ve);if(h.meshes)for(const De of h.meshes){const Pe=G.get(De.material.name);if(Pe&&Pe.opacity<=0)continue;if(De.material.alphaMode!=="BLEND"){z.push({mesh:De,depth:0,modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:ve,isLightMesh:je,materialOverride:Pe,modelOpacity:J,modelColor:ae});continue}const We=i.af([],De.centroid,Ne);!le.isOrthographic&&We[2]<=0||F.push({mesh:De,depth:We[2],modelIndex:D,worldViewProjection:Ne,nodeModelMatrix:ve,isLightMesh:je,materialOverride:Pe,modelOpacity:J,modelColor:ae})}if(h.children)for(const De of h.children)xv(T,De,y,A,D,F,z,G,J,ae)}function $p(T,h,y,A){const D=y.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),G=D.calculateShadowPassMatrixFromMatrix(h),J=S6(G);y.getOrCreateProgram("modelDepth",{defines:y._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(y,y.context.gl.TRIANGLES,F,vn.disabled,z,pn.disabled,J,A.id,T.vertexBuffer,T.indexBuffer,T.segments,A.paint,y.transform.zoom,void 0,void 0)}function NF(T,h,y,A,D,F){for(const z of D){const G=Object.assign({},A);G.part=z;const J={type:"Unknown",id:h,properties:G},ae={orientation:T.paint.get("model-rotation").evaluate(J,y)};F.set(z,ae)}}function kF(T,h,y,A,D,F){for(const z of D){const G=Object.assign({},A);G.part=z;const J={type:"Unknown",id:h,properties:G},ae={color:T.paint.get("model-color").evaluate(J,y),colorMix:T.paint.get("model-color-mix-intensity").evaluate(J,y),opacity:T.paint.get("model-opacity").evaluate(J,y),emissionStrength:T.paint.get("model-emissive-strength").evaluate(J,y)};F.set(z,ae)}}function SF(T,h,y,A,D){let F=!1;for(const G of A)G.modelOpacity!==1&&(EC(G,T,h,D[G.modelIndex],vn.disabled,Hn.disabled),F=!0);for(const G of A)EC(G,T,h,D[G.modelIndex],G.modelOpacity!==1?T.stencilModeFor3D():vn.disabled,T.colorModeForRenderPass());F&&T.resetStencilClippingMasks();const z=Hn.additive;for(const G of y)EC(G,T,h,D[G.modelIndex],vn.disabled,G.isLightMesh?z:T.colorModeForRenderPass())}function CF(T,h,y){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,G){let J,ae,le,je=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&je>0){const ve=F.terrain,Ne=ve.findDEMTileFor(G);Ne&&Ne.dem?J=i.eF.create(ve,G,Ne):je=0}if(je===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),je===z.validForExaggeration&&(je===0||J&&J._demTile&&J._demTile.tileID===z.validForDEMTile.id&&J._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const ve in z.instancesPerModel){const Ne=z.instancesPerModel[ve];for(let De=0;Deae&&(ae=Ne.max)}const le=i.aA(A.x,F,z)-A.x,je=i.aA(A.y,G,J)-A.y,ve=i.cf(ae,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(le*le+je*je+ve*ve))}function MF(T,h,y,A,D,F,z){const G=T.context,J=T.renderPass==="shadow",ae=T.shadowRenderer,le=J&&ae?ae.getShadowPassDepthMode():new Fr(G.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),je=T.isTileAffectedByFog(F),ve=T.transform.projection.name==="globe";if(y.meshes)for(const Ne of y.meshes){const De=ve?[]:["MODEL_POSITION_ON_GPU"],Pe=[];let We,Ve,nt;const ut=!ve&&A.instancedDataArray.length>20;ut&&De.push("INSTANCED_ARRAYS");const ot=Ny(T,h.paint.get("model-cutoff-fade-range"));if(ot.shouldRenderCutoff&&De.push("RENDER_CUTOFF"),J&&ae)We=T.getOrCreateProgram("modelDepth",{defines:De}),Ve=S6(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(y.globalMatrix)),nt=ae.getShadowPassColorMode();else{AC(De,Pe,Ne,T,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),We=T.getOrCreateProgram("model",{defines:De,overrideFog:je});const Nt=Ne.material,Tt=Nt.pbrMetallicRoughness,jt=h.paint.get("model-opacity").constantOr(1),yt=h.paint.get("model-emissive-strength").constantOr(0);Ve=dv(F.expandedProjMatrix,Float32Array.from(y.globalMatrix),new Float32Array(16),null,T,jt,Tt.baseColorFactor,Nt.emissiveFactor,Tt.metallicFactor,Tt.roughnessFactor,Nt,yt,h,D),ae&&(z.shadowUniformsInitialized?We.setShadowUniformValues(G,ae.getShadowUniformValues()):(ae.setupShadows(F.toUnwrapped(),We,"model-tile"),z.shadowUniformsInitialized=!0)),nt=ot.shouldRenderCutoff||jt<1||Nt.alphaMode!=="OPAQUE"?Hn.alphaBlended:Hn.unblended}T.uploadCommonUniforms(G,We,F.toUnwrapped(),null,ot);const Et=Ne.material.doubleSided?pn.disabled:pn.backCCW;if(ut)Pe.push(A.instancedDataBuffer),We.draw(T,G.gl.TRIANGLES,le,vn.disabled,nt,Et,Ve,h.id,Ne.vertexBuffer,Ne.indexBuffer,Ne.segments,h.paint,T.transform.zoom,void 0,Pe,A.instancedDataArray.length);else{const Nt=J?"u_instance":"u_normal_matrix";for(let Tt=0;TtJ[1]?z:J,F[0]=y.max[0],z=i.aC(i.eG(),F,D),G=z[1]J[1]?z:J,F[1]=y.min[1],z=i.aC(i.eG(),F,D),G=z[1]J[1]?z:J;const ae=i.aA(A[0],0,1),le=100*h.pixelsPerMeter*i.aA(A[1],0,1),je=i.aA(A[2],0,1),ve=i.eH(i.eG(),G,J,ae),Ne=Math.tan(.5*h.fovX),De=-ve[2]*Ne;if(le===0)return ve[1]<-Math.abs(De)?je:1;const Pe=(-Math.abs(De)-ve[1])/le,We=(nt,ut,ot)=>(1-ot)*nt+ot*ut,Ve=i.aA(We(1,je,Pe),je,1);return We(1,Ve,i.aA((h.pitch-20)/20,0,1))}class TF{}class Ly{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,y,A){{const je=this._storage.get(y.id);if(je)return je.lastUsedFrameIdx=h,je.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),G=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const J=new i.eJ;for(let je=0;je30&&(A.buf.destroy(),this._storage.delete(y))}destroy(){for(const[h,y]of this._storage)y.buf.destroy(),this._storage.delete(h)}}class vb{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const bb=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class dg{constructor(h){this.revealStart=11,this.revealRange=2}}const P6=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class I6{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,y){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,G=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),G.emplaceBack(0,1,2),G.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,P6.members),this.vignetteIdx=h.context.createIndexBuffer(G)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,A);const z={u_vignetteShape:(F={vignetteShape:[y.start,y.range,Math.pow(10,y.fadePower)],vignetteColor:[y.color.r,y.color.g,y.color.b,y.color.a*y.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Fr.disabled,vn.disabled,Hn.alphaBlended,pn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class L6{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,y){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),z=i.an(F.lng),G=i.an(F.lat),J=h.pixelsPerMeter/y,ae=z*i.eM,le=i.eM*Math.log(Math.tan(Math.PI/4+G/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const je=-this._offsetYPrev+le,ve=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ae)*J,this._accumulatedOffsetY+=je*J,this._accumulatedElevation+=ve*J,this._offsetXPrev=ae,this._offsetYPrev=le,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function PC(T,h){return[-(T[0]-Math.floor(T[0]/h)*h),-(T[1]-Math.floor(T[1]/h)*h),-(T[2]-Math.floor(T[2]/h)*h)]}function um(T){const h=i.eq(1323123451230),y=[];for(let A=0;A Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=um(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const G=i.eq(1323123451230);for(let J=0;JA)return;const D=mh(0,1,y.revealStart,y.revealStart+y.revealRange,A);if(!this.particlesVx||!this.particlesIdx)return;const F=structuredClone(this._params);let z=[-F.direction.x,F.direction.y,-100];i.aw(z,z);const G=structuredClone(this._vignetteParams);G.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,G.strength=1,G.color=structuredClone(h.style.rain.state.vignetteColor));const J=this.updateOnRender(h,F.timeFactor),ae=h.context,le=ae.gl,je=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ae,{width:h.width,height:h.height,data:null},le.RGBA8)),F.distortionStrength>0&&(ae.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE),le.copyTexSubImage2D(le.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const ve=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ae,ve),ae.activeTexture.set(le.TEXTURE0),this.screenTexture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const Ne=[F.color.r,F.color.g,F.color.b,F.color.a],De=(Pe,We)=>{const Ve=PC(this._movement.getPosition(),Pe),nt=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,ot=h.width/2,Et=h.height/2,Nt=mh(0,F.screenThinning.start,0,1,F.screenThinning.intensity),Tt=mh(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),jt=mh(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),yt=(Ot={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ve,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Pe,rainDropletSize:[nt,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:Ne,screenSize:[je.width,je.height],thinningCenterPos:[ot,Et],thinningShape:[Nt,Tt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:jt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:We?0:1},{u_modelview:Float32Array.from(Ot.modelview),u_projection:Float32Array.from(Ot.projection),u_time:Ot.time,u_cam_pos:Ot.camPos,u_texScreen:0,u_velocityConeAperture:Ot.velocityConeAperture,u_velocity:Ot.velocity,u_boxSize:Ot.boxSize,u_rainDropletSize:Ot.rainDropletSize,u_distortionStrength:Ot.distortionStrength,u_rainDirection:Ot.rainDirection,u_color:Ot.color,u_screenSize:Ot.screenSize,u_thinningCenterPos:Ot.thinningCenterPos,u_thinningShape:Ot.thinningShape,u_thinningAffectedRatio:Ot.thinningAffectedRatio,u_thinningParticleOffset:Ot.thinningParticleOffset,u_shapeDirectionalPower:Ot.shapeDirectionalPower,u_shapeNormalPower:Ot.shapeNormalPower,u_mode:Ot.mode});var Ot;const Gt=Math.round(F.intensity*this.particlesCount),Ht=i.bg.simpleSegment(0,0,4*Gt,2*Gt);ve.draw(h,le.TRIANGLES,Fr.disabled,vn.disabled,Hn.alphaBlended,pn.disabled,yt,"rain_particles",this.particlesVx,this.particlesIdx,Ht)};F.distortionStrength>0&&De(F.boxSize,!0),De(F.boxSize,!1),this._vignette.draw(h,G)}}const D6=i.ei([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class O6 extends gv{constructor(h){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new dg("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(h){const y=h.context;if(!this.particlesVx){const A=um(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const G=i.eq(1323123451230);for(let J=0;Jz)return;const G=mh(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=G,y.overrideStyleParameters||(y.intensity=h.style.snow.state.density,y.timeFactor=h.style.snow.state.intensity,y.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),y.screenThinning.intensity=h.style.snow.state.centerThinning,y.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const J=this.updateOnRender(h,y.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ae=h.context,le=ae.gl,je=h.transform,ve=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ae,ve),((Ne,De,Pe)=>{const We=PC(this._movement.getPosition(),Ne),Ve=je.width/2,nt=je.height/2,ut=mh(0,Pe.screenThinning.start,0,1,Pe.screenThinning.intensity),ot=mh(.001,Pe.screenThinning.range,0,1,Pe.screenThinning.intensity),Et=mh(0,Pe.screenThinning.particleOffset,0,1,Pe.screenThinning.intensity),Nt=(Tt={modelview:J.modelviewMatrix,projection:J.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:We,velocityConeAperture:Pe.velocityConeAperture,velocity:Pe.velocity,horizontalOscillationRadius:Pe.horizontalOscillationRadius,horizontalOscillationRate:Pe.horizontalOscillationRate,boxSize:Ne,billboardSize:1*Pe.billboardSize,simpleShapeParameters:[Pe.shapeFadeStart,Pe.shapeFadePower],screenSize:[je.width,je.height],thinningCenterPos:[Ve,nt],thinningShape:[ut,ot,Math.pow(10,Pe.screenThinning.fadePower)],thinningAffectedRatio:Pe.screenThinning.affectedRatio,thinningParticleOffset:Et,color:[Pe.color.r,Pe.color.g,Pe.color.b,Pe.color.a],direction:A},{u_modelview:Float32Array.from(Tt.modelview),u_projection:Float32Array.from(Tt.projection),u_time:Tt.time,u_cam_pos:Tt.camPos,u_velocityConeAperture:Tt.velocityConeAperture,u_velocity:Tt.velocity,u_horizontalOscillationRadius:Tt.horizontalOscillationRadius,u_horizontalOscillationRate:Tt.horizontalOscillationRate,u_boxSize:Tt.boxSize,u_billboardSize:Tt.billboardSize,u_simpleShapeParameters:Tt.simpleShapeParameters,u_screenSize:Tt.screenSize,u_thinningCenterPos:Tt.thinningCenterPos,u_thinningShape:Tt.thinningShape,u_thinningAffectedRatio:Tt.thinningAffectedRatio,u_thinningParticleOffset:Tt.thinningParticleOffset,u_particleColor:Tt.color,u_direction:Tt.direction});var Tt;const jt=Math.round(Pe.intensity*this.particlesCount),yt=i.bg.simpleSegment(0,0,4*jt,2*jt);this.particlesVx&&this.particlesIdx&&ve.draw(h,le.TRIANGLES,Fr.disabled,vn.disabled,Hn.alphaBlended,pn.disabled,Nt,"snow_particles",this.particlesVx,this.particlesIdx,yt)})(y.boxSize,0,y),this._vignette.draw(h,D)}}const Dy={symbol:function(T,h,y,A,D){if(T.renderPass!=="translucent")return;const F=vn.disabled,z=T.colorModeForRenderPass(),G=y.layout.get("text-variable-anchor"),J=y.layout.get("text-size-scale-range"),ae=i.aA(T.scaleFactor,J[0],J[1]);G&&function(ve,Ne,De,Pe,We,Ve,nt,ut){const ot=Ne.transform,Et=We==="map",Nt=Ve==="map";for(const Tt of ve){const jt=Pe.getTile(Tt),yt=jt.getBucket(De);if(!yt||!yt.text||!yt.text.segments.get().length)continue;const Ot=i.bK(yt.textSizeData,ot.zoom,ut),Gt=Qm(Tt,yt.getProjection(),ot),Ht=ot.calculatePixelsToTileUnitsMatrix(jt),es=Xs(Gt,jt.tileID.canonical,Nt,Et,ot,yt.getProjection(),Ht),ts=yt.hasIconTextFit()&&yt.hasIconData();Ot&&tn(yt,Et,Nt,nt,ot,es,Tt,Math.pow(2,ot.zoom-jt.tileID.overscaledZ),Ot,ts)}}(A,T,y,h,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),D,ae);const le=y.paint.get("icon-opacity").constantOr(1)!==0,je=y.paint.get("text-opacity").constantOr(1)!==0;y.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(le||je)?y2(T,h,y,A,F,z):(le&&y2(T,h,y,A,F,z,{onlyIcons:!0}),je&&y2(T,h,y,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(kr(T,h,y,A,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),!0),kr(T,h,y,A,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),!1))},circle:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("circle-opacity"),F=y.paint.get("circle-stroke-width"),z=y.paint.get("circle-stroke-opacity"),G=y.layout.get("circle-sort-key").constantOr(1)!==void 0,J=y.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ae=T.context,le=ae.gl,je=T.transform,ve=!(!T.terrain||!T.terrain.enabled),Ne=y.layout.get("circle-elevation-reference"),De=T.depthModeForSublayer(0,Fr.ReadOnly),Pe=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),We=Ne==="none"||ve?De:Pe,Ve=vn.disabled,nt=T.colorModeForDrapableLayerRenderPass(J),ut=je.projection.name==="globe",ot=[i.aF(je.center.lng),i.aJ(je.center.lat)],Et=[];for(let Tt=0;TtTt.sortKey-jt.sortKey);const Nt={useDepthForOcclusion:je.depthOcclusionForSymbolsAndCircles};for(const Tt of Et){const{programConfiguration:jt,program:yt,layoutVertexBuffer:Ot,dynamicBuffers:Gt,indexBuffer:Ht,uniformValues:es,tile:ts}=Tt.state,gs=Tt.segments;T.terrain&&T.terrain.setupElevationDraw(ts,yt,Nt),T.uploadCommonUniforms(ae,yt,ts.tileID.toUnwrapped()),yt.draw(T,le.TRIANGLES,We,Ve,nt,pn.disabled,es,y.id,Ot,Ht,gs,y.paint,je.zoom,jt,Gt)}},heatmap:function(T,h,y,A){if(y.paint.get("heatmap-opacity")!==0)if(T.renderPass==="offscreen"){const D=T.context,F=D.gl,z=vn.disabled,G=new Hn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(Ne,De,Pe,We){const Ve=Ne.gl,nt=De.width*We,ut=De.height*We;Ne.activeTexture.set(Ve.TEXTURE1),Ne.viewport.set([0,0,nt,ut]);let ot=Pe.heatmapFbo;if(!ot||ot&&(ot.width!==nt||ot.height!==ut)){ot&&ot.destroy();const Et=Ve.createTexture();Ve.bindTexture(Ve.TEXTURE_2D,Et),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_WRAP_S,Ve.CLAMP_TO_EDGE),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_WRAP_T,Ve.CLAMP_TO_EDGE),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_MIN_FILTER,Ve.LINEAR),Ve.texParameteri(Ve.TEXTURE_2D,Ve.TEXTURE_MAG_FILTER,Ve.LINEAR),ot=Pe.heatmapFbo=Ne.createFramebuffer(nt,ut,1,null),function(Nt,Tt,jt,yt,Ot,Gt){const Ht=Nt.gl;Ht.texImage2D(Ht.TEXTURE_2D,0,Nt.extRenderToTextureHalfFloat?Ht.RGBA16F:Ht.RGBA,Ot,Gt,0,Ht.RGBA,Nt.extRenderToTextureHalfFloat?Ht.HALF_FLOAT:Ht.UNSIGNED_BYTE,null),yt.colorAttachment0.set(jt)}(Ne,0,Et,ot,nt,ut)}else Ve.bindTexture(Ve.TEXTURE_2D,ot.colorAttachment0.get()),Ne.bindFramebuffer.set(ot.framebuffer)})(D,T,y,T.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const J=T.transform,ae=J.projection.name==="globe",le=ae?["PROJECTION_GLOBE_VIEW"]:[],je=ae?pn.frontCCW:pn.disabled,ve=[i.aF(J.center.lng),i.aJ(J.center.lat)];for(let Ne=0;Ne({u_image:0,u_color_ramp:1,u_opacity:je.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(T,y))},line:function(T,h,y,A){if(T.renderPass!=="translucent")return;const D=y.paint.get("line-opacity"),F=y.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=y.paint.get("line-emissive-strength").isConstant(),G=y.paint.get("line-emissive-strength").constantOr(0),J=y.paint.get("line-occlusion-opacity"),ae=y.layout.get("line-elevation-reference"),le=y.layout.get("line-width-unit")==="meters",je=ae==="sea",ve=!(!T.terrain||!T.terrain.enabled),Ne=T.context,De=Ne.gl;if(y.hasElevatedBuckets&&T.transform.projection.name==="globe")return;const Pe=y.layout.get("line-cross-slope"),We=Pe!==void 0,Ve=Pe<1,nt=T.colorModeForDrapableLayerRenderPass(z?G:null),ut=T.terrain&&T.terrain.renderingToTexture,ot=ut?1:i.o.devicePixelRatio,Et=y.paint.get("line-dasharray"),Nt=Et.constantOr(1),Tt=y.layout.get("line-cap"),jt=Et.constantOr(null),yt=Tt.constantOr(null),Ot=y.paint.get("line-pattern"),Gt=Ot.constantOr(1),Ht=y.paint.get("line-pattern-cross-fade"),es=Ot.constantOr(null),ts=y.paint.get("line-opacity").constantOr(1);let gs=!Gt&&ts!==1||T.depthOcclusion&&J>0&&J<1;const Us=y.paint.get("line-gradient"),Yt=Gt?"linePattern":"line",Bt=i.e2(y);let as;if(ut&&T.terrain&&T.terrain.clipOrMaskOverlapStencilType()&&(gs=!1),J!==0&&T.depthOcclusion){const yr=y.paint._values["line-opacity"];yr&&yr.value&&yr.value.kind==="constant"?as=yr.value:i.w(`Occlusion opacity for layer ${y.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&Bt.push("VARIABLE_LINE_WIDTH"),ut&&(T.emissiveMode!=="dual-source-blending"||z?T.emissiveMode==="mrt-fallback"&&Bt.push("USE_MRT1"):Bt.push("DUAL_SOURCE_BLENDING"));const Jt=(yr,Js,Vs,Ir,Cr,pr)=>{for(const br of yr){const Kr=h.getTile(br);if(Gt&&!Kr.patternsLoaded())continue;const In=Kr.getBucket(y);if(!In||In.elevationType!=="none"&&!Cr||In.elevationType==="none"&&Cr)continue;T.prepareDrawTile();const ja=[...Js],ai=T.shadowRenderer,Rr=In.elevationType==="road"&&!!ai&&ai.enabled;let Xa=[0,0,0];if(Rr){const Wn=T.style.directionalLight,Xi=T.style.ambientLight;Wn&&Xi&&(Xa=ng(T.style,Wn,Xi)),ja.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const Tn=In.programConfigurations.get(y.id);let ui=!1;if(es&&Kr.imageAtlas){const Wn=i.e3.from(es),Xi=Wn.getPrimary().scaleSelf(ot).toString(),Ho=Kr.imageAtlas.patternPositions.get(Xi),jo=Wn.getSecondary(),Di=jo?Kr.imageAtlas.patternPositions.get(jo.scaleSelf(ot).toString()):null;ui=!!Ho&&!!Di,Ho&&Tn.setConstantPatternPositions(Ho,Di)}Ht>0&&(ui||Tn.getPatternTransitionVertexBuffer("line-pattern"))&&ja.push("LINE_PATTERN_TRANSITION");const Mi=T.isTileAffectedByFog(br),_i=T.getOrCreateProgram(Yt,{config:Tn,defines:ja,overrideFog:Mi});if(!Gt&&jt&&yt&&Kr.lineAtlas){const Wn=Kr.lineAtlas.getDash(jt,yt);Wn&&Tn.setConstantPatternPositions(Wn)}Rr&&ai.setupShadows(Kr.tileID.toUnwrapped(),_i,"vector-tile");let[Za,Gn]=y.paint.get("line-trim-offset");(yt==="round"||yt==="square")&&Za!==Gn&&(Za===0&&(Za-=1),Gn===1&&(Gn+=1));const li=ut?br.projMatrix:null,Co=le?1/In.tileToMeter/i.ay(Kr,1,T.transform.zoom):1,no=le?1/In.tileToMeter/i.ay(Kr,1,Math.floor(T.transform.zoom)):1,hi=Gt?i.e4(T,Kr,y,li,ot,Co,no,[Za,Gn],Xa,Ht):i.e5(T,Kr,y,li,In.lineClipsArray.length,ot,Co,no,[Za,Gn],Xa);if(Us){const Wn=In.gradients[y.id];let Xi=Wn.texture;if(y.gradientVersion!==Wn.version){let Ho=256;if(y.stepInterpolant){const jo=h.getSource().maxzoom,Di=br.canonical.z===jo?Math.ceil(1<{as!=null&&(as.value=ts*J),_i.draw(T,De.TRIANGLES,Vs,Wn,nt,pn.disabled,hi,y.id,In.layoutVertexBuffer,In.indexBuffer,In.segments,y.paint,T.transform.zoom,Tn,[In.layoutVertexBuffer2,In.patternVertexBuffer,In.zOffsetVertexBuffer]),as!=null&&(as.value=ts)};if(gs&&!Cr){const Wn=T.stencilModeForClipping(br).ref;Wn===0&&ut&&Ne.clear({stencil:0});const Xi={func:De.EQUAL,mask:255};hi.u_alpha_discard_threshold=.8,$a(new vn(Xi,Wn,255,De.KEEP,De.KEEP,De.INVERT)),hi.u_alpha_discard_threshold=0,$a(new vn(Xi,Wn,255,De.KEEP,De.KEEP,De.KEEP))}else hi.u_alpha_discard_threshold=gs&&Cr&&pr?.8:0,$a(Cr?Ir:T.stencilModeForClipping(br))}};let Ls=T.depthModeForSublayer(0,Fr.ReadOnly);const rr=new Fr(T.depthOcclusion?De.GREATER:De.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);if(y.hasNonElevatedBuckets){const yr=!ut&&T.terrain;J!==0&&yr?i.w(`Occlusion opacity for layer ${y.id} is supported on terrain only if the layer has line-z-offset enabled.`):yr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${y.id}.`):Jt(A,Bt,Ls,vn.disabled,!1,!0)}if(y.hasElevatedBuckets){ae==="hd-road-markup"?ve||(Ls=rr,Bt.push("ELEVATED_ROADS")):(Bt.push("ELEVATED"),Ls=rr,We&&Bt.push(Ve?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),je&&Bt.push("ELEVATION_REFERENCE_SEA"));const yr=gs?T.stencilModeFor3D():vn.disabled;T.forceTerrainMode=!0,Jt(A,Bt,Ls,yr,!0,!0),gs&&Jt(A,Bt,Ls,yr,!0,!1),T.forceTerrainMode=!1}gs&&(T.resetStencilClippingMasks(),ut&&Ne.clear({stencil:0})),J===0||T.depthOcclusion||ut||T.layersWithOcclusionOpacity.push(T.currentLayer)},fill:function(T,h,y,A){const D=y.paint.get("fill-color"),F=y.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=y.paint.get("fill-emissive-strength"),G=T.colorModeForDrapableLayerRenderPass(z),J=y.paint.get("fill-pattern"),ae=T.opaquePassEnabledForLayer()&&!J.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let le="none";y.layout.get("fill-elevation-reference")!=="none"?le="road":y.paint.get("fill-z-offset").constantOr(1)!==0&&(le="offset");const je=!(!T.terrain||!T.terrain.enabled),ve={painter:T,sourceCache:h,layer:y,coords:A,colorMode:G,elevationType:le,terrainEnabled:je,pass:ae};if(T.renderPass==="shadow")return void(T.shadowRenderer&&le==="road"&&!je&&function(De){const{painter:Pe,sourceCache:We,layer:Ve,coords:nt}=De,ut=Pe.context.gl,ot=De.painter.shadowRenderer;for(const Et of nt){const Nt=We.getTile(Et),Tt=Nt.getBucket(Ve);if(!Tt)continue;const jt=Tt.elevatedStructures;if(!jt||!jt.shadowCasterSegments||jt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Pe.prepareDrawTile();const yt=Tt.bufferData.programConfigurations.get(Ve.id),Ot=Pe.isTileAffectedByFog(Et),Gt=Pe.getOrCreateProgram("elevatedStructuresDepth",{config:yt,overrideFog:Ot}),Ht=ot.calculateShadowPassMatrixFromTile(Nt.tileID.toUnwrapped());Pe.uploadCommonUniforms(Pe.context,Gt,Et.toUnwrapped());const es={u_matrix:Ht,u_depth_bias:0};Gt.draw(Pe,ut.TRIANGLES,ot.getShadowPassDepthMode(),vn.disabled,ot.getShadowPassColorMode(),pn.disabled,es,Ve.id,jt.vertexBuffer,jt.indexBuffer,jt.shadowCasterSegments,Ve.paint,Pe.transform.zoom,yt)}}(ve));const Ne=T.emissiveMode==="mrt-fallback";if(le!=="offset"){if(_C(ve,!1,Ne),le==="road"){const De=!je&&T.renderPass==="translucent";De&&bC(T,h,y,A,"geometry"),_C(ve,!0,Ne,vn.disabled),De&&function(Pe){const{painter:We,sourceCache:Ve,layer:nt,coords:ut,colorMode:ot}=Pe,Et=We.context.gl,Nt=Pe.painter.shadowRenderer,Tt=!!Nt&&Nt.enabled,jt=new Fr(We.context.gl.LEQUAL,Fr.ReadOnly,We.depthRangeFor3D);let yt=[0,0,0];if(Tt){const Gt=We.style.directionalLight,Ht=We.style.ambientLight;Gt&&Ht&&(yt=ng(We.style,Gt,Ht))}const Ot=Gt=>{for(const Ht of ut){const es=Ve.getTile(Ht),ts=es.getBucket(nt);if(!ts)continue;const gs=ts.elevatedStructures;if(!gs)continue;let Us,Yt;if(Gt?(Us=gs.renderableBridgeSegments,Yt=gs.bridgeProgramConfigurations.get(nt.id)):(Us=gs.renderableTunnelSegments,Yt=gs.tunnelProgramConfigurations.get(nt.id)),!Us||Us.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),We.prepareDrawTile();const Bt=We.isTileAffectedByFog(Ht),as=[];Tt&&as.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=We.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Bt,defines:as}),Ls=We.translatePosMatrix(Ht.projMatrix,es,nt.paint.get("fill-translate"),nt.paint.get("fill-translate-anchor"));Tt&&Nt.setupShadows(es.tileID.toUnwrapped(),Jt,"vector-tile");const rr=Ay(Ls,yt);We.uploadCommonUniforms(We.context,Jt,Ht.toUnwrapped()),Jt.draw(We,Et.TRIANGLES,jt,vn.disabled,ot,pn.backCCW,rr,nt.id,gs.vertexBuffer,gs.indexBuffer,Us,nt.paint,We.transform.zoom,Yt,[gs.vertexBufferNormal])}};Ot(!0),Ot(!1)}(ve)}}else _C(ve,!1,Ne,T.stencilModeFor3D())},"fill-extrusion":function(T,h,y,A){const D=y.paint.get("fill-extrusion-opacity"),F=T.context,z=F.gl,G=T.terrain,J=G&&G.renderingToTexture;if(D===0)return;const ae=T.emissiveMode==="mrt-fallback",le=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),je=T.style.order.indexOf(y.fqid);if(le&&function(ve,Ne,De,Pe,We){for(const Ve of Pe){const nt=Ne.getTile(Ve).getBucket(De);nt&&(nt.updateReplacement(Ve,ve.replacementSource,We),nt.uploadCentroid(ve.context))}}(T,h,y,A,je),G||le)for(const ve of A){const Ne=h.getTile(ve).getBucket(y);Ne&&epe(T.context,h,ve,Ne,y,G,le)}if(T.renderPass==="shadow"&&T.shadowRenderer){const ve=T.shadowRenderer;if(G&&D<.65&&y._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const Ne=ve.getShadowPassDepthMode(),De=ve.getShadowPassColorMode();wC(T,h,y,A,Ne,vn.disabled,De,le)}else if(T.renderPass==="translucent"){const ve=!y.paint.get("fill-extrusion-pattern").constantOr(1),Ne=y.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!J&&Ne.a!==0){const De=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);D===1&&ve?wC(T,h,y,A,De,vn.disabled,Hn.unblended,le):(wC(T,h,y,A,De,vn.disabled,Hn.disabled,le),wC(T,h,y,A,De,T.stencilModeFor3D(),T.colorModeForRenderPass(),le),T.resetStencilClippingMasks())}if(T.style.enable3dLights()&&ve&&(!G&&T.transform.projection.name!=="globe"||J)){const De=y.paint.get("fill-extrusion-opacity"),Pe=y.paint.get("fill-extrusion-ambient-occlusion-intensity"),We=y.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Ve=y.paint.get("fill-extrusion-flood-light-intensity"),nt=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(nt?null:y.lut).toArray01().slice(0,3),ot=Pe>0&&We>0,Et=Ve>0,Nt=(yt,Ot,Gt)=>(1-Gt)*yt+Gt*Ot,Tt=new T6;Tt.translate=y.paint.get("fill-extrusion-translate"),Tt.translateAnchor=y.paint.get("fill-extrusion-translate-anchor"),Tt.edgeRadius=y.layout.get("fill-extrusion-edge-radius"),Tt.cutoffFadeRange=y.paint.get("fill-extrusion-cutoff-fade-range");const jt=yt=>{const Ot=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!0),Gt=y.paint.get(yt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ht=Nt(.1,3,Gt),es=T._showOverdrawInspector;if(!es){const ts=new vn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),gs=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);og(Tt,T,h,y,A,Ot,ts,gs,pn.disabled,yt,"sdf",De,Pe,We,Ve,ut,Ht,le,!1)}{const ts=es?vn.disabled:new vn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),gs=es?T.colorModeForRenderPass():new Hn([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);og(Tt,T,h,y,A,Ot,ts,gs,pn.disabled,yt,"color",De,Pe,We,Ve,ut,Ht,le,!1)}};if(J){const yt=()=>{const Gt=G.drapeBufferSize[0],Ht=G.drapeBufferSize[1];let es=G.framebufferCopyTexture;return es&&(!es||es.size[0]===Gt&&es.size[1]===Ht)||(es&&es.destroy(),es=G.framebufferCopyTexture=new i.T(F,new i.q({width:Gt,height:Ht}),z.RGBA8)),es.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Gt,Ht),es},Ot=(Gt,Ht,es)=>{const ts=T.depthModeForSublayer(1,Fr.ReadOnly,z.LEQUAL,!1),gs=y.paint.get(Gt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Us=Nt(.1,3,gs);{const Yt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);og(Tt,T,h,y,A,ts,vn.disabled,Yt,pn.disabled,Gt,"clear",De,Pe,We,Ve,ut,Us,le,Ht)}{const Yt=new vn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);og(Tt,T,h,y,A,ts,Yt,Bt,pn.disabled,Gt,"sdf",De,Pe,We,Ve,ut,Us,le,Ht)}ae&&!Gt&&(es=yt());{const Yt=Gt?z.ZERO:z.ONE_MINUS_DST_ALPHA,Bt=new vn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),as=new Hn([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);og(Tt,T,h,y,A,ts,Bt,as,pn.disabled,Gt,"color",De,Pe,We,Ve,ut,Us,le,Ht)}if(!ae||Gt){const Yt=new Hn([z.ONE,z.ONE,z.ONE,Gt?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Gt?z.FUNC_ADD:z.MAX);og(Tt,T,h,y,A,ts,vn.disabled,Yt,pn.disabled,Gt,"clear",De,Pe,We,Ve,ut,Us,le,Ht,es)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new vn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Bt=new Hn([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);og(Tt,T,h,y,A,ts,Yt,Bt,pn.disabled,Gt,"emissive",De,Pe,We,Ve,ut,Us,le,Ht,es),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(ot||Et){let Gt;T.prepareDrawTile(),ae&&!ot||(Gt=yt()),ot&&Ot(!0,!1,Gt),Et&&Ot(!1,!0,Gt)}}else ot&&jt(!0),Et&&jt(!1),(ot||Et)&&T.resetStencilClippingMasks()}}},building:function(T,h,y,A){T.currentLayer0&&F>0,ae=!0;const le=y.paint.get("building-vertical-scale");if(le<=0)return;T.shadowRenderer||(ae=!1);const je=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),ve=T.style.order.indexOf(y.fqid);if(function(Ne,De,Pe,We,Ve,nt){for(const ut of nt){const ot=De.getTile(ut).getBucket(Pe);ot&&(Ve&&ot.updateReplacement(ut,Ne.replacementSource,We),ot.uploadUpdatedIndexBuffer(Ne.context))}}(T,h,y,ve,je,A),function(Ne,De,Pe,We){for(const Ve of We){const nt=De.getTile(Ve).getBucket(Pe);nt&&nt.needsEvaluation()&&nt.uploadUpdatedColorBuffer(Ne.context)}}(T,h,y,A),y.resetLayerRenderingStats(T),T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0),T.renderPass==="shadow"&&T.shadowRenderer){const Ne=T.shadowRenderer,De=[],Pe=Ne.getShadowPassDepthMode();v2({painter:T,source:h,layer:y,coords:A,defines:De,blendMode:Ne.getShadowPassColorMode(),depthMode:Pe,opacity:G,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(T.renderPass==="translucent"){let Ne=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ae&&(Ne=Ne.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),T.shadowRenderer&&T.shadowRenderer.useNormalOffset&&(Ne=Ne.concat("NORMAL_OFFSET"));const De=y.paint.get("building-facade-emissive-chance"),Pe=y.paint.get("building-ambient-occlusion-intensity"),We=y.paint.get("building-flood-light-intensity"),Ve=y.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",nt=y.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Ve?null:y.lut).toArray01().slice(0,3),ut=y.paint.get("building-flood-light-ground-attenuation"),ot=We>0,Et=new Fr(T.context.gl.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D);G<1&&v2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Hn.disabled,depthMode:Et,opacity:G,verticalScale:le,facadeEmissiveChance:De,facadeAOIntensity:Pe,floodLightIntensity:We,floodLightColor:nt,depthOnly:!0});const Nt=T.colorModeForRenderPass();v2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Nt,depthMode:Et,opacity:G,verticalScale:le,facadeEmissiveChance:De,facadeAOIntensity:Pe,floodLightIntensity:We,floodLightColor:nt}),J&&jC(T,h,y,A,!0,G,D,F,We,nt,z,je),ot&&jC(T,h,y,A,!1,G,D,F,We,nt,ut,je)}else if(T.renderPass==="light-beam"){const Ne=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],De=new Fr(T.context.gl.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);v2({painter:T,source:h,layer:y,coords:A,defines:Ne,blendMode:Hn.alphaBlended,depthMode:De,opacity:G,verticalScale:le,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1),T.resetStencilClippingMasks()},hillshade:function(T,h,y,A){if(T.renderPass!=="offscreen"&&T.renderPass!=="translucent"||T.style.disableElevatedTerrain)return;const D=T.context,F=T.terrain&&T.terrain.renderingToTexture,[z,G]=T.renderPass!=="translucent"||F?[{},A]:T.stencilConfigForOverlap(A);for(const J of G){const ae=h.getTile(J);if(ae.needsHillshadePrepare&&T.renderPass==="offscreen")Vme(T,ae,y);else if(T.renderPass==="translucent"){const le=T.depthModeForSublayer(0,Fr.ReadOnly),je=y.paint.get("hillshade-emissive-strength"),ve=T.colorModeForDrapableLayerRenderPass(je),Ne=F&&T.terrain?T.terrain.stencilModeForRTTOverlap(J):z[J.overscaledZ];Ume(T,J,ae,y,le,Ne,ve)}}D.viewport.set([0,0,T.width,T.height]),T.resetStencilClippingMasks()},raster:function(T,h,y,A,D,F){if(T.renderPass!=="translucent"||y.paint.get("raster-opacity")===0)return;const z=T.transform.projection.name==="globe",G=y.paint.get("raster-elevation")!==0,J=G&&z;if(T.renderElevatedRasterBackface&&!J)return;const ae=T.context,le=ae.gl,je=h.getSource(),ve=function(Nt,Tt,jt,yt,Ot){const Gt=Tt.paint.get("raster-color"),Ht=Nt.type==="raster-array",es=[],ts=Tt.paint.get("raster-resampling"),gs=Tt.paint.get("raster-color-mix");let Us=Tt.paint.get("raster-color-range");const Yt=[gs[0],gs[1],gs[2],0],Bt=gs[3];let as=ts==="nearest"?yt.NEAREST:yt.LINEAR;if(Ht&&(es.push("RASTER_ARRAY"),Gt||es.push("RASTER_COLOR"),ts==="linear"&&es.push("RASTER_ARRAY_LINEAR"),as=yt.NEAREST,!Us&&Nt.rasterLayers)){const Jt=Nt.rasterLayers.find(({id:Ls})=>Ls===Tt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(Us=Jt.fields.range)}if(Us=Us||[0,1],Gt){es.push("RASTER_COLOR"),jt.activeTexture.set(yt.TEXTURE2),Tt.updateColorRamp(Us);let Jt=Tt.colorRampTexture;Jt||(Jt=Tt.colorRampTexture=new i.T(jt,Tt.colorRamp,yt.RGBA8)),Jt.bind(yt.LINEAR,yt.CLAMP_TO_EDGE)}return Ot&&es.push("USE_MRT1"),{mix:Yt,range:Us,offset:Bt,defines:es,resampling:as}}(je,y,ae,le,T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback");if(je instanceof i.aU&&!A.length&&!z)return;const Ne=y.paint.get("raster-emissive-strength"),De=T.colorModeForDrapableLayerRenderPass(Ne),Pe=T.terrain&&T.terrain.renderingToTexture,We=!T.options.moving,Ve=y.paint.get("raster-resampling")==="nearest"?le.NEAREST:le.LINEAR;if(je instanceof i.aU&&!A.length&&(je.onNorthPole||je.onSouthPole)){const Nt=G?T.stencilModeFor3D():vn.disabled;return void b2(!!je.onNorthPole,null,T,h,y,Ne,ve,pn.disabled,Nt)}if(!A.length)return;const[nt,ut]=je instanceof i.aU||Pe?[{},A]:T.stencilConfigForOverlap(A),ot=ut[ut.length-1].overscaledZ;J&&ve.defines.push("PROJECTION_GLOBE_VIEW"),G&&ve.defines.push("RENDER_CUTOFF");const Et=(Nt,Tt,jt)=>{for(const yt of Nt){const Ot=yt.toUnwrapped(),Gt=h.getTile(yt);if(Pe&&(!Gt||!Gt.hasData()))continue;ae.activeTexture.set(le.TEXTURE0);const Ht=cg(Gt,je,y,ve);if(!Ht||!Ht.texture)continue;const{texture:es,mix:ts,offset:gs,tileSize:Us,buffer:Yt}=Ht;let Bt,as;Pe?(Bt=Fr.disabled,as=yt.projMatrix):G?(Bt=new Fr(le.LEQUAL,Fr.ReadWrite,T.depthRangeFor3D),as=z?Float32Array.from(T.transform.expandedFarZProjMatrix):T.transform.calculateProjMatrix(Ot,We)):(Bt=T.depthModeForSublayer(yt.overscaledZ-ot,y.paint.get("raster-opacity")===1?Fr.ReadWrite:Fr.ReadOnly,le.LESS),as=T.transform.calculateProjMatrix(Ot,We));const Jt=T.terrain&&Pe?T.terrain.stencilModeForRTTOverlap(yt):nt[yt.overscaledZ],Ls=F?0:y.paint.get("raster-fade-duration");Gt.registerFadeDuration(Ls);const rr=h.findLoadedParent(yt,0),yr=p2(Gt,rr,h,T.transform,Ls);let Js,Vs;!yr.isFading&&Gt.refreshedUponExpiration&&(Gt.refreshedUponExpiration=!1),T.terrain&&T.terrain.prepareDrawTile(),ae.activeTexture.set(le.TEXTURE0),es.bind(Ve,le.CLAMP_TO_EDGE),ae.activeTexture.set(le.TEXTURE1),rr?(rr.texture&&rr.texture.bind(Ve,le.CLAMP_TO_EDGE),Js=Math.pow(2,rr.tileID.overscaledZ-Gt.tileID.overscaledZ),Vs=[Gt.tileID.canonical.x*Js%1,Gt.tileID.canonical.y*Js%1]):es.bind(Ve,le.CLAMP_TO_EDGE),"useMipmap"in es&&ae.extTextureFilterAnisotropic&&T.transform.pitch>20&&le.texParameterf(le.TEXTURE_2D,ae.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ae.extTextureFilterAnisotropicMax);const Ir=T.transform;let Cr;const pr=G?xF(Ir):[0,0,0,0];let br,Kr,In,ja,ai,Rr=0;if(J&&je instanceof i.aU&&je.coordinates.length>3)br=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Kr=Float32Array.from(Ir.globeMatrix),In=Float32Array.from(i.dF(Ir)),ja=[i.aF(Ir.center.lng),i.aJ(Ir.center.lat)],Cr=je.elevatedGlobePerspectiveTransform,ai=je.elevatedGlobeGridMatrix||new Float32Array(9);else if(J){const Mi=i.dG(yt.canonical);Rr=i.dH(Mi.getCenter().lat),br=Float32Array.from(i.bk(i.dJ(yt.canonical))),Kr=Float32Array.from(Ir.globeMatrix),In=Float32Array.from(i.dF(Ir)),ja=[i.aF(Ir.center.lng),i.aJ(Ir.center.lat)],Cr=[0,0],ai=Float32Array.from(i.dI(yt.canonical,Mi,Rr,Ir.worldSize/Ir._pixelsPerMercatorPixel))}else Cr=je instanceof i.aU?je.perspectiveTransform:[0,0],br=new Float32Array(16),Kr=new Float32Array(9),In=new Float32Array(16),ja=[0,0],ai=new Float32Array(9);const Xa=cF(as,br,Kr,In,ai,Vs||[0,0],i.aj(T.transform.zoom),ja,pr,Js||1,yr,y,Cr,G?y.paint.get("raster-elevation"):0,2,ts,gs,ve.range,Us,Yt,Ne),Tn=T.isTileAffectedByFog(yt),ui=T.getOrCreateProgram("raster",{defines:ve.defines,overrideFog:Tn});if(T.uploadCommonUniforms(ae,ui,Ot),je instanceof i.aU){const Mi=je.elevatedGlobeVertexBuffer,_i=je.elevatedGlobeIndexBuffer;if(Pe||!z)je.boundsBuffer&&je.boundsSegments&&ui.draw(T,le.TRIANGLES,Bt,vn.disabled,De,pn.disabled,Xa,y.id,je.boundsBuffer,T.quadTriangleIndexBuffer,je.boundsSegments);else if(Mi&&_i){const Za=Ir.zoom<=i.c_?je.elevatedGlobeSegments:je.getSegmentsForLongitude(Ir.center.lng);Za&&ui.draw(T,le.TRIANGLES,Bt,vn.disabled,De,Tt,Xa,y.id,Mi,_i,Za)}}else if(J){Bt=new Fr(le.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D);const Mi=T.globeSharedBuffers;if(Mi){const[_i,Za,Gn]=Mi.getGridBuffers(Rr,!1);ui.draw(T,le.TRIANGLES,Bt,jt||Jt,T.colorModeForRenderPass(),Tt,Xa,y.id,_i,Za,Gn)}}else{const{tileBoundsBuffer:Mi,tileBoundsIndexBuffer:_i,tileBoundsSegments:Za}=T.getTileBoundsBuffers(Gt);ui.draw(T,le.TRIANGLES,Bt,Jt,De,pn.disabled,Xa,y.id,Mi,_i,Za)}}if(!(je instanceof i.aU)&&J)for(const yt of Nt){const Ot=yt.canonical.y===(1<>>16,2654435769),((yt=Math.imul(yt^yt>>>16,2654435769))>>>0)/4294967296},jt=1/1.1;for(let yt=0;yti.e9[Jt](es));Yt.push(es);const Bt=es.canonical.x,as=es.canonical.y;for(const Jt of Yt){const Ls=ot.getTile(Ot?Jt.wrapped():Jt);if(!Ls)continue;const rr=Ls.rasterParticleState;if(!rr)continue;const yr=Jt.canonical.x+(1<Tt.tileID)),Ne&&(ae.activeTexture.set(le.TEXTURE0),T.imageManager.bind(T.context,y.scope));const Nt=[];if(T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&Nt.push("USE_MRT1"),J){const Tt=T.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:Nt}),jt=new Float32Array(i.bA([])),yt=new i.aQ(0,0,0,0,0),Ot=Ne?Py(jt,G,z,T,0,y.scope,De,J,{tileID:yt,tileSize:ve}):x2(jt,G,z,D.toPremultipliedRenderColor(F?null:y.lut));Tt.draw(T,le.TRIANGLES,Ve,We,nt,pn.disabled,Ot,y.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments)}else for(const Tt of Et){const jt=T.isTileAffectedByFog(Tt),yt=T.getOrCreateProgram(ut,{overrideFog:jt,defines:Nt}),Ot=Tt.toUnwrapped(),Gt=A?Tt.projMatrix:T.transform.calculateProjMatrix(Ot);T.prepareDrawTile();const Ht=h?h.getTile(Tt):ot?ot[Tt.key]:new Ym(Tt,ve,je.zoom,T),es=Ne?Py(Gt,G,z,T,0,y.scope,De,J,{tileID:Tt,tileSize:ve}):x2(Gt,G,z,D.toPremultipliedRenderColor(F?null:y.lut));T.uploadCommonUniforms(ae,yt,Ot);const{tileBoundsBuffer:ts,tileBoundsIndexBuffer:gs,tileBoundsSegments:Us}=T.getTileBoundsBuffers(Ht);yt.draw(T,le.TRIANGLES,Ve,We,nt,pn.disabled,es,y.id,ts,gs,Us)}},sky:function(T,h,y){const A=T._atmosphere?i.aj(T.transform.zoom):1,D=y.paint.get("sky-opacity")*A;if(D===0)return;const F=T.context,z=y.paint.get("sky-type"),G=new Fr(F.gl.LEQUAL,Fr.ReadOnly,[0,1]),J=T.frameCounter/1e3%1;z==="atmosphere"?T.renderPass==="offscreen"?y.needsSkyboxCapture(T)&&(function(ae,le,je,ve){const Ne=ae.context,De=Ne.gl;let Pe=le.skyboxFbo;if(!Pe){Pe=le.skyboxFbo=Ne.createFramebuffer(32,32,1,null),le.skyboxGeometry=new CC(Ne),le.skyboxTexture=Ne.gl.createTexture(),De.bindTexture(De.TEXTURE_CUBE_MAP,le.skyboxTexture),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_WRAP_S,De.CLAMP_TO_EDGE),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_WRAP_T,De.CLAMP_TO_EDGE),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_MIN_FILTER,De.LINEAR),De.texParameteri(De.TEXTURE_CUBE_MAP,De.TEXTURE_MAG_FILTER,De.LINEAR);for(let ut=0;ut<6;++ut)De.texImage2D(De.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,De.RGBA,32,32,0,De.RGBA,De.UNSIGNED_BYTE,null)}Ne.bindFramebuffer.set(Pe.framebuffer),Ne.viewport.set([0,0,32,32]);const We=le.getCenter(ae,!0),Ve=ae.getOrCreateProgram("skyboxCapture"),nt=new Float64Array(16);i.bA(nt),i.en(nt,nt,.5*-Math.PI),fv(ae,le,Ve,nt,We,0),i.bA(nt),i.en(nt,nt,.5*Math.PI),fv(ae,le,Ve,nt,We,1),i.bA(nt),i.cU(nt,nt,.5*-Math.PI),fv(ae,le,Ve,nt,We,2),i.bA(nt),i.cU(nt,nt,.5*Math.PI),fv(ae,le,Ve,nt,We,3),i.bA(nt),fv(ae,le,Ve,nt,We,4),i.bA(nt),i.en(nt,nt,Math.PI),fv(ae,le,Ve,nt,We,5),Ne.viewport.set([0,0,ae.width,ae.height])}(T,y),y.markSkyboxValid(T)):T.renderPass==="sky"&&function(ae,le,je,ve,Ne){const De=ae.context,Pe=De.gl,We=ae.transform,Ve=ae.getOrCreateProgram("skybox");De.activeTexture.set(Pe.TEXTURE0),Pe.bindTexture(Pe.TEXTURE_CUBE_MAP,le.skyboxTexture);const nt=((ut,ot,Et,Nt,Tt)=>({u_matrix:ut,u_sun_direction:ot,u_cubemap:0,u_opacity:Nt,u_temporal_offset:Tt}))(We.skyboxMatrix,le.getCenter(ae,!1),0,ve,Ne);ae.uploadCommonUniforms(De,Ve),Ve.draw(ae,Pe.TRIANGLES,je,vn.disabled,ae.colorModeForRenderPass(),pn.backCW,nt,"skybox",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,G,D,J):z==="gradient"&&T.renderPass==="sky"&&function(ae,le,je,ve,Ne){const De=ae.context,Pe=De.gl,We=ae.transform,Ve=ae.getOrCreateProgram("skyboxGradient");le.skyboxGeometry||(le.skyboxGeometry=new CC(De)),De.activeTexture.set(Pe.TEXTURE0);let nt=le.colorRampTexture;nt||(nt=le.colorRampTexture=new i.T(De,le.colorRamp,Pe.RGBA8)),nt.bind(Pe.LINEAR,Pe.CLAMP_TO_EDGE);const ut=((ot,Et,Nt,Tt,jt)=>({u_matrix:ot,u_color_ramp:0,u_center_direction:Et,u_radius:i.an(Nt),u_opacity:Tt,u_temporal_offset:jt}))(We.skyboxMatrix,le.getCenter(ae,!1),le.paint.get("sky-gradient-radius"),ve,Ne);ae.uploadCommonUniforms(De,Ve),Ve.draw(ae,Pe.TRIANGLES,je,vn.disabled,ae.colorModeForRenderPass(),pn.backCW,ut,"skyboxGradient",le.skyboxGeometry.vertexBuffer,le.skyboxGeometry.indexBuffer,le.skyboxGeometry.segment)}(T,y,G,D,J)},custom:function(T,h,y,A){const D=T.context,F=y.implementation;if(!T.transform.projection.unsupportedLayers||!T.transform.projection.unsupportedLayers.includes("custom")||T.terrain&&(T.terrain.renderingToTexture||T.renderPass==="offscreen")&&y.isDraped(h)){if(T.renderPass==="offscreen"){const z=F.prerender;if(z){if(T.setCustomLayerDefaults(),D.setColorMode(T.colorModeForRenderPass()),T.transform.projection.name==="globe"){const G=T.transform.pointMerc;z.call(F,D.gl,T.transform.customLayerMatrix(),T.transform.getProjection(),T.transform.globeToMercatorMatrix(),i.aj(T.transform.zoom),[G.x,G.y],T.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,T.transform.customLayerMatrix());D.setDirty(),T.setBaseState()}}else if(T.renderPass==="translucent"){if(T.terrain&&T.terrain.renderingToTexture){const G=F.renderToTile;if(G){const J=A[0].canonical,ae={x:J.x+A[0].wrap*(F.wrapTileId?0:1<{ae&&(ae.useNormalOffset=!0,le||(ae.enabled=!0))},ve=h.getSource();if(T.renderPass==="light-beam"&&ve.type!=="batched-model")return;if(ve.type==="vector"||ve.type==="geojson")return function(ot,Et,Nt,Tt,jt){const yt=ot.transform,Ot=yt.projection.name==="globe",Gt=yt.getFreeCameraOptions().position;if(!ot.modelManager)return;const Ht=ot.modelManager;Nt.modelManager=Ht;const es=ot.shadowRenderer;if(!Nt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ts=Nt._unevaluatedLayout._values["model-id"],gs=Object.assign({},Nt.layout.get("model-id").parameters),Us=ot.style.order.indexOf(Nt.fqid),Yt=Nt.paint.get("model-opacity").constantOr(1);for(const Bt of Tt){const as=Et.getTile(Bt).getBucket(Nt);if(!as||as.projection.name!==yt.projection.name)continue;const Jt=as.getModelUris();if(Jt&&!as.modelsRequested&&(Ht.addModelsFromBucket(Jt,jt),as.modelsRequested=!0),Ot)gs.zoom=Bt.overscaledZ;else{const pr=$u(Bt,yt);gs.zoom=pr}const Ls=ts.possiblyEvaluate(gs);if(CF(ot,as,Bt),Gf.shadowUniformsInitialized=!1,Gf.useSingleShadowCascade=!!es&&es.getMaxCascadeForTile(Bt.toUnwrapped())===0,ot.renderPass==="shadow"&&es){if(ot.currentShadowCascade===1&&as.isInsideFirstShadowMapFrustum)continue;const pr=yt.calculatePosMatrix(Bt.toUnwrapped(),yt.worldSize);if(Gf.tileMatrix.set(pr),Gf.shadowTileMatrix=Float32Array.from(es.calculateShadowPassMatrixFromMatrix(pr)),Gf.aabb.min=[0,0,0],Gf.aabb.max[0]=Gf.aabb.max[1]=i.al,Gf.aabb.max[2]=0,rpe(as,Gf,ot,Nt.scope))continue}const rr=1<0&&ot.style.isLayerClipped(Nt,Et.getSource())&&as.updateReplacement(Bt,ot.replacementSource,Us,Nt.scope)&&(as.uploaded=!1,as.upload(ot.context));let Js=0;const Vs=new Array,Ir=new Array,Cr=new Array;for(let pr in as.instancesPerModel){const br=as.instancesPerModel[pr];br.features.length>0&&!Ot&&(pr=Ls.evaluate(br.features[0].feature,{}));const Kr=Ht.getModel(pr,jt);if(Kr||Ht.hasURLBeenRequested(pr)||as.modelUris.includes(pr)||(as.modelUris.push(pr),as.modelsRequested=!1),Kr&&Kr.uploaded)if(Ot){const In=i.c5([],[Gt.x,Gt.y,Gt.z],ot.transform.worldSize);i.ew(In,In);for(let ja=0;ja0&&Xa.elevationUpdate(pr.terrain,ja,Rr,Kr.source),Xa.needsReEvaluation(pr,ai,Kr)&&Xa.evaluate(Kr))}})(ot,Et,Nt,Tt),function(){let pr,br,Kr;Vs?(pr=Tt.length-1,br=-1,Kr=-1):(pr=0,br=Tt.length,Kr=1);const In=new Float64Array(16),ja=i.cA(),ai=new i.P(0,0);for(let Rr=pr;Rr!==br;Rr+=Kr){const Xa=Tt[Rr],Tn=Et.getTile(Xa).getBucket(Nt);if(!Tn||!Tn.uploaded)continue;let ui=!1;Gt&&(ui=Gt.getMaxCascadeForTile(Xa.toUnwrapped())===0);const Mi=yt.calculatePosMatrix(Xa.toUnwrapped(),yt.worldSize),_i=Tn.modelTraits;!rr&&Vs&&(i.bl(In,Mi),i.af(ja,es,In),ai.x=ja[0],ai.y=ja[1]);const Za=[];Tn.setFilter(Nt.filter);for(const Gn of Tn.getNodesInfo()){if(Gn.hiddenByReplacement||!Gn.node.meshes)continue;const li=Gn.node;let Co=0;ot.terrain&&li.elevation&&(Co=li.elevation*ot.terrain.exaggeration());const no=(()=>{const Vd=Gn.aabb;return Ls.min=[...Vd.min],Ls.max=[...Vd.max],Ls.min[2]+=Co,Ls.max[2]+=Co,i.af(Ls.min,Ls.min,Mi),i.af(Ls.max,Ls.max,Mi),Ls})(),hi=Gn.evaluatedScale;if(hi[0]<=1&&hi[1]<=1&&hi[2]<=1&&no.intersects(yr)===0)continue;if(!rr&&Vs){const Vd=.16666666666666666;Gn.cameraCollisionOpacity=es[0]>no.min[0]&&es[0]no.min[1]&&es[1]!Vs||Gn.opacity===1&&li.opacity===1?Gn.depthli.depth?-1:1);for(const Gn of Za){const li=Gn.nodeInfo,Co=li.node;let no=i.aB([],Yt,Gn.tileModelMatrix);i.aB(no,gs,no);const hi=i.bl([],no);i.eg(hi,hi),i.cS(hi,hi,w2),no=i.aB(no,no,Co.globalMatrix);const $a=ot.renderPass==="light-beam",Wn=Nt.paint.get("model-color-use-theme").constantOr("default")==="none",Xi=_i&i.eI.HasMapboxMeshFeatures,Ho=Xi?0:li.evaluatedRMEA[0][2];for(let jo=0;jo=ys||No>=ys}}const ld=Di.material;let mm;ld.occlusionTexture&&ld.occlusionTexture.offsetScale&&(mm=ld.occlusionTexture.offsetScale,Gl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const ap=ot.getOrCreateProgram("model",Gl);!rr&&Gt&&Gt.setupShadowsFromMatrix(Gn.tileModelMatrix,ap,Gt.useNormalOffset),ot.uploadCommonUniforms(jt,ap,null,Hd);const fh=ld.pbrMetallicRoughness;fh.metallicFactor=.9,fh.roughnessFactor=.5;const Lo=dv(new Float32Array(Td),new Float32Array(no),new Float32Array(hi),new Float32Array(Co.globalMatrix),ot,Gn.opacity,fh.baseColorFactor,ld.emissiveFactor,fh.metallicFactor,fh.roughnessFactor,ld,Ho,Nt,[0,0,0],mm);!qu&&(li.hasTranslucentParts||Gn.opacity<1)&&ap.draw(ot,jt.gl.TRIANGLES,as,vn.disabled,Hn.disabled,pn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd),ap.draw(ot,jt.gl.TRIANGLES,qu?Jt:as,vn.disabled,qu||Gn.opacity<1||li.hasTranslucentParts?Hn.alphaBlended:Hn.unblended,pn.backCCW,Lo,Nt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,Nt.paint,ot.transform.zoom,void 0,Vd)}}}}()}(T,h,y,A),void je();if(ve.type!=="model")return;const Ne=ve.getModels(),De=[],Pe=T.transform.getFreeCameraOptions().position,We=i.c5([],[Pe.x,Pe.y,Pe.z],T.transform.worldSize);i.ew(We,We);const Ve=[],nt=[];let ut=0;for(const ot of Ne){const Et=h.getFeatureState("",ot.id),Nt={type:"Unknown",id:ot.id,properties:ot.featureProperties},Tt=y.paint.get("model-rotation").evaluate(Nt,Et),jt=y.paint.get("model-scale").evaluate(Nt,Et),yt=y.paint.get("model-translation").evaluate(Nt,Et),Ot=y.paint.get("model-opacity").evaluate(Nt,Et);NF(y,ot.id,Et,ot.featureProperties,ot.nodeOverrideNames,ot.nodeOverrides),kF(y,ot.id,Et,ot.featureProperties,ot.materialOverrideNames,ot.materialOverrides),ot.nodeOverrides.size>0&&ot.computeBoundsAndApplyParent(),ot.computeModelMatrix(T,Tt,jt,yt,G,z,!1);const Gt=i.bA([]),Ht=i.ef(ot.position.lat,T.transform.zoom),es=i.bq([],[1,1,1/Ht]);i.br(Gt,Gt,We),De.push({zScaleMatrix:es,negCameraPosMatrix:Gt});for(const ts of ot.nodes)xv(T,ts,ot.matrix,T.transform.expandedFarZProjMatrix,ut,Ve,nt,ot.materialOverrides,Ot);ut++}if(Ve.sort((ot,Et)=>Et.depth-ot.depth),T.renderPass!=="shadow")SF(T,y,Ve,nt,De),je();else{for(const ot of nt)$p(ot.mesh,ot.nodeModelMatrix,T,y);for(const ot of Ve)$p(ot.mesh,ot.nodeModelMatrix,T,y);je()}}},LC={line:function(T,h,y){if(T.hasElevatedBuckets=!1,T.hasNonElevatedBuckets=!1,T._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||T._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const A=h.getVisibleCoordinates();for(const D of A){const F=h.getTile(D).getBucket(T);if(F&&(F.elevationType!=="none"?T.hasElevatedBuckets=!0:T.hasNonElevatedBuckets=!0,T.hasElevatedBuckets&&T.hasNonElevatedBuckets))break}}}else T.hasNonElevatedBuckets=!0},model:function(T,h,y){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(y.modelManager&&y.modelManager.upload(y,_2(y,T)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(y.context)},raster:function(T,h,y){const A=h.getSource();if(!(A instanceof Sd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(G=>h.getTileByID(G));for(const G of z)G.updateNeeded(T.id,F)&&A.prepareTile(G,D,T.id,F)},"raster-particle":function(T,h,y){const A=h.getSource();if(!(A instanceof Sd&&A.loaded()))return;const D=T.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=T.paint.get("raster-particle-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(G=>h.getTileByID(G));for(const G of z)G.updateNeeded(T.id,F)&&A.prepareTile(G,D,T.id,F)}},hm={fill:bC},DC={fill:function(T,h,y,A){if(!y.layout||y.layout.get("fill-elevation-reference")==="none"||y.paint.get("fill-opacity").constantOr(1)===0)return;const D=T.context.gl,F=new Fr(D.LEQUAL,Fr.ReadOnly,T.depthRangeFor3D),z=new vn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),G=T.transform.getFreeCameraOptions().position,J=T.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ae of A){const le=h.getTile(ae),je=le.getBucket(y);if(!je)continue;const ve=je.elevatedStructures;if(!ve||ve.depthSegments.segments[0].primitiveLength===0)continue;const Ne=fF(ae.toUnwrapped(),G),De=T.translatePosMatrix(ae.projMatrix,le,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor")),Pe=cv(De,Ne,0,1,0);J.draw(T,D.TRIANGLES,F,z,Hn.disabled,pn.disabled,Pe,y.id,ve.vertexBuffer,ve.indexBuffer,ve.depthSegments,y.paint,T.transform.zoom)}}};class OC{constructor(h,y,A,D,F){this.context=new gb(h,y),this.transform=A,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=i.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const z=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const J of z)this._debugParams.enabledLayers[J]=!0;for(const J of z);this.occlusionParams=new vb,this.setup(),this.numSublayers=Pl.maxUnderzooming+Pl.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new i.eP,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new ab(this),this._wireframeDebugCache=new Ly,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const G=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,G,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,y){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new b6(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,y),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const y=h.fog;if(!y||this.transform.projection.name==="globe"||y.getOpacity(this.transform.pitch)<1||y.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=y.getFovAdjustedRange(this.transform._fov);if(A>D)return void(this.transform.fogCullDistSq=null);const F=A+.78*(D-A);this.transform.fogCullDistSq=F*F}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(h){h&&!this._terrain&&(this._terrain=new b6(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,y){if(this.width=h*i.o.devicePixelRatio,this.height=y*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const A of this.style.order)this.style._mergedLayers[A].resize()}setup(){const h=this.context,y=new i.bd;y.emplaceBack(0,0),y.emplaceBack(i.al,0),y.emplaceBack(0,i.al),y.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(y,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const A=new i.bd;A.emplaceBack(0,0),A.emplaceBack(i.al,0),A.emplaceBack(0,i.al),A.emplaceBack(i.al,i.al),this.debugBuffer=h.createVertexBuffer(A,i.bf.members),this.debugSegments=i.bg.simpleSegment(0,0,4,5);const D=new i.bd;D.emplaceBack(-1,-1),D.emplaceBack(1,-1),D.emplaceBack(-1,1),D.emplaceBack(1,1),this.viewportBuffer=h.createVertexBuffer(D,i.bf.members),this.viewportSegments=i.bg.simpleSegment(0,0,4,2);const F=new i.b1;F.emplaceBack(0,0,0,0),F.emplaceBack(i.al,0,i.al,0),F.emplaceBack(0,i.al,0,i.al),F.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=h.createVertexBuffer(F,i.bi.members),this.mercatorBoundsSegments=i.bg.simpleSegment(0,0,4,2);const z=new i.b0;z.emplaceBack(0,1,2),z.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=h.createIndexBuffer(z);const G=new i.be;for(const ae of[0,1,3,2,0])G.emplaceBack(ae);this.debugIndexBuffer=h.createIndexBuffer(G),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const J=this.context.gl;this.stencilClearMode=new vn({func:J.ALWAYS,mask:0},0,255,J.ZERO,J.ZERO,J.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(h){return h._makeTileBoundsBuffers(this.context,this.transform.projection),h._tileBoundsBuffer?{tileBoundsBuffer:h._tileBoundsBuffer,tileBoundsIndexBuffer:h._tileBoundsIndexBuffer,tileBoundsSegments:h._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const h=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,h.TRIANGLES,Fr.disabled,this.stencilClearMode,Hn.disabled,pn.disabled,m2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,y,A){if(!y||this.currentStencilSource===y.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let G=!1;for(const J of A)if(this._tileClippingMaskIDs[J.key]===void 0){G=!0;break}if(!G)return}this.currentStencilSource=y.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(Hn.disabled),D.setDepthMode(Fr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const G of A){const J=y.getTile(G),ae=this._tileClippingMaskIDs[G.key]=this.nextStencilID++,{tileBoundsBuffer:le,tileBoundsIndexBuffer:je,tileBoundsSegments:ve}=this.getTileBoundsBuffers(J);z.draw(this,F.TRIANGLES,Fr.disabled,new vn({func:F.ALWAYS,mask:0},ae,255,F.KEEP,F.KEEP,F.REPLACE),Hn.disabled,pn.disabled,m2(G.projMatrix),"$clipping",le,je,ve)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,y=this.context.gl;return new vn({func:y.NOTEQUAL,mask:255},h,255,y.KEEP,y.KEEP,y.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const y=this.context.gl;return new vn({func:y.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,y.KEEP,y.KEEP,y.REPLACE)}stencilConfigForOverlap(h){const y=this.context.gl,A=h.sort((z,G)=>G.overscaledZ-z.overscaledZ),D=A[A.length-1].overscaledZ,F=A[0].overscaledZ-D+1;if(F>1){this.currentStencilSource=void 0,this.nextStencilID+F>256&&this.clearStencil();const z={};for(let G=0;Gthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,y)=>h+y/this._fpsHistory.length,0))}render(h,y){const A=i.o.now();this._dt=A-this._timeStamp,this._timeStamp=A,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=h.map.repaint,this.style=h,this.options=y;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const Bt=D[Yt];return!(Bt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Bt.type]});let G=z(),J=!1,ae=!1,le=null,je=0,ve=!1;for(const Yt of G){const Bt=D[Yt];Bt.visibility!=="none"&&(Bt.type==="circle"?J=!0:Bt.type==="building"?(le=Bt,++je):Bt.type==="symbol"&&(Bt.hasOcclusionOpacityProperties?ae=!0:J=!0))}this.updateEmissiveMode();let Ne=G.map(Yt=>D[Yt]);const De=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in De){const Bt=De[Yt];Bt.used&&(Bt.prepare(this.context),Bt.getSource().usedInConflation&&++je)}let Pe=!1;for(const Yt of Ne)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Pe=!0),this.prepareLayer(Yt));const We={},Ve={},nt={},ut={},ot={};for(const Yt in De){const Bt=De[Yt];We[Yt]=Bt.getVisibleCoordinates(),Ve[Yt]=We[Yt].slice().reverse(),nt[Yt]=Bt.getVisibleCoordinates(!0).reverse(),ut[Yt]=Bt.getShadowCasterCoordinates(),ot[Yt]=Bt.sortCoordinatesByDistance(We[Yt])}const Et=Yt=>{const Bt=this.style.getLayerSourceCache(Yt);return Bt&&Bt.used?Bt.getSource():null};if(je||Pe||this._clippingActiveLastFrame){const Yt=[],Bt=[];let as=0;for(const Jt of Ne)this.isSourceForClippingOrConflation(Jt,Et(Jt))&&(Yt.push(Jt),Bt.push(as)),as++;if(Yt&&(Pe||Yt.length>1)||this._clippingActiveLastFrame){Pe=!1;const Jt=[];for(let Ls=0;Ls0){const Jt=Et(Bt);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),Bt.minzoom&&(this.minCutoffZoom=Math.max(Bt.minzoom,this.minCutoffZoom))}Bt.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const Nt=this.style&&this.style.fog;Nt?(this._fogVisible=Nt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=Nt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(nt),this.opaquePassCutoff=0,G=z(),Ne=G.map(Yt=>D[Yt]));const Tt=this._shadowRenderer;if(Tt){Tt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in De)for(const Bt of We[Yt]){let as={min:0,max:0};this.terrain&&(as=this.terrain.getMinMaxForTile(Bt)||as),Tt.addShadowReceiver(Bt.toUnwrapped(),as.min,as.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eR(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new jF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const jt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),yt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(jt&&!this._snow&&(this._snow=new O6(this)),!jt&&this._snow&&(this._snow.destroy(),delete this._snow),yt&&!this._rain&&(this._rain=new IC(this)),!yt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),le){this.buildingTileBorderManager||(this.buildingTileBorderManager=new MC);const Yt=this.style.getLayerSourceCache(le);this.buildingTileBorderManager.updateBorders(Yt,le)}if(!at.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of Ne){const Bt=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const as=Bt?Ve[Bt.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||as&&as.length)&&this.renderLayer(this,Bt,Yt,as)}this.depthRangeFor3D=[0,1-(Ne.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ut)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Ot=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Gt=(()=>{if(y.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Bt=this.style.getLut(Yt.scope);if(!Ot){const as=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}if(Ot){const as=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(as?null:Bt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Gt,depth:1}),this.clearStencil(),this._showOverdrawInspector=y.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=G.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=Ne[this.currentLayer],Bt=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const as=Bt?(Yt.is3D(F)?ot:Ve)[Bt.id]:void 0;this._renderTileClippingMasks(Yt,Bt,as),this.renderLayer(this,Bt,Yt,as)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Ot&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--es==0){{this.clearStencil(),this.resetStencilClippingMasks();const as=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const as=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Ls=Ne[this.currentLayer],rr=h.getLayerSourceCache(Ls),yr=rr?Ve[rr.id]:void 0;this.terrain||this._renderTileClippingMasks(Ls,rr,rr?We[rr.id]:void 0),this.renderLayer(this,rr,Ls,yr)}this.depthOcclusion=!1,this.currentLayer=as,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;Ne.forEach(Bt=>{const as=h.getLayerSourceCache(Bt);as&&!Bt.isHidden(this.transform.zoom)&&as.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?y.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,y,A){const D=A===void 0?this.terrain&&this.terrain.renderingToTexture:A,F=[];return this.style&&this.style.enable3dLights()&&(h==="globeRaster"||h==="terrainRaster"?(F.push("LIGHTING_3D_MODE"),F.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):D||F.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||F.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(F.push("TERRAIN"),this.linearFloatFilteringSupported()&&F.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&F.push("GLOBE"),!this._fogVisible||D||y!==void 0&&!y||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,y){this.cache=this.cache||{};const A=y&&y.defines||[],D=y&&y.config,F=this.currentGlobalDefines(h,y&&y.overrideFog,y&&y.overrideRtt).concat(A),z=sF.cacheKey(o6[h],h,F,D);return this.cache[z]||(this.cache[z]=new sF(this.context,h,o6[h],D,vC[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,y){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((z,G,J)=>{const ae=z.properties.get("direction"),le=z.properties.get("color-use-theme")==="none",je=z.properties.get("color").toNonPremultipliedRenderColor(le?null:J.getLut(z.scope)).toArray01(),ve=z.properties.get("intensity"),Ne=G.properties.get("color-use-theme")==="none",De=G.properties.get("color").toNonPremultipliedRenderColor(Ne?null:J.getLut(G.scope)).toArray01(),Pe=G.properties.get("intensity"),We=[ae.x,ae.y,ae.z],Ve=i.dN(De,Pe),nt=i.dN(je,ve);return{u_lighting_ambient_color:Ve,u_lighting_directional_dir:We,u_lighting_directional_color:nt,u_ground_radiance:pb(We,nt,Ve)}})(A,D,this.style);y.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,y,A,D,F){if(this.uploadCommonLightUniforms(h,y),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const G=z.getOpacity(this.transform.pitch),J=((ae,le,je,ve,Ne,De,Pe,We,Ve,nt,ut,ot)=>{const Et=ae.transform,Nt=le.properties.get("color-use-theme")==="none",Tt=le.properties.get("color").toNonPremultipliedRenderColor(Nt?null:ae.style.getLut(le.scope)).toArray01();Tt[3]=ve;const jt=ae.frameCounter/1e3%1,[yt,Ot]=le.properties.get("vertical-range");return{u_fog_matrix:je?Et.calculateFogTileMatrix(je):ot||ae.identityMat,u_fog_range:le.getFovAdjustedRange(Et._fov),u_fog_color:Tt,u_fog_horizon_blend:le.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(yt,Ot),Ot],u_fog_temporal_offset:jt,u_frustum_tl:Ne,u_frustum_tr:De,u_frustum_br:Pe,u_frustum_bl:We,u_globe_pos:Ve,u_globe_radius:nt,u_viewport:ut,u_globe_transition:i.aj(Et.zoom),u_is_globe:+(Et.projection.name==="globe")}})(this,z,A,G,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);y.setFogUniformValues(h,J)}F&&y.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,y=h.createTexture();return h.bindTexture(h.TEXTURE_2D,y),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),y}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const h=this.style&&this.style.fog;return!!h&&h.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const h=this._backgroundTiles,y=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)y[D.key]=h[D.key]||new Ym(D,512,this.transform.tileZoom,this,void 0,this.worldview);return y}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,y){return!(!h.is3D(!(!this.terrain||!this.terrain.enabled))||h.type!=="clip"&&h.type!=="building"&&(h.minzoom&&h.minzoom>this.transform.zoom||(this.style._clipLayerPresent||h.sourceLayer!=="building"&&h.sourceLayer!=="procedural_buildings")&&(!y||y.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let y=this._cachedTileFogOpacities[h.key];return y||(this._cachedTileFogOpacities[h.key]=y=this.style.fog.getOpacityForTile(h)),y[0]>=ys||y[1]>=ys}setupDepthForOcclusion(h,y,A){const D=this.context,F=D.gl,z=!!A;var G;A||(A={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),D.activeTexture.set(F.TEXTURE3),h&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),A.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],A.u_depth_range_unpack=[2/((G=this.depthRangeFor3D)[1]-G[0]),-1-2*G[0]/(G[1]-G[0])],A.u_occluder_half_size=.5*this.occlusionParams.occluderSize,A.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(F.NEAREST,F.CLAMP_TO_EDGE),D.activeTexture.set(F.TEXTURE0),z||y.setTerrainUniformValues(D,A)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const h=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=h?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function RC(T,h){let y=!1,A=null;const D=()=>{A=null,y&&(T(),A=setTimeout(D,h),y=!1)};return()=>(y=!0,A||D(),A)}class R6{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=RC(this._updateHashUnthrottled.bind(this),300)}addTo(h){return this._map=h,window.addEventListener("hashchange",this._onHashChange,!1),h.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const h=this._map;if(!h)return"";const y=Vl(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const G=z.split("=")[0];return G===A?(D=!0,`${G}=${y}`):z}).filter(z=>z);return D||F.push(`${A}=${y}`),`#${F.join("&")}`}return`#${y}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let y;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(y=A)}),(y&&y[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const y=this._getCurrentHash();if(y.length>=3&&!y.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(y[3]||0):h.getBearing();return h.jumpTo({center:[+y[2],+y[1]],zoom:+y[0],bearing:A,pitch:+(y[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Vl(T,h){const y=T.getCenter(),A=Math.round(100*T.getZoom())/100,D=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(y.lng*F)/F,G=Math.round(y.lat*F)/F,J=T.getBearing(),ae=T.getPitch();let le=h?`/${z}/${G}/${A}`:`${A}/${G}/${z}`;return(J||ae)&&(le+="/"+Math.round(10*J)/10),ae&&(le+=`/${Math.round(ae)}`),le}const _b={linearity:.3,easing:i.eT(0,0,.3,1)},F6=Object.assign({deceleration:2500,maxSpeed:1400},_b),z6=Object.assign({deceleration:20,maxSpeed:1400},_b),yv=Object.assign({deceleration:1e3,maxSpeed:360},_b),B6=Object.assign({deceleration:1e3,maxSpeed:90},_b);class $6{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,y=i.o.now();for(;h.length>0&&y-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const y={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:F}of this._inertiaBuffer)y.zoom+=F.zoomDelta||0,y.bearing+=F.bearingDelta||0,y.pitch+=F.pitchDelta||0,F.panDelta&&y.pan._add(F.panDelta),F.around&&(y.around=F.around),F.pinchAround&&(y.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(y.pan.mag()){const F=Wf(y.pan.mag(),A,Object.assign({},F6,h||{}));D.offset=y.pan.mult(F.amount/y.pan.mag()),D.center=this._map.transform.center,wb(D,F)}if(y.zoom){const F=Wf(y.zoom,A,z6);D.zoom=this._map.transform.zoom+F.amount,wb(D,F)}if(y.bearing){const F=Wf(y.bearing,A,yv);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),wb(D,F)}if(y.pitch){const F=Wf(y.pitch,A,B6);D.pitch=this._map.transform.pitch+F.amount,wb(D,F)}if(D.zoom||D.bearing){const F=y.pinchAround===void 0?y.around:y.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function wb(T,h){(!T.duration||T.durationy.unproject(J)),G=F.reduce((J,ae,le,je)=>J.add(ae.div(je.length)),new i.P(0,0));super(h,{points:F,point:G,lngLats:z,lngLat:y.unproject(G),originalEvent:A}),this._defaultPrevented=!1}}class q6 extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,y){super("wheel",{originalEvent:y}),this._defaultPrevented=!1}}class FC{constructor(h,y){this._map=h,this._clickTolerance=y.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new q6(this._map,h))}mousedown(h,y){return this._mousedownPos=y,this._firePreventable(new ph(h.type,this._map,h))}mouseup(h){this._map.fire(new ph(h.type,this._map,h))}preclick(h){const y=new MouseEvent("preclick",h);this._map.fire(new ph(y.type,this._map,y))}click(h,y){this._mousedownPos&&this._mousedownPos.dist(y)>=this._clickTolerance||(this.preclick(h),this._map.fire(new ph(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new ph(h.type,this._map,h))}mouseover(h){this._map.fire(new ph(h.type,this._map,h))}mouseout(h){this._map.fire(new ph(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Oy(h.type,this._map,h))}touchmove(h){this._map.fire(new Oy(h.type,this._map,h))}touchend(h){this._map.fire(new Oy(h.type,this._map,h))}touchcancel(h){this._map.fire(new Oy(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class U6{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new ph(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ph("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new ph(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class zC{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=y.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,y){this.isEnabled()&&h.shiftKey&&h.button===0&&(L(),this._startPos=this._lastPos=y,this._active=!0)}mousemoveWindow(h,y){if(!this._active)return;const A=y,D=this._startPos,F=this._lastPos;if(!D||!F||F.equals(A)||!this._box&&A.dist(D){this._box&&(this._box.style.transform=`translate(${z}px,${J}px)`,this._box.style.width=G-z+"px",this._box.style.height=ae-J+"px")})}mouseupWindow(h,y){if(!this._active)return;const A=this._startPos,D=y;if(A&&h.button===0){if(this.reset(),$(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(A,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",h)}}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),P(),delete this._startPos,delete this._lastPos}_fireEvent(h,y){return this._map.fire(new i.z(h,{originalEvent:y}))}}function BC(T,h){const y={};for(let A=0;Athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=h.timeStamp),A.length===this.numTouches&&(this.centroid=function(D){const F=new i.P(0,0);for(const z of D)F._add(z);return F.div(D.length)}(y),this.touches=BC(A,y)))}touchmove(h,y,A){if(this.aborted||!this.centroid)return;const D=BC(A,y);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,y,A){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),A.length===0){const D=!this.aborted&&this.centroid;if(this.reset(),D)return D}}}class $C{constructor(h){this.singleTap=new AF(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,y,A){this.singleTap.touchstart(h,y,A)}touchmove(h,y,A){this.singleTap.touchmove(h,y,A)}touchend(h,y,A){const D=this.singleTap.touchend(h,y,A);if(D){const F=h.timeStamp-this.lastTime<500,z=!this.lastTap||this.lastTap.dist(D)<30;if(F&&z||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=D,this.count===this.numTaps)return this.reset(),D}}}class EF{constructor(){this._zoomIn=new $C({numTouches:1,numTaps:2}),this._zoomOut=new $C({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,y,A){this._zoomIn.touchstart(h,y,A),this._zoomOut.touchstart(h,y,A)}touchmove(h,y,A){this._zoomIn.touchmove(h,y,A),this._zoomOut.touchmove(h,y,A)}touchend(h,y,A){const D=this._zoomIn.touchend(h,y,A),F=this._zoomOut.touchend(h,y,A);return D?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()+1,around:z.unproject(D)},{originalEvent:h})}):F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:z=>z.easeTo({duration:300,zoom:z.getZoom()-1,around:z.unproject(F)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const PF={0:1,2:2},V6={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class qC{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(h,y){return!1}_move(h,y){return{}}mousedown(h,y){if(this._lastPoint)return;const A=V(h);this._correctButton(h,A)&&(this._lastPoint=y,this._eventButton=A)}mousemoveWindow(h,y){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=PF[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(y.dist(A)0&&(this._active=!0);const D=BC(A,y),F=new i.P(0,0),z=new i.P(0,0);let G=0;for(const ae in D){const le=D[ae],je=this._touches[ae];je&&(F._add(le),z._add(le.sub(je)),G++,D[ae]=le)}if(this._touches=D,G{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class UC{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,y,A){return{}}touchstart(h,y,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([y[0],y[1]]))}touchmove(h,y,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,G=j2(A,y,F),J=j2(A,y,z);if(!G||!J)return;const ae=this._aroundCenter?null:G.add(J).div(2);return this._move([G,J],ae,h)}touchend(h,y,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=j2(A,y,D),G=j2(A,y,F);z&&G||(this._active&&$(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function j2(T,h,y){for(let A=0;AMath.abs(T.x)}class ape extends UC{constructor(h){super(),this._map=h}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(h){this._lastPoints=h,VC(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,y,A){const D=this._lastPoints;if(!D)return;const F=h[0].sub(D[0]),z=h[1].sub(D[1]);return this._map._cooperativeGestures&&!i.eU()&&A.touches.length<3||(this._valid=this.gestureBeginsVertically(F,z,A.timeStamp),!this._valid)?void 0:(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+z.y)/2*-.5})}gestureBeginsVertically(h,y,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=y.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const z=h.y>0==y.y>0;return VC(h)&&VC(y)&&z}}const ipe={panStep:100,bearingStep:15,pitchStep:10};class ope{constructor(){const h=ipe;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let y=0,A=0,D=0,F=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:y=1;break;case 189:case 109:case 173:y=-1;break;case 37:h.shiftKey?A=-1:(h.preventDefault(),F=-1);break;case 39:h.shiftKey?A=1:(h.preventDefault(),F=1);break;case 38:h.shiftKey?D=1:(h.preventDefault(),z=-1);break;case 40:h.shiftKey?D=-1:(h.preventDefault(),z=1);break;default:return}return this._rotationDisabled&&(A=0,D=0),{cameraAnimation:G=>{const J=G.getZoom();G.easeTo({duration:300,easeId:"keyboardHandler",easing:N2,zoom:y?Math.round(J)+y*(h.shiftKey?2:1):J,bearing:G.getBearing()+A*this._bearingStep,pitch:G.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:G.getCenter()},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function N2(T){return T*(2-T)}const W6=4.000244140625,K6=1/450;class HC{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._handler=y,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=K6,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!h&&h.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(h.ctrlKey||h.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let y=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,y!==0&&y%W6==0?this._type="wheel":y!==0&&Math.abs(y)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=y,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*y)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,y+=this._lastValue)),h.shiftKey&&y&&(y/=4),this._type&&(this._lastWheelEvent=h,this._delta-=y,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const y=U(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:y,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;this._type==="wheel"&&h.projection.wrap&&(h._center.lng>=180||h._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const y=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ae=this._type==="wheel"&&Math.abs(this._delta)>W6?this._wheelZoomRate:this._defaultZoomRate;let le=2/(1+Math.exp(-Math.abs(this._delta*ae)));this._delta<0&&le!==0&&(le=1/le);const je=y(),ve=Math.pow(2,je),Ne=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):ve;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(Ne*le))),this._type==="wheel"&&(this._startZoom=je,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:y(),D=this._startZoom,F=this._easing;let z,G=!1;if(this._type==="wheel"&&D&&F){const ae=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),le=F(ae);z=i.ak(D,A,le),ae<1?this._frameId||(this._frameId=!0):G=!0}else z=A,G=!0;this._active=!0,G&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let J=z-y();return J*this._lastDelta<0&&(J=0),{noInertia:!0,needsRenderFrame:!G,zoomDelta:J,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let y=i.eV;if(this._prevEase){const A=this._prevEase,D=(i.o.now()-A.start)/A.duration,F=A.easing(D+.01)-A.easing(D),z=.27/Math.sqrt(F*F+1e-4)*.01,G=Math.sqrt(.0729-z*z);y=i.eT(z,G,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:y},y}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class ug{constructor(h,y){this._clickZoom=h,this._tapZoom=y}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class GC{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,y){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(y)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Hl{constructor(){this._tap=new $C({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(h,y,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=y[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,y,A))}touchmove(h,y,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=y[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,y,A)}touchend(h,y,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,y,A)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Kf{constructor(h,y,A){this._el=h,this._mousePan=y,this._touchPan=A}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class k2{constructor(h,y,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=y,this._mousePitch=A}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class WC{constructor(h,y,A,D){this._el=h,this._touchZoom=y,this._touchRotate=A,this._tapDragZoom=D,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const S2=T=>T.zoom||T.drag||T.pitch||T.rotate;class lpe extends i.z{}class C2{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,y){const A=i.av([],y,h);this.radius=i.ag(A[2]<0?i.eX([],A,this.constants):[A[0],A[1],0])}projectRay(h){i.eX(h,h,this.constants),i.aw(h,h),i.eY(h,h,this.constants);const y=i.c5([],h,this.radius);if(y[2]>0){const A=i.c5([],[0,0,1],i.bJ(y,[0,0,1])),D=i.c5([],i.aw([],[y[0],y[1],0]),this.radius),F=i.d8([],y,i.c5([],i.av([],i.d8([],D,A),y),2));y[0]=F[0],y[1]=F[1]}return y}}function KC(T){return T.panDelta&&T.panDelta.mag()||T.zoomDelta||T.bearingDelta||T.pitchDelta}class cpe{constructor(h,y){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new $6(h),this._bearingSnap=y.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new C2,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(y),i.aY(["handleEvent","handleWindowEvent"],this);const A=this._el;this._listeners=[[A,"touchstart",{passive:!0}],[A,"touchmove",{passive:!1}],[A,"touchend",void 0],[A,"touchcancel",void 0],[A,"mousedown",void 0],[A,"mousemove",void 0],[A,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[A,"mouseover",void 0],[A,"mouseout",void 0],[A,"dblclick",void 0],[A,"click",void 0],[A,"keydown",{capture:!1}],[A,"keyup",void 0],[A,"wheel",{passive:!1}],[A,"contextmenu",void 0],[window,"blur",void 0]];for(const[D,F,z]of this._listeners){const G=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,G,z)}}destroy(){for(const[h,y,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(y,D,A)}}_addDefaultHandlers(h){const y=this._map,A=y.getCanvasContainer();this._add("mapEvent",new FC(y,h));const D=y.boxZoom=new zC(y,h);this._add("boxZoom",D);const F=new EF,z=new GC;y.doubleClickZoom=new ug(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const G=new Hl;this._add("tapDragZoom",G);const J=y.touchPitch=new ape(y);this._add("touchPitch",J);const ae=new H6(h),le=new G6(h);y.dragRotate=new k2(h,ae,le),this._add("mouseRotate",ae,["mousePitch"]),this._add("mousePitch",le,["mouseRotate"]);const je=new IF(h),ve=new LF(y,h);y.dragPan=new Kf(A,je,ve),this._add("mousePan",je),this._add("touchPan",ve,["touchZoom","touchRotate"]);const Ne=new wo,De=new npe;y.touchZoomRotate=new WC(A,De,Ne,G),this._add("touchRotate",Ne,["touchPan","touchZoom"]),this._add("touchZoom",De,["touchPan","touchRotate"]),this._add("blockableMapEvent",new U6(y));const Pe=y.scrollZoom=new HC(y,this);this._add("scrollZoom",Pe,["mousePan"]);const We=y.keyboard=new ope;this._add("keyboard",We);for(const Ve of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Ve]&&y[Ve].enable(h[Ve])}_add(h,y,A){this._handlers.push({handlerName:h,handler:y,allowed:A}),this._handlersById[h]=y}stop(h){if(!this._updatingCamera){for(const{handler:y}of this._handlers)y.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!S2(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,y,A){for(const D in h)if(D!==A&&(!y||y.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const y=[];for(const A of h)this._el.contains(A.target)&&y.push(A);return y}handleEvent(h,y){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},z={},G={},J=h.touches?this._getMapTouches(h.touches):void 0,ae=J?B(this._el,J):A?void 0:U(this._el,h);for(const{handlerName:ve,handler:Ne,allowed:De}of this._handlers){if(!Ne.isEnabled())continue;let Pe;this._blockedByActive(G,De,ve)?Ne.reset():Ne[y||h.type]&&(Pe=Ne[y||h.type](h,ae,J),this.mergeHandlerResult(F,z,Pe,ve,D),Pe&&Pe.needsRenderFrame&&this._triggerRenderFrame()),(Pe||Ne.isActive())&&(G[ve]=Ne)}const le={};for(const ve in this._previousActiveHandlers)G[ve]||(le[ve]=D);this._previousActiveHandlers=G,(Object.keys(le).length||KC(F))&&(this._changes.push([F,z,le]),this._triggerRenderFrame()),(Object.keys(G).length||KC(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:je}=F;je&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],je(this._map))}mergeHandlerResult(h,y,A,D,F){if(!A)return;Object.assign(h,A);const z={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(y.zoom=z),A.panDelta!==void 0&&(y.drag=z),A.pitchDelta!==void 0&&(y.pitch=z),A.bearingDelta!==void 0&&(y.rotate=z)}_applyChanges(){const h={},y={},A={};for(const[D,F,z]of this._changes)D.panDelta&&(h.panDelta=(h.panDelta||new i.P(0,0))._add(D.panDelta)),D.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+D.zoomDelta),D.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+D.bearingDelta),D.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+D.pitchDelta),D.around!==void 0&&(h.around=D.around),D.aroundCoord!==void 0&&(h.aroundCoord=D.aroundCoord),D.pinchAround!==void 0&&(h.pinchAround=D.pinchAround),D.noInertia&&(h.noInertia=D.noInertia),Object.assign(y,F),Object.assign(A,z);this._updateMapTransform(h,y,A),this._changes=[]}_updateMapTransform(h,y,A){const D=this._map,F=D.transform,z=nt=>[nt.x,nt.y,nt.z];if((nt=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!KC(h)){const nt=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),nt!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!KC(h))return void this._fireEvents(y,A,!0);let{panDelta:G,zoomDelta:J,bearingDelta:ae,pitchDelta:le,around:je,aroundCoord:ve,pinchAround:Ne}=h;F._isCameraConstrained&&(J>0&&(J=0),F._isCameraConstrained=!1),Ne!==void 0&&(je=Ne),(J||(nt=>y[nt]&&!this._eventsInProgress[nt])("drag"))&&je&&(this._dragOrigin=z(F.pointCoordinate3D(je)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),je=je||D.transform.centerPoint,ae&&(F.bearing+=ae),le&&(F.pitch+=le),F._updateCameraState();const De=[0,0,0];if(G)if(F.projection.name==="mercator"){const nt=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(je).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(je.sub(G)).dir);De[0]=ut[0]-nt[0],De[1]=ut[1]-nt[1]}else{const nt=F.pointCoordinate(je);if(F.projection.name==="globe"){G=G.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;De[0]=-G.x*i.eW(i.a$(nt.y))*ut,De[1]=-G.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(je.sub(G));nt&&ut&&(De[0]=ut.x-nt.x,De[1]=ut.y-nt.y)}}const Pe=F.zoom,We=[0,0,0];if(J){const nt=z(ve||F.pointCoordinate3D(je)),ut={dir:i.aw([],i.av([],nt,F._camera.position))};if(ut.dir[2]<0){const ot=F.zoomDeltaToMovement(nt,J);i.c5(We,ut.dir,ot)}}const Ve=i.d8(De,De,We);F._translateCameraConstrained(Ve),J&&Math.abs(F.zoom-Pe)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(y,A,!0)}_fireEvents(h,y,A){const D=S2(this._eventsInProgress),F=S2(h),z={};for(const le in h){const{originalEvent:je}=h[le];this._eventsInProgress[le]||(z[`${le}start`]=je),this._eventsInProgress[le]=h[le]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const le in z)this._fireEvent(le,z[le]);F&&this._fireEvent("move",F.originalEvent);for(const le in h){const{originalEvent:je}=h[le];this._fireEvent(le,je)}const G={};let J;for(const le in this._eventsInProgress){const{handlerName:je,originalEvent:ve}=this._eventsInProgress[le];this._handlersById[je].isActive()||(delete this._eventsInProgress[le],J=y[je]||ve,G[`${le}end`]=J)}for(const le in G)this._fireEvent(le,G[le]);const ae=S2(this._eventsInProgress);if(A&&(D||F)&&!ae){this._updatingCamera=!0;const le=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),je=ve=>ve!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new lpe("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const ZC="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Z6 extends i.E{constructor(h,y){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=y.bearingSnap,this._respectPrefersReducedMotion=y.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,y){return this.jumpTo({center:h},y)}panBy(h,y,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},y),A)}panTo(h,y,A){return this.easeTo(Object.assign({center:h},y),A)}getZoom(){return this.transform.zoom}setZoom(h,y){return this.jumpTo({zoom:h},y),this}zoomTo(h,y,A){return this.easeTo(Object.assign({zoom:h},y),A)}zoomIn(h,y){return this.zoomTo(this.getZoom()+1,h,y),this}zoomOut(h,y){return this.zoomTo(this.getZoom()-1,h,y),this}getBearing(){return this.transform.bearing}setBearing(h,y){return this.jumpTo({bearing:h},y),this}getPadding(){return this.transform.padding}setPadding(h,y){return this.jumpTo({padding:h},y),this}rotateTo(h,y,A){return this.easeTo(Object.assign({bearing:h},y),A)}resetNorth(h,y){return this.rotateTo(0,Object.assign({duration:1e3},h),y),this}resetNorthPitch(h,y){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),y),this}snapToNorth(h,y){return Math.abs(this.getBearing())h.aspect?A/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,y,A,D,F,z){const G=h.clone(),J=this._extendCameraOptions(z);G.bearing=D,G.pitch=F;const ae=i.aT.convert(y),le=i.aT.convert(A),je=.5*(ae.lat+le.lat),ve=.5*(ae.lng+le.lng),Ne=i.eZ(je,ve),De=i.aw([],Ne),Pe=i.aw([],i.bI([],De,[0,1,0])),We=i.bI([],Pe,De),Ve=[Pe[0],Pe[1],Pe[2],0,We[0],We[1],We[2],0,De[0],De[1],De[2],0,0,0,0,1],nt=[Ne,i.eZ(ae.lat,ae.lng),i.eZ(le.lat,ae.lng),i.eZ(le.lat,le.lng),i.eZ(ae.lat,le.lng),i.eZ(je,ae.lng),i.eZ(je,le.lng),i.eZ(ae.lat,ve),i.eZ(le.lat,ve)];let ut=i.d9.fromPoints(nt.map(Jt=>[i.bJ(Pe,Jt),i.bJ(We,Jt),i.bJ(De,Jt)]));const ot=i.af([],ut.center,Ve);i.e_(ot)===0&&i.e$(ot,0,0,1),i.aw(ot,ot),i.c5(ot,ot,i.aD),G.center=i.f0(ot);const Et=G.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ut=i.d9.applyTransform(ut,i.aB([],Et,Ve));const Tt=this._extendAABB(ut,G,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=Tt,i.af(ot,ot,Et);const jt=.5*(ut.max[2]-ut.min[2]),yt=this._minimumAABBFrustumDistance(G,ut),Ot=i.c5([],[0,0,1],jt),Gt=i.d8(Ot,ot,Ot),Ht=yt+(G.pitch===0?0:i.bG(ot,Gt)),es=G.globeCenterInViewSpace,ts=i.av([],ot,[es[0],es[1],es[2]]);i.aw(ts,ts),i.c5(ts,ts,Ht);const gs=i.d8([],ot,ts);i.af(gs,gs,Nt);const Us=i.eM/i.aD,Yt=i.ag(gs),Bt=i.cf(Math.max(Yt*Us-i.eM,Number.EPSILON),0),as=Math.min(G.zoomFromMercatorZAdjusted(Bt),J.maxZoom);return as>.5*(i.c_+i.cL)?(G.setProjection({name:"mercator"}),G.zoom=as,this._cameraForBounds(G,y,A,D,F,z)):{center:G.center,zoom:as,bearing:D,pitch:F}}_extendAABB(h,y,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),z=.5*((A.padding.top||0)+(A.padding.bottom||0)),G=z,J=F,ae=F,le=z,je=y.width-(J+ae),ve=y.height-(G+le),Ne=i.av([],h.max,h.min),De=Math.min(je/Ne[0],ve/Ne[1]),Pe=Math.min(y.scaleZoom(y.scale*De),A.maxZoom);if(isNaN(Pe))return null;const We=y.scale/y.zoomScale(Pe),Ve=new i.d9([h.min[0]-J*We,h.min[1]-le*We,h.min[2]],[h.max[0]+ae*We,h.max[1]+G*We,h.max[2]]),nt=(typeof A.offset.x=="number"&&typeof A.offset.y=="number"?new i.P(A.offset.x,A.offset.y):i.P.convert(A.offset)).rotate(-i.an(D));return Ve.center[0]-=nt.x*We,Ve.center[1]+=nt.y*We,Ve}queryTerrainElevation(h,y){const A=this.transform.elevation;return A?(y=Object.assign({},{exaggerated:!0},y),A.getAtPoint(i.ae.fromLngLat(h),null,y.exaggerated)):null}_cameraForBounds(h,y,A,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,y,A,D,F,z);const G=h.clone(),J=this._extendCameraOptions(z);G.bearing=D,G.pitch=F;const ae=i.aT.convert(y),le=i.aT.convert(A),je=new i.aT(ae.lng,le.lat),ve=new i.aT(le.lng,ae.lat),Ne=G.project(ae),De=G.project(le),Pe=this.queryTerrainElevation(ae),We=this.queryTerrainElevation(le),Ve=this.queryTerrainElevation(je),nt=this.queryTerrainElevation(ve),ut=[[Ne.x,Ne.y,Math.min(Pe||0,We||0,Ve||0,nt||0)],[De.x,De.y,Math.max(Pe||0,We||0,Ve||0,nt||0)]];let ot=i.d9.fromPoints(ut);const Et=G.getWorldToCameraMatrix(),Nt=i.bl(new Float64Array(16),Et);ot=i.d9.applyTransform(ot,Et);const Tt=this._extendAABB(ot,G,J,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ot=Tt;const jt=.5*i.av([],ot.max,ot.min)[2],yt=this._minimumAABBFrustumDistance(G,ot),Ot=[0,0,1,0];i.aC(Ot,Ot,Et),i.f1(Ot,Ot);const Gt=i.c5([],Ot,yt+jt),Ht=i.d8([],ot.center,Gt);i.af(ot.center,ot.center,Nt),i.af(Ht,Ht,Nt);const es=G.unproject(new i.P(ot.center[0],ot.center[1])),ts=i.f2(G.projection,es),gs=Math.pow(2,ts),Us=Math.min(G._zoomFromMercatorZ(Ht[2]*G.pixelsPerMeter*gs/G.worldSize),J.maxZoom);return G.mercatorFromTransition&&Us<.5*(i.c_+i.cL)?(G.setProjection({name:"globe"}),G.zoom=Us,this._cameraForBounds(G,y,A,D,F,z)):{center:es,zoom:Us,bearing:D,pitch:F}}fitBounds(h,y,A){const D=this.cameraForBounds(h,y);return this._fitInternal(D,y,A)}fitScreenCoordinates(h,y,A,D,F){const z=i.P.convert(h),G=i.P.convert(y),J=new i.P(Math.min(z.x,G.x),Math.min(z.y,G.y)),ae=new i.P(Math.max(z.x,G.x),Math.max(z.y,G.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,G))return this;const le=this.transform.pointLocation3D(J),je=this.transform.pointLocation3D(ae),ve=this.transform.pointLocation3D(new i.P(J.x,ae.y)),Ne=this.transform.pointLocation3D(new i.P(ae.x,J.y)),De=[Math.min(le.lng,je.lng,ve.lng,Ne.lng),Math.min(le.lat,je.lat,ve.lat,Ne.lat)],Pe=[Math.max(le.lng,je.lng,ve.lng,Ne.lng),Math.max(le.lat,je.lat,ve.lat,Ne.lat)],We=D&&D.pitch?D.pitch:this.getPitch(),Ve=this._cameraForBounds(this.transform,De,Pe,A,We,D);return this._fitInternal(Ve,D,F)}_fitInternal(h,y,A){return h?(y=Object.assign(h,y)).linear?this.easeTo(y,A):this.flyTo(y,A):this}jumpTo(h,y){this.stop();const A=h.preloadOnly?this.transform.clone():this.transform;let D=!1,F=!1,z=!1;"zoom"in h&&A.zoom!==+h.zoom&&(D=!0,A.zoom=+h.zoom),h.center!==void 0&&(A.center=i.aT.convert(h.center)),"bearing"in h&&A.bearing!==+h.bearing&&(F=!0,A.bearing=+h.bearing),"pitch"in h&&A.pitch!==+h.pitch&&(z=!0,A.pitch=+h.pitch);const G=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(G))if(h.retainPadding===!1){const J=A.clone();J.padding=G,A.setLocationAtPoint(A.center,J.centerPoint)}else A.padding=G;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),D&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),F&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),z&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(ZC),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,y){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(ZC),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const G=D!==A.zoom,J=F!==A.pitch,ae=z!==A.bearing;return this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),G&&this.fire(new i.z("zoomstart",y)).fire(new i.z("zoom",y)).fire(new i.z("zoomend",y)),ae&&this.fire(new i.z("rotatestart",y)).fire(new i.z("rotate",y)).fire(new i.z("rotateend",y)),J&&this.fire(new i.z("pitchstart",y)).fire(new i.z("pitch",y)).fire(new i.z("pitchend",y)),this.fire(new i.z("moveend",y)),this}easeTo(h,y){this._stop(!1,h.easeId),((h=Object.assign({offset:[0,0],duration:500,easing:i.eV},h)).animate===!1||this._prefersReducedMotion(h))&&(h.duration=0);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),G=this.getPadding(),J="zoom"in h?+h.zoom:D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,je=this._extendPadding(h.padding),ve=i.P.convert(h.offset);let Ne,De,Pe;if(A.projection.name==="globe"){const Ot=i.ae.fromLngLat(A.center),Gt=ve.rotate(-A.angle);Ot.x+=Gt.x/A.worldSize,Ot.y+=Gt.y/A.worldSize;const Ht=Ot.toLngLat(),es=i.aT.convert(h.center||Ht);this._normalizeCenter(es),Ne=A.centerPoint.add(Gt),De=new i.P(Ot.x,Ot.y).mult(A.worldSize),Pe=new i.P(i.aF(es.lng),i.aJ(es.lat)).mult(A.worldSize).sub(De)}else{Ne=A.centerPoint.add(ve);const Ot=A.pointLocation(Ne),Gt=i.aT.convert(h.center||Ot);this._normalizeCenter(Gt),De=A.project(Ot),Pe=A.project(Gt).sub(De)}const We=A.zoomScale(J-D);let Ve,nt;h.around&&(Ve=i.aT.convert(h.around),nt=A.locationPoint(Ve));const ut=this._zooming||J!==D,ot=this._rotating||F!==ae,Et=this._pitching||le!==z,Nt=!A.isPaddingEqual(je),Tt=h.retainPadding===!1?A.clone():A,jt=Ot=>Gt=>{if(ut&&(Ot.zoom=i.ak(D,J,Gt)),ot&&(Ot.bearing=i.ak(F,ae,Gt)),Et&&(Ot.pitch=i.ak(z,le,Gt)),Nt&&(Tt.interpolatePadding(G,je,Gt),Ne=Tt.centerPoint.add(ve)),Ve)Ot.setLocationAtPoint(Ve,nt);else{const Ht=Ot.zoomScale(Ot.zoom-D),es=J>D?Math.min(2,We):Math.max(.5,We),ts=Math.pow(es,1-Gt),gs=Ot.unproject(De.add(Pe.mult(Gt*ts)).mult(Ht));Ot.setLocationAtPoint(Ot.renderWorldCopies?gs.wrap():gs,Ne)}return h.preloadOnly||this._fireMoveEvents(y),Ot};if(h.preloadOnly){const Ot=this._emulate(jt,h.duration,A);return this._preloadTiles(Ot),this}const yt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ut,this._rotating=ot,this._pitching=Et,this._padding=Nt,this._easeId=h.easeId,this._prepareEase(y,h.noMoveStart,yt),this._ease(jt(A),Ot=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(y,Ot)},h),this}_prepareEase(h,y,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),y||A.moving||this.fire(new i.z("movestart",h)),this._zooming&&!A.zooming&&this.fire(new i.z("zoomstart",h)),this._rotating&&!A.rotating&&this.fire(new i.z("rotatestart",h)),this._pitching&&!A.pitching&&this.fire(new i.z("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.z("move",h)),this._zooming&&this.fire(new i.z("zoom",h)),this._rotating&&this.fire(new i.z("rotate",h)),this._pitching&&this.fire(new i.z("pitch",h))}_afterEase(h,y){if(this._easeId&&y&&this._easeId===y)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const A=this._zooming,D=this._rotating,F=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,A&&this.fire(new i.z("zoomend",h)),D&&this.fire(new i.z("rotateend",h)),F&&this.fire(new i.z("pitchend",h)),this.fire(new i.z("moveend",h))}flyTo(h,y){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,y)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),G=this.getPadding(),J="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,le="pitch"in h?+h.pitch:z,je=this._extendPadding(h.padding),ve=A.zoomScale(J-D),Ne=i.P.convert(h.offset);let De=A.centerPoint.add(Ne);const Pe=A.pointLocation(De),We=i.aT.convert(h.center||Pe);this._normalizeCenter(We);const Ve=A.project(Pe),nt=A.project(We).sub(Ve);let ut=h.curve;const ot=Math.max(A.width,A.height),Et=ot/ve,Nt=nt.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,J),A.minZoom,A.maxZoom),Ls=ot/A.zoomScale(Jt-D);ut=Math.sqrt(Ls/Nt*2)}const Tt=ut*ut;function jt(Jt){const Ls=(Et*Et-ot*ot+(Jt?-1:1)*Tt*Tt*Nt*Nt)/(2*(Jt?Et:ot)*Tt*Nt);return Math.log(Math.sqrt(Ls*Ls+1)-Ls)}function yt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Ot(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Gt=jt(0);let Ht=function(Jt){return Ot(Gt)/Ot(Gt+ut*Jt)},es=function(Jt){return ot*((Ot(Gt)*(yt(Ls=Gt+ut*Jt)/Ot(Ls))-yt(Gt))/Tt)/Nt;var Ls},ts=(jt(1)-Gt)/ut;if(Math.abs(Nt)<1e-6||!isFinite(ts)){if(Math.abs(ot-Et)<1e-6)return this.easeTo(h,y);const Jt=Eth.maxDuration&&(h.duration=0);const gs=F!==ae,Us=le!==z,Yt=!A.isPaddingEqual(je),Bt=h.retainPadding===!1?A.clone():A,as=Jt=>Ls=>{const rr=Ls*ts,yr=1/Ht(rr);Jt.zoom=Ls===1?J:D+Jt.scaleZoom(yr),gs&&(Jt.bearing=i.ak(F,ae,Ls)),Us&&(Jt.pitch=i.ak(z,le,Ls)),Yt&&(Bt.interpolatePadding(G,je,Ls),De=Bt.centerPoint.add(Ne));const Js=Ls===1?We:Jt.unproject(Ve.add(nt.mult(es(rr))).mult(yr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Js.wrap():Js,De),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(y),Jt};if(h.preloadOnly){const Jt=this._emulate(as,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=gs,this._pitching=Us,this._padding=Yt,this._prepareEase(y,!1),this._ease(as(A),()=>this._afterEase(y),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,y){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,y)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,y,A){A.animate===!1||A.duration===0?(h(1),y()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=y,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),y=this._onEaseFrame;y&&y(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,y){h=i.bT(h,-180,180);const A=Math.abs(h-y);return Math.abs(h-360-y)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,y,A){const D=Math.ceil(15*y/1e3),F=[],z=h(A.clone());for(let G=0;G<=D;G++){const J=z(G/D);F.push(J.clone())}return F}_preloadTiles(h,y){}}class M2{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const y=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=w("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),y&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),y===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let h=this._editLink;h||(h=this._editLink=this._container.querySelector(".mapbox-improve-map"));const y=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.e.ACCESS_TOKEN}];if(h){const A=y.reduce((D,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const A=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(G=>{const J=G.textContent||"";if(G.tagName!=="A")return void G.replaceWith(z.createTextNode(J));const ae=G.getAttribute("href");if(!ae||!/^(https?:|mailto:)/i.test(ae))return void G.replaceWith(z.createTextNode(J));const le=z.createElement("a");le.href=ae,le.textContent=J,le.rel="noopener nofollow";const je=G.getAttribute("class");je&&(le.className=je),G.replaceWith(le)}),z.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,h.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class T2{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=w("div","mapboxgl-ctrl");const y=w("a","mapboxgl-ctrl-logo");return y.target="_blank",y.rel="noopener nofollow",y.href="https://www.mapbox.com/",y.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),y.setAttribute("rel","noopener nofollow"),this._container.appendChild(y),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(h){h&&h.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const h=this._map.style._sourceCaches;if(Object.entries(h).length===0)return!0;for(const y in h){const A=h[y].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const y=h[0];this._map.getCanvasContainer().offsetWidth<250?y.classList.add("mapboxgl-compact"):y.classList.remove("mapboxgl-compact")}}}class jb{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",y=>this._onIndoorUpdate(y)),this._container}_createButton(h,y){const A=w("button",h,this._container);return A.type="button",A.addEventListener("click",y),A}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,y){this._map&&(h.setAttribute("aria-label",y),h.textContent=y)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(h){if(!h||!h.floors)return this._model=h,void(this._container.style.display="none");const y=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",y&&Array.from(this._container.children).forEach(A=>A.remove()),h.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(h.floors,h.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const h=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const y=this._map;this._model&&y&&y._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,y){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&y&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const y=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-y)+this._end*y}isEasing(h){return h>=this._startTime&&h<=this._endTime}jumpTo(h){this._startTime=-1/0,this._endTime=-1/0,this._start=h,this._end=h}easeTo(h,y,A){this._start=this.getValue(y),this._end=h,this._startTime=y,this._endTime=y+A}}const pg={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Ry extends i.z{constructor(h,y,A,D){const{point:F,lngLat:z,originalEvent:G,target:J}=h;super(h.type,{point:F,lngLat:z,originalEvent:G,target:J}),this.preventDefault=()=>{h.preventDefault()},this.id=y,this.interaction=A,this.feature=D}}class qp{constructor(h){this.map=h,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(h,y){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=y.filter;let D=y.type;A&&this.filters.set(h,i.b6(A)),D==="mouseover"&&(D="mouseenter"),D==="mouseout"&&(D="mouseleave");const F=this.interactionsByType.get(D)||new Map;D==="mouseenter"||D==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(h,y)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,y),this.typeById.set(h,D)}get(h){const y=this.typeById.get(h);if(!y)return;const A=this.interactionsByType.get(y);return A?A.get(h):void 0}remove(h){const y=this.typeById.get(h);if(!y)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(y);A&&(A.delete(h),y==="mouseenter"||y==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):A.size===0&&this.map.off(y,this.handleType))}queryTargets(h,y){const A=[];for(const[D,F]of y)F.target&&A.push({targetId:D,target:F.target,filter:this.filters.get(D)});return this.map.style.queryRenderedTargets(h,A,this.map.transform)}handleMove(h){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const y=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());y.length&&(h.type="mouseenter",this.handleType(h,y));const A=new Map;for(const[D,{feature:F}]of this.prevHoveredFeatures)this.hoveredFeatures.has(D)||A.set(F.id,F);A.size&&(h.type="mouseleave",this.handleType(h,Array.from(A.values())))}handleOut(h){const y=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);y.length&&(h.type="mouseleave",this.handleType(h,y)),this.hoveredFeatures.clear()}handleType(h,y){const A=h.type==="mouseenter";if(A&&!this.interactionsByType.has(h.type))return void i.w("mouseenter interaction required for mouseleave to work.");const D=Array.from(this.interactionsByType.get(h.type)).reverse(),F=!!y;y=y||this.queryTargets(h.point,D);let z=!1;const G=new Set;for(const J of y){for(const[ae,le]of D){if(!le.target)continue;const je=J.variants?J.variants[ae]:null;if(je){for(const ve of je){if(by(ve,J,G,ae))continue;const Ne=new i.dx(J,ve),De=Xx(ve,J,ae);F&&Ne.id!==void 0&&(Ne.state=this.map.getFeatureState(Ne));const Pe=A?this.prevHoveredFeatures.get(De):null,We=new Ry(h,ae,le,Ne),Ve=Pe?Pe.stop:le.handler(We);if(A&&this.hoveredFeatures.set(De,{feature:J,stop:Ve}),Ve!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[J,ae]of D){const{handler:le,target:je}=ae;if(!je&&le(new Ry(h,J,ae,null))!==!1)break}}}function dpe(T,h){if(Array.isArray(T)&&Array.isArray(h)){const y=new Set(T),A=new Set(h);return y.size===A.size&&T.every(D=>A.has(D))}return i.by(T,h)}const upe={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},hpe={showCompass:!0,showZoom:!0,visualizePitch:!1};class mpe{constructor(h,y,A=!1){this._clickTolerance=10,this.element=y,this.mouseRotate=new H6({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new G6({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),y.addEventListener("mousedown",this.mousedown),y.addEventListener("touchstart",this.touchstart,{passive:!1}),y.addEventListener("touchmove",this.touchmove),y.addEventListener("touchend",this.touchend),y.addEventListener("touchcancel",this.reset)}down(h,y){this.mouseRotate.mousedown(h,y),this.mousePitch&&this.mousePitch.mousedown(h,y),L()}move(h,y){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,y),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,y),G=z&&z.pitchDelta;G&&A.setPitch(A.getPitch()+G)}}off(){const h=this.element;h.removeEventListener("mousedown",this.mousedown),h.removeEventListener("touchstart",this.touchstart),h.removeEventListener("touchmove",this.touchmove),h.removeEventListener("touchend",this.touchend),h.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){P(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),U(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,U(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=B(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=B(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)y.width||h.y>y.height;y.locationPoint3D(A).distSqr(h)180;){const A=y.locationPoint3D(T);if(A.x>=0&&A.y>=0&&A.x<=y.width&&A.y<=y.height)break;T.lng>y.center.lng?T.lng-=360:T.lng+=360}return T}const Ud={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},sp={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class YC extends i.E{constructor(h,y){super(),(h instanceof HTMLElement||y)&&(h=Object.assign({element:h},y)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:G=0,rotation:J=sp.rotation,rotationAlignment:ae=sp.rotationAlignment,pitchAlignment:le=sp.pitchAlignment,occludedOpacity:je=sp.occludedOpacity,altitude:ve=sp.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=G,this._rotation=J,this._rotationAlignment=ae,this._pitchAlignment=le,this._occludedOpacity=je,this._altitude=ve,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),h&&h.element?(this._element=h.element,this._offset=i.P.convert(h&&h.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(h&&h.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",Pe=>{Pe.preventDefault()}),this._element.addEventListener("mousedown",Pe=>{Pe.preventDefault()});const Ne=this._element.classList;for(const Pe in Ud)Ne.remove(`mapboxgl-marker-anchor-${Pe}`);Ne.add(`mapboxgl-marker-anchor-${this._anchor}`);const De=h&&h.className?h.className.trim().split(/\s+/):[];Ne.add(...De),this._popup=null}_createDefaultMarker(){const h=w("div"),y=j("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=j("radialGradient",{id:"shadowGradient"},j("defs",{},y));j("stop",{offset:"10%","stop-opacity":.4},A),j("stop",{offset:"100%","stop-opacity":.05},A),j("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},y)}return j("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},y),j("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},y),j("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},y),h}addTo(h){return h===this._map||(this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._updateMoving),h.on("moveend",this._update),h.on("remove",this._clearFadeTimer),h._addMarker(this),this.setDraggable(this._draggable),this._update(),h.on("click",this._onMapClick)),this}remove(){const h=this._map;return h&&(h.off("click",this._onMapClick),h.off("move",this._updateMoving),h.off("moveend",this._update),h.off("mousedown",this._addDragHandler),h.off("touchstart",this._addDragHandler),h.off("mouseup",this._onUp),h.off("touchend",this._onUp),h.off("mousemove",this._onMove),h.off("touchmove",this._onMove),h.off("remove",this._clearFadeTimer),h._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.aT.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(h){return h===this._altitude||(this._defaultMarker&&(this._altitude===0&&h!==0||this._altitude!==0&&h===0)&&(this._element=this._createDefaultMarker()),this._altitude=h||sp.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[D,-1*(38.1-13.5+D)],"bottom-right":[-D,-1*(38.1-13.5+D)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,h._marker=this,h._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(h){const y=h.code,A=h.charCode||h.keyCode;y!=="Space"&&y!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const y=h.originalEvent.target,A=this._element;this._popup&&(y===A||A.contains(y))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?(h.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(h.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const h=this._map,y=this._pos;if(!h||!y)return!1;const A=h.unproject(y,this._altitude),D=h.getFreeCameraOptions();if(!D.position)return!1;const F=D.position.toLngLat();return F.distanceTo(A)<.9*F.distanceTo(this._lngLat)}_evaluateOpacity(){const h=this._map;if(!h)return;const y=this._pos;if(!y||y.x<0||y.x>h.transform.width||y.y<0||y.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(y,this._altitude);let D;h._showingGlobe()&&i.f5(h.transform,this._lngLat)?D=0:(D=1-h._queryFogOpacity(A),h.transform._terrainEnabled()&&h.getTerrain()&&this._behindTerrain()&&(D*=this._occludedOpacity)),this._element.style.opacity=`${D}`,this._element.style.pointerEvents=D>0?"auto":"none",this._popup&&this._popup._setOpacity(D),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const h=this._pos;if(!h||!this._map)return;const y=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${Ud[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${y.x}px,${y.y}px) `}_calculateXYTransform(){const h=this._pos,y=this._map,A=this.getPitchAlignment();if(!y||!h||A!=="map")return"";if(!y._showingGlobe()){const J=y.getPitch();return J?`rotateX(${J}deg)`:""}const D=i.cX(i.f6(y.transform,this._lngLat)),F=h.sub(i.f7(y.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const G=D/z;return`rotateX(${-F.y*G}deg) rotateY(${F.x*G}deg)`}_calculateZTransform(){const h=this._pos,y=this._map;if(!y||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(y._showingGlobe()){const F=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=y.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(z.y,z.x))-90}else A=-y.getBearing();else if(D==="horizon"){const F=i.ah(4,6,y.getZoom()),z=i.f7(y.transform);z.y+=F*y.transform.height;const G=h.sub(z),J=i.cX(Math.atan2(G.y,G.x));A=(J>90?J-270:J+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const y=this._map;y&&(y.transform.renderWorldCopies&&(this._lngLat=Y6(this._lngLat,this._pos,y.transform)),this._pos=y.project(this._lngLat,this._altitude),h===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),y._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(y._showingGlobe()||y.getTerrain()||y.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(h){return this._offset=i.P.convert(h),this._update(),this}addClassName(h){return this._element.classList.add(h),this}removeClassName(h){return this._element.classList.remove(h),this}toggleClassName(h){return this._element.classList.toggle(h)}_onMove(h){const y=this._map;if(!y)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||y._clickTolerance;if(h.point.dist(A)T.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(T.minPitch!=null&&T.maxPitch!=null&&T.minPitch>T.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(T.minPitch!=null&&T.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(T.maxPitch!=null&&T.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(T.antialias&&i.f3(window)&&(T.antialias=!1,i.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new e6(T.minZoom,T.maxZoom,T.minPitch,T.maxPitch,T.renderWorldCopies,null,null),T),this._repaint=!!T.repaint,this._interactive=T.interactive,this._minTileCacheSize=T.minTileCacheSize,this._maxTileCacheSize=T.maxTileCacheSize,this._failIfMajorPerformanceCaveat=T.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=T.preserveDrawingBuffer,this._antialias=T.antialias,this._trackResize=T.trackResize,this._bearingSnap=T.bearingSnap,this._refreshExpiredTiles=T.refreshExpiredTiles,this._fadeDuration=T.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=T.crossSourceCollisions,this._collectResourceTiming=T.collectResourceTiming,this._language=this._parseLanguage(T.language),this._worldview=T.worldview,this._renderTaskQueue=new hg,this._domRenderTaskQueue=new hg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},pg,T.locale),this._clickTolerance=T.clickTolerance,this._cooperativeGestures=T.cooperativeGestures,this._performanceMetricsCollection=T.performanceMetricsCollection,this._tessellationStep=T.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=T.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new mg(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=T.scaleFactor,this._requestManager=new Q(T.transformRequest,T.accessToken,T.testMode),this._silenceAuthErrors=!!T.testMode,this._contextCreateOptions=T.contextCreateOptions?Object.assign({},T.contextCreateOptions):{},typeof T.container=="string"){const y=document.getElementById(T.container);if(!y)throw new Error(`Container '${T.container.toString()}' not found.`);this._container=y}else{if(!(T.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=T.container}if(this._container.childNodes.length>0&&i.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),T.maxBounds&&this.setMaxBounds(T.maxBounds),this._spriteFormat=T.spriteFormat,i.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new cpe(this,T),this._localFontFamily=T.localFontFamily,this._localIdeographFontFamily=T.localIdeographFontFamily,(T.style||!T.testMode)&&this.setStyle(T.style||i.e.DEFAULT_STYLE,{config:T.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),T.projection&&this.setProjection(T.projection),T.hash&&(this._hash=new R6(typeof T.hash=="string"&&T.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:T.center,zoom:T.zoom,bearing:T.bearing,pitch:T.pitch});const y=T.bounds;y&&(this.resize(),this.fitBounds(y,Object.assign({},T.fitBoundsOptions,{duration:0})))}this.resize(),T.attributionControl&&this.addControl(new M2({customAttribution:T.customAttribution})),this._logoControl=new T2,this.addControl(this._logoControl,T.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",y=>{this._update(y.dataType==="style"),this.fire(new i.z(`${y.dataType}data`,y))}),this.on("dataloading",y=>{this.fire(new i.z(`${y.dataType}dataloading`,y))}),this._interactions=new qp(this)}_getMapId(){return this._mapId}addControl(T,h){if(h===void 0&&(h=T.getDefaultPosition?T.getDefaultPosition():"top-right"),!T||!T.onAdd)return this.fire(new i.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const y=T.onAdd(this);this._controls.push(T);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(y,A.firstChild):A.appendChild(y),this}removeControl(T){if(!T||!T.onRemove)return this.fire(new i.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(T);return h>-1&&this._controls.splice(h,1),T.onRemove(this),this}hasControl(T){return this._controls.indexOf(T)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(T){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const h=!this._moving;return h&&this.fire(new i.z("movestart",T)).fire(new i.z("move",T)),this.fire(new i.z("resize",T)),h&&this.fire(new i.z("moveend",T)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(T){return this.transform.setMaxBounds(i.aI.convert(T)),this._update()}setMinZoom(T){if((T=T??-2)>=-2&&T<=this.transform.maxZoom)return this.transform.minZoom=T,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=T,this._update(),this.getZoom()>T?this.setZoom(T):this.fire(new i.z("zoomstart")).fire(new i.z("zoom")).fire(new i.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(T){if((T=T??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(T>=0&&T<=this.transform.maxPitch)return this.transform.minPitch=T,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(T>=this.transform.minPitch)return this.transform.maxPitch=T,this._update(),this.getPitch()>T?this.setPitch(T):this.fire(new i.z("pitchstart")).fire(new i.z("pitch")).fire(new i.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(T){return this._scaleFactor=T,this.painter.scaleFactor=T,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(T){return this.transform.renderWorldCopies=T,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(T){return T==="auto"?navigator.language:Array.isArray(T)?T.length===0?void 0:T.map(h=>h==="auto"?navigator.language:h):T}setLanguage(T){const h=this._parseLanguage(T);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const y of this._controls)y._setLanguage&&y._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(T){return this.style&&T!==this._worldview?(this._worldview=T,this._styleDirty=!0,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(T){return this._lazyInitEmptyStyle(),T?typeof T=="string"&&(T={name:T}):T=null,this._useExplicitProjection=!!T,this._prioritizeAndUpdateProjection(T,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const T=this.transform,h=T.projection.name;let y;h==="globe"&&T.zoom>=i.cL?(T.setMercatorFromTransition(),y=!0):h==="mercator"&&T.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(T),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&y!==this.transform.mercatorFromTransition;return(h||A)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(T,h){return this.transform.locationPoint3D(i.aT.convert(T),h)}unproject(T,h){return this.transform.pointLocation3D(i.P.convert(T),h)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(T,h,y){const A=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(G=>this.getLayer(G));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(T==="mouseenter"||T==="mouseover"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:z=>{const G=A(z.point);G.length?D||(D=!0,y.call(this,new ph(T,this,z.originalEvent,{features:G}))):D=!1},mouseout:()=>{D=!1}}}}if(T==="mouseleave"||T==="mouseout"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:G=>{A(G.point).length?D=!0:D&&(D=!1,y.call(this,new ph(T,this,G.originalEvent)))},mouseout:G=>{D&&(D=!1,y.call(this,new ph(T,this,G.originalEvent)))}}}}{const D=F=>{const z=A(F.point);z.length&&(F.features=z,y.call(this,F),delete F.features)};return{listener:y,targets:h,delegates:{[T]:D}}}}on(T,h,y){if(typeof h=="function"||y===void 0)return super.on(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[T]=this._delegatedListeners[T]||[],this._delegatedListeners[T].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(T,h,y){if(typeof h=="function"||y===void 0)return super.once(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(T,h,y);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(T,h,y){if(typeof h=="function"||y===void 0)return super.off(T,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._delegatedListeners?this._delegatedListeners[T]:void 0;return A&&(D=>{for(let F=0;F{if(y){const D=typeof y=="string"?y:y instanceof Error?y.message:y.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(T,h)}else A&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(T,h))}_getUIString(T){const h=this._locale[T];if(h==null)throw new Error(`Missing UI string '${T}'`);return h}_updateStyle(T,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),T){const y=Object.assign({},h);h&&h.config&&(y.initialConfig=h.config,delete y.config),this.style=new tp(this,y).load(T),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new tp(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.w("There is no style added to the map."),!1)}_isValidId(T){return T==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(T)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${T}".`))),!1)}_isTargetValid(T){return"featuresetId"in T?this._isValidId("importId"in T?T.importId:T.featuresetId):"layerId"in T&&this._isValidId(T.layerId)}_areTargetsValid(T){if(Array.isArray(T)){for(const h of T)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(T)}addSource(T,h){return this._isValidId(T)?(this._lazyInitEmptyStyle(),this.style.addSource(T,h),this._update(!0)):this}isSourceLoaded(T){return!!this._isValidId(T)&&!!this.style&&this.style._isSourceCacheLoaded(T)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(T,h,y){this._lazyInitEmptyStyle(),this.style.addSourceType(T,h,y)}removeSource(T){return this._isValidId(T)?(this.style.removeSource(T),this._updateTerrain(),this._update(!0)):this}getSource(T){return this._isValidId(T)?this.style.getOwnSource(T):null}addImage(T,h,{pixelRatio:y=1,sdf:A=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const G=i.I.from(T);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:J,height:ae,data:le}=i.o.getImageData(h);this.style.addImage(G,{data:new i.q({width:J,height:ae},le),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,version:0,usvg:!1})}else if(h.width===void 0||h.height===void 0)this.fire(new i.y(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:J,height:ae}=h,le=h;this.style.addImage(G,{data:new i.q({width:J,height:ae},new Uint8Array(le.data)),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:le}),le.onAdd&&le.onAdd(this,T)}}updateImage(T,h){this._lazyInitEmptyStyle();const y=i.I.from(T),A=this.style.getImage(y);if(!A)return void this.fire(new i.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const D=h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap?i.o.getImageData(h):h,{width:F,height:z,data:G}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(A.usvg?A.icon.usvg_tree.width:A.data.width)||z!==(A.usvg?A.icon.usvg_tree.height:A.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${F}, ${z}) must be that same as the previous version of the image (${A.data.width}, ${A.data.height})`)));const J=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ae=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(G)),A.usvg=!1,A.icon=void 0,ae=!0):A.data.replace(G,J),this.style.updateImage(y,A,ae)}hasImage(T){return T?!!this.style&&!!this.style.getImage(i.I.from(T)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(T){this.style.removeImage(i.I.from(T))}loadImage(T,h){i.n(this._requestManager.transformRequest(T,i.R.Image),(y,A)=>{h(y,A instanceof HTMLImageElement?i.o.getImageData(A):A)})}listImages(){return this.style.listImages().map(T=>T.name)}addModel(T,h){this._lazyInitEmptyStyle(),this.style.addModel(T,h)}hasModel(T){return T?this.style.hasModel(T):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(T){this.style.removeModel(T)}listModels(){return this.style.listModels()}addLayer(T,h){return this._isValidId(T.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(T,h),this._update(!0)):this}getSlot(T){const h=this.getLayer(T);return h&&h.slot||null}setSlot(T,h){return this.style.setSlot(T,h),this.style.mergeLayers(),this._update(!0)}addImport(T,h){return this.style.addImport(T,h).catch(y=>this.fire(new i.y(new Error("Failed to add import",y)))),this}updateImport(T,h){return typeof h!="string"&&h.id!==T?(this.removeImport(T),this.addImport(h)):(this.style.updateImport(T,h),this._update(!0))}removeImport(T){return this.style.removeImport(T),this}moveImport(T,h){return this.style.moveImport(T,h),this._update(!0)}moveLayer(T,h){return this._isValidId(T)?(this.style.moveLayer(T,h),this._update(!0)):this}removeLayer(T){return this._isValidId(T)?(this.style.removeLayer(T),this._update(!0)):this}getLayer(T){if(!this._isValidId(T))return null;const h=this.style.getOwnLayer(T);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(T,h,y){return this._isValidId(T)?(this.style.setLayerZoomRange(T,h,y),this._update(!0)):this}setFilter(T,h,y={}){return this._isValidId(T)?(this.style.setFilter(T,h,y),this._update(!0)):this}getFilter(T){return this._isValidId(T)?this.style.getFilter(T):null}setPaintProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setPaintProperty(T,h,y,A),this._update(!0)):this}getPaintProperty(T,h){return this._isValidId(T)?this.style.getPaintProperty(T,h):null}setLayoutProperty(T,h,y,A={}){return this._isValidId(T)?(this.style.setLayoutProperty(T,h,y,A),this._update(!0)):this}getLayoutProperty(T,h){return this._isValidId(T)?this.style.getLayoutProperty(T,h):null}setLayerProperty(T,h,y,A={}){return this._isValidId(T)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(T,h,y,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(T){return this.style.setGlyphsUrl(T),this._update(!0)}getSchema(T){return this.style.getSchema(T)}setSchema(T,h){return this.style.setSchema(T,h),this._update(!0)}getConfig(T){return this.style.getConfig(T)}setConfig(T,h){return this.style.setConfig(T,h),this._update(!0)}getConfigProperty(T,h){return this.style.getConfigProperty(T,h)}setConfigProperty(T,h,y){return this.style.setConfigProperty(T,h,y),this._update(!0)}getFeaturesetDescriptors(T){return this.style.getFeaturesetDescriptors(T)}setLights(T){if(this._lazyInitEmptyStyle(),T&&T.length===1&&T[0].type==="flat"){const h=T[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(T),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const T=this.style.getLights()||[];return T.length===0&&T.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),T}setLight(T,h={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:T}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(T){return this._lazyInitEmptyStyle(),!T&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(T),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(T){return this._lazyInitEmptyStyle(),this.style.setFog(T),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(T){return this._lazyInitEmptyStyle(),this.style.setSnow(T),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(T){return this._lazyInitEmptyStyle(),this.style.setRain(T),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(T){return this._lazyInitEmptyStyle(),this.style.setColorTheme(T),this._update(!0)}setImportColorTheme(T,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(T,h),this._update(!0)}setCamera(T){return this.style.setCamera(T),this._triggerCameraUpdate(T)}_triggerCameraUpdate(T){return this._update(this.transform.setOrthographicProjectionAtLowPitch(T["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(T){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(T),this.transform):0}setFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.setFeatureState(T,h),this._update())}removeFeatureState(T,h){return T.source&&!this._isValidId(T.source)?this:(this.style.removeFeatureState(T,h),this._update())}getFeatureState(T){return T.source&&!this._isValidId(T.source)?null:this.style.getFeatureState(T)}_selectIndoorFloor(T){this.indoor.selectFloor(T)}_setIndoorActiveFloorsVisibility(T){this.indoor.setActiveFloorsVisibility(T)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new jb),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const T=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let y,A,D,F=this._container;for(;F&&(!A||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(y=z.match(/matrix.*\((.+)\)/)[1].split(", "),y[0]&&y[0]!=="0"&&y[0]!=="1"&&(A=y[0]),y[3]&&y[3]!=="0"&&y[3]!=="1"&&(D=y[3])),F=F.parentElement}this._containerWidth=A?Math.abs(T/A):T,this._containerHeight=D?Math.abs(h/D):h}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new VR(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const T=this._container;T.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",T)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=w("div","mapboxgl-canvas-container",T);this._canvas=w("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const y=this._controlContainer=w("div","mapboxgl-control-container",T),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=w("div",`mapboxgl-ctrl-${D}`,y)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(T,h){const y=i.o.devicePixelRatio||1;this._canvas.width=y*Math.ceil(T),this._canvas.height=y*Math.ceil(h),this._canvas.style.width=`${T}px`,this._canvas.style.height=`${h}px`}_addMarker(T){this._markers.push(T)}_removeMarker(T){const h=this._markers.indexOf(T);h!==-1&&this._markers.splice(h,1)}_addPopup(T){this._popups.push(T)}_removePopup(T){const h=this._popups.indexOf(T);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const T=Object.assign({},_.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",T);h?(tt(h,!0),this.painter=new OC(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",y=>{y.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(T){T.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:T}))}_contextRestored(T){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.z("webglcontextrestored",{originalEvent:T}))}_onMapScroll(T){if(T.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(T){return this.style?(this._styleDirty=this._styleDirty||T,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(T){return this._update(),this._renderTaskQueue.add(T)}_cancelRenderFrame(T){this._renderTaskQueue.remove(T)}_requestDomTask(T){!this.loaded()||this.loaded()&&!this.isMoving()?T():this._domRenderTaskQueue.add(T)}_render(T){let h;this.fire(new i.z("renderstart")),++this._frameId;const y=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(y.TIME_ELAPSED_EXT,h)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(T),this._domRenderTaskQueue.run(T),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ae=this.transform.zoom,le=this.transform.pitch,je=i.o.now(),ve=new i.ac(ae,{now:je,fadeDuration:F,pitch:le,transition:this.style.transition,worldview:this._worldview});this.style.update(ve)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let z=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),z=this._updateAverageElevation(A),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):z=this._updateAverageElevation(A);const G=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),G&&(this._placementDirty=G.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const ae=i.o.now()-A;D.endQuery(y.TIME_ELAPSED_EXT),setTimeout(()=>{const le=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ae,gpuTime:le}))},50)}if(this.listens("gpu-timing-layer")){const ae=this.painter.collectGpuTimers();setTimeout(()=>{const le=this.painter.queryGpuTimers(ae);this.fire(new i.z("gpu-timing-layer",{layerTimes:le}))},50)}if(this.listens("gpu-timing-deferred-render")){const ae=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const le=this.painter.queryGpuTimeDeferredRender(ae);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:le}))},50)}const J=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(J||this._repaint)this.triggerRepaint();else{const ae=this.idle();if(ae&&(z=this._updateAverageElevation(A,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),ae&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const le=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:le})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||J||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&pt(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(T){for(const h of this._markers)T&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!T||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(T,h=!1){const y=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&y(0);const A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(h||T-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(T)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=T;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),y(F);this._averageElevation.easeTo(F,T,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),y(F)}return!!this._averageElevation.isEasing(T)&&y(this._averageElevation.getValue(T))}_authenticate(){qe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,T=>{if(T&&(T.message===ee||T.status===401)){const h=this.painter.context.gl;tt(h,!1),this._logoControl instanceof T2&&this._logoControl._updateLogo(),h&&h.clear(h.DEPTH_BUFFER_BIT|h.COLOR_BUFFER_BIT|h.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),Me(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&ke(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&we(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){Qe(this._requestManager._customAccessToken)}_updateTerrain(){const T=this._isDragging();this.painter.updateTerrain(this.style,T)}_calculateSpeedIndex(){const T=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const y=this.painter.context.gl,A=y.createFramebuffer();function D(F){y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,F,0);const z=new Uint8Array(y.drawingBufferWidth*y.drawingBufferHeight*4);return y.readPixels(0,0,y.drawingBufferWidth,y.drawingBufferHeight,y.RGBA,y.UNSIGNED_BYTE,z),z}return y.bindFramebuffer(y.FRAMEBUFFER,A),this._canvasPixelComparison(D(T),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(T,h,y){let A=y[1]-y[0];const D=T.length/4;for(let F=0;F{const y=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,y&&this._render(h)}))}_preloadTiles(T){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(y,A)=>y._preloadTiles(T,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(T){this._trackResize&&this.resize({originalEvent:T})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(T){this._showTileBoundaries!==T&&(this._showTileBoundaries=T,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(T){this._showParseStatus!==T&&(this._showParseStatus=T,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(T){this._showTerrainWireframe!==T&&(this._showTerrainWireframe=T,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(T){this._showLayers2DWireframe!==T&&(this._showLayers2DWireframe=T,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(T){this._showLayers3DWireframe!==T&&(this._showLayers3DWireframe=T,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(T){this._speedIndexTiming!==T&&(this._speedIndexTiming=T,this._update())}get showPadding(){return!!this._showPadding}set showPadding(T){this._showPadding!==T&&(this._showPadding=T,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(T){this._showCollisionBoxes!==T&&(this._showCollisionBoxes=T,this.style&&T?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(T){this._showOverdrawInspector!==T&&(this._showOverdrawInspector=T,this._update())}get repaint(){return!!this._repaint}set repaint(T){this._repaint!==T&&(this._repaint=T,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(T){this._vertices=T,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(T){this._showTileAABBs!==T&&(this._showTileAABBs=T,T&&this._update())}_setCacheLimits(T,h){i.f4(T,h)}get version(){return c}},NavigationControl:class{constructor(T={}){this.options=Object.assign({},hpe,T),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const y=this._map;y&&(this.options.visualizePitch?y.resetNorthPitch({},{originalEvent:h}):y.resetNorth({},{originalEvent:h}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const T=this._map;if(!T)return;const h=T.getZoom(),y=h===T.getMaxZoom(),A=h===T.getMinZoom();this._zoomInButton.disabled=y,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",y.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())}_rotateCompassArrow(){const T=this._map;if(!T)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(T.transform.pitch*(Math.PI/180)),.5)}) rotateX(${T.transform.pitch}deg) rotateZ(${T.transform.angle*(180/Math.PI)}deg)`:`rotate(${T.transform.angle*(180/Math.PI)}deg)`;T._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(T){return this._map=T,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),T.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&T.on("pitch",this._rotateCompassArrow),T.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new mpe(T,this._compass,this.options.visualizePitch)),this._container}onRemove(){const T=this._map;T&&(this._container.remove(),this.options.showZoom&&T.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&T.off("pitch",this._rotateCompassArrow),T.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(T,h){const y=w("button",T,this._container);return y.type="button",y.addEventListener("click",h),y}_setButtonTitle(T,h){if(!this._map)return;const y=this._map._getUIString(`NavigationControl.${h}`);T.setAttribute("aria-label",y),T.firstElementChild&&T.firstElementChild.setAttribute("title",y)}},GeolocateControl:class extends i.E{constructor(T={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},ppe,T),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=RC(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(T){return this._map=T,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(T){const h=(y=!!this.options.geolocation)=>{this._supportsGeolocation=y,T(y)};this._supportsGeolocation!==void 0?T(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(y=>h(y.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(T){const h=this._map.getMaxBounds(),y=T.coords;return!!h&&(y.longitudeh.getEast()||y.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(T){if(this._map){if(this._isOutOfMapMaxBounds(T))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",T)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=T,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(T),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(T),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:T.coords,timestamp:T.timestamp},T.toJSON?{toJSON:T.toJSON.bind(T)}:{}))),this._finish()}}_updateCamera(T){const h=new i.aT(T.coords.longitude,T.coords.latitude),y=T.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(y),D,{geolocateSource:!0})}_updateMarker(T){if(T){const h=new i.aT(T.coords.longitude,T.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=T.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const T=this._map.transform,h=i.cf(1,T._center.lat)*T.worldSize,y=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${y}px`,this._circleElement.style.height=`${y}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(T){if(this._map){if(this.options.trackUserLocation)if(T.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(T.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("error",T)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(T){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=w("button","mapboxgl-ctrl-geolocate",this._container),w("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",T===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new YC({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new YC({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.z("trackuserlocationend")))})}}_onDeviceOrientation(T){this._userLocationDotMarker&&(T.webkitCompassHeading?this._heading=T.webkitCompassHeading:T.absolute===!0&&(this._heading=-1*T.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let T;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(T={maximumAge:6e5,timeout:0},this._noTimeout=!0):(T=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,T),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const T=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(h=>{h==="granted"&&T()}).catch(console.error):T()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:M2,ScaleControl:class{constructor(T={}){this.options=Object.assign({},Nb,T),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const T=this.options.maxWidth||100,h=this._map,y=h._containerHeight/2,A=h._containerWidth/2-T/2,D=h.unproject([A,y]),F=h.unproject([A+T,y]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const G=3.2808*z;G>5280?this._setScale(T,G/5280,"mile"):this._setScale(T,G,"foot")}else this.options.unit==="nautical"?this._setScale(T,z/1852,"nautical-mile"):z>=1e3?this._setScale(T,z/1e3,"kilometer"):this._setScale(T,z,"meter")}_setScale(T,h,y){this._map._requestDomTask(()=>{const A=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let G=F/z;return G=G>=10?10:G>=5?5:G>=3?3:G>=2?2:G>=1?1:function(J){const ae=Math.pow(10,Math.ceil(-Math.log(J)/Math.LN10));return Math.round(J*ae)/ae}(G),z*G}(h),D=A/h;this._container.innerHTML=y!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:y}).format(A):`${A} ${Q6[y]}`,this._container.style.width=T*D+"px"})}onAdd(T){return this._map=T,this._language=T.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",T.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(T){this._language=T,this._update()}setUnit(T){this.options.unit=T,this._update()}},FullscreenControl:class{constructor(T={}){this._fullscreen=!1,T&&T.container&&(T.container instanceof HTMLElement?this._container=T.container:i.w("Full screen control 'container' must be a DOM element.")),i.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(T){return this._map=T,this._container||(this._container=this._map.getContainer()),this._controlContainer=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const T=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",T).setAttribute("aria-hidden","true"),T.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const T=this._getTitle();this._fullscreenButton.setAttribute("aria-label",T),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",T)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:jb,Popup:class extends i.E{constructor(T){super(),this.options=Object.assign(Object.create(rp),T),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(T&&T.className?T.className.trim().split(/\s+/):[])}addTo(T){return this._map&&this.remove(),this._map=T,this.options.closeOnClick&&T.on("preclick",this._onClose),this.options.closeOnMove&&T.on("move",this._onClose),T.on("remove",this.remove),this._update(),T._addPopup(this),this._focusFirstElement(),this._trackPointer?(T.on("mousemove",this._onMouseEvent),T.on("mouseup",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")):T.on("move",this._update),this.fire(new i.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const T=this._map;return T&&(T.off("move",this._update),T.off("move",this._onClose),T.off("preclick",this._onClose),T.off("click",this._onClose),T.off("remove",this.remove),T.off("mousemove",this._onMouseEvent),T.off("mouseup",this._onMouseEvent),T.off("drag",this._onMouseEvent),T._canvasContainer&&T._canvasContainer.classList.remove("mapboxgl-track-pointer"),T._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(T){this._lngLat=i.aT.convert(T),this._pos=null,this._trackPointer=!1,this._update();const h=this._map;return h&&(h.on("move",this._update),h.off("mousemove",this._onMouseEvent),h._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(T){return this._altitude=T,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const T=this._map;return T&&(T.off("move",this._update),T.on("mousemove",this._onMouseEvent),T.on("drag",this._onMouseEvent),T._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(T){return this.setDOMContent(document.createTextNode(T))}setHTML(T){const h=document.createDocumentFragment(),y=document.createElement("body");let A;for(y.innerHTML=T;A=y.firstChild,A;)h.appendChild(A);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(T){return this.options.maxWidth=T,this._update(),this}setDOMContent(T){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=w("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(T),this.options.closeButton){const y=this._closeButton=w("button","mapboxgl-popup-close-button",h);y.type="button",y.setAttribute("aria-label","Close popup"),y.innerHTML='',y.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(T){return this._classList.add(T),this._updateClassList(),this}removeClassName(T){return this._classList.delete(T),this._updateClassList(),this}setOffset(T){return this.options.offset=T,this._update(),this}toggleClassName(T){let h;return this._classList.delete(T)?h=!1:(this._classList.add(T),h=!0),this._updateClassList(),h}_onMouseEvent(T){this._update(T.point)}_getAnchor(T){if(this.options.anchor)return this.options.anchor;const h=this._map,y=this._container,A=this._pos;if(!h||!y||!A)return"bottom";const D=y.offsetWidth,F=y.offsetHeight,z=A.xh.transform.width-D/2;if(A.y+Th.transform.height-F){if(z)return"bottom-left";if(G)return"bottom-right"}return z?"left":G?"right":"bottom"}_updateClassList(){const T=this._container;if(!T)return;const h=[...this._classList];h.push("mapboxgl-popup"),this._anchor&&h.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&h.push("mapboxgl-popup-track-pointer"),T.className=h.join(" ")}_update(T){const h=this._map,y=this._content;if(!h||!this._lngLat&&!this._trackPointer||!y)return;let A=this._container;if(A||(A=this._container=w("div","mapboxgl-popup",h.getContainer()),this._tip=w("div","mapboxgl-popup-tip",A),A.appendChild(y)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Y6(this._lngLat,this._pos,h.transform)),!this._trackPointer||T){const D=this._pos=this._trackPointer&&T instanceof i.P?T:h.project(this._lngLat,this._altitude),F=vv(this.options.offset),z=this._anchor=this._getAnchor(F.y),G=vv(this.options.offset,z),J=D.add(G).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${Ud[z]} translate(${J.x}px,${J.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const T=this._container.querySelector(np);T&&T.focus()}_onClose(){this.remove()}_setOpacity(T){this._container&&(this._container.style.opacity=`${T}`),this._content&&(this._content.style.pointerEvents=T?"auto":"none")}},Marker:YC,Style:tp,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:zu,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(T){i.e.ACCESS_TOKEN=T},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(T){i.e.API_URL=T},get workerCount(){return i.fi.workerCount},set workerCount(T){i.fi.workerCount=T},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(T){i.e.MAX_PARALLEL_IMAGE_REQUESTS=T},clearStorage(T){i.fh(T)},get workerUrl(){return i.fg.workerUrl},set workerUrl(T){i.fg.workerUrl=T},get workerClass(){return i.fg.workerClass},set workerClass(T){i.fg.workerClass=T},get workerParams(){return i.fg.workerParams},set workerParams(T){i.fg.workerParams=T},get dracoUrl(){return i.ff()},set dracoUrl(T){i.fe(T)},get meshoptUrl(){return i.fd()},set meshoptUrl(T){i.fc(T)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(EGe);var $Nt=EGe.exports;const Eo=Po($Nt);function vs({className:t,...s}){return e.jsx("div",{className:It("animate-pulse rounded-md bg-muted",t),...s})}const g6e={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},y6e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function qNt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function UNt({listings:t,isLoading:s}){const r=nr(),n=N.useRef(null),a=N.useRef(null),o=N.useRef([]),[l,i]=N.useState(""),[c,u]=N.useState(!0);return N.useEffect(()=>{(async()=>{u(!0);try{const{data:g}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();g!=null&&g.value&&i(g.value)}catch(g){console.error("Error fetching mapbox token:",g)}u(!1)})()},[]),N.useEffect(()=>{if(!n.current||!l||a.current)return;Eo.accessToken=l;const f=t.filter(_=>_.latitude!=null&&_.longitude!=null);let g=[-98.5795,39.8283],v=4;if(f.length>0){const _=f.reduce((j,k)=>j+k.longitude,0)/f.length,w=f.reduce((j,k)=>j+k.latitude,0)/f.length;g=[_,w],v=f.length===1?12:10}return a.current=new Eo.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:v,center:g}),a.current.addControl(new Eo.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[l]),N.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(g=>g.remove()),o.current=[];const f=t.filter(g=>g.latitude!=null&&g.longitude!=null);if(f.forEach(g=>{var L,P,O;const v=g6e[g.status]||"#10B981",_=((L=g.photos)==null?void 0:L.find($=>$.is_primary))||((P=g.photos)==null?void 0:P[0]),j=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`,k=document.createElement("div");k.className="cursor-pointer",k.innerHTML=`
`;const S=new Eo.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${_!=null&&_.photo_url?``:""}
${qNt(g.price)}
${g.property_address||""}
${g.city}, ${g.state}
${y6e[g.status]||g.status} ${g.bedrooms?`${g.bedrooms} bed`:""} ${g.bathrooms?`${g.bathrooms} bath`:""}
${(O=g.agent)!=null&&O.name?`
Listed by ${g.agent.name}
`:""}
Click to view details →
`),M=new Eo.Marker(k).setLngLat([g.longitude,g.latitude]).setPopup(S).addTo(a.current);o.current.push(M)}),f.length>1){const g=new Eo.LngLatBounds;f.forEach(v=>g.extend([v.longitude,v.latitude])),a.current.fitBounds(g,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),N.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),c||s?e.jsx(vs,{className:"w-full h-[500px] rounded-lg"}):!l||t.filter(f=>f.latitude!=null&&f.longitude!=null).length===0?null:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(g6e).map(([f,g])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:g}}),e.jsx("span",{className:"text-xs text-gray-600",children:y6e[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function uD(t,[s,r]){return Math.min(r,Math.max(s,t))}function HO(t){const s=N.useRef({value:t,previous:t});return N.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var VNt=[" ","Enter","ArrowUp","ArrowDown"],HNt=[" ","Enter"],WS="Select",[sue,rue,GNt]=TO(WS),[nE]=od(WS,[GNt,$0]),nue=$0(),[WNt,Ow]=nE(WS),[KNt,ZNt]=nE(WS),IGe=t=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:c,dir:u,name:p,autoComplete:f,disabled:g,required:v,form:_}=t,w=nue(s),[j,k]=N.useState(null),[S,M]=N.useState(null),[L,P]=N.useState(!1),O=Lw(u),[$,U]=oh({prop:n,defaultProp:a??!1,onChange:o,caller:WS}),[B,V]=oh({prop:l,defaultProp:i,onChange:c,caller:WS}),X=N.useRef(null),Y=j?_||!!j.closest("form"):!0,[ee,Q]=N.useState(new Set),ce=Array.from(ee).map(ne=>ne.props.value).join(";");return e.jsx(IO,{...w,children:e.jsxs(WNt,{required:v,scope:s,trigger:j,onTriggerChange:k,valueNode:S,onValueNodeChange:M,valueNodeHasChildren:L,onValueNodeHasChildrenChange:P,contentId:Eu(),value:B,onValueChange:V,open:$,onOpenChange:U,dir:O,triggerPointerDownPosRef:X,disabled:g,children:[e.jsx(sue.Provider,{scope:s,children:e.jsx(KNt,{scope:t.__scopeSelect,onNativeOptionAdd:N.useCallback(ne=>{Q(re=>new Set(re).add(ne))},[]),onNativeOptionRemove:N.useCallback(ne=>{Q(re=>{const oe=new Set(re);return oe.delete(ne),oe})},[]),children:r})}),Y?e.jsxs(rWe,{"aria-hidden":!0,required:v,tabIndex:-1,name:p,autoComplete:f,value:B,onChange:ne=>V(ne.target.value),disabled:g,form:_,children:[B===void 0?e.jsx("option",{value:""}):null,Array.from(ee)]},ce):null]})})};IGe.displayName=WS;var LGe="SelectTrigger",DGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=nue(r),l=Ow(LGe,r),i=l.disabled||n,c=Va(s,l.onTriggerChange),u=rue(r),p=N.useRef("touch"),[f,g,v]=aWe(w=>{const j=u().filter(M=>!M.disabled),k=j.find(M=>M.value===l.value),S=iWe(j,w,k);S!==void 0&&l.onValueChange(S.value)}),_=w=>{i||(l.onOpenChange(!0),v()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(YA,{asChild:!0,...o,children:e.jsx(an.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":nWe(l.value)?"":void 0,...a,ref:c,onClick:Lr(a.onClick,w=>{w.currentTarget.focus(),p.current!=="mouse"&&_(w)}),onPointerDown:Lr(a.onPointerDown,w=>{p.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:Lr(a.onKeyDown,w=>{const j=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(j&&w.key===" ")&&VNt.includes(w.key)&&(_(),w.preventDefault())})})})});DGe.displayName=LGe;var OGe="SelectValue",RGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=Ow(OGe,r),{onValueNodeHasChildrenChange:u}=c,p=o!==void 0,f=Va(s,c.onValueNodeChange);return jd(()=>{u(p)},[u,p]),e.jsx(an.span,{...i,ref:f,style:{pointerEvents:"none"},children:nWe(c.value)?e.jsx(e.Fragment,{children:l}):o})});RGe.displayName=OGe;var YNt="SelectIcon",FGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(an.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});FGe.displayName=YNt;var QNt="SelectPortal",zGe=t=>e.jsx(GA,{asChild:!0,...t});zGe.displayName=QNt;var KS="SelectContent",BGe=N.forwardRef((t,s)=>{const r=Ow(KS,t.__scopeSelect),[n,a]=N.useState();if(jd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?yp.createPortal(e.jsx($Ge,{scope:t.__scopeSelect,children:e.jsx(sue.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(qGe,{...t,ref:s})});BGe.displayName=KS;var Pg=10,[$Ge,Rw]=nE(KS),XNt="SelectContentImpl",JNt=mw("SelectContent.RemoveScroll"),qGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:j,...k}=t,S=Ow(KS,r),[M,L]=N.useState(null),[P,O]=N.useState(null),$=Va(s,ke=>L(ke)),[U,B]=N.useState(null),[V,X]=N.useState(null),Y=rue(r),[ee,Q]=N.useState(!1),ce=N.useRef(!1);N.useEffect(()=>{if(M)return Kde(M)},[M]),Hde();const ne=N.useCallback(ke=>{const[pe,...we]=Y().map(Te=>Te.ref.current),[Le]=we.slice(-1),Qe=document.activeElement;for(const Te of ke)if(Te===Qe||(Te==null||Te.scrollIntoView({block:"nearest"}),Te===pe&&P&&(P.scrollTop=0),Te===Le&&P&&(P.scrollTop=P.scrollHeight),Te==null||Te.focus(),document.activeElement!==Qe))return},[Y,P]),re=N.useCallback(()=>ne([U,M]),[ne,U,M]);N.useEffect(()=>{ee&&re()},[ee,re]);const{onOpenChange:oe,triggerPointerDownPosRef:fe}=S;N.useEffect(()=>{if(M){let ke={x:0,y:0};const pe=Le=>{var Qe,Te;ke={x:Math.abs(Math.round(Le.pageX)-(((Qe=fe.current)==null?void 0:Qe.x)??0)),y:Math.abs(Math.round(Le.pageY)-(((Te=fe.current)==null?void 0:Te.y)??0))}},we=Le=>{ke.x<=10&&ke.y<=10?Le.preventDefault():M.contains(Le.target)||oe(!1),document.removeEventListener("pointermove",pe),fe.current=null};return fe.current!==null&&(document.addEventListener("pointermove",pe),document.addEventListener("pointerup",we,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",pe),document.removeEventListener("pointerup",we,{capture:!0})}}},[M,oe,fe]),N.useEffect(()=>{const ke=()=>oe(!1);return window.addEventListener("blur",ke),window.addEventListener("resize",ke),()=>{window.removeEventListener("blur",ke),window.removeEventListener("resize",ke)}},[oe]);const[ge,ue]=aWe(ke=>{const pe=Y().filter(Qe=>!Qe.disabled),we=pe.find(Qe=>Qe.ref.current===document.activeElement),Le=iWe(pe,ke,we);Le&&setTimeout(()=>Le.ref.current.focus())}),xe=N.useCallback((ke,pe,we)=>{const Le=!ce.current&&!we;(S.value!==void 0&&S.value===pe||Le)&&(B(ke),Le&&(ce.current=!0))},[S.value]),_e=N.useCallback(()=>M==null?void 0:M.focus(),[M]),$e=N.useCallback((ke,pe,we)=>{const Le=!ce.current&&!we;(S.value!==void 0&&S.value===pe||Le)&&X(ke)},[S.value]),Me=n==="popper"?Fve:UGe,Ie=Me===Fve?{side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:j}:{};return e.jsx($Ge,{scope:r,content:M,viewport:P,onViewportChange:O,itemRefCallback:xe,selectedItem:U,onItemLeave:_e,itemTextRefCallback:$e,focusSelectedItem:re,selectedItemText:V,position:n,isPositioned:ee,searchRef:ge,children:e.jsx(zO,{as:JNt,allowPinchZoom:!0,children:e.jsx(RO,{asChild:!0,trapped:S.open,onMountAutoFocus:ke=>{ke.preventDefault()},onUnmountAutoFocus:Lr(a,ke=>{var pe;(pe=S.trigger)==null||pe.focus({preventScroll:!0}),ke.preventDefault()}),children:e.jsx(Aw,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:ke=>ke.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(Me,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:ke=>ke.preventDefault(),...k,...Ie,onPlaced:()=>Q(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:Lr(k.onKeyDown,ke=>{const pe=ke.ctrlKey||ke.altKey||ke.metaKey;if(ke.key==="Tab"&&ke.preventDefault(),!pe&&ke.key.length===1&&ue(ke.key),["ArrowUp","ArrowDown","Home","End"].includes(ke.key)){let Le=Y().filter(Qe=>!Qe.disabled).map(Qe=>Qe.ref.current);if(["ArrowUp","End"].includes(ke.key)&&(Le=Le.slice().reverse()),["ArrowUp","ArrowDown"].includes(ke.key)){const Qe=ke.target,Te=Le.indexOf(Qe);Le=Le.slice(Te+1)}setTimeout(()=>ne(Le)),ke.preventDefault()}})})})})})})});qGe.displayName=XNt;var ekt="SelectItemAlignedPosition",UGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Ow(KS,r),l=Rw(KS,r),[i,c]=N.useState(null),[u,p]=N.useState(null),f=Va(s,$=>p($)),g=rue(r),v=N.useRef(!1),_=N.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:k,focusSelectedItem:S}=l,M=N.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&w&&j&&k){const $=o.trigger.getBoundingClientRect(),U=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),V=k.getBoundingClientRect();if(o.dir!=="rtl"){const Qe=V.left-U.left,Te=B.left-Qe,pt=$.left-Te,ye=$.width+pt,qe=Math.max(ye,U.width),at=window.innerWidth-Pg,tt=uD(Te,[Pg,Math.max(Pg,at-qe)]);i.style.minWidth=ye+"px",i.style.left=tt+"px"}else{const Qe=U.right-V.right,Te=window.innerWidth-B.right-Qe,pt=window.innerWidth-$.right-Te,ye=$.width+pt,qe=Math.max(ye,U.width),at=window.innerWidth-Pg,tt=uD(Te,[Pg,Math.max(Pg,at-qe)]);i.style.minWidth=ye+"px",i.style.right=tt+"px"}const X=g(),Y=window.innerHeight-Pg*2,ee=w.scrollHeight,Q=window.getComputedStyle(u),ce=parseInt(Q.borderTopWidth,10),ne=parseInt(Q.paddingTop,10),re=parseInt(Q.borderBottomWidth,10),oe=parseInt(Q.paddingBottom,10),fe=ce+ne+ee+oe+re,ge=Math.min(j.offsetHeight*5,fe),ue=window.getComputedStyle(w),xe=parseInt(ue.paddingTop,10),_e=parseInt(ue.paddingBottom,10),$e=$.top+$.height/2-Pg,Me=Y-$e,Ie=j.offsetHeight/2,ke=j.offsetTop+Ie,pe=ce+ne+ke,we=fe-pe;if(pe<=$e){const Qe=X.length>0&&j===X[X.length-1].ref.current;i.style.bottom="0px";const Te=u.clientHeight-w.offsetTop-w.offsetHeight,pt=Math.max(Me,Ie+(Qe?_e:0)+Te+re),ye=pe+pt;i.style.height=ye+"px"}else{const Qe=X.length>0&&j===X[0].ref.current;i.style.top="0px";const pt=Math.max($e,ce+w.offsetTop+(Qe?xe:0)+Ie)+we;i.style.height=pt+"px",w.scrollTop=pe-$e+w.offsetTop}i.style.margin=`${Pg}px 0`,i.style.minHeight=ge+"px",i.style.maxHeight=Y+"px",n==null||n(),requestAnimationFrame(()=>v.current=!0)}},[g,o.trigger,o.valueNode,i,u,w,j,k,o.dir,n]);jd(()=>M(),[M]);const[L,P]=N.useState();jd(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const O=N.useCallback($=>{$&&_.current===!0&&(M(),S==null||S(),_.current=!1)},[M,S]);return e.jsx(skt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:v,onScrollButtonChange:O,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:L},children:e.jsx(an.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});UGe.displayName=ekt;var tkt="SelectPopperPosition",Fve=N.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Pg,...o}=t,l=nue(r);return e.jsx(LO,{...l,...o,ref:s,align:n,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Fve.displayName=tkt;var[skt,wje]=nE(KS,{}),zve="SelectViewport",VGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Rw(zve,r),l=wje(zve,r),i=Va(s,o.onViewportChange),c=N.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),e.jsx(sue.Slot,{scope:r,children:e.jsx(an.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Lr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&f){const v=Math.abs(c.current-p.scrollTop);if(v>0){const _=window.innerHeight-Pg*2,w=parseFloat(f.style.minHeight),j=parseFloat(f.style.height),k=Math.max(w,j);if(k<_){const S=k+v,M=Math.min(_,S),L=S-M;f.style.height=M+"px",f.style.bottom==="0px"&&(p.scrollTop=L>0?L:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});VGe.displayName=zve;var HGe="SelectGroup",[rkt,nkt]=nE(HGe),akt=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Eu();return e.jsx(rkt,{scope:r,id:a,children:e.jsx(an.div,{role:"group","aria-labelledby":a,...n,ref:s})})});akt.displayName=HGe;var GGe="SelectLabel",WGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=nkt(GGe,r);return e.jsx(an.div,{id:a.id,...n,ref:s})});WGe.displayName=GGe;var Ioe="SelectItem",[ikt,KGe]=nE(Ioe),ZGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Ow(Ioe,r),c=Rw(Ioe,r),u=i.value===n,[p,f]=N.useState(o??""),[g,v]=N.useState(!1),_=Va(s,S=>{var M;return(M=c.itemRefCallback)==null?void 0:M.call(c,S,n,a)}),w=Eu(),j=N.useRef("touch"),k=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(ikt,{scope:r,value:n,disabled:a,textId:w,isSelected:u,onItemTextChange:N.useCallback(S=>{f(M=>M||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(sue.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(an.div,{role:"option","aria-labelledby":w,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:_,onFocus:Lr(l.onFocus,()=>v(!0)),onBlur:Lr(l.onBlur,()=>v(!1)),onClick:Lr(l.onClick,()=>{j.current!=="mouse"&&k()}),onPointerUp:Lr(l.onPointerUp,()=>{j.current==="mouse"&&k()}),onPointerDown:Lr(l.onPointerDown,S=>{j.current=S.pointerType}),onPointerMove:Lr(l.onPointerMove,S=>{var M;j.current=S.pointerType,a?(M=c.onItemLeave)==null||M.call(c):j.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Lr(l.onPointerLeave,S=>{var M;S.currentTarget===document.activeElement&&((M=c.onItemLeave)==null||M.call(c))}),onKeyDown:Lr(l.onKeyDown,S=>{var L;((L=c.searchRef)==null?void 0:L.current)!==""&&S.key===" "||(HNt.includes(S.key)&&k(),S.key===" "&&S.preventDefault())})})})})});ZGe.displayName=Ioe;var II="SelectItemText",YGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Ow(II,r),i=Rw(II,r),c=KGe(II,r),u=ZNt(II,r),[p,f]=N.useState(null),g=Va(s,k=>f(k),c.onItemTextChange,k=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,k,c.value,c.disabled)}),v=p==null?void 0:p.textContent,_=N.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:v},c.value),[c.disabled,c.value,v]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=u;return jd(()=>(w(_),()=>j(_)),[w,j,_]),e.jsxs(e.Fragment,{children:[e.jsx(an.span,{id:c.textId,...o,ref:g}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?yp.createPortal(o.children,l.valueNode):null]})});YGe.displayName=II;var QGe="SelectItemIndicator",XGe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return KGe(QGe,r).isSelected?e.jsx(an.span,{"aria-hidden":!0,...n,ref:s}):null});XGe.displayName=QGe;var Bve="SelectScrollUpButton",JGe=N.forwardRef((t,s)=>{const r=Rw(Bve,t.__scopeSelect),n=wje(Bve,t.__scopeSelect),[a,o]=N.useState(!1),l=Va(s,n.onScrollButtonChange);return jd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollTop>0;o(u)};const c=r.viewport;return i(),c.addEventListener("scroll",i),()=>c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(tWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});JGe.displayName=Bve;var $ve="SelectScrollDownButton",eWe=N.forwardRef((t,s)=>{const r=Rw($ve,t.__scopeSelect),n=wje($ve,t.__scopeSelect),[a,o]=N.useState(!1),l=Va(s,n.onScrollButtonChange);return jd(()=>{if(r.viewport&&r.isPositioned){let i=function(){const u=c.scrollHeight-c.clientHeight,p=Math.ceil(c.scrollTop)c.removeEventListener("scroll",i)}},[r.viewport,r.isPositioned]),a?e.jsx(tWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});eWe.displayName=$ve;var tWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Rw("SelectScrollButton",r),l=N.useRef(null),i=rue(r),c=N.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return N.useEffect(()=>()=>c(),[c]),jd(()=>{var p;const u=i().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),e.jsx(an.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Lr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Lr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Lr(a.onPointerLeave,()=>{c()})})}),okt="SelectSeparator",sWe=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(an.div,{"aria-hidden":!0,...n,ref:s})});sWe.displayName=okt;var qve="SelectArrow",lkt=N.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=nue(r),o=Ow(qve,r),l=Rw(qve,r);return o.open&&l.position==="popper"?e.jsx(DO,{...a,...n,ref:s}):null});lkt.displayName=qve;var ckt="SelectBubbleInput",rWe=N.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=N.useRef(null),o=Va(n,a),l=HO(s);return N.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("change",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(an.select,{...r,style:{...tqe,...r.style},ref:o,defaultValue:s})});rWe.displayName=ckt;function nWe(t){return t===""||t===void 0}function aWe(t){const s=bd(t),r=N.useRef(""),n=N.useRef(0),a=N.useCallback(l=>{const i=r.current+l;s(i),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(i)},[s]),o=N.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function iWe(t,s,r){const a=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,o=r?t.indexOf(r):-1;let l=dkt(t,Math.max(o,0));a.length===1&&(l=l.filter(u=>u!==r));const c=l.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function dkt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var ukt=IGe,oWe=DGe,hkt=RGe,mkt=FGe,pkt=zGe,lWe=BGe,fkt=VGe,cWe=WGe,dWe=ZGe,xkt=YGe,gkt=XGe,uWe=JGe,hWe=eWe,mWe=sWe;const Ks=ukt,Ys=hkt,Gs=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(oWe,{ref:n,className:It("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[s,e.jsx(mkt,{asChild:!0,children:e.jsx(oo,{className:"h-4 w-4 opacity-50"})})]}));Gs.displayName=oWe.displayName;const pWe=N.forwardRef(({className:t,...s},r)=>e.jsx(uWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(xf,{className:"h-4 w-4"})}));pWe.displayName=uWe.displayName;const fWe=N.forwardRef(({className:t,...s},r)=>e.jsx(hWe,{ref:r,className:It("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(oo,{className:"h-4 w-4"})}));fWe.displayName=hWe.displayName;const Ws=N.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(pkt,{children:e.jsxs(lWe,{ref:a,className:It("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(pWe,{}),e.jsx(fkt,{className:It("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(fWe,{})]})}));Ws.displayName=lWe.displayName;const ykt=N.forwardRef(({className:t,...s},r)=>e.jsx(cWe,{ref:r,className:It("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));ykt.displayName=cWe.displayName;const Mt=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(dWe,{ref:n,className:It("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(gkt,{children:e.jsx(ba,{className:"h-4 w-4"})})}),e.jsx(xkt,{children:s})]}));Mt.displayName=dWe.displayName;const vkt=N.forwardRef(({className:t,...s},r)=>e.jsx(mWe,{ref:r,className:It("-mx-1 my-1 h-px bg-muted",t),...s}));vkt.displayName=mWe.displayName;const bkt=t=>mt({queryKey:["public-listings",t],queryFn:async()=>{let s=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),xWe=t=>mt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=H.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),gWe=()=>Lt({mutationFn:async({listingId:t,agentId:s,firstName:r,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,c=null;if(l){const{data:g}=await H.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();g&&(i=g.id,c=g.sharing_agent_id)}const{data:u,error:p}=await H.from("listing_leads").insert({listing_id:t,agent_id:c||s,first_name:r,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:c}).select().single();if(p)throw p;const{error:f}=await H.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),_kt=()=>Lt({mutationFn:async t=>{const{error:s}=await H.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),wkt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},v6e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},jkt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function yWe(){const[t,s]=N.useState(""),[r,n]=N.useState(!1),[a,o]=N.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=bkt({city:t||void 0,status:a.status||void 0,propertyType:a.propertyType||void 0,minPrice:a.minPrice?Number(a.minPrice):void 0,maxPrice:a.maxPrice?Number(a.maxPrice):void 0}),c=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f),u=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),s("")},p=t||a.status||a.propertyType||a.minPrice||a.maxPrice;return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:"LevelUp Listings - Find Your Dream Home | Real Estate for Sale"}),e.jsx("meta",{name:"description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, condos, townhouses, and luxury properties. View photos, prices, and connect with agents."}),e.jsx("link",{rel:"canonical",href:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{property:"og:description",content:"Browse exclusive property listings from LevelUp real estate agents. Find homes for sale, view photos, and connect with agents."}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:"https://listings.relevelup.com"}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:"LevelUp Listings - Find Your Dream Home"}),e.jsx("meta",{name:"twitter:description",content:"Browse exclusive property listings from LevelUp real estate agents."}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"keywords",content:"homes for sale, real estate, property listings, houses, condos, townhouses, luxury homes, LevelUp"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"WebSite",name:"LevelUp Listings",url:"https://listings.relevelup.com",description:"Browse exclusive property listings from LevelUp real estate agents",potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:"https://listings.relevelup.com?q={search_term_string}"},"query-input":"required name=search_term_string"}})}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateAgent",name:"LevelUp",url:"https://relevelup.com",logo:"https://listings.relevelup.com/assets/levelup-logo-color.png"})})]}),e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("header",{className:"bg-white border-b border-gray-200 sticky top-0 z-50",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pa,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:AGe,alt:"LevelUp",className:"h-8"})}),e.jsx("nav",{className:"hidden md:flex items-center gap-6",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors",children:"About LevelUp"})})]})})}),e.jsxs("section",{className:"relative bg-cover bg-center py-20 md:py-32",style:{backgroundImage:`url(${BNt})`},children:[e.jsx("div",{className:"absolute inset-0 bg-black/40"}),e.jsxs("div",{className:"relative max-w-7xl mx-auto px-4",children:[e.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-white mb-3 text-center drop-shadow-lg",children:"Find Your Perfect Home"}),e.jsx("p",{className:"text-white/90 text-center mb-10 text-lg md:text-xl drop-shadow",children:"Exclusive listings from LevelUp agents"}),e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex gap-0 shadow-2xl rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"relative flex-1 bg-white",children:[e.jsx(sn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(ze,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:t,onChange:f=>s(f.target.value),className:"pl-12 h-14 md:h-16 text-base md:text-lg border-0 focus-visible:ring-0 rounded-none bg-white"})]}),e.jsx(K,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:e.jsx(sn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),e.jsx("div",{className:"flex justify-center mt-6",children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>n(!r),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[e.jsx(y1,{className:"h-4 w-4"}),r?"Hide Filters":"More Filters"]})}),r&&e.jsxs("div",{className:"mt-4 p-6 bg-white rounded-lg shadow-xl",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Status"}),e.jsxs(Ks,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Gs,{className:"bg-white",children:e.jsx(Ys,{placeholder:"Any status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"Any status"}),Object.entries(v6e).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),e.jsxs(Ks,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Gs,{className:"bg-white",children:e.jsx(Ys,{placeholder:"Any type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"Any type"}),Object.entries(jkt).map(([f,g])=>e.jsx(Mt,{value:f,children:g},f))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No min",value:a.minPrice,onChange:f=>o({...a,minPrice:f.target.value}),className:"bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Mr,{className:"h-4 w-4"}),"Clear all"]})})]})]})]})]}),l&&l.length>0&&e.jsx("section",{className:"py-8 bg-white border-b border-gray-200",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Explore on Map"}),e.jsx(UNt,{listings:l,isLoading:i})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((f,g)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(vs,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(vs,{className:"h-7 w-28"}),e.jsx(vs,{className:"h-4 w-full"}),e.jsx(vs,{className:"h-4 w-3/4"})]})]},g))}):l&&l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(f=>{var w,j,k;const g=((w=f.photos)==null?void 0:w.find(S=>S.is_primary))||((j=f.photos)==null?void 0:j[0]),_=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(pa,{to:_,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[g?e.jsx("img",{src:g.photo_url,alt:f.property_address||f.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(dn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(st,{className:`absolute top-2 left-2 ${wkt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:v6e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:S=>S.preventDefault(),children:e.jsx(Ya,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:c(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((k=f.agent.brokerage)==null?void 0:k.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(dn,{className:"h-10 w-10 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),e.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&e.jsx(K,{variant:"outline",onClick:u,children:"Clear filters"})]})})}),e.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("img",{src:_je,alt:"LevelUp",className:"h-6"})}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-white text-sm transition-colors",children:"relevelup.com"})]})})})]})]})}const Ee=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const Pt=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex flex-col space-y-1.5 p-6",t),...s}));Pt.displayName="CardHeader";const Rt=N.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:It("text-2xl font-semibold leading-none tracking-tight",t),...s}));Rt.displayName="CardTitle";const gr=N.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:It("text-sm text-muted-foreground",t),...s}));gr.displayName="CardDescription";const Oe=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const t8=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("flex items-center p-6 pt-0",t),...s}));t8.displayName="CardFooter";var Nkt="Label",vWe=N.forwardRef((t,s)=>e.jsx(an.label,{...t,ref:s,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));vWe.displayName=Nkt;var bWe=vWe;const kkt=b3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),be=N.forwardRef(({className:t,...s},r)=>e.jsx(bWe,{ref:r,className:It(kkt(),t),...s}));be.displayName=bWe.displayName;const Loe="/assets/levelup-logo-color-D3mY9gCJ.png";function Skt(){const t=dc(),s=window.location.hostname;if(!(s==="listings.relevelup.com"||s.startsWith("listings.")))return null;const n=t.pathname.slice(1);return!n||n===""?e.jsx(yWe,{}):n.startsWith("public/")?null:e.jsx(Ckt,{slug:n})}function Ckt({slug:t}){return e.jsx(Akt,{slug:t})}const Mkt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Tkt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},b6e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Akt({slug:t}){var B,V;const{data:s,isLoading:r}=xWe(t),n=gWe(),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(null),S=X=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(X),M=async X=>{if(X.preventDefault(),!(!a.trim()||!c.trim()||!s)){v(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:p.trim()}),w(!0),me.success("Thanks! The agent will be in touch soon.")}catch(Y){console.error("Lead submission error:",Y),me.error(`Failed to submit: ${Y.message||"Please try again"}`)}finally{v(!1)}}},L=(s==null?void 0:s.photos)||[],P=L.find(X=>X.is_primary)||L[0],O=()=>{j!==null&&k(j===0?L.length-1:j-1)},$=()=>{j!==null&&k(j===L.length-1?0:j+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(vs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(vs,{className:"h-10 w-48 mb-6"}),e.jsx(vs,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(vs,{className:"h-12 w-48"}),e.jsx(vs,{className:"h-6 w-full"}),e.jsx(vs,{className:"h-6 w-3/4"})]}),e.jsx(vs,{className:"h-64"})]})]})]});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Loe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(dn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const U=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsxs("title",{children:[U," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${b6e[s.property_type]} in ${s.city}, ${s.state}. ${((B=s.description)==null?void 0:B.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),P&&e.jsx("meta",{property:"og:image",content:P.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:Loe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs("a",{href:"/",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),L.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>k(0),children:e.jsx("img",{src:P==null?void 0:P.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:L.slice(1,5).map((X,Y)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>k(Y+1),children:[e.jsx("img",{src:X.photo_url,alt:`Photo ${Y+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),Y===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",L.length-5," more"]})]},X.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(st,{className:`${Mkt[s.status]} text-white border-0`,children:Tkt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:S(s.price)}),s.property_address&&e.jsx("p",{className:"text-xl font-medium",children:s.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),s.city,", ",s.state,s.neighborhood&&` • ${s.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[s.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Mh,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),s.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(su,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),s.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(w0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),b6e[s.property_type]]}),s.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Wi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:_?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(lr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:M,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:X=>o(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:X=>i(X.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:X=>u(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:X=>f(X.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(xs,{open:j!==null,onOpenChange:()=>k(null),children:e.jsxs(fs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{className:"sr-only",children:e.jsx(_s,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>k(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Mr,{className:"h-5 w-5"})}),j!==null&&L[j]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:L[j].photo_url,alt:`Photo ${j+1}`,className:"w-full max-h-[80vh] object-contain"}),L.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:O,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx("button",{onClick:$,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(oa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[j+1," / ",L.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function aue({card:t,variant:s}){const r=t.brokerage_display_name||t.brokerage_logo_url,n=t.team_name||t.team_logo_url;if(!r&&!n)return null;const a={standard:{container:"bg-slate-50 border border-slate-100",text:"text-slate-600",subtext:"text-slate-400"},luxury:{container:"bg-[#1e2636] border border-[#c9a84c]/10",text:"text-[#e2e8f0]",subtext:"text-[#4a5568]"},bold:{container:"bg-gray-50 border border-gray-100",text:"text-[#1a1a2e]",subtext:"text-gray-400"},classic:{container:"bg-white border border-[#d4cfc5] shadow-sm",text:"text-[#1b3a4b]",subtext:"text-[#a0aec0]"}}[s];return e.jsx("div",{className:`rounded-2xl p-4 mb-6 ${a.container}`,children:e.jsxs("div",{className:`flex flex-col items-center gap-3 ${r&&n?"divide-y divide-current/10":""}`,children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-full",children:[t.brokerage_logo_url&&e.jsx("img",{src:t.brokerage_logo_url,alt:t.brokerage_display_name||"Brokerage",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.brokerage_display_name&&!t.brokerage_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.brokerage_display_name})]}),n&&e.jsxs("div",{className:`flex flex-col items-center gap-1.5 w-full ${r?"pt-3":""}`,children:[t.team_logo_url&&e.jsx("img",{src:t.team_logo_url,alt:t.team_name||"Team",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[280px] object-contain"}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:`text-sm font-medium ${a.text}`,children:t.team_name})]})]})})}const _We=t=>mt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await H.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await H.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await H.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await H.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:c}=await H.storage.from("avatars").list(`${s.user_id}`);if(c&&c.length>0){const{data:u}=H.storage.from("avatars").getPublicUrl(`${s.user_id}/${c[0].name}`);o=`${u.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:s.display_email||(n==null?void 0:n.email)||null};return{...s,social_links:s.social_links||[],profile:l,brokerage_name:s.brokerage_display_name||a,avatar_url:o}},enabled:!!t}),Ekt=()=>mt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),Pkt=t=>mt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),wWe=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card created")},onError:s=>me.error(s.message)})},jWe=()=>{const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card updated")},onError:s=>me.error(s.message)})},go=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await H.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},Ikt=async(t,s)=>{const{error:r}=await H.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},NWe=t=>mt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await H.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(c=>c.interaction_type==="card_view").length)||0,l=(s==null?void 0:s.filter(c=>c.interaction_type==="button_click").length)||0,i=(s==null?void 0:s.filter(c=>c.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:s||[]}},enabled:!!t});function iue({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=N.useState(""),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(""),[w,j]=N.useState(!1),k=async S=>{if(S.preventDefault(),!o.trim()){me.error("Please enter your name");return}j(!0);try{await Ikt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:v.trim()||void 0,intent:f||void 0}),go(r,"lead_submitted",n),H.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:v.trim()||void 0,intent:f||void 0}}).catch(M=>console.error("Card lead notify failed:",M)),me.success(n==="booking"?"Request sent! They'll be in touch soon.":n==="connect"?"Info shared! They'll be in touch soon.":"Referral submitted! Thank you."),s(!1),l(""),c(""),p(""),g(""),_("")}catch{me.error("Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(js,{children:[e.jsx(_s,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Wr,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-name",children:"Name *"}),e.jsx(ze,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(ze,{id:"lead-phone",type:"tel",value:u,onChange:S=>p(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-email",children:"Email"}),e.jsx(ze,{id:"lead-email",type:"email",value:i,onChange:S=>c(S.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select one"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(ze,{id:"lead-message",value:v,onChange:S=>_(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const Lkt=t=>mt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),Dkt=t=>mt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),Okt=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),me.success("Block added")},onError:s=>me.error(s.message)})},Rkt=()=>{const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block updated")},onError:s=>me.error(s.message)})},Fkt=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block removed")},onError:s=>me.error(s.message)})};function zkt(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:(t.includes("iframe.mediadelivery.net"),t)}function Bkt(t){const s=t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return s?`https://www.youtube.com/embed/${s[1]}`:null}const $kt={standard:"rounded-2xl overflow-hidden mb-6 bg-slate-100",luxury:"rounded-xl overflow-hidden mb-6 bg-[#1e2636] border border-[#c9a84c]/10",bold:"rounded-2xl overflow-hidden mb-6",classic:"rounded-lg overflow-hidden mb-6 border border-[#d4cfc5] shadow-sm"};function qkt({block:t,variant:s}){const r=t.config;if(!r.video_url)return null;const n=r.video_url.includes("mediadelivery.net")||r.video_url.includes("bunnycdn.com"),a=Bkt(r.video_url),o=n||!!a,l=n?zkt(r.video_url):a||r.video_url;return e.jsx("div",{className:$kt[s],children:o?e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:l,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsx("video",{src:r.video_url,controls:!0,className:"w-full",preload:"metadata"})})}const Ukt={standard:{container:"mb-6",card:"bg-slate-50 rounded-2xl p-5 border border-slate-100",quote:"text-sm text-slate-600 italic",name:"text-sm font-semibold text-slate-800",role:"text-xs text-slate-500",dot:"bg-primary",dotInactive:"bg-slate-300",nav:"text-slate-400 hover:text-slate-600"},luxury:{container:"mb-6",card:"bg-[#1e2636] rounded-xl p-5 border border-[#c9a84c]/10",quote:"text-sm text-[#a0aec0] italic font-serif",name:"text-sm font-semibold text-white",role:"text-xs text-[#c9a84c]",dot:"bg-[#c9a84c]",dotInactive:"bg-[#2a3040]",nav:"text-[#4a5568] hover:text-[#c9a84c]"},bold:{container:"mb-6",card:"bg-[#fff3e0] rounded-2xl p-5",quote:"text-sm text-[#1a1a2e] font-medium",name:"text-sm font-black text-[#1a1a2e]",role:"text-xs text-[#ff5722] font-bold",dot:"bg-[#ff5722]",dotInactive:"bg-gray-300",nav:"text-gray-400 hover:text-[#ff5722]"},classic:{container:"mb-6",card:"bg-white rounded-lg p-5 border border-[#d4cfc5] shadow-sm",quote:"text-sm text-[#4a5568] italic font-serif",name:"text-sm font-semibold text-[#1b3a4b]",role:"text-xs text-[#5a7a6f]",dot:"bg-[#1b3a4b]",dotInactive:"bg-[#d4cfc5]",nav:"text-[#a0aec0] hover:text-[#1b3a4b]"}};function Vkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=N.useState(0);if(n.length===0)return null;const l=Ukt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(f1,{className:"h-4 w-4 mb-2 opacity-30"}),e.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:l.name,children:i.name}),i.role&&e.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[e.jsx("button",{onClick:()=>o(c=>(c-1+n.length)%n.length),className:l.nav,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((c,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(c=>(c+1)%n.length),className:l.nav,children:e.jsx(oa,{className:"h-4 w-4"})})]})]})}const Hkt={standard:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-primary/10 text-primary"},luxury:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-full bg-[#c9a84c]/10 text-[#e8d48b] border border-[#c9a84c]/20"},bold:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-black rounded-full bg-[#1a1a2e] text-white uppercase tracking-wide"},classic:{container:"flex flex-wrap gap-2 mb-6 justify-center",tag:"px-3 py-1.5 text-xs font-medium rounded-md bg-[#1b3a4b]/10 text-[#1b3a4b] border border-[#d4cfc5]"}};function Gkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Hkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Wkt={standard:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-slate-50 hover:bg-slate-100 border border-slate-100 transition-colors text-sm font-medium text-slate-700",icon:"text-primary"},luxury:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-xl bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/10 transition-colors text-sm font-medium text-[#e2e8f0]",icon:"text-[#c9a84c]"},bold:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-2xl bg-gray-50 hover:bg-gray-100 transition-colors text-sm font-bold text-[#1a1a2e]",icon:"text-[#ff5722]"},classic:{container:"space-y-2 mb-6",link:"w-full flex items-center justify-between h-12 px-4 rounded-lg bg-white hover:bg-[#f5f1eb] border border-[#d4cfc5] shadow-sm transition-colors text-sm font-medium text-[#1b3a4b]",icon:"text-[#5a7a6f]"}};function Kkt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Wkt[r];return e.jsx("div",{className:o.container,children:a.map((l,i)=>e.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(en,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Uve={instagram:{label:"Instagram",icon:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z",color:"#E4405F",hoverBg:"hover:bg-[#E4405F]/10"},facebook:{label:"Facebook",icon:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z",color:"#1877F2",hoverBg:"hover:bg-[#1877F2]/10"},linkedin:{label:"LinkedIn",icon:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z",color:"#0A66C2",hoverBg:"hover:bg-[#0A66C2]/10"},twitter:{label:"X",icon:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",color:"#000000",hoverBg:"hover:bg-black/10"},youtube:{label:"YouTube",icon:"M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814z M9.545 15.568V8.432L15.818 12z",color:"#FF0000",hoverBg:"hover:bg-[#FF0000]/10"},tiktok:{label:"TikTok",icon:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z",color:"#000000",hoverBg:"hover:bg-black/10"},zillow:{label:"Zillow",icon:"M12 0L1 6v12l11 6 11-6V6L12 0zm0 2.18L21 7.5v9L12 21.82 3 16.5v-9L12 2.18z",color:"#006AFF",hoverBg:"hover:bg-[#006AFF]/10"},realtor:{label:"Realtor",icon:"M12 2L2 7v10l10 5 10-5V7L12 2zm0 2.18l8 4v8l-8 4-8-4v-8l8-4z",color:"#D92228",hoverBg:"hover:bg-[#D92228]/10"},spotify:{label:"Spotify",icon:"M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",color:"#1DB954",hoverBg:"hover:bg-[#1DB954]/10"},apple_music:{label:"Apple Music",icon:"M23.994 6.124a9.23 9.23 0 00-.24-2.19c-.317-1.31-1.062-2.31-2.18-3.043A5.022 5.022 0 0019.7.198a10.7 10.7 0 00-1.564-.15C17.637.017 17.14 0 12.002 0h-.004C6.858 0 6.362.017 5.862.047 5.34.08 4.82.13 4.309.325a5.017 5.017 0 00-1.874.826C1.317 2.07.573 3.07.255 4.38A9.234 9.234 0 00.02 6.57C-.013 7.068-.03 7.564 0 12.002v.004c-.03 4.438.013 4.934.047 5.432.033.522.083 1.042.278 1.554a5.017 5.017 0 00.826 1.874c.92 1.118 1.92 1.862 3.23 2.18a9.23 9.23 0 002.19.24c.498.03.994.013 5.432.047h.004c4.438.034 4.934-.013 5.432-.047a9.23 9.23 0 002.19-.24c1.31-.317 2.31-1.062 3.043-2.18a5.022 5.022 0 00.627-1.874c.195-.492.245-1.012.278-1.534.03-.498.047-.994.047-5.432v-.004c.034-4.438-.013-4.934-.047-5.432zM17.42 16.41c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772 2.305 2.305 0 01-.668-1.653c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V9.472L10.2 10.637v7.093c0 .612-.15 1.21-.44 1.758a3.58 3.58 0 01-1.207 1.31c-.518.339-1.09.521-1.705.545-.13.005-.26 0-.39-.017a2.617 2.617 0 01-1.653-.772A2.305 2.305 0 014.137 18.9c-.005-.13 0-.26.017-.39.07-.52.275-.986.602-1.39a2.998 2.998 0 011.218-.94 3.14 3.14 0 011.12-.282c.17-.009.336.002.502.034V8.377c0-.453.066-.903.195-1.34a3.2 3.2 0 01.694-1.204 2.62 2.62 0 011.063-.738c.39-.14.793-.208 1.196-.196l4.84-1.01v10.52z",color:"#FA243C",hoverBg:"hover:bg-[#FA243C]/10"}};function Zkt({path:t,color:s,size:r=20}){return e.jsx("svg",{viewBox:"0 0 24 24",width:r,height:r,fill:s,children:e.jsx("path",{d:t})})}const Ykt={standard:{container:"bg-white rounded-2xl border border-slate-100 p-5 mb-6 shadow-sm",title:"text-sm font-semibold text-slate-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-slate-50 border border-slate-100 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"},luxury:{container:"bg-zinc-900/50 backdrop-blur rounded-2xl border border-amber-900/20 p-5 mb-6",title:"text-sm font-semibold text-amber-200/80 mb-3",linkClass:"h-11 w-11 rounded-xl bg-zinc-800/80 border border-amber-900/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:border-amber-500/40 hover:shadow-md hover:shadow-amber-500/10"},bold:{container:"bg-white/10 backdrop-blur rounded-2xl border border-white/20 p-5 mb-6",title:"text-sm font-semibold text-white/90 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white/10 border border-white/20 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:bg-white/20 hover:shadow-md"},classic:{container:"bg-stone-50 rounded-2xl border border-stone-200 p-5 mb-6",title:"text-sm font-semibold text-stone-800 mb-3",linkClass:"h-11 w-11 rounded-xl bg-white border border-stone-200 flex items-center justify-center transition-all duration-200 hover:scale-110 hover:shadow-md"}};function Qkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=Ykt[r];return a.length===0?null:e.jsxs("div",{className:o.container,children:[e.jsx("h3",{className:o.title,children:"Follow Me"}),e.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const c=Uve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(Zkt,{path:c.icon,color:c.color})},i)})})]})}function oue({cardId:t,variant:s}){const{data:r}=Lkt(t);if(!r||r.length===0)return null;const n=r.filter(l=>l.block_type==="social_media"&&l.is_visible),a=r.filter(l=>l.block_type!=="social_media"),o=n.length>0?{...n[0],config:{platforms:n.flatMap(l=>l.config.platforms||[])}}:null;return r.findIndex(l=>l.block_type==="social_media"),e.jsxs(e.Fragment,{children:[a.map(l=>{switch(l.block_type){case"video_intro":return e.jsx(qkt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Vkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Gkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Kkt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(Qkt,{block:o,cardId:t,variant:s})]})}async function Xkt(t){try{const s=await fetch(t);if(!s.ok)return null;const r=await s.blob(),n=r.type||"image/jpeg";return new Promise(a=>{const o=new FileReader;o.onloadend=()=>{const i=o.result.split(",")[1];a({base64:i,mimeType:n})},o.onerror=()=>a(null),o.readAsDataURL(r)})}catch{return null}}function Jkt(t){const s=t.trim().split(/\s+/);if(s.length<=1)return{first:s[0]||"",last:""};const r=s.pop();return{first:s.join(" "),last:r}}async function lue(t){const{first:s,last:r}=Jkt(t.name),n=["BEGIN:VCARD","VERSION:3.0",`FN:${t.name}`,`N:${r};${s};;;`];if(t.phone&&n.push(`TEL;TYPE=CELL:${t.phone}`),t.email&&n.push(`EMAIL;TYPE=INTERNET:${t.email}`),t.brokerage&&n.push(`ORG:${t.brokerage}`),n.push(`URL:${t.cardUrl}`),t.avatarUrl){const i=await Xkt(t.avatarUrl);if(i){const u={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${u}:${i.base64}`)}}n.push("END:VCARD");const a=new Blob([n.join(`\r `)],{type:"text/vcard"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${t.name.replace(/\s+/g,"_")}.vcf`,l.click(),URL.revokeObjectURL(o),me.success("Contact saved!")}function e4t({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{go(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),go(t.id,"button_click","book"))},g=()=>{var S,M;go(t.id,"contact_saved"),lue({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},v=async()=>{if(go(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),go(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),go(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(kn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ua,{src:t.avatar_url||void 0,alt:o}),e.jsx(Sn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',t.positioning_statement,'"']})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs(K,{onClick:c,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(Mn,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),e.jsxs(K,{onClick:u,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(so,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),e.jsxs(K,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[e.jsx(lr,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(hn,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),e.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:e.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),e.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:t.bio})]}),e.jsx(aue,{card:t,variant:"standard"}),e.jsx(oue,{cardId:t.id,variant:"standard"}),e.jsxs("div",{className:"space-y-2 mb-6",children:[t.show_save_contact&&e.jsxs(K,{variant:"ghost",onClick:g,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(vi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs(K,{variant:"ghost",onClick:()=>{go(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Jn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(hr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(El,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(nd,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(iue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function t4t({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{go(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),go(t.id,"button_click","book"))},g=()=>{var S,M;go(t.id,"contact_saved"),lue({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},v=async()=>{if(go(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:t.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),go(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),go(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(kn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Ua,{src:t.avatar_url||void 0,alt:o}),e.jsx(Sn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Mn,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:lr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),e.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:e.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),e.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:t.bio})]}),e.jsx(aue,{card:t,variant:"luxury"}),e.jsx(oue,{cardId:t.id,variant:"luxury"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(vi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{go(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(hr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(El,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:v,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(nd,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(iue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function s4t({card:t}){var M,L,P,O;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),i={accent:((L=t.bold_theme_colors)==null?void 0:L.accent)||"#ff5722",dark:((P=t.bold_theme_colors)==null?void 0:P.dark)||"#1a1a2e",button:((O=t.bold_theme_colors)==null?void 0:O.button)||"#ff5722"},c=($,U)=>{const B=parseInt($.replace("#",""),16),V=Math.max(0,(B>>16)-U),X=Math.max(0,(B>>8&255)-U),Y=Math.max(0,(B&255)-U);return`#${(V<<16|X<<8|Y).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=($,U)=>{go(t.id,"button_click",$),U()},p=()=>u("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),f=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),g=()=>u("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),v=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),go(t.id,"button_click","book"))},_=()=>{var $,U;go(t.id,"contact_saved"),lue({name:o,phone:($=t.profile)==null?void 0:$.phone,email:(U=t.profile)==null?void 0:U.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{if(go(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},j=()=>{a("referral"),r(!0),go(t.id,"button_click","refer")},k=()=>{a("connect"),r(!0),go(t.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[e.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[t.show_photo&&e.jsxs(kn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Ua,{src:t.avatar_url||void 0,alt:o}),e.jsx(Sn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),e.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:t.team_name})]}),e.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[t.positioning_statement&&e.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:t.positioning_statement}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Mn,label:"Call",handler:p},{icon:so,label:"Text",handler:f},{icon:lr,label:"Email",handler:g}].map(({icon:$,label:U,handler:B})=>e.jsxs("button",{onClick:B,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx($,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:U})]},U))}),e.jsxs("button",{onClick:v,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),e.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),t.review_snippet&&e.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:e.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:t.bio})]}),e.jsx(aue,{card:t,variant:"bold"}),e.jsx(oue,{cardId:t.id,variant:"bold"}),e.jsxs("div",{className:"space-y-1 mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(vi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{go(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Jn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(hr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(El,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(nd,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map(($,U)=>e.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(t.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[$.platform.toLowerCase()]||"🔗"},U))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(iue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function r4t({card:t}){var k;const[s,r]=N.useState(!1),[n,a]=N.useState("booking"),o=((k=t.profile)==null?void 0:k.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,M)=>{go(t.id,"button_click",S),M()},c=()=>i("call",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),u=()=>i("text",()=>{var S;(S=t.profile)!=null&&S.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),p=()=>i("email",()=>{var S;(S=t.profile)!=null&&S.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),go(t.id,"button_click","book"))},g=()=>{var S,M;go(t.id,"contact_saved"),lue({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},v=async()=>{if(go(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},_=()=>{a("referral"),r(!0),go(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),go(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(kn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Ua,{src:t.avatar_url||void 0,alt:o}),e.jsx(Sn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),t.title&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.title}),t.brokerage_name&&!t.brokerage_logo_url&&e.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:t.brokerage_name}),t.team_name&&!t.team_logo_url&&e.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:t.team_name}),t.positioning_statement&&e.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',t.positioning_statement,'"']})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:Mn,label:"Call",handler:c},{icon:so,label:"Text",handler:u},{icon:lr,label:"Email",handler:p}].map(({icon:S,label:M,handler:L})=>e.jsxs("button",{onClick:L,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:M})]},M))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(hn,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),e.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',t.review_snippet,'"']})}),t.show_bio&&t.bio&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),e.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:t.bio})]}),e.jsx(aue,{card:t,variant:"classic"}),e.jsx(oue,{cardId:t.id,variant:"classic"}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[t.show_save_contact&&e.jsxs("button",{onClick:g,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(vi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{go(t.id,"button_click","review"),window.open(t.review_source_url,"_blank")},className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Jn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(hr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(El,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:v,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(nd,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-8",children:t.social_links.slice(0,3).map((S,M)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>go(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:j[S.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(iue,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function jje({card:t}){switch(t.theme){case"luxury":return e.jsx(t4t,{card:t});case"bold":return e.jsx(s4t,{card:t});case"classic":return e.jsx(r4t,{card:t});case"standard":default:return e.jsx(e4t,{card:t})}}function n4t(){const t=dc();N.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):e.jsx(a4t,{slug:s})}function a4t({slug:t}){return e.jsx(i4t,{slug:t})}function i4t({slug:t}){var o;const{data:s,isLoading:r,error:n}=_We(t);if(N.useEffect(()=>{s!=null&&s.id&&go(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(vs,{className:"h-28 w-28 rounded-full"}),e.jsx(vs,{className:"h-6 w-48"}),e.jsx(vs,{className:"h-4 w-36"})]}),e.jsx(vs,{className:"h-12 w-full"}),e.jsx(vs,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(jje,{card:s})]})}function kWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=N.useState(n||""),[c,u]=N.useState(a||""),[p,f]=N.useState(o||""),[g,v]=N.useState(""),[_,w]=N.useState(""),[j,k]=N.useState(!1),[S,M]=N.useState(!1),L=async P=>{if(P.preventDefault(),!l.trim()){me.error("Please enter your name");return}k(!0);try{const{error:O}=await H.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:c.trim()||null,phone:p.trim()||null,intent:g||null,message:_.trim()||null});if(O)throw O;try{await H.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}H.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:c.trim()||void 0,phone:p.trim()||void 0,intent:g||void 0,message:_.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),M(!0)}catch{me.error("Something went wrong. Please try again.")}finally{k(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ba,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:L,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(ze,{id:"pres-lead-name",value:l,onChange:P=>i(P.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(ze,{id:"pres-lead-phone",type:"tel",value:p,onChange:P=>f(P.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(ze,{id:"pres-lead-email",type:"email",value:c,onChange:P=>u(P.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Ks,{value:g,onValueChange:v,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select one"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buy",children:"Buy a home"}),e.jsx(Mt,{value:"sell",children:"Sell my home"}),e.jsx(Mt,{value:"both",children:"Buy & Sell"}),e.jsx(Mt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(ze,{id:"pres-lead-message",value:_,onChange:P=>w(P.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:j,children:j?"Sending...":s})]})}function o4t(){const t=dc();N.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const s=t.pathname.slice(1);return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),e.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):e.jsx(l4t,{shareToken:s})}function l4t({shareToken:t}){var _;const[s,r]=N.useState(null),[n,a]=N.useState(!0),[o,l]=N.useState(0),[i,c]=N.useState(!1);N.useEffect(()=>{u()},[t]);const u=async()=>{const{data:w,error:j}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(j||!w){c(!0),a(!1);return}const{data:k}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(k!=null&&k.brokerage_id){const{data:L}=await H.from("brokerages").select("name").eq("id",k.brokerage_id).single();S=(L==null?void 0:L.name)||void 0}let M=null;if(w.contact_id){const{data:L}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();M=L}r({...w,owner_name:k==null?void 0:k.name,owner_email:k==null?void 0:k.email,owner_phone:k==null?void 0:k.phone,owner_avatar:k==null?void 0:k.avatar_url,owner_title:(k==null?void 0:k.title)||void 0,brokerage_name:S,contact_name:M?[M.first_name,M.last_name].filter(Boolean).join(" "):void 0,contact_email:(M==null?void 0:M.email)||void 0,contact_phone:(M==null?void 0:M.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=w=>{const j=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(j)return`https://www.youtube.com/embed/${j[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const M=w.replace("/play/","/embed/"),L=M.includes("?")?"&":"?";return`${M}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const M=w.includes("?")?"&":"?";return`${w}${M}responsive=true`}const k=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(k)return`https://www.loom.com/embed/${k[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(vs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(vs,{className:"h-64 w-full"}),e.jsx(vs,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const g=s.sections.filter(w=>w.is_visible!==!1),v=g[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[v!=null&&v.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(v.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):v!=null&&v.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:v.image_url,alt:v.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:v==null?void 0:v.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:v==null?void 0:v.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:v==null?void 0:v.description})]}),(v==null?void 0:v.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:v.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((w,j)=>e.jsx("button",{onClick:()=>l(j),className:It("w-full text-left p-4 rounded-xl border transition-all",o===j?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(j+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},j))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(_=s.cta_url)!=null&&_.trim()?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(en,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(kWe,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})}const Ux=()=>{const t=ri();return mt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await H.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function c4t(){const{user:t}=Os(),s=ri(),{data:r}=Ux();return mt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await H.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await H.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const c=[...new Set(l.map(f=>f.agent_id))],u={};if(c.length>0){const{data:f}=await H.from("profiles").select("id, name").in("id",c);f==null||f.forEach(g=>{g.name&&(u[g.id]=g.name)})}const p=l.map(f=>({...f,agent_name:u[f.agent_id]||void 0}));o=[...o,...p]}}return o.sort((l,i)=>i.event_date.localeCompare(l.event_date)),o},enabled:!!t&&!!s})}function VTs(t){const{user:s}=Os();return mt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function SWe(t){const{user:s}=Os(),r=Xt();return N.useEffect(()=>{if(!t)return;const n=H.channel(`visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${t}`},()=>{r.invalidateQueries({queryKey:["open-house-visitors",t]}),r.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{H.removeChannel(n)}},[t,r]),mt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await H.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function d4t(){const t=Xt(),s=ri();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),jn({title:"Open house created!"})},onError:r=>{jn({title:"Error",description:r.message,variant:"destructive"})}})}function CWe(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{error:n}=await H.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function u4t(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),jn({title:"Open house deleted"})}})}function h4t(t){return mt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await H.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function m4t(t){const{user:s}=Os();return mt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function p4t(t){return mt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function f4t(){return Lt({mutationFn:async t=>{const{error:s}=await H.from("open_house_survey_responses").insert(t);if(s)throw s}})}function x4t(t){const{user:s}=Os();return mt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await H.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function g4t(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function y4t(){const t=Xt();return Lt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await H.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function v4t(){const t=Xt();return Lt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await H.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function b4t(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function _4t(){return Lt({mutationFn:async t=>{const{data:s,error:r}=await H.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var cue="Switch",[w4t]=od(cue),[j4t,N4t]=w4t(cue),MWe=N.forwardRef((t,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c="on",onCheckedChange:u,form:p,...f}=t,[g,v]=N.useState(null),_=Va(s,M=>v(M)),w=N.useRef(!1),j=g?p||!!g.closest("form"):!0,[k,S]=oh({prop:a,defaultProp:o??!1,onChange:u,caller:cue});return e.jsxs(j4t,{scope:r,checked:k,disabled:i,children:[e.jsx(an.button,{type:"button",role:"switch","aria-checked":k,"aria-required":l,"data-state":PWe(k),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:_,onClick:Lr(t.onClick,M=>{S(L=>!L),j&&(w.current=M.isPropagationStopped(),w.current||M.stopPropagation())})}),j&&e.jsx(EWe,{control:g,bubbles:!w.current,name:n,value:c,checked:k,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});MWe.displayName=cue;var TWe="SwitchThumb",AWe=N.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=N4t(TWe,r);return e.jsx(an.span,{"data-state":PWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});AWe.displayName=TWe;var k4t="SwitchBubbleInput",EWe=N.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=N.useRef(null),i=Va(l,o),c=HO(r),u=PO(s);return N.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&v){const _=new Event("click",{bubbles:n});v.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});EWe.displayName=k4t;function PWe(t){return t?"checked":"unchecked"}var IWe=MWe,S4t=AWe;const qr=N.forwardRef(({className:t,...s},r)=>e.jsx(IWe,{className:It("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...s,ref:r,children:e.jsx(S4t,{className:It("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));qr.displayName=IWe.displayName;function ra(t){const s=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&s==="[object Date]"?new t.constructor(+t):typeof t=="number"||s==="[object Number]"||typeof t=="string"||s==="[object String]"?new Date(t):new Date(NaN)}function yl(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Il(t,s){const r=ra(t);return isNaN(s)?yl(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Bm(t,s){const r=ra(t);if(isNaN(s))return yl(t,NaN);if(!s)return r;const n=r.getDate(),a=yl(t,r.getTime());a.setMonth(r.getMonth()+s+1,0);const o=a.getDate();return n>=o?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}function LWe(t,s){const r=+ra(t);return yl(t,r+s)}const Nje=6048e5,C4t=864e5,due=6e4,GO=36e5,M4t=1e3,pz=43200,_6e=1440;function w6e(t,s){return LWe(t,s*GO)}let T4t={};function Fw(){return T4t}function Xh(t,s){var i,c,u,p;const r=Fw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function $m(t){const s=ra(t);return s.setHours(0,0,0,0),s}function gw(t){const s=ra(t),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+t-+r}function mf(t,s){const r=$m(t),n=$m(s),a=+r-gw(r),o=+n-gw(n);return Math.round((a-o)/C4t)}function A4t(t){const s=DWe(t),r=yl(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),D1(r)}function pM(t,s){return LWe(t,s*due)}function j4(t,s){const r=s*7;return Il(t,r)}function E4t(t,s){return Bm(t,s*12)}function P4t(t){let s;return t.forEach(function(r){const n=ra(r);(s===void 0||s{const n=ra(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function jie(t,s){const r=ra(t),n=ra(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function kje(t){return yl(t,Date.now())}function Tl(t,s){const r=$m(t),n=$m(s);return+r==+n}function Sje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Vve(t){if(!Sje(t)&&typeof t!="number")return!1;const s=ra(t);return!isNaN(Number(s))}function VT(t,s){const r=ra(t),n=ra(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function L4t(t,s,r){const n=Xh(t,r),a=Xh(s,r),o=+n-gw(n),l=+a-gw(a);return Math.round((o-l)/Nje)}function cy(t,s){const r=ra(t),n=ra(s),a=j6e(r,n),o=Math.abs(mf(r,n));r.setDate(r.getDate()-a*o);const l=+(j6e(r,n)===-a),i=a*(o-l);return i===0?0:i}function j6e(t,s){const r=t.getFullYear()-s.getFullYear()||t.getMonth()-s.getMonth()||t.getDate()-s.getDate()||t.getHours()-s.getHours()||t.getMinutes()-s.getMinutes()||t.getSeconds()-s.getSeconds()||t.getMilliseconds()-s.getMilliseconds();return r<0?-1:r>0?1:r}function OWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function RWe(t,s){return+ra(t)-+ra(s)}function D4t(t,s,r){const n=RWe(t,s)/GO;return OWe(r==null?void 0:r.roundingMethod)(n)}function O4t(t){const s=ra(t);return s.setHours(23,59,59,999),s}function dx(t){const s=ra(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function R4t(t){const s=ra(t);return+O4t(s)==+dx(s)}function F4t(t,s){const r=ra(t),n=ra(s),a=jie(r,n),o=Math.abs(VT(r,n));let l;if(o<1)l=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*o);let i=jie(r,n)===-a;R4t(ra(t))&&o===1&&jie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function z4t(t,s,r){const n=RWe(t,s)/1e3;return OWe(r==null?void 0:r.roundingMethod)(n)}function B4t(t,s){const r=ra(t.start),n=ra(t.end);let a=+r>+n;const o=a?+r:+n,l=a?n:r;l.setHours(0,0,0,0);let i=1;const c=[];for(;+l<=o;)c.push(ra(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function zc(t){const s=ra(t);return s.setDate(1),s.setHours(0,0,0,0),s}function FWe(t){const s=ra(t),r=yl(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function uue(t,s){var i,c,u,p;const r=Fw(),n=(s==null?void 0:s.weekStartsOn)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.weekStartsOn)??0,a=ra(t),o=a.getDay(),l=(o{let n;const a=$4t[t];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Fxe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const U4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},V4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},H4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},G4t={date:Fxe({formats:U4t,defaultWidth:"full"}),time:Fxe({formats:V4t,defaultWidth:"full"}),dateTime:Fxe({formats:H4t,defaultWidth:"full"})},W4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},K4t=(t,s,r,n)=>W4t[t];function XP(t){return(s,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let a;if(n==="formatting"&&t.formattingValues){const l=t.defaultFormattingWidth||t.defaultWidth,i=r!=null&&r.width?String(r.width):l;a=t.formattingValues[i]||t.formattingValues[l]}else{const l=t.defaultWidth,i=r!=null&&r.width?String(r.width):t.defaultWidth;a=t.values[i]||t.values[l]}const o=t.argumentCallback?t.argumentCallback(s):s;return a[o]}}const Z4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Y4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Q4t={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},X4t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},J4t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},eSt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},tSt=(t,s)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},sSt={ordinalNumber:tSt,era:XP({values:Z4t,defaultWidth:"wide"}),quarter:XP({values:Y4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:XP({values:Q4t,defaultWidth:"wide"}),day:XP({values:X4t,defaultWidth:"wide"}),dayPeriod:XP({values:J4t,defaultWidth:"wide",formattingValues:eSt,defaultFormattingWidth:"wide"})};function JP(t){return(s,r={})=>{const n=r.width,a=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=s.match(a);if(!o)return null;const l=o[0],i=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(i)?nSt(i,f=>f.test(l)):rSt(i,f=>f.test(l));let u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const p=s.slice(l.length);return{value:u,rest:p}}}function rSt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function nSt(t,s){for(let r=0;r{const n=s.match(t.matchPattern);if(!n)return null;const a=n[0],o=s.match(t.parsePattern);if(!o)return null;let l=t.valueCallback?t.valueCallback(o[0]):o[0];l=r.valueCallback?r.valueCallback(l):l;const i=s.slice(a.length);return{value:l,rest:i}}}const iSt=/^(\d+)(th|st|nd|rd)?/i,oSt=/\d+/i,lSt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},cSt={any:[/^b/i,/^(a|c)/i]},dSt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},uSt={any:[/1/i,/2/i,/3/i,/4/i]},hSt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},mSt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},pSt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},fSt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},xSt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},gSt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ySt={ordinalNumber:aSt({matchPattern:iSt,parsePattern:oSt,valueCallback:t=>parseInt(t,10)}),era:JP({matchPatterns:lSt,defaultMatchWidth:"wide",parsePatterns:cSt,defaultParseWidth:"any"}),quarter:JP({matchPatterns:dSt,defaultMatchWidth:"wide",parsePatterns:uSt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:JP({matchPatterns:hSt,defaultMatchWidth:"wide",parsePatterns:mSt,defaultParseWidth:"any"}),day:JP({matchPatterns:pSt,defaultMatchWidth:"wide",parsePatterns:fSt,defaultParseWidth:"any"}),dayPeriod:JP({matchPatterns:xSt,defaultMatchWidth:"any",parsePatterns:gSt,defaultParseWidth:"any"})},hue={code:"en-US",formatDistance:q4t,formatLong:G4t,formatRelative:K4t,localize:sSt,match:ySt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function vSt(t){const s=ra(t);return mf(s,FWe(s))+1}function Cje(t){const s=ra(t),r=+D1(s)-+A4t(s);return Math.round(r/Nje)+1}function Mje(t,s){var p,f,g,v;const r=ra(t),n=r.getFullYear(),a=Fw(),o=(s==null?void 0:s.firstWeekContainsDate)??((f=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((v=(g=a.locale)==null?void 0:g.options)==null?void 0:v.firstWeekContainsDate)??1,l=yl(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Xh(l,s),c=yl(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=Xh(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function bSt(t,s){var i,c,u,p;const r=Fw(),n=(s==null?void 0:s.firstWeekContainsDate)??((c=(i=s==null?void 0:s.locale)==null?void 0:i.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((p=(u=r.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??1,a=Mje(t,s),o=yl(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Xh(o,s)}function Tje(t,s){const r=ra(t),n=+Xh(r,s)-+bSt(r,s);return Math.round(n/Nje)+1}function gl(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Bb={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return gl(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):gl(r+1,2)},d(t,s){return gl(t.getDate(),s.length)},a(t,s){const r=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,s){return gl(t.getHours()%12||12,s.length)},H(t,s){return gl(t.getHours(),s.length)},m(t,s){return gl(t.getMinutes(),s.length)},s(t,s){return gl(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return gl(a,s.length)}},T5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},N6e={G:function(t,s,r){const n=t.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,s,r){if(s==="yo"){const n=t.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Bb.y(t,s)},Y:function(t,s,r,n){const a=Mje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return gl(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):gl(o,s.length)},R:function(t,s){const r=DWe(t);return gl(r,s.length)},u:function(t,s){const r=t.getFullYear();return gl(r,s.length)},Q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return gl(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,s,r){const n=Math.ceil((t.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return gl(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,s,r){const n=t.getMonth();switch(s){case"M":case"MM":return Bb.M(t,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,s,r){const n=t.getMonth();switch(s){case"L":return String(n+1);case"LL":return gl(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,s,r,n){const a=Tje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):gl(a,s.length)},I:function(t,s,r){const n=Cje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):gl(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Bb.d(t,s)},D:function(t,s,r){const n=vSt(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):gl(n,s.length)},E:function(t,s,r){const n=t.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(o);case"ee":return gl(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(t,s,r,n){const a=t.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(o);case"cc":return gl(o,s.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(t,s,r){const n=t.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return gl(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,s,r){const a=t.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,s,r){const n=t.getHours();let a;switch(n===12?a=T5.noon:n===0?a=T5.midnight:a=n/12>=1?"pm":"am",s){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,s,r){const n=t.getHours();let a;switch(n>=17?a=T5.evening:n>=12?a=T5.afternoon:n>=4?a=T5.morning:a=T5.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,s,r){if(s==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Bb.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Bb.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):gl(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):gl(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Bb.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Bb.s(t,s)},S:function(t,s){return Bb.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return S6e(n);case"XXXX":case"XX":return c4(n);case"XXXXX":case"XXX":default:return c4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return S6e(n);case"xxxx":case"xx":return c4(n);case"xxxxx":case"xxx":default:return c4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+k6e(n,":");case"OOOO":default:return"GMT"+c4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+k6e(n,":");case"zzzz":default:return"GMT"+c4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return gl(n,s.length)},T:function(t,s,r){const n=t.getTime();return gl(n,s.length)}};function k6e(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=Math.trunc(n/60),o=n%60;return o===0?r+String(a):r+String(a)+s+gl(o,2)}function S6e(t,s){return t%60===0?(t>0?"-":"+")+gl(Math.abs(t)/60,2):c4(t,s)}function c4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=gl(Math.trunc(n/60),2),o=gl(n%60,2);return r+a+s+o}const C6e=(t,s)=>{switch(t){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});case"PPPP":default:return s.date({width:"full"})}},BWe=(t,s)=>{switch(t){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});case"pppp":default:return s.time({width:"full"})}},_St=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return C6e(t,s);let o;switch(n){case"P":o=s.dateTime({width:"short"});break;case"PP":o=s.dateTime({width:"medium"});break;case"PPP":o=s.dateTime({width:"long"});break;case"PPPP":default:o=s.dateTime({width:"full"});break}return o.replace("{{date}}",C6e(n,s)).replace("{{time}}",BWe(a,s))},Hve={p:BWe,P:_St},wSt=/^D+$/,jSt=/^Y+$/,NSt=["D","DD","YY","YYYY"];function $We(t){return wSt.test(t)}function qWe(t){return jSt.test(t)}function Gve(t,s,r){const n=kSt(t,s,r);if(console.warn(n),NSt.includes(t))throw new RangeError(n)}function kSt(t,s,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const SSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,CSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,MSt=/^'([^]*?)'?$/,TSt=/''/g,ASt=/[a-zA-Z]/;function ms(t,s,r){var p,f,g,v,_,w,j,k;const n=Fw(),a=(r==null?void 0:r.locale)??n.locale??hue,o=(r==null?void 0:r.firstWeekContainsDate)??((f=(p=r==null?void 0:r.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((v=(g=n.locale)==null?void 0:g.options)==null?void 0:v.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((w=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((k=(j=n.locale)==null?void 0:j.options)==null?void 0:k.weekStartsOn)??0,i=ra(t);if(!Vve(i))throw new RangeError("Invalid time value");let c=s.match(CSt).map(S=>{const M=S[0];if(M==="p"||M==="P"){const L=Hve[M];return L(S,a.formatLong)}return S}).join("").match(SSt).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const M=S[0];if(M==="'")return{isToken:!1,value:ESt(S)};if(N6e[M])return{isToken:!0,value:S};if(M.match(ASt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:S}});a.localize.preprocessor&&(c=a.localize.preprocessor(i,c));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return c.map(S=>{if(!S.isToken)return S.value;const M=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&qWe(M)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&$We(M))&&Gve(M,s,String(t));const L=N6e[M[0]];return L(i,M,a.localize,u)}).join("")}function ESt(t){const s=t.match(MSt);return s?s[1].replace(TSt,"'"):t}function PSt(t,s,r){const n=Fw(),a=(r==null?void 0:r.locale)??n.locale??hue,o=2520,l=jie(t,s);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:l});let c,u;l>0?(c=ra(s),u=ra(t)):(c=ra(t),u=ra(s));const p=z4t(u,c),f=(gw(u)-gw(c))/1e3,g=Math.round((p-f)/60);let v;if(g<2)return r!=null&&r.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):g===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",g,i);if(g<45)return a.formatDistance("xMinutes",g,i);if(g<90)return a.formatDistance("aboutXHours",1,i);if(g<_6e){const _=Math.round(g/60);return a.formatDistance("aboutXHours",_,i)}else{if(gn.getTime()}function YS(t,s){const r=ra(t),n=ra(s);return+r<+n}function zSt(t){return+ra(t)>Date.now()}function BSt(t,s){const r=s instanceof Date?yl(s,0):new s(0);return r.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),r.setHours(t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()),r}const $St=10;class UWe{constructor(){An(this,"subPriority",0)}validate(s,r){return!0}}class qSt extends UWe{constructor(s,r,n,a,o){super(),this.value=s,this.validateValue=r,this.setValue=n,this.priority=a,o&&(this.subPriority=o)}validate(s,r){return this.validateValue(s,this.value,r)}set(s,r,n){return this.setValue(s,r,this.value,n)}}class USt extends UWe{constructor(){super(...arguments);An(this,"priority",$St);An(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:yl(r,BSt(r,Date))}}class ll{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new qSt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class VSt extends ll{constructor(){super(...arguments);An(this,"priority",140);An(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"});case"GGGGG":return a.era(r,{width:"narrow"});case"GGGG":default:return a.era(r,{width:"wide"})||a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"})}}set(r,n,a){return n.era=a,r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}const Ld={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},a0={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Dd(t,s){return t&&{value:s(t.value),rest:t.rest}}function ed(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function i0(t,s){const r=s.match(t);if(!r)return null;if(r[0]==="Z")return{value:0,rest:s.slice(1)};const n=r[1]==="+"?1:-1,a=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,l=r[5]?parseInt(r[5],10):0;return{value:n*(a*GO+o*due+l*M4t),rest:s.slice(r[0].length)}}function VWe(t){return ed(Ld.anyDigitsSigned,t)}function Nd(t,s){switch(t){case 1:return ed(Ld.singleDigit,s);case 2:return ed(Ld.twoDigits,s);case 3:return ed(Ld.threeDigits,s);case 4:return ed(Ld.fourDigits,s);default:return ed(new RegExp("^\\d{1,"+t+"}"),s)}}function Doe(t,s){switch(t){case 1:return ed(Ld.singleDigitSigned,s);case 2:return ed(Ld.twoDigitsSigned,s);case 3:return ed(Ld.threeDigitsSigned,s);case 4:return ed(Ld.fourDigitsSigned,s);default:return ed(new RegExp("^-?\\d{1,"+t+"}"),s)}}function Aje(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function HWe(t,s){const r=s>0,n=r?s:1-s;let a;if(n<=50)a=t||100;else{const o=n+50,l=Math.trunc(o/100)*100,i=t>=o%100;a=t+l-(i?100:0)}return r?a:1-a}function GWe(t){return t%400===0||t%4===0&&t%100!==0}class HSt extends ll{constructor(){super(...arguments);An(this,"priority",130);An(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="yy"});switch(n){case"y":return Dd(Nd(4,r),o);case"yo":return Dd(a.ordinalNumber(r,{unit:"year"}),o);default:return Dd(Nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a){const o=r.getFullYear();if(a.isTwoDigitYear){const i=HWe(a.year,o);return r.setFullYear(i,0,1),r.setHours(0,0,0,0),r}const l=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(l,0,1),r.setHours(0,0,0,0),r}}class GSt extends ll{constructor(){super(...arguments);An(this,"priority",130);An(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(r,n,a){const o=l=>({year:l,isTwoDigitYear:n==="YY"});switch(n){case"Y":return Dd(Nd(4,r),o);case"Yo":return Dd(a.ordinalNumber(r,{unit:"year"}),o);default:return Dd(Nd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=Mje(r,o);if(a.isTwoDigitYear){const c=HWe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}const i=!("era"in n)||n.era===1?a.year:1-a.year;return r.setFullYear(i,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Xh(r,o)}}class WSt extends ll{constructor(){super(...arguments);An(this,"priority",130);An(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return Doe(n==="R"?4:n.length,r)}set(r,n,a){const o=yl(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),D1(o)}}class KSt extends ll{constructor(){super(...arguments);An(this,"priority",130);An(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return Doe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class ZSt extends ll{constructor(){super(...arguments);An(this,"priority",120);An(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"Q":case"QQ":return Nd(n.length,r);case"Qo":return a.ordinalNumber(r,{unit:"quarter"});case"QQQ":return a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(r,{width:"wide",context:"formatting"})||a.quarter(r,{width:"abbreviated",context:"formatting"})||a.quarter(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class YSt extends ll{constructor(){super(...arguments);An(this,"priority",120);An(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"q":case"qq":return Nd(n.length,r);case"qo":return a.ordinalNumber(r,{unit:"quarter"});case"qqq":return a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(r,{width:"wide",context:"standalone"})||a.quarter(r,{width:"abbreviated",context:"standalone"})||a.quarter(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=1&&n<=4}set(r,n,a){return r.setMonth((a-1)*3,1),r.setHours(0,0,0,0),r}}class QSt extends ll{constructor(){super(...arguments);An(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);An(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Dd(ed(Ld.month,r),o);case"MM":return Dd(Nd(2,r),o);case"Mo":return Dd(a.ordinalNumber(r,{unit:"month"}),o);case"MMM":return a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(r,{width:"wide",context:"formatting"})||a.month(r,{width:"abbreviated",context:"formatting"})||a.month(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}class XSt extends ll{constructor(){super(...arguments);An(this,"priority",110);An(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(r,n,a){const o=l=>l-1;switch(n){case"L":return Dd(ed(Ld.month,r),o);case"LL":return Dd(Nd(2,r),o);case"Lo":return Dd(a.ordinalNumber(r,{unit:"month"}),o);case"LLL":return a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(r,{width:"wide",context:"standalone"})||a.month(r,{width:"abbreviated",context:"standalone"})||a.month(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.setMonth(a,1),r.setHours(0,0,0,0),r}}function JSt(t,s,r){const n=ra(t),a=Tje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class e3t extends ll{constructor(){super(...arguments);An(this,"priority",100);An(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return ed(Ld.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Xh(JSt(r,a,o),o)}}function t3t(t,s){const r=ra(t),n=Cje(r)-s;return r.setDate(r.getDate()-n*7),r}class s3t extends ll{constructor(){super(...arguments);An(this,"priority",100);An(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(r,n,a){switch(n){case"I":return ed(Ld.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return D1(t3t(r,a))}}const r3t=[31,28,31,30,31,30,31,31,30,31,30,31],n3t=[31,29,31,30,31,30,31,31,30,31,30,31];class a3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"subPriority",1);An(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return ed(Ld.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return Nd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=GWe(a),l=r.getMonth();return o?n>=1&&n<=n3t[l]:n>=1&&n<=r3t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class i3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"subpriority",1);An(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(r,n,a){switch(n){case"D":case"DD":return ed(Ld.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return Nd(n.length,r)}}validate(r,n){const a=r.getFullYear();return GWe(a)?n>=1&&n<=366:n>=1&&n<=365}set(r,n,a){return r.setMonth(0,a),r.setHours(0,0,0,0),r}}function Eje(t,s,r){var f,g,v,_;const n=Fw(),a=(r==null?void 0:r.weekStartsOn)??((g=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:g.weekStartsOn)??n.weekStartsOn??((_=(v=n.locale)==null?void 0:v.options)==null?void 0:_.weekStartsOn)??0,o=ra(t),l=o.getDay(),c=(s%7+7)%7,u=7-a,p=s<0||s>6?s-(l+u)%7:(c+u)%7-(l+u)%7;return Il(o,p)}class o3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"E":case"EE":case"EEE":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=Eje(r,a,o),r.setHours(0,0,0,0),r}}class l3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"e":case"ee":return Dd(Nd(n.length,r),l);case"eo":return Dd(a.ordinalNumber(r,{unit:"day"}),l);case"eee":return a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeeee":return a.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=Eje(r,a,o),r.setHours(0,0,0,0),r}}class c3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(r,n,a,o){const l=i=>{const c=Math.floor((i-1)/7)*7;return(i+o.weekStartsOn+6)%7+c};switch(n){case"c":case"cc":return Dd(Nd(n.length,r),l);case"co":return Dd(a.ordinalNumber(r,{unit:"day"}),l);case"ccc":return a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"ccccc":return a.day(r,{width:"narrow",context:"standalone"});case"cccccc":return a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(r,{width:"wide",context:"standalone"})||a.day(r,{width:"abbreviated",context:"standalone"})||a.day(r,{width:"short",context:"standalone"})||a.day(r,{width:"narrow",context:"standalone"})}}validate(r,n){return n>=0&&n<=6}set(r,n,a,o){return r=Eje(r,a,o),r.setHours(0,0,0,0),r}}function d3t(t,s){const r=ra(t),n=DSt(r),a=s-n;return Il(r,a)}class u3t extends ll{constructor(){super(...arguments);An(this,"priority",90);An(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(r,n,a){const o=l=>l===0?7:l;switch(n){case"i":case"ii":return Nd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Dd(a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiii":return Dd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Dd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Dd(a.day(r,{width:"wide",context:"formatting"})||a.day(r,{width:"abbreviated",context:"formatting"})||a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o)}}validate(r,n){return n>=1&&n<=7}set(r,n,a){return r=d3t(r,a),r.setHours(0,0,0,0),r}}class h3t extends ll{constructor(){super(...arguments);An(this,"priority",80);An(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(Aje(a),0,0,0),r}}class m3t extends ll{constructor(){super(...arguments);An(this,"priority",80);An(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(Aje(a),0,0,0),r}}class p3t extends ll{constructor(){super(...arguments);An(this,"priority",80);An(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(Aje(a),0,0,0),r}}class f3t extends ll{constructor(){super(...arguments);An(this,"priority",70);An(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return ed(Ld.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=12}set(r,n,a){const o=r.getHours()>=12;return o&&a<12?r.setHours(a+12,0,0,0):!o&&a===12?r.setHours(0,0,0,0):r.setHours(a,0,0,0),r}}class x3t extends ll{constructor(){super(...arguments);An(this,"priority",70);An(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return ed(Ld.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class g3t extends ll{constructor(){super(...arguments);An(this,"priority",70);An(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return ed(Ld.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=11}set(r,n,a){return r.getHours()>=12&&a<12?r.setHours(a+12,0,0,0):r.setHours(a,0,0,0),r}}class y3t extends ll{constructor(){super(...arguments);An(this,"priority",70);An(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return ed(Ld.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return Nd(n.length,r)}}validate(r,n){return n>=1&&n<=24}set(r,n,a){const o=a<=24?a%24:a;return r.setHours(o,0,0,0),r}}class v3t extends ll{constructor(){super(...arguments);An(this,"priority",60);An(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return ed(Ld.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class b3t extends ll{constructor(){super(...arguments);An(this,"priority",50);An(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return ed(Ld.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return Nd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class _3t extends ll{constructor(){super(...arguments);An(this,"priority",30);An(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Dd(Nd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class w3t extends ll{constructor(){super(...arguments);An(this,"priority",10);An(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return i0(a0.basicOptionalMinutes,r);case"XX":return i0(a0.basic,r);case"XXXX":return i0(a0.basicOptionalSeconds,r);case"XXXXX":return i0(a0.extendedOptionalSeconds,r);case"XXX":default:return i0(a0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:yl(r,r.getTime()-gw(r)-a)}}class j3t extends ll{constructor(){super(...arguments);An(this,"priority",10);An(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return i0(a0.basicOptionalMinutes,r);case"xx":return i0(a0.basic,r);case"xxxx":return i0(a0.basicOptionalSeconds,r);case"xxxxx":return i0(a0.extendedOptionalSeconds,r);case"xxx":default:return i0(a0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:yl(r,r.getTime()-gw(r)-a)}}class N3t extends ll{constructor(){super(...arguments);An(this,"priority",40);An(this,"incompatibleTokens","*")}parse(r){return VWe(r)}set(r,n,a){return[yl(r,a*1e3),{timestampIsSet:!0}]}}class k3t extends ll{constructor(){super(...arguments);An(this,"priority",20);An(this,"incompatibleTokens","*")}parse(r){return VWe(r)}set(r,n,a){return[yl(r,a),{timestampIsSet:!0}]}}const S3t={G:new VSt,y:new HSt,Y:new GSt,R:new WSt,u:new KSt,Q:new ZSt,q:new YSt,M:new QSt,L:new XSt,w:new e3t,I:new s3t,d:new a3t,D:new i3t,E:new o3t,e:new l3t,c:new c3t,i:new u3t,a:new h3t,b:new m3t,B:new p3t,h:new f3t,H:new x3t,K:new g3t,k:new y3t,m:new v3t,s:new b3t,S:new _3t,X:new w3t,x:new j3t,t:new N3t,T:new k3t},C3t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,M3t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,T3t=/^'([^]*?)'?$/,A3t=/''/g,E3t=/\S/,P3t=/[a-zA-Z]/;function Pje(t,s,r,n){var w,j,k,S;const a=LSt(),o=a.locale??hue,l=a.firstWeekContainsDate??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(k=a.locale)==null?void 0:k.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?ra(r):yl(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new USt],p=s.match(M3t).map(M=>{const L=M[0];if(L in Hve){const P=Hve[L];return P(M,o.formatLong)}return M}).join("").match(C3t),f=[];for(let M of p){qWe(M)&&Gve(M,s,t),$We(M)&&Gve(M,s,t);const L=M[0],P=S3t[L];if(P){const{incompatibleTokens:O}=P;if(Array.isArray(O)){const U=f.find(B=>O.includes(B.token)||B.token===L);if(U)throw new RangeError(`The format string mustn't contain \`${U.fullToken}\` and \`${M}\` at the same time`)}else if(P.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${M}\` and any other token at the same time`);f.push({token:L,fullToken:M});const $=P.run(t,M,o.match,c);if(!$)return yl(r,NaN);u.push($.setter),t=$.rest}else{if(L.match(P3t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+L+"`");if(M==="''"?M="'":L==="'"&&(M=I3t(M)),t.indexOf(M)===0)t=t.slice(M.length);else return yl(r,NaN)}}if(t.length>0&&E3t.test(t))return yl(r,NaN);const g=u.map(M=>M.priority).sort((M,L)=>L-M).filter((M,L,P)=>P.indexOf(M)===L).map(M=>u.filter(L=>L.priority===M).sort((L,P)=>P.subPriority-L.subPriority)).map(M=>M[0]);let v=ra(r);if(isNaN(v.getTime()))return yl(r,NaN);const _={};for(const M of g){if(!M.validate(v,c))return yl(r,NaN);const L=M.set(v,_,c);Array.isArray(L)?(v=L[0],Object.assign(_,L[1])):v=L}return yl(r,v)}function I3t(t){return t.match(T3t)[1].replace(A3t,"'")}function k0(t){return+ra(t)o-l);return r>=n&&r<=a}function Nie(t,s){return Il(t,-s)}function Nm(t,s){const n=B3t(t);let a;if(n.date){const c=$3t(n.date,2);a=q3t(c.restDateString,c.year)}if(!a||isNaN(a.getTime()))return new Date(NaN);const o=a.getTime();let l=0,i;if(n.time&&(l=U3t(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=V3t(n.timezone),isNaN(i))return new Date(NaN)}else{const c=new Date(o+l),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(o+l+i)}const fz={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},R3t=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,F3t=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,z3t=/^([+-])(\d{2})(?::?(\d{2}))?$/;function B3t(t){const s={},r=t.split(fz.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],fz.timeZoneDelimiter.test(s.date)&&(s.date=t.split(fz.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=fz.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function $3t(t,s){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+s)+"})|(\\d{2}|[+-]\\d{"+(2+s)+"})$)"),n=t.match(r);if(!n)return{year:NaN,restDateString:""};const a=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?a:o*100,restDateString:t.slice((n[1]||n[2]).length)}}function q3t(t,s){if(s===null)return new Date(NaN);const r=t.match(R3t);if(!r)return new Date(NaN);const n=!!r[4],a=eI(r[1]),o=eI(r[2])-1,l=eI(r[3]),i=eI(r[4]),c=eI(r[5])-1;if(n)return Z3t(s,i,c)?H3t(s,i,c):new Date(NaN);{const u=new Date(0);return!W3t(s,o,l)||!K3t(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function eI(t){return t?parseInt(t):1}function U3t(t){const s=t.match(F3t);if(!s)return NaN;const r=zxe(s[1]),n=zxe(s[2]),a=zxe(s[3]);return Y3t(r,n,a)?r*GO+n*due+a*1e3:NaN}function zxe(t){return t&&parseFloat(t.replace(",","."))||0}function V3t(t){if(t==="Z")return 0;const s=t.match(z3t);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return Q3t(n,a)?r*(n*GO+a*due):NaN}function H3t(t,s,r){const n=new Date(0);n.setUTCFullYear(t,0,4);const a=n.getUTCDay()||7,o=(s-1)*7+r+1-a;return n.setUTCDate(n.getUTCDate()+o),n}const G3t=[31,null,31,30,31,30,31,31,30,31,30,31];function WWe(t){return t%400===0||t%4===0&&t%100!==0}function W3t(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(G3t[s]||(WWe(t)?29:28))}function K3t(t,s){return s>=1&&s<=(WWe(t)?366:365)}function Z3t(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function Y3t(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function Q3t(t,s){return s>=0&&s<=59}function Bxe(t,s){const r=ra(t),n=r.getFullYear(),a=r.getDate(),o=yl(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=ISt(o);return r.setMonth(s,Math.min(a,l)),r}function s8(t,s){const r=ra(t);return r.setHours(s),r}function r8(t,s){const r=ra(t);return r.setMinutes(s),r}function T6e(t,s){const r=ra(t);return isNaN(+r)?yl(t,NaN):(r.setFullYear(s),r)}function N4(t,s){return Bm(t,-s)}var Ko;(function(t){t.assertEqual=a=>{};function s(a){}t.assertIs=s;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const o={};for(const l of a)o[l]=l;return o},t.getValidEnumValues=a=>{const o=t.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),l={};for(const i of o)l[i]=a[i];return t.objectValues(l)},t.objectValues=a=>t.objectKeys(a).map(function(o){return a[o]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const o=[];for(const l in a)Object.prototype.hasOwnProperty.call(a,l)&&o.push(l);return o},t.find=(a,o)=>{for(const l of a)if(o(l))return l},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,o=" | "){return a.map(l=>typeof l=="string"?`'${l}'`:l).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(Ko||(Ko={}));var A6e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(A6e||(A6e={}));const ma=Ko.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Jb=t=>{switch(typeof t){case"undefined":return ma.undefined;case"string":return ma.string;case"number":return Number.isNaN(t)?ma.nan:ma.number;case"boolean":return ma.boolean;case"function":return ma.function;case"bigint":return ma.bigint;case"symbol":return ma.symbol;case"object":return Array.isArray(t)?ma.array:t===null?ma.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ma.promise:typeof Map<"u"&&t instanceof Map?ma.map:typeof Set<"u"&&t instanceof Set?ma.set:typeof Date<"u"&&t instanceof Date?ma.date:ma.object;default:return ma.unknown}},ln=Ko.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class P0 extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(o){return o.message},n={_errors:[]},a=o=>{for(const l of o.issues)if(l.code==="invalid_union")l.unionErrors.map(a);else if(l.code==="invalid_return_type")a(l.returnTypeError);else if(l.code==="invalid_arguments")a(l.argumentsError);else if(l.path.length===0)n._errors.push(r(l));else{let i=n,c=0;for(;cr.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];r[o]=r[o]||[],r[o].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}P0.create=t=>new P0(t);const Wve=(t,s)=>{let r;switch(t.code){case ln.invalid_type:t.received===ma.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case ln.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ko.jsonStringifyReplacer)}`;break;case ln.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ko.joinValues(t.keys,", ")}`;break;case ln.invalid_union:r="Invalid input";break;case ln.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ko.joinValues(t.options)}`;break;case ln.invalid_enum_value:r=`Invalid enum value. Expected ${Ko.joinValues(t.options)}, received '${t.received}'`;break;case ln.invalid_arguments:r="Invalid function arguments";break;case ln.invalid_return_type:r="Invalid function return type";break;case ln.invalid_date:r="Invalid date";break;case ln.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ko.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case ln.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case ln.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case ln.custom:r="Invalid input";break;case ln.invalid_intersection_types:r="Intersection results could not be merged";break;case ln.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case ln.not_finite:r="Number must be finite";break;default:r=s.defaultError,Ko.assertNever(t)}return{message:r}};let X3t=Wve;function J3t(){return X3t}const eCt=t=>{const{data:s,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)i=u(l,{data:s,defaultError:i}).message;return{...a,path:o,message:i}};function Qn(t,s){const r=J3t(),n=eCt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Wve?void 0:Wve].filter(a=>!!a)});t.common.issues.push(n)}class Tf{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return Fi;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return Tf.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return Fi;o.status==="dirty"&&s.dirty(),l.status==="dirty"&&s.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:s.value,value:n}}}const Fi=Object.freeze({status:"aborted"}),LI=t=>({status:"dirty",value:t}),Vx=t=>({status:"valid",value:t}),E6e=t=>t.status==="aborted",P6e=t=>t.status==="dirty",HT=t=>t.status==="valid",Ooe=t=>typeof Promise<"u"&&t instanceof Promise;var ka;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ka||(ka={}));class yw{constructor(s,r,n,a){this._cachedPath=[],this.parent=s,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const I6e=(t,s)=>{if(HT(s))return{success:!0,data:s.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new P0(t.common.issues);return this._error=r,this._error}}};function io(t){if(!t)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=t;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,description:a}:{errorMap:(l,i)=>{const{message:c}=t;return l.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??n??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:c??r??i.defaultError}},description:a}}class Vo{get description(){return this._def.description}_getType(s){return Jb(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Jb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Tf,ctx:{common:s.parent.common,data:s.data,parsedType:Jb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(Ooe(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(s){const r=this._parse(s);return Promise.resolve(r)}parse(s,r){const n=this.safeParse(s,r);if(n.success)return n.data;throw n.error}safeParse(s,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Jb(s)},a=this._parseSync({data:s,path:n.path,parent:n});return I6e(n,a)}"~validate"(s){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Jb(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return HT(o)?{value:o.value}:{issues:r.common.issues}}catch(o){(a=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:s,path:[],parent:r}).then(o=>HT(o)?{value:o.value}:{issues:r.common.issues})}async parseAsync(s,r){const n=await this.safeParseAsync(s,r);if(n.success)return n.data;throw n.error}async safeParseAsync(s,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Jb(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(Ooe(a)?a:Promise.resolve(a));return I6e(n,o)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,o)=>{const l=s(a),i=()=>o.addIssue({code:ln.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(c=>c?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new KT({schema:this,typeName:zi.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return sw.create(this,this._def)}nullable(){return ZT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S0.create(this)}promise(){return Boe.create(this,this._def)}or(s){return Foe.create([this,s],this._def)}and(s){return zoe.create(this,s,this._def)}transform(s){return new KT({...io(this._def),schema:this,typeName:zi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Qve({...io(this._def),innerType:this,defaultValue:r,typeName:zi.ZodDefault})}brand(){return new jCt({typeName:zi.ZodBranded,type:this,...io(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Xve({...io(this._def),innerType:this,catchValue:r,typeName:zi.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return Ije.create(this,s)}readonly(){return Jve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const tCt=/^c[^\s-]{8,}$/i,sCt=/^[0-9a-z]+$/,rCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,nCt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,aCt=/^[a-z0-9_-]{21}$/i,iCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oCt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lCt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $xe;const dCt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,uCt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,hCt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,mCt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,KWe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xCt=new RegExp(`^${KWe}$`);function ZWe(t){let s="[0-5]\\d";t.precision?s=`${s}\\.\\d{${t.precision}}`:t.precision==null&&(s=`${s}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${s})${r}`}function gCt(t){return new RegExp(`^${ZWe(t)}$`)}function yCt(t){let s=`${KWe}T${ZWe(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${r.join("|")})`,new RegExp(`^${s}$`)}function vCt(t,s){return!!((s==="v4"||!s)&&dCt.test(t)||(s==="v6"||!s)&&hCt.test(t))}function bCt(t,s){if(!iCt.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||s&&a.alg!==s)}catch{return!1}}function _Ct(t,s){return!!((s==="v4"||!s)&&uCt.test(t)||(s==="v6"||!s)&&mCt.test(t))}class A_ extends Vo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ma.string){const o=this._getOrReturnCtx(s);return Qn(o,{code:ln.invalid_type,expected:ma.string,received:o.parsedType}),Fi}const n=new Tf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Qn(a,{code:ln.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const l=s.data.length>o.value,i=s.data.lengths.test(a),{validation:r,code:ln.invalid_string,...ka.errToObj(n)})}_addCheck(s){return new A_({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ka.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ka.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ka.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ka.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ka.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ka.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ka.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ka.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ka.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ka.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ka.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ka.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ka.errToObj(s)})}datetime(s){return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,offset:(s==null?void 0:s.offset)??!1,local:(s==null?void 0:s.local)??!1,...ka.errToObj(s==null?void 0:s.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof(s==null?void 0:s.precision)>"u"?null:s==null?void 0:s.precision,...ka.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ka.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ka.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ka.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ka.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ka.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ka.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ka.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ka.errToObj(r)})}nonempty(s){return this.min(1,ka.errToObj(s))}trim(){return new A_({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new A_({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new A_({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isCIDR(){return!!this._def.checks.find(s=>s.kind==="cidr")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get isBase64url(){return!!this._def.checks.find(s=>s.kind==="base64url")}get minLength(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxLength(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew A_({checks:[],typeName:zi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});function wCt(t,s){const r=(t.toString().split(".")[1]||"").length,n=(s.toString().split(".")[1]||"").length,a=r>n?r:n,o=Number.parseInt(t.toFixed(a).replace(".","")),l=Number.parseInt(s.toFixed(a).replace(".",""));return o%l/10**a}class GT extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==ma.number){const o=this._getOrReturnCtx(s);return Qn(o,{code:ln.invalid_type,expected:ma.number,received:o.parsedType}),Fi}let n;const a=new Tf;for(const o of this._def.checks)o.kind==="int"?Ko.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?wCt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.not_finite,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ka.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ka.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ka.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ka.toString(r))}setLimit(s,r,n,a){return new GT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ka.toString(a)}]})}_addCheck(s){return new GT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ka.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ka.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ka.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ka.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ka.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ka.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ka.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ka.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ka.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.values.kind==="int"||s.kind==="multipleOf"&&Ko.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.valuenew GT({checks:[],typeName:zi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class hD extends Vo{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==ma.bigint)return this._getInvalidInput(s);let n;const a=new Tf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),Qn(n,{code:ln.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Ko.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Qn(r,{code:ln.invalid_type,expected:ma.bigint,received:r.parsedType}),Fi}gte(s,r){return this.setLimit("min",s,!0,ka.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ka.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ka.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ka.toString(r))}setLimit(s,r,n,a){return new hD({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ka.toString(a)}]})}_addCheck(s){return new hD({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ka.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ka.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ka.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ka.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ka.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew hD({checks:[],typeName:zi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...io(t)});class Kve extends Vo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ma.boolean){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.boolean,received:n.parsedType}),Fi}return Vx(s.data)}}Kve.create=t=>new Kve({typeName:zi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...io(t)});class Roe extends Vo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ma.date){const o=this._getOrReturnCtx(s);return Qn(o,{code:ln.invalid_type,expected:ma.date,received:o.parsedType}),Fi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Qn(o,{code:ln.invalid_date}),Fi}const n=new Tf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Qn(a,{code:ln.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Ko.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Roe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ka.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ka.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.valuenew Roe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:zi.ZodDate,...io(t)});class L6e extends Vo{_parse(s){if(this._getType(s)!==ma.symbol){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.symbol,received:n.parsedType}),Fi}return Vx(s.data)}}L6e.create=t=>new L6e({typeName:zi.ZodSymbol,...io(t)});class D6e extends Vo{_parse(s){if(this._getType(s)!==ma.undefined){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.undefined,received:n.parsedType}),Fi}return Vx(s.data)}}D6e.create=t=>new D6e({typeName:zi.ZodUndefined,...io(t)});class O6e extends Vo{_parse(s){if(this._getType(s)!==ma.null){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.null,received:n.parsedType}),Fi}return Vx(s.data)}}O6e.create=t=>new O6e({typeName:zi.ZodNull,...io(t)});class R6e extends Vo{constructor(){super(...arguments),this._any=!0}_parse(s){return Vx(s.data)}}R6e.create=t=>new R6e({typeName:zi.ZodAny,...io(t)});class F6e extends Vo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Vx(s.data)}}F6e.create=t=>new F6e({typeName:zi.ZodUnknown,...io(t)});class vw extends Vo{_parse(s){const r=this._getOrReturnCtx(s);return Qn(r,{code:ln.invalid_type,expected:ma.never,received:r.parsedType}),Fi}}vw.create=t=>new vw({typeName:zi.ZodNever,...io(t)});class z6e extends Vo{_parse(s){if(this._getType(s)!==ma.undefined){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.void,received:n.parsedType}),Fi}return Vx(s.data)}}z6e.create=t=>new z6e({typeName:zi.ZodVoid,...io(t)});class S0 extends Vo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ma.array)return Qn(r,{code:ln.invalid_type,expected:ma.array,received:r.parsedType}),Fi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Qn(r,{code:ln.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((l,i)=>a.type._parseAsync(new yw(r,l,r.path,i)))).then(l=>Tf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new yw(r,l,r.path,i)));return Tf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new S0({...this._def,minLength:{value:s,message:ka.toString(r)}})}max(s,r){return new S0({...this._def,maxLength:{value:s,message:ka.toString(r)}})}length(s,r){return new S0({...this._def,exactLength:{value:s,message:ka.toString(r)}})}nonempty(s){return this.min(1,s)}}S0.create=(t,s)=>new S0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:zi.ZodArray,...io(s)});function W5(t){if(t instanceof Yd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=sw.create(W5(n))}return new Yd({...t._def,shape:()=>s})}else return t instanceof S0?new S0({...t._def,type:W5(t.element)}):t instanceof sw?sw.create(W5(t.unwrap())):t instanceof ZT?ZT.create(W5(t.unwrap())):t instanceof QS?QS.create(t.items.map(s=>W5(s))):t}class Yd extends Vo{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=Ko.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ma.object){const u=this._getOrReturnCtx(s);return Qn(u,{code:ln.invalid_type,expected:ma.object,received:u.parsedType}),Fi}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof vw&&this._def.unknownKeys==="strip"))for(const u in a.data)l.includes(u)||i.push(u);const c=[];for(const u of l){const p=o[u],f=a.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new yw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof vw){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of i)c.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")i.length>0&&(Qn(a,{code:ln.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new yw(a,f,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>Tf.mergeObjectSync(n,u)):Tf.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return ka.errToObj,new Yd({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:ka.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Yd({...this._def,unknownKeys:"strip"})}passthrough(){return new Yd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Yd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Yd({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:zi.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Yd({...this._def,catchall:s})}pick(s){const r={};for(const n of Ko.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Ko.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Yd({...this._def,shape:()=>r})}deepPartial(){return W5(this)}partial(s){const r={};for(const n of Ko.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Yd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Ko.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof sw;)o=o._def.innerType;r[n]=o}return new Yd({...this._def,shape:()=>r})}keyof(){return YWe(Ko.objectKeys(this.shape))}}Yd.create=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strip",catchall:vw.create(),typeName:zi.ZodObject,...io(s)});Yd.strictCreate=(t,s)=>new Yd({shape:()=>t,unknownKeys:"strict",catchall:vw.create(),typeName:zi.ZodObject,...io(s)});Yd.lazycreate=(t,s)=>new Yd({shape:t,unknownKeys:"strip",catchall:vw.create(),typeName:zi.ZodObject,...io(s)});class Foe extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=this._def.options;function a(o){for(const i of o)if(i.result.status==="valid")return i.result;for(const i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new P0(i.ctx.common.issues));return Qn(r,{code:ln.invalid_union,unionErrors:l}),Fi}if(r.common.async)return Promise.all(n.map(async o=>{const l={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const c of n){const u={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&l.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(c=>new P0(c));return Qn(r,{code:ln.invalid_union,unionErrors:i}),Fi}}get options(){return this._def.options}}Foe.create=(t,s)=>new Foe({options:t,typeName:zi.ZodUnion,...io(s)});function Zve(t,s){const r=Jb(t),n=Jb(s);if(t===s)return{valid:!0,data:t};if(r===ma.object&&n===ma.object){const a=Ko.objectKeys(s),o=Ko.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=Zve(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===ma.array&&n===ma.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(E6e(o)||E6e(l))return Fi;const i=Zve(o.value,l.value);return i.valid?((P6e(o)||P6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Qn(n,{code:ln.invalid_intersection_types}),Fi)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,l])=>a(o,l)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}zoe.create=(t,s,r)=>new zoe({left:t,right:s,typeName:zi.ZodIntersection,...io(r)});class QS extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ma.array)return Qn(n,{code:ln.invalid_type,expected:ma.array,received:n.parsedType}),Fi;if(n.data.lengththis._def.items.length&&(Qn(n,{code:ln.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new yw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Tf.mergeArray(r,l)):Tf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new QS({...this._def,rest:s})}}QS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new QS({items:t,typeName:zi.ZodTuple,rest:null,...io(s)})};class B6e extends Vo{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ma.map)return Qn(n,{code:ln.invalid_type,expected:ma.map,received:n.parsedType}),Fi;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,c],u)=>({key:a._parse(new yw(n,i,n.path,[u,"key"])),value:o._parse(new yw(n,c,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of l){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const c of l){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return Fi;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}B6e.create=(t,s,r)=>new B6e({valueType:s,keyType:t,typeName:zi.ZodMap,...io(r)});class mD extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ma.set)return Qn(n,{code:ln.invalid_type,expected:ma.set,received:n.parsedType}),Fi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Qn(n,{code:ln.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(c){const u=new Set;for(const p of c){if(p.status==="aborted")return Fi;p.status==="dirty"&&r.dirty(),u.add(p.value)}return{status:r.value,value:u}}const i=[...n.data.values()].map((c,u)=>o._parse(new yw(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new mD({...this._def,minSize:{value:s,message:ka.toString(r)}})}max(s,r){return new mD({...this._def,maxSize:{value:s,message:ka.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}mD.create=(t,s)=>new mD({valueType:t,minSize:null,maxSize:null,typeName:zi.ZodSet,...io(s)});class $6e extends Vo{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}$6e.create=(t,s)=>new $6e({getter:t,typeName:zi.ZodLazy,...io(s)});class Yve extends Vo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Qn(r,{received:r.data,code:ln.invalid_literal,expected:this._def.value}),Fi}return{status:"valid",value:s.data}}get value(){return this._def.value}}Yve.create=(t,s)=>new Yve({value:t,typeName:zi.ZodLiteral,...io(s)});function YWe(t,s){return new WT({values:t,typeName:zi.ZodEnum,...io(s)})}class WT extends Vo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Qn(r,{expected:Ko.joinValues(n),received:r.parsedType,code:ln.invalid_type}),Fi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Qn(r,{received:r.data,code:ln.invalid_enum_value,options:n}),Fi}return Vx(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return WT.create(s,{...this._def,...r})}exclude(s,r=this._def){return WT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}WT.create=YWe;class q6e extends Vo{_parse(s){const r=Ko.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ma.string&&n.parsedType!==ma.number){const a=Ko.objectValues(r);return Qn(n,{expected:Ko.joinValues(a),received:n.parsedType,code:ln.invalid_type}),Fi}if(this._cache||(this._cache=new Set(Ko.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Ko.objectValues(r);return Qn(n,{received:n.data,code:ln.invalid_enum_value,options:a}),Fi}return Vx(s.data)}get enum(){return this._def.values}}q6e.create=(t,s)=>new q6e({values:t,typeName:zi.ZodNativeEnum,...io(s)});class Boe extends Vo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ma.promise&&r.common.async===!1)return Qn(r,{code:ln.invalid_type,expected:ma.promise,received:r.parsedType}),Fi;const n=r.parsedType===ma.promise?r.data:Promise.resolve(r.data);return Vx(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Boe.create=(t,s)=>new Boe({type:t,typeName:zi.ZodPromise,...io(s)});class KT extends Vo{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===zi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,o={addIssue:l=>{Qn(n,l),l.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){const l=a.transform(n.data,o);if(n.common.async)return Promise.resolve(l).then(async i=>{if(r.value==="aborted")return Fi;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?Fi:c.status==="dirty"||r.value==="dirty"?LI(c.value):c});{if(r.value==="aborted")return Fi;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Fi:i.status==="dirty"||r.value==="dirty"?LI(i.value):i}}if(a.type==="refinement"){const l=i=>{const c=a.refinement(i,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?Fi:(i.status==="dirty"&&r.dirty(),l(i.value).then(()=>({status:r.value,value:i.value}))))}if(a.type==="transform")if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!HT(l))return Fi;const i=a.transform(l.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>HT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Fi);Ko.assertNever(a)}}KT.create=(t,s,r)=>new KT({schema:t,typeName:zi.ZodEffects,effect:s,...io(r)});KT.createWithPreprocess=(t,s,r)=>new KT({schema:s,effect:{type:"preprocess",transform:t},typeName:zi.ZodEffects,...io(r)});class sw extends Vo{_parse(s){return this._getType(s)===ma.undefined?Vx(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}sw.create=(t,s)=>new sw({innerType:t,typeName:zi.ZodOptional,...io(s)});class ZT extends Vo{_parse(s){return this._getType(s)===ma.null?Vx(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}ZT.create=(t,s)=>new ZT({innerType:t,typeName:zi.ZodNullable,...io(s)});class Qve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ma.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Qve.create=(t,s)=>new Qve({innerType:t,typeName:zi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...io(s)});class Xve extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ooe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new P0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new P0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Xve.create=(t,s)=>new Xve({innerType:t,typeName:zi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...io(s)});class U6e extends Vo{_parse(s){if(this._getType(s)!==ma.nan){const n=this._getOrReturnCtx(s);return Qn(n,{code:ln.invalid_type,expected:ma.nan,received:n.parsedType}),Fi}return{status:"valid",value:s.data}}}U6e.create=t=>new U6e({typeName:zi.ZodNaN,...io(t)});class jCt extends Vo{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Ije extends Vo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Fi:o.status==="dirty"?(r.dirty(),LI(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Fi:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new Ije({in:s,out:r,typeName:zi.ZodPipeline})}}class Jve extends Vo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(HT(a)&&(a.value=Object.freeze(a.value)),a);return Ooe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Jve.create=(t,s)=>new Jve({innerType:t,typeName:zi.ZodReadonly,...io(s)});var zi;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(zi||(zi={}));const _c=A_.create,n8=GT.create,NCt=Kve.create;vw.create;S0.create;const N3=Yd.create;Foe.create;zoe.create;QS.create;const $oe=Yve.create,QWe=WT.create;Boe.create;sw.create;ZT.create;const Pr=N.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:It("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...s}));Pr.displayName="Textarea";const kCt=["Excellent","Good","Neutral","Bad","Very Bad"],SCt=[5,4,3,2,1];function CCt({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=f4t(),[o,l]=N.useState({}),i=t.filter(g=>g.question_type==="rating"),c=t.filter(g=>g.question_type!=="rating"),u=(g,v)=>{l(_=>({..._,[g]:{rating_value:v}}))},p=(g,v)=>{l(_=>({..._,[g]:{text_value:v}}))},f=async()=>{const g=Object.entries(o).filter(([,v])=>v.rating_value!=null||v.text_value&&v.text_value.trim()).map(([v,_])=>{var w;return{visitor_id:s,question_id:v,rating_value:_.rating_value??null,text_value:((w=_.text_value)==null?void 0:w.trim())||null}});if(g.length>0)try{await a.mutateAsync(g)}catch{}r()};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Quick Feedback"}),e.jsx("button",{onClick:n,className:"text-sm text-slate-400 hover:text-slate-600 underline",children:"Skip"})]}),e.jsx("p",{className:"text-sm text-slate-500 -mt-2",children:"Your feedback helps the agent — totally optional!"}),i.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"flex-1"}),kCt.map(g=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:g})},g))]}),i.map(g=>e.jsxs("div",{className:"flex items-center gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"flex-1 text-sm text-slate-700 pr-2",children:g.question_text}),SCt.map(v=>{var _;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(g.id,v),className:`w-6 h-6 rounded-full border-2 transition-all ${((_=o[g.id])==null?void 0:_.rating_value)===v?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},v)})]},g.id))]}),c.map(g=>{var v;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:g.question_text}),e.jsx(Pr,{value:((v=o[g.id])==null?void 0:v.text_value)||"",onChange:_=>p(g.id,_.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},g.id)}),e.jsx(K,{onClick:f,disabled:a.isPending,className:"w-full h-12 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:a.isPending?e.jsx(bs,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const MCt=N3({first_name:_c().trim().min(1,"First name is required").max(50),last_name:_c().trim().max(50).optional(),email:_c().trim().email("Please enter a valid email").max(255).optional().or($oe("")),phone:_c().trim().max(20).optional().or($oe(""))}),TCt=[{value:"buying",label:"Looking to Buy",emoji:"🏠"},{value:"selling",label:"Thinking of Selling",emoji:"📋"},{value:"browsing",label:"Just Browsing",emoji:"👀"},{value:"neighbor",label:"I'm a Neighbor",emoji:"👋"}];function XWe({slug:t}={}){var ne;const s=lo(),r=t||s.slug,{data:n,isLoading:a,error:o}=h4t(r),l=_4t(),[i,c]=N.useState("welcome"),[u,p]=N.useState(null),[f,g]=N.useState({first_name:"",last_name:"",email:"",phone:""}),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(""),[P,O]=N.useState(""),{data:$,isLoading:U}=p4t(n==null?void 0:n.id),B=!!(n!=null&&n.enable_survey);N.useEffect(()=>{i==="pending_survey"&&(U||c(B&&(($==null?void 0:$.length)??0)>0?"survey":"done"))},[i,U,B,$]);const V=re=>{if(!re)return"";const[oe,fe]=re.split(":"),ge=parseInt(oe),ue=ge>=12?"PM":"AM";return`${ge>12?ge-12:ge||12}:${fe} ${ue}`},X=()=>{O("");const re=MCt.safeParse(f);if(!re.success){O(re.error.issues[0].message);return}if(!f.email&&!f.phone){O("Please provide either an email or phone number");return}c("intent")},Y=async re=>{_(re);try{const oe=await l.mutateAsync({open_house_id:n.id,first_name:f.first_name.trim(),last_name:f.last_name.trim()||void 0,email:f.email.trim()||void 0,phone:f.phone.trim()||void 0,visitor_intent:re,wants_market_updates:w,has_agent:k,working_with_agent_name:k&&M.trim()?M.trim():void 0});p(oe.id),B?!U&&$&&$.length>0?c("survey"):c("pending_survey"):c("done")}catch{O("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(dn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),e.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const ee=n.profiles,Q=((ne=ee==null?void 0:ee.name)==null?void 0:ne.split(" ").map(re=>re[0]).join("").slice(0,2))||"?",ce=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsxs("title",{children:[ce?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${ce?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(kn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Ua,{src:(ee==null?void 0:ee.avatar_url)||"",alt:(ee==null?void 0:ee.name)||""}),e.jsx(Sn,{className:"bg-white/10 text-white text-lg",children:Q})]}),e.jsx("p",{className:"text-white/60 text-sm",children:ee==null?void 0:ee.name}),(ee==null?void 0:ee.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:ee.title})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[n.photo_url&&e.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[e.jsx("img",{src:n.photo_url,alt:n.property_address,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:ce?e.jsx(Ca,{className:"h-5 w-5 text-white"}):e.jsx(dn,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:n.property_address}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[n.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>c("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",e.jsx(Sa,{className:"h-5 w-5 ml-2"})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),i==="info"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("welcome"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(ze,{value:f.first_name,onChange:re=>g(oe=>({...oe,first_name:re.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(ze,{value:f.last_name,onChange:re=>g(oe=>({...oe,last_name:re.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(ze,{type:"email",value:f.email,onChange:re=>g(oe=>({...oe,email:re.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(ze,{type:"tel",value:f.phone,onChange:re=>g(oe=>({...oe,phone:re.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:re=>j(re.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:k?"Yes":"No"}),e.jsx(qr,{checked:k,onCheckedChange:S})]})]}),k&&e.jsx(ze,{value:M,onChange:re=>L(re.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),P&&e.jsx("p",{className:"text-destructive text-sm",children:P}),e.jsxs(K,{onClick:X,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Sa,{className:"h-5 w-5 ml-2"})]})]}),i==="intent"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("button",{onClick:()=>c("info"),className:"text-slate-400 hover:text-slate-600",children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:TCt.map(re=>e.jsxs("button",{onClick:()=>Y(re.value),disabled:l.isPending,className:"flex flex-col items-center gap-2 p-5 rounded-xl border-2 border-slate-200 hover:border-slate-900 hover:bg-slate-50 transition-all text-center group",children:[e.jsx("span",{className:"text-2xl",children:re.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:re.label})]},re.value))}),P&&e.jsx("p",{className:"text-destructive text-sm text-center",children:P})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&$&&e.jsx(CCt,{questions:$,visitorId:u,onComplete:()=>c("done"),onSkip:()=>c("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",ce?"Enjoy the event!":"Enjoy the open house!"]})]}),(n==null?void 0:n.disclosure_pdf_url)&&e.jsxs("a",{href:`https://docs.google.com/gview?url=${encodeURIComponent(n.disclosure_pdf_url)}&embedded=true`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl bg-slate-100 hover:bg-slate-200 text-slate-800 font-medium text-sm transition-colors",children:[e.jsx(wn,{className:"h-4 w-4"}),"View Seller's Disclosures"]}),(ee==null?void 0:ee.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:ee.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function HTs(t){const{user:s}=Os();return mt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await H.from("open_house_cohost_tokens").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(n)throw n;return r},enabled:!!s&&!!t})}function GTs(){const t=Xt(),{user:s}=Os();return Lt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await H.from("open_house_cohost_tokens").insert({open_house_id:r,label:n||null,created_by:s.id,expires_at:new Date(Date.now()+864e5).toISOString()}).select().single();if(o)throw o;return a},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["cohost-tokens",n.openHouseId]})}})}function WTs(){const t=Xt();return Lt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await H.from("open_house_cohost_tokens").update({is_active:!1}).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["cohost-tokens",r.openHouseId]})}})}function ACt(t){return mt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await H.from("open_house_cohost_tokens").select("*, open_houses(*)").eq("token",t).eq("is_active",!0).single();if(r)throw r;if(s.expires_at&&new Date(s.expires_at)s[r][n]??r,t)}var Lje="ScrollArea",[JWe]=od(Lje),[PCt,Hx]=JWe(Lje),eKe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(null),[k,S]=N.useState(0),[M,L]=N.useState(0),[P,O]=N.useState(!1),[$,U]=N.useState(!1),B=Va(s,X=>c(X)),V=Lw(a);return e.jsx(PCt,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:g,scrollbarX:v,onScrollbarXChange:_,scrollbarXEnabled:P,onScrollbarXEnabledChange:O,scrollbarY:w,onScrollbarYChange:j,scrollbarYEnabled:$,onScrollbarYEnabledChange:U,onCornerWidthChange:S,onCornerHeightChange:L,children:e.jsx(an.div,{dir:V,...l,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":k+"px","--radix-scroll-area-corner-height":M+"px",...t.style}})})});eKe.displayName=Lje;var tKe="ScrollAreaViewport",sKe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Hx(tKe,r),i=N.useRef(null),c=Va(s,i,l.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),e.jsx(an.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:e.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});sKe.displayName=tKe;var U0="ScrollAreaScrollbar",Dje=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Hx(U0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return N.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(ICt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(LCt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(rKe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(Oje,{...n,ref:s}):null});Dje.displayName=U0;var ICt=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Hx(U0,t.__scopeScrollArea),[o,l]=N.useState(!1);return N.useEffect(()=>{const i=a.scrollArea;let c=0;if(i){const u=()=>{window.clearTimeout(c),l(!0)},p=()=>{c=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),e.jsx(zd,{present:r||o,children:e.jsx(rKe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),LCt=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Hx(U0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=fue(()=>c("SCROLL_END"),100),[i,c]=ECt("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return N.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,c]),N.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const g=()=>{const v=u[p];f!==v&&(c("SCROLL"),l()),f=v};return u.addEventListener("scroll",g),()=>u.removeEventListener("scroll",g)}},[a.viewport,o,c,l]),e.jsx(zd,{present:r||i!=="hidden",children:e.jsx(Oje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Lr(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Lr(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),rKe=N.forwardRef((t,s)=>{const r=Hx(U0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=N.useState(!1),i=t.orientation==="horizontal",c=fue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Hx(U0,t.__scopeScrollArea),o=N.useRef(null),l=N.useRef(0),[i,c]=N.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=lKe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:g=>o.current=g,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:g=>l.current=g};function f(g,v){return BCt(g,l.current,i,v)}return r==="horizontal"?e.jsx(DCt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollLeft,v=V6e(g,i,a.dir);o.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollLeft=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollLeft=f(g,a.dir))}}):r==="vertical"?e.jsx(OCt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollTop,v=V6e(g,i);o.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=f(g))}}):null}),DCt=N.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Hx(U0,t.__scopeScrollArea),[l,i]=N.useState(),c=N.useRef(null),u=Va(s,c,o.onScrollbarXChange);return N.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(aKe,{"data-orientation":"horizontal",...a,ref:u,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":pue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(g),dKe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Uoe(l.paddingLeft),paddingEnd:Uoe(l.paddingRight)}})}})}),OCt=N.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Hx(U0,t.__scopeScrollArea),[l,i]=N.useState(),c=N.useRef(null),u=Va(s,c,o.onScrollbarYChange);return N.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(aKe,{"data-orientation":"vertical",...a,ref:u,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":pue(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const g=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(g),dKe(g,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Uoe(l.paddingTop),paddingEnd:Uoe(l.paddingBottom)}})}})}),[RCt,nKe]=JWe(U0),aKe=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:p,onResize:f,...g}=t,v=Hx(U0,r),[_,w]=N.useState(null),j=Va(s,B=>w(B)),k=N.useRef(null),S=N.useRef(""),M=v.viewport,L=n.content-n.viewport,P=bd(p),O=bd(c),$=fue(f,10);function U(B){if(k.current){const V=B.clientX-k.current.left,X=B.clientY-k.current.top;u({x:V,y:X})}}return N.useEffect(()=>{const B=V=>{const X=V.target;(_==null?void 0:_.contains(X))&&P(V,L)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[M,_,L,P]),N.useEffect(O,[n,O]),YT(_,$),YT(v.content,$),e.jsx(RCt,{scope:r,scrollbar:_,hasThumb:a,onThumbChange:bd(o),onThumbPointerUp:bd(l),onThumbPositionChange:O,onThumbPointerDown:bd(i),children:e.jsx(an.div,{...g,ref:j,style:{position:"absolute",...g.style},onPointerDown:Lr(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),k.current=_.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),U(B))}),onPointerMove:Lr(t.onPointerMove,U),onPointerUp:Lr(t.onPointerUp,B=>{const V=B.target;V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=S.current,v.viewport&&(v.viewport.style.scrollBehavior=""),k.current=null})})})}),qoe="ScrollAreaThumb",iKe=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=nKe(qoe,t.__scopeScrollArea);return e.jsx(zd,{present:r||a.hasThumb,children:e.jsx(FCt,{ref:s,...n})})}),FCt=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Hx(qoe,r),l=nKe(qoe,r),{onThumbPositionChange:i}=l,c=Va(s,f=>l.onThumbChange(f)),u=N.useRef(void 0),p=fue(()=>{u.current&&(u.current(),u.current=void 0)},100);return N.useEffect(()=>{const f=o.viewport;if(f){const g=()=>{if(p(),!u.current){const v=$Ct(f,i);u.current=v,i()}};return i(),f.addEventListener("scroll",g),()=>f.removeEventListener("scroll",g)}},[o.viewport,p,i]),e.jsx(an.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Lr(t.onPointerDownCapture,f=>{const v=f.target.getBoundingClientRect(),_=f.clientX-v.left,w=f.clientY-v.top;l.onThumbPointerDown({x:_,y:w})}),onPointerUp:Lr(t.onPointerUp,l.onThumbPointerUp)})});iKe.displayName=qoe;var Rje="ScrollAreaCorner",oKe=N.forwardRef((t,s)=>{const r=Hx(Rje,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(zCt,{...t,ref:s}):null});oKe.displayName=Rje;var zCt=N.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Hx(Rje,r),[o,l]=N.useState(0),[i,c]=N.useState(0),u=!!(o&&i);return YT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),YT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(an.div,{...n,ref:s,style:{width:o,height:i,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Uoe(t){return t?parseInt(t,10):0}function lKe(t,s){const r=t/s;return isNaN(r)?0:r}function pue(t){const s=lKe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function BCt(t,s,r,n="ltr"){const a=pue(r),o=a/2,l=s||o,i=a-l,c=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,p=r.content-r.viewport,f=n==="ltr"?[0,p]:[p*-1,0];return cKe([c,u],f)(t)}function V6e(t,s,r="ltr"){const n=pue(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,o=s.scrollbar.size-a,l=s.content-s.viewport,i=o-n,c=r==="ltr"?[0,l]:[l*-1,0],u=uD(t,c);return cKe([0,l],[0,i])(u)}function cKe(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function dKe(t,s){return t>0&&t{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function a(){const o={left:t.scrollLeft,top:t.scrollTop},l=r.left!==o.left,i=r.top!==o.top;(l||i)&&s(),r=o,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function fue(t,s){const r=bd(t),n=N.useRef(0);return N.useEffect(()=>()=>window.clearTimeout(n.current),[]),N.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function YT(t,s){const r=bd(s);jd(()=>{let n=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(t),()=>{window.cancelAnimationFrame(n),a.unobserve(t)}}},[t,r])}var uKe=eKe,qCt=sKe,UCt=oKe;const Ki=N.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(uKe,{ref:n,className:It("relative overflow-hidden",t),...r,children:[e.jsx(qCt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(xue,{}),e.jsx(UCt,{})]}));Ki.displayName=uKe.displayName;const xue=N.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(Dje,{ref:n,orientation:s,className:It("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:e.jsx(iKe,{className:"relative flex-1 rounded-full bg-border"})}));xue.displayName=Dje.displayName;const Fje=N.createContext({});function zje(t){const s=N.useRef(null);return s.current===null&&(s.current=t()),s.current}const VCt=typeof window<"u",hKe=VCt?N.useLayoutEffect:N.useEffect,gue=N.createContext(null);function Bje(t,s){t.indexOf(s)===-1&&t.push(s)}function Voe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const I0=(t,s,r)=>r>s?s:r{};const bw={},mKe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function pKe(t){return typeof t=="object"&&t!==null}const fKe=t=>/^0[^.\s]+$/u.test(t);function xKe(t){let s;return()=>(s===void 0&&(s=t()),s)}const Px=t=>t,HCt=(t,s)=>r=>s(t(r)),WO=(...t)=>t.reduce(HCt),pD=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class qje{constructor(){this.subscriptions=[]}add(s){return Bje(this.subscriptions,s),()=>Voe(this.subscriptions,s)}notify(s,r,n){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](s,r,n);else for(let o=0;ot*1e3,wx=t=>t/1e3;function gKe(t,s){return s?t*(1e3/s):0}const yKe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,GCt=1e-7,WCt=12;function KCt(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=yKe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>GCt&&++iKCt(o,0,1,t,r);return o=>o===0||o===1?o:yKe(a(o),s,n)}const vKe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,bKe=t=>s=>1-t(1-s),_Ke=KO(.33,1.53,.69,.99),Uje=bKe(_Ke),wKe=vKe(Uje),jKe=t=>t>=1?1:(t*=2)<1?.5*Uje(t):.5*(2-Math.pow(2,-10*(t-1))),Vje=t=>1-Math.sin(Math.acos(t)),NKe=bKe(Vje),kKe=vKe(Vje),ZCt=KO(.42,0,1,1),YCt=KO(0,0,.58,1),SKe=KO(.42,0,.58,1),QCt=t=>Array.isArray(t)&&typeof t[0]!="number",CKe=t=>Array.isArray(t)&&typeof t[0]=="number",XCt={linear:Px,easeIn:ZCt,easeInOut:SKe,easeOut:YCt,circIn:Vje,circInOut:kKe,circOut:NKe,backIn:Uje,backInOut:wKe,backOut:_Ke,anticipate:jKe},JCt=t=>typeof t=="string",H6e=t=>{if(CKe(t)){$je(t.length===4);const[s,r,n,a]=t;return KO(s,r,n,a)}else if(JCt(t))return XCt[t];return t},xz=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function e5t(t,s){let r=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function c(p){l.has(p)&&(u.schedule(p),t()),p(i)}const u={schedule:(p,f=!1,g=!1)=>{const _=g&&a?r:n;return f&&l.add(p),_.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(c),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const t5t=40;function MKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=xz.reduce((M,L)=>(M[L]=e5t(o),M),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:p,update:f,preRender:g,render:v,postRender:_}=l,w=()=>{const M=bw.useManualTiming,L=M?a.timestamp:performance.now();r=!1,M||(a.delta=n?1e3/60:Math.max(Math.min(L-a.timestamp,t5t),1)),a.timestamp=L,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),p.process(a),f.process(a),g.process(a),v.process(a),_.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},j=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:xz.reduce((M,L)=>{const P=l[L];return M[L]=(O,$=!1,U=!1)=>(r||j(),P.schedule(O,$,U)),M},{}),cancel:M=>{for(let L=0;L(kie===void 0&&km.set(_h.isProcessing||bw.useManualTiming?_h.timestamp:performance.now()),kie),set:t=>{kie=t,queueMicrotask(s5t)}},TKe=t=>s=>typeof s=="string"&&s.startsWith(t),AKe=TKe("--"),r5t=TKe("var(--"),Hje=t=>r5t(t)?n5t.test(t.split("/*")[0].trim()):!1,n5t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function G6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const aE={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},fD={...aE,transform:t=>I0(0,1,t)},gz={...aE,default:1},a8=t=>Math.round(t*1e5)/1e5,Gje=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function a5t(t){return t==null}const i5t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Wje=(t,s)=>r=>!!(typeof r=="string"&&i5t.test(r)&&r.startsWith(t)||s&&!a5t(r)&&Object.prototype.hasOwnProperty.call(r,s)),EKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Gje);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},o5t=t=>I0(0,255,t),Uxe={...aE,transform:t=>Math.round(o5t(t))},k4={test:Wje("rgb","red"),parse:EKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Uxe.transform(t)+", "+Uxe.transform(s)+", "+Uxe.transform(r)+", "+a8(fD.transform(n))+")"};function l5t(t){let s="",r="",n="",a="";return t.length>5?(s=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),a=t.substring(7,9)):(s=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),a=t.substring(4,5),s+=s,r+=r,n+=n,a+=a),{red:parseInt(s,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:a?parseInt(a,16)/255:1}}const e1e={test:Wje("#"),parse:l5t,transform:k4.transform},ZO=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),Wb=ZO("deg"),C0=ZO("%"),la=ZO("px"),c5t=ZO("vh"),d5t=ZO("vw"),W6e={...C0,parse:t=>C0.parse(t)/100,transform:t=>C0.transform(t*100)},fM={test:Wje("hsl","hue"),parse:EKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+C0.transform(a8(s))+", "+C0.transform(a8(r))+", "+a8(fD.transform(n))+")"},Qd={test:t=>k4.test(t)||e1e.test(t)||fM.test(t),parse:t=>k4.test(t)?k4.parse(t):fM.test(t)?fM.parse(t):e1e.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?k4.transform(t):fM.transform(t),getAnimatableNone:t=>{const s=Qd.parse(t);return s.alpha=0,Qd.transform(s)}},u5t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function h5t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(Gje))==null?void 0:s.length)||0)+(((r=t.match(u5t))==null?void 0:r.length)||0)>0}const PKe="number",IKe="color",m5t="var",p5t="var(",K6e="${}",f5t=/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 QT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(f5t,c=>(Qd.test(c)?(n.color.push(o),a.push(IKe),r.push(Qd.parse(c))):c.startsWith(p5t)?(n.var.push(o),a.push(m5t),r.push(c)):(n.number.push(o),a.push(PKe),r.push(parseFloat(c))),++o,K6e)).split(K6e);return{values:r,split:i,indexes:n,types:a}}function x5t(t){return QT(t).values}function LKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Qd.test(t)?Qd.getAnimatableNone(t):t,v5t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:y5t(t);function b5t(t){const s=QT(t);return LKe(s)(s.values.map((n,a)=>v5t(n,s.split[a])))}const ry={test:h5t,parse:x5t,createTransformer:g5t,getAnimatableNone:b5t};function Vxe(t,s,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(s-t)*6*r:r<1/2?s:r<2/3?t+(s-t)*(2/3-r)*6:t}function _5t({hue:t,saturation:s,lightness:r,alpha:n}){t/=360,s/=100,r/=100;let a=0,o=0,l=0;if(!s)a=o=l=r;else{const i=r<.5?r*(1+s):r+s-r*s,c=2*r-i;a=Vxe(c,i,t+1/3),o=Vxe(c,i,t),l=Vxe(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Hoe(t,s){return r=>r>0?s:t}const Sc=(t,s,r)=>t+(s-t)*r,Hxe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},w5t=[e1e,k4,fM],j5t=t=>w5t.find(s=>s.test(t));function Z6e(t){const s=j5t(t);if(!s)return!1;let r=s.parse(t);return s===fM&&(r=_5t(r)),r}const Y6e=(t,s)=>{const r=Z6e(t),n=Z6e(s);if(!r||!n)return Hoe(t,s);const a={...r};return o=>(a.red=Hxe(r.red,n.red,o),a.green=Hxe(r.green,n.green,o),a.blue=Hxe(r.blue,n.blue,o),a.alpha=Sc(r.alpha,n.alpha,o),k4.transform(a))},t1e=new Set(["none","hidden"]);function N5t(t,s){return t1e.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function k5t(t,s){return r=>Sc(t,s,r)}function Kje(t){return typeof t=="number"?k5t:typeof t=="string"?Hje(t)?Hoe:Qd.test(t)?Y6e:M5t:Array.isArray(t)?DKe:typeof t=="object"?Qd.test(t)?Y6e:S5t:Hoe}function DKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>Kje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function C5t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=ry.createTransformer(s),n=QT(t),a=QT(s);return n.indexes.var.length===a.indexes.var.length&&n.indexes.color.length===a.indexes.color.length&&n.indexes.number.length>=a.indexes.number.length?t1e.has(t)&&!a.values.length||t1e.has(s)&&!n.values.length?N5t(t,s):WO(DKe(C5t(n,a),a.values),r):Hoe(t,s)};function OKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?Sc(t,s,r):Kje(t)(t,s)}const T5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Ol.update(s,r),stop:()=>_w(s),now:()=>_h.isProcessing?_h.timestamp:km.now()}},RKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Goe?1/0:s}function A5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(Zje(n),Goe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:wx(a)}}const pd={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};function s1e(t,s){return t*Math.sqrt(1-s*s)}const E5t=12;function P5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,g=p-r,v=s1e(u,l),_=Math.exp(-f);return Gxe-g/v*_},o=u=>{const f=u*l*t,g=f*r+r,v=Math.pow(l,2)*Math.pow(u,2)*t,_=Math.exp(-f),w=s1e(Math.pow(u,2),l);return(-a(u)+Gxe>0?-1:1)*((g-v)*_)/w}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Gxe+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,c=P5t(a,o,i);if(t=yf(t),isNaN(c))return{stiffness:pd.stiffness,damping:pd.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const L5t=["duration","bounce"],D5t=["stiffness","damping","mass"];function Q6e(t,s){return s.some(r=>t[r]!==void 0)}function O5t(t){let s={velocity:pd.velocity,stiffness:pd.stiffness,damping:pd.damping,mass:pd.mass,isResolvedFromDuration:!1,...t};if(!Q6e(t,D5t)&&Q6e(t,L5t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*I0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:pd.mass,stiffness:a,damping:o}}else{const r=I5t({...t,velocity:0});s={...s,...r,mass:pd.mass},s.isResolvedFromDuration=!0}return s}function Woe(t=pd.visualDuration,s=pd.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:n,restDelta:a}=r;const o=r.keyframes[0],l=r.keyframes[r.keyframes.length-1],i={done:!1,value:o},{stiffness:c,damping:u,mass:p,duration:f,velocity:g,isResolvedFromDuration:v}=O5t({...r,velocity:-wx(r.velocity||0)}),_=g||0,w=u/(2*Math.sqrt(c*p)),j=l-o,k=wx(Math.sqrt(c/p)),S=Math.abs(j)<5;n||(n=S?pd.restSpeed.granular:pd.restSpeed.default),a||(a=S?pd.restDelta.granular:pd.restDelta.default);let M,L,P,O,$,U;if(w<1)P=s1e(k,w),O=(_+w*k*j)/P,M=V=>{const X=Math.exp(-w*k*V);return l-X*(O*Math.sin(P*V)+j*Math.cos(P*V))},$=w*k*O+j*P,U=w*k*j-O*P,L=V=>Math.exp(-w*k*V)*($*Math.sin(P*V)+U*Math.cos(P*V));else if(w===1){M=X=>l-Math.exp(-k*X)*(j+(_+k*j)*X);const V=_+k*j;L=X=>Math.exp(-k*X)*(k*V*X-_)}else{const V=k*Math.sqrt(w*w-1);M=Q=>{const ce=Math.exp(-w*k*Q),ne=Math.min(V*Q,300);return l-ce*((_+w*k*j)*Math.sinh(ne)+V*j*Math.cosh(ne))/V};const X=(_+w*k*j)/V,Y=w*k*X-j*V,ee=w*k*j-X*V;L=Q=>{const ce=Math.exp(-w*k*Q),ne=Math.min(V*Q,300);return ce*(Y*Math.sinh(ne)+ee*Math.cosh(ne))}}const B={calculatedDuration:v&&f||null,velocity:V=>yf(L(V)),next:V=>{if(!v&&w<1){const Y=Math.exp(-w*k*V),ee=Math.sin(P*V),Q=Math.cos(P*V),ce=l-Y*(O*ee+j*Q),ne=yf(Y*($*ee+U*Q));return i.done=Math.abs(ne)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const X=M(V);if(v)i.done=V>=f;else{const Y=yf(L(V));i.done=Math.abs(Y)<=n&&Math.abs(l-X)<=a}return i.value=i.done?l:X,i},toString:()=>{const V=Math.min(Zje(B),Goe),X=RKe(Y=>B.next(V*Y).value,V,30);return V+"ms "+X},toTransition:()=>{}};return B}Woe.applyToOptions=t=>{const s=A5t(t,100,Woe);return t.ease=s.ease,t.duration=yf(s.duration),t.type="keyframes",t};const R5t=5;function FKe(t,s,r){const n=Math.max(s-R5t,0);return gKe(r-t(n),s-n)}function r1e({keyframes:t,velocity:s=0,power:r=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:c,restDelta:u=.5,restSpeed:p}){const f=t[0],g={done:!1,value:f},v=U=>i!==void 0&&Uc,_=U=>i===void 0?c:c===void 0||Math.abs(i-U)-w*Math.exp(-U/n),M=U=>k+S(U),L=U=>{const B=S(U),V=M(U);g.done=Math.abs(B)<=u,g.value=g.done?k:V};let P,O;const $=U=>{v(g.value)&&(P=U,O=Woe({keyframes:[g.value,_(g.value)],velocity:FKe(M,U,g.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return $(0),{calculatedDuration:null,next:U=>{let B=!1;return!O&&P===void 0&&(B=!0,L(U),$(U)),P!==void 0&&U>=P?O.next(U-P):(!B&&L(U),g)}}}function F5t(t,s,r){const n=[],a=r||bw.mix||OKe,o=t.length-1;for(let l=0;ls[0];if(o===2&&s[0]===s[1])return()=>s[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),s=[...s].reverse());const i=F5t(s,n,a),c=i.length,u=p=>{if(l&&p1)for(;fu(I0(t[0],t[o-1],p)):u}function B5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=pD(0,s,n);t.push(Sc(r,1,a))}}function $5t(t){const s=[0];return B5t(s,t.length-1),s}function q5t(t,s){return t.map(r=>r*s)}function U5t(t,s){return t.map(()=>s||SKe).splice(0,t.length-1)}function i8({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=QCt(n)?n.map(H6e):H6e(n),o={done:!1,value:s[0]},l=q5t(r&&r.length===s.length?r:$5t(s),t),i=z5t(l,s,{ease:Array.isArray(a)?a:U5t(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const V5t=t=>t!==null;function yue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(V5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const H5t={decay:r1e,inertia:r1e,tween:i8,keyframes:i8,spring:Woe};function zKe(t){typeof t.type=="string"&&(t.type=H5t[t.type])}class Yje{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(s=>{this.resolve=s})}notifyFinished(){this.resolve()}then(s,r){return this.finished.then(s,r)}}const G5t=t=>t/100;class Koe extends Yje{constructor(s){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var n,a;const{motionValue:r}=this.options;r&&r.updatedAt!==km.now()&&this.tick(km.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(n=this.options).onStop)==null||a.call(n))},this.options=s,this.initAnimation(),this.play(),s.autoplay===!1&&this.pause()}initAnimation(){const{options:s}=this;zKe(s);const{type:r=i8,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||i8;c!==i8&&typeof i[0]!="number"&&(this.mixKeyframes=WO(G5t,OKe(i[0],i[1])),i=[0,100]);const u=c({...s,keyframes:i});o==="mirror"&&(this.mirroredGenerator=c({...s,keyframes:[...i].reverse(),velocity:-l})),u.calculatedDuration===null&&(u.calculatedDuration=Zje(u));const{calculatedDuration:p}=u;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=u}updateTime(s){const r=Math.round(s-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(s,r=!1){const{generator:n,totalDuration:a,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:i,calculatedDuration:c}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:p,repeat:f,repeatType:g,repeatDelay:v,type:_,onUpdate:w,finalKeyframe:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const k=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?k<0:k>a;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let M=this.currentTime,L=n;if(f){const U=Math.min(this.currentTime,a)/i;let B=Math.floor(U),V=U%1;!V&&U>=1&&(V=1),V===1&&B--,B=Math.min(B,f+1),!!(B%2)&&(g==="reverse"?(V=1-V,v&&(V-=v/i)):g==="mirror"&&(L=l)),M=I0(0,1,V)*i}let P;S?(this.delayState.value=p[0],P=this.delayState):P=L.next(M),o&&!S&&(P.value=o(P.value));let{done:O}=P;!S&&c!==null&&(O=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&O);return $&&_!==r1e&&(P.value=yue(p,this.options,j,this.speed)),w&&w(P.value),$&&this.finish(),P}then(s,r){return this.finished.then(s,r)}get duration(){return wx(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+wx(s)}get time(){return wx(this.currentTime)}set time(s){s=yf(s),this.currentTime=s,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=s,this.tick(s))}getGeneratorVelocity(){const s=this.currentTime;if(s<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(s);const r=this.generator.next(s).value;return FKe(n=>this.generator.next(n).value,s,r)}get speed(){return this.playbackSpeed}set speed(s){const r=this.playbackSpeed!==s;r&&this.driver&&this.updateTime(km.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=wx(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=T5t,startTime:r}=this.options;this.driver||(this.driver=s(l=>this.tick(l))),(o=(a=this.options).onPlay)==null||o.call(a);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(km.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var s,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(s=this.options).onComplete)==null||r.call(s)}cancel(){var s,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(s=this.options).onCancel)==null||r.call(s)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}attachTimeline(s){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),s.observe(this)}}function W5t(t){for(let s=1;st*180/Math.PI,n1e=t=>{const s=S4(Math.atan2(t[1],t[0]));return a1e(s)},K5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:n1e,rotateZ:n1e,skewX:t=>S4(Math.atan(t[1])),skewY:t=>S4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},a1e=t=>(t=t%360,t<0&&(t+=360),t),X6e=n1e,J6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ePe=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Z5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:J6e,scaleY:ePe,scale:t=>(J6e(t)+ePe(t))/2,rotateX:t=>a1e(S4(Math.atan2(t[6],t[5]))),rotateY:t=>a1e(S4(Math.atan2(-t[2],t[0]))),rotateZ:X6e,rotate:X6e,skewX:t=>S4(Math.atan(t[4])),skewY:t=>S4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function i1e(t){return t.includes("scale")?1:0}function o1e(t,s){if(!t||t==="none")return i1e(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=Z5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=K5t,a=i}if(!a)return i1e(s);const o=n[s],l=a[1].split(",").map(Q5t);return typeof o=="function"?o(l):l[o]}const Y5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return o1e(r,s)};function Q5t(t){return parseFloat(t.trim())}const iE=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],oE=new Set(iE),tPe=t=>t===aE||t===la,X5t=new Set(["x","y","z"]),J5t=iE.filter(t=>!X5t.has(t));function eMt(t){const s=[];return J5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const E_={width:({x:t},{paddingLeft:s="0",paddingRight:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},height:({y:t},{paddingTop:s="0",paddingBottom:r="0",boxSizing:n})=>{const a=t.max-t.min;return n==="border-box"?a:a-parseFloat(s)-parseFloat(r)},top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:(t,{transform:s})=>o1e(s,"x"),y:(t,{transform:s})=>o1e(s,"y")};E_.translateX=E_.x;E_.translateY=E_.y;const NS=new Set;let l1e=!1,c1e=!1,d1e=!1;function BKe(){if(c1e){const t=Array.from(NS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=eMt(n);a.length&&(r.set(n,a),n.render())}),t.forEach(n=>n.measureInitialState()),s.forEach(n=>{n.render();const a=r.get(n);a&&a.forEach(([o,l])=>{var i;(i=n.getValue(o))==null||i.set(l)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}c1e=!1,l1e=!1,NS.forEach(t=>t.complete(d1e)),NS.clear()}function $Ke(){NS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(c1e=!0)})}function tMt(){d1e=!0,$Ke(),BKe(),d1e=!1}class Qje{constructor(s,r,n,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...s],this.onComplete=r,this.name=n,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(NS.add(this),l1e||(l1e=!0,Ol.read($Ke),Ol.resolveKeyframes(BKe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:r,element:n,motionValue:a}=this;if(s[0]===null){const o=a==null?void 0:a.get(),l=s[s.length-1];if(o!==void 0)s[0]=o;else if(n&&r){const i=n.readValue(r,l);i!=null&&(s[0]=i)}s[0]===void 0&&(s[0]=l),a&&o===void 0&&a.set(s[0])}W5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),NS.delete(this)}cancel(){this.state==="scheduled"&&(NS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const sMt=t=>t.startsWith("--");function qKe(t,s,r){sMt(s)?t.style.setProperty(s,r):t.style[s]=r}const rMt={};function UKe(t,s){const r=xKe(t);return()=>rMt[s]??r()}const nMt=UKe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),VKe=UKe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),DI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,sPe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:DI([0,.65,.55,1]),circOut:DI([.55,0,1,.45]),backIn:DI([.31,.01,.66,-.59]),backOut:DI([.33,1.53,.69,.99])};function HKe(t,s){if(t)return typeof t=="function"?VKe()?RKe(t,s):"ease-out":CKe(t)?DI(t):Array.isArray(t)?t.map(r=>HKe(r,s)||sPe.easeOut):sPe[t]}function aMt(t,s,r,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:c}={},u=void 0){const p={[s]:r};c&&(p.offset=c);const f=HKe(i,a);Array.isArray(f)&&(p.easing=f);const g={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(g.pseudoElement=u),t.animate(p,g)}function GKe(t){return typeof t=="function"&&"applyToOptions"in t}function iMt({type:t,...s}){return GKe(t)&&VKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class WKe extends Yje{constructor(s){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!s)return;const{element:r,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:c}=s;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=s,$je(typeof s.type!="string");const u=iMt(s);this.animation=aMt(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=yue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),qKe(r,n,p),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var s,r;(r=(s=this.animation).finish)==null||r.call(s)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:s}=this;s==="idle"||s==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var r,n,a;const s=(r=this.options)==null?void 0:r.element;!this.isPseudoElement&&(s!=null&&s.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var r,n;const s=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return wx(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+wx(s)}get time(){return wx(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=yf(s),r&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(s){s<0&&(this.finishedTime=null),this.animation.playbackRate=s}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(s){this.manualStartTime=this.animation.startTime=s}attachTimeline({timeline:s,rangeStart:r,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,s&&nMt()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Px):a(this)}}const KKe={anticipate:jKe,backInOut:wKe,circInOut:kKe};function oMt(t){return t in KKe}function lMt(t){typeof t.ease=="string"&&oMt(t.ease)&&(t.ease=KKe[t.ease])}const Wxe=10;class cMt extends WKe{constructor(s){lMt(s),zKe(s),super(s),s.startTime!==void 0&&s.autoplay!==!1&&(this.startTime=s.startTime),this.options=s}updateMotionValue(s){const{motionValue:r,onUpdate:n,onComplete:a,element:o,...l}=this.options;if(!r)return;if(s!==void 0){r.set(s);return}const i=new Koe({...l,autoplay:!1}),c=Math.max(Wxe,km.now()-this.startTime),u=I0(0,Wxe,c-Wxe),p=i.sample(c).value,{name:f}=this.options;o&&f&&qKe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,p,u),i.stop()}}const rPe=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ry.test(t)||t==="0")&&!t.startsWith("url("));function dMt(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function xMt(t){var f;const{motionValue:s,name:r,repeatDelay:n,repeatType:a,damping:o,type:l,keyframes:i}=t;if(!(((f=s==null?void 0:s.owner)==null?void 0:f.current)instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:p}=s.owner.getProps();return fMt()&&r&&(ZKe.has(r)||pMt.has(r)&&mMt(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const gMt=40;class yMt extends Yje{constructor({autoplay:s=!0,delay:r=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:c,motionValue:u,element:p,...f}){var _;super(),this.stop=()=>{var w,j;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(j=this.keyframeResolver)==null||j.cancel()},this.createdAt=km.now();const g={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:p,...f},v=(p==null?void 0:p.KeyframeResolver)||Qje;this.keyframeResolver=new v(i,(w,j,k)=>this.onKeyframesResolved(w,j,g,!k),c,u,p),(_=this.keyframeResolver)==null||_.scheduleResolve()}onKeyframesResolved(s,r,n,a){var k,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:c,isHandoff:u,onUpdate:p}=n;this.resolvedAt=km.now();let f=!0;uMt(s,o,l,i)||(f=!1,(bw.instantAnimations||!c)&&(p==null||p(yue(s,n,r))),s[0]=s[s.length-1],u1e(n),n.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>gMt?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=f&&!u&&xMt(v),w=(S=(k=v.motionValue)==null?void 0:k.owner)==null?void 0:S.current;let j;if(_)try{j=new cMt({...v,element:w})}catch{j=new Koe(v)}else j=new Koe(v);j.finished.then(()=>{this.notifyFinished()}).catch(Px),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),tMt()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(s){this.animation.time=s}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(s){this.animation.speed=s}get startTime(){return this.animation.startTime}attachTimeline(s){return this._animation?this.stopTimeline=this.animation.attachTimeline(s):this.pendingTimeline=s,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var s;this._animation&&this.animation.cancel(),(s=this.keyframeResolver)==null||s.cancel()}}function YKe(t,s,r,n=0,a=1){const o=Array.from(t).sort((u,p)=>u.sortNodePosition(p)).indexOf(s),l=t.size,i=(l-1)*n;return typeof r=="function"?r(o,l):a===1?o*n:i-o*n}const vMt=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function bMt(t){const s=vMt.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function QKe(t,s,r=1){const[n,a]=bMt(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return mKe(l)?parseFloat(l):l}return Hje(a)?QKe(a,s,r+1):a}const _Mt={type:"spring",stiffness:500,damping:25,restSpeed:10},wMt=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),jMt={type:"keyframes",duration:.8},NMt={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},kMt=(t,{keyframes:s})=>s.length>2?jMt:oE.has(t)?t.startsWith("scale")?wMt(s[1]):_Mt:NMt;function XKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function Xje(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?XKe(r,t):r}const SMt=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function CMt(t){for(const s in t)if(!SMt.has(s))return!0;return!1}const Jje=(t,s,r,n={},a,o)=>l=>{const i=Xje(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-yf(c);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:g=>{s.set(g),i.onUpdate&&i.onUpdate(g)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};CMt(i)||Object.assign(p,kMt(t,p)),p.duration&&(p.duration=yf(p.duration)),p.repeatDelay&&(p.repeatDelay=yf(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(u1e(p),p.delay===0&&(f=!0)),(bw.instantAnimations||bw.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,u1e(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const g=yue(p.keyframes,i);if(g!==void 0){Ol.update(()=>{p.onUpdate(g),p.onComplete()});return}}return i.isSync?new Koe(p):new yMt(p)};function nPe(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function eNe(t,s,r,n){if(typeof s=="function"){const[a,o]=nPe(n);s=s(r!==void 0?r:t.custom,a,o)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[a,o]=nPe(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function kS(t,s,r){const n=t.getProps();return eNe(n,s,r!==void 0?r:n.custom,t)}const JKe=new Set(["width","height","top","left","right","bottom",...iE]),aPe=30,MMt=t=>!isNaN(parseFloat(t));class TMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=km.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(s),this.owner=r.owner}setCurrent(s){this.current=s,this.updatedAt=km.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=MMt(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,r){this.events[s]||(this.events[s]=new qje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Ol.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,r){this.passiveEffect=s,this.stopPassiveEffect=r}set(s){this.passiveEffect?this.passiveEffect(s,this.updateAndNotify):this.updateAndNotify(s)}setWithVelocity(s,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-n}jump(s,r=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var s;(s=this.events.change)==null||s.notify(this.current)}addDependent(s){this.dependents||(this.dependents=new Set),this.dependents.add(s)}removeDependent(s){this.dependents&&this.dependents.delete(s)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=km.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>aPe)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,aPe);return gKe(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(s){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=s(r),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(){var s,r;(s=this.dependents)==null||s.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function XT(t,s){return new TMt(t,s)}const h1e=t=>Array.isArray(t);function AMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,XT(r))}function EMt(t){return h1e(t)?t[t.length-1]||0:t}function PMt(t,s){const r=kS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=EMt(o[l]);AMt(t,l,i)}}const kh=t=>!!(t&&t.getVelocity);function IMt(t){return!!(kh(t)&&t.add)}function m1e(t,s){const r=t.getValue("willChange");if(IMt(r))return r.add(s);if(!r&&bw.WillChange){const n=new bw.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function tNe(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const LMt="framerAppearId",eZe="data-"+tNe(LMt);function tZe(t){return t.props[eZe]}function DMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function sZe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?XKe(o,c):c;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const g in i){const v=t.getValue(g,t.latestValues[g]??null),_=i[g];if(_===void 0||f&&DMt(f,g))continue;const w={delay:r,...Xje(o||{},g)},j=v.get();if(j!==void 0&&!v.isAnimating()&&!Array.isArray(_)&&_===j&&!w.velocity){Ol.update(()=>v.set(_));continue}let k=!1;if(window.MotionHandoffAnimation){const L=tZe(t);if(L){const P=window.MotionHandoffAnimation(L,g,Ol);P!==null&&(w.startTime=P,k=!0)}}m1e(t,g);const S=u??t.shouldReduceMotion;v.start(Jje(g,v,_,S&&JKe.has(g)?{type:!1}:w,t,k));const M=v.animation;M&&p.push(M)}if(l){const g=()=>Ol.update(()=>{l&&PMt(t,l)});p.length?Promise.all(p).then(g):g()}return p}function p1e(t,s,r={}){var c;const n=kS(t,s,r.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:a=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(a=r.transitionOverride);const o=n?()=>Promise.all(sZe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:g}=a;return OMt(t,s,u,p,f,g,r)}:()=>Promise.resolve(),{when:i}=a;if(i){const[u,p]=i==="beforeChildren"?[o,l]:[l,o];return u().then(()=>p())}else return Promise.all([o(),l(r.delay)])}function OMt(t,s,r=0,n=0,a=0,o=1,l){const i=[];for(const c of t.variantChildren)c.notify("AnimationStart",s),i.push(p1e(c,s,{...l,delay:r+(typeof n=="function"?0:n)+YKe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function RMt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>p1e(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=p1e(t,s,r);else{const a=typeof s=="function"?kS(t,s,r.custom):s;n=Promise.all(sZe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const FMt={test:t=>t==="auto",parse:t=>t},rZe=t=>s=>s.test(t),nZe=[aE,la,C0,Wb,d5t,c5t,FMt],iPe=t=>nZe.find(rZe(t));function zMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||fKe(t):!0}const BMt=new Set(["brightness","contrast","saturate","opacity"]);function $Mt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(Gje)||[];if(!n)return t;const a=r.replace(n,"");let o=BMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const qMt=/\b([a-z-]*)\(.*?\)/gu,f1e={...ry,getAnimatableNone:t=>{const s=t.match(qMt);return s?s.map($Mt).join(" "):t}},x1e={...ry,getAnimatableNone:t=>{const s=ry.parse(t);return ry.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},oPe={...aE,transform:Math.round},UMt={rotate:Wb,rotateX:Wb,rotateY:Wb,rotateZ:Wb,scale:gz,scaleX:gz,scaleY:gz,scaleZ:gz,skew:Wb,skewX:Wb,skewY:Wb,distance:la,translateX:la,translateY:la,translateZ:la,x:la,y:la,z:la,perspective:la,transformPerspective:la,opacity:fD,originX:W6e,originY:W6e,originZ:la},sNe={borderWidth:la,borderTopWidth:la,borderRightWidth:la,borderBottomWidth:la,borderLeftWidth:la,borderRadius:la,borderTopLeftRadius:la,borderTopRightRadius:la,borderBottomRightRadius:la,borderBottomLeftRadius:la,width:la,maxWidth:la,height:la,maxHeight:la,top:la,right:la,bottom:la,left:la,inset:la,insetBlock:la,insetBlockStart:la,insetBlockEnd:la,insetInline:la,insetInlineStart:la,insetInlineEnd:la,padding:la,paddingTop:la,paddingRight:la,paddingBottom:la,paddingLeft:la,paddingBlock:la,paddingBlockStart:la,paddingBlockEnd:la,paddingInline:la,paddingInlineStart:la,paddingInlineEnd:la,margin:la,marginTop:la,marginRight:la,marginBottom:la,marginLeft:la,marginBlock:la,marginBlockStart:la,marginBlockEnd:la,marginInline:la,marginInlineStart:la,marginInlineEnd:la,fontSize:la,backgroundPositionX:la,backgroundPositionY:la,...UMt,zIndex:oPe,fillOpacity:fD,strokeOpacity:fD,numOctaves:oPe},VMt={...sNe,color:Qd,backgroundColor:Qd,outlineColor:Qd,fill:Qd,stroke:Qd,borderColor:Qd,borderTopColor:Qd,borderRightColor:Qd,borderBottomColor:Qd,borderLeftColor:Qd,filter:f1e,WebkitFilter:f1e,mask:x1e,WebkitMask:x1e},aZe=t=>VMt[t],HMt=new Set([f1e,x1e]);function iZe(t,s){let r=aZe(t);return HMt.has(r)||(r=ry),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const GMt=new Set(["auto","none","0"]);function WMt(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function rNe(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){const a=document.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const oZe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function Sie(t){return pKe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:nNe}=MKe(queueMicrotask,!1),Ig={x:!1,y:!1};function lZe(){return Ig.x||Ig.y}function ZMt(t){return t==="x"||t==="y"?Ig[t]?null:(Ig[t]=!0,()=>{Ig[t]=!1}):Ig.x||Ig.y?null:(Ig.x=Ig.y=!0,()=>{Ig.x=Ig.y=!1})}function cZe(t,s){const r=rNe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function YMt(t){return!(t.pointerType==="touch"||lZe())}function QMt(t,s,r={}){const[n,a,o]=cZe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const p=()=>{l.removeEventListener("pointerleave",_)},f=j=>{u&&(u(j),u=void 0),p()},g=j=>{i=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),c&&(c=!1,f(j))},v=()=>{i=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},_=j=>{if(j.pointerType!=="touch"){if(i){c=!0;return}f(j)}},w=j=>{if(!YMt(j))return;c=!1;const k=s(l,j);typeof k=="function"&&(u=k,l.addEventListener("pointerleave",_,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",v,a)}),o}const dZe=(t,s)=>s?t===s?!0:dZe(t,s.parentElement):!1,aNe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,XMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function JMt(t){return XMt.has(t.tagName)||t.isContentEditable===!0}const eTt=new Set(["INPUT","SELECT","TEXTAREA"]);function tTt(t){return eTt.has(t.tagName)||t.isContentEditable===!0}const Cie=new WeakSet;function lPe(t){return s=>{s.key==="Enter"&&t(s)}}function Kxe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const sTt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=lPe(()=>{if(Cie.has(r))return;Kxe(r,"down");const a=lPe(()=>{Kxe(r,"up")}),o=()=>Kxe(r,"cancel");r.addEventListener("keyup",a,s),r.addEventListener("blur",o,s)});r.addEventListener("keydown",n,s),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),s)};function cPe(t){return aNe(t)&&!lZe()}const dPe=new WeakSet;function rTt(t,s,r={}){const[n,a,o]=cZe(t,r),l=i=>{const c=i.currentTarget;if(!cPe(i)||dPe.has(i))return;Cie.add(c),r.stopPropagation&&dPe.add(i);const u=s(c,i),p=(v,_)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),Cie.has(c)&&Cie.delete(c),cPe(v)&&typeof u=="function"&&u(v,{success:_})},f=v=>{p(v,c===window||c===document||r.useGlobalTarget||dZe(c,v.target))},g=v=>{p(v,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",g,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Sie(i)&&(i.addEventListener("focus",u=>sTt(u,a)),!JMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function iNe(t){return pKe(t)&&"ownerSVGElement"in t}const Mie=new WeakMap;let Kb;const uZe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:iNe(n)&&"getBBox"in n?n.getBBox()[s]:n[r],nTt=uZe("inline","width","offsetWidth"),aTt=uZe("block","height","offsetHeight");function iTt({target:t,borderBoxSize:s}){var r;(r=Mie.get(t))==null||r.forEach(n=>{n(t,{get width(){return nTt(t,s)},get height(){return aTt(t,s)}})})}function oTt(t){t.forEach(iTt)}function lTt(){typeof ResizeObserver>"u"||(Kb=new ResizeObserver(oTt))}function cTt(t,s){Kb||lTt();const r=rNe(t);return r.forEach(n=>{let a=Mie.get(n);a||(a=new Set,Mie.set(n,a)),a.add(s),Kb==null||Kb.observe(n)}),()=>{r.forEach(n=>{const a=Mie.get(n);a==null||a.delete(s),a!=null&&a.size||Kb==null||Kb.unobserve(n)})}}const Tie=new Set;let xM;function dTt(){xM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Tie.forEach(s=>s(t))},window.addEventListener("resize",xM)}function uTt(t){return Tie.add(t),xM||dTt(),()=>{Tie.delete(t),!Tie.size&&typeof xM=="function"&&(window.removeEventListener("resize",xM),xM=void 0)}}function uPe(t,s){return typeof t=="function"?uTt(t):cTt(t,s)}function hTt(t){return iNe(t)&&t.tagName==="svg"}const mTt=[...nZe,Qd,ry],pTt=t=>mTt.find(rZe(t)),hPe=()=>({translate:0,scale:1,origin:0,originPoint:0}),gM=()=>({x:hPe(),y:hPe()}),mPe=()=>({min:0,max:0}),xu=()=>({x:mPe(),y:mPe()}),fTt=new WeakMap;function vue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function xD(t){return typeof t=="string"||Array.isArray(t)}const oNe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],lNe=["initial",...oNe];function bue(t){return vue(t.animate)||lNe.some(s=>xD(t[s]))}function hZe(t){return!!(bue(t)||t.variants)}function xTt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(kh(a))t.addValue(n,a);else if(kh(o))t.addValue(n,XT(a,{owner:t}));else if(o!==a)if(t.hasValue(n)){const l=t.getValue(n);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=t.getStaticValue(n);t.addValue(n,XT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const g1e={current:null},mZe={current:!1},gTt=typeof window<"u";function yTt(){if(mZe.current=!0,!!gTt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>g1e.current=t.matches;t.addEventListener("change",s),s()}else g1e.current=!1}const pPe=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Zoe={};function pZe(t){Zoe=t}function vTt(){return Zoe}class bTt{scrapeMotionValuesFromProps(s,r,n){return{}}constructor({parent:s,props:r,presenceContext:n,reducedMotionConfig:a,skipAnimations:o,blockInitialAnimation:l,visualState:i},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Qje,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,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 v=km.now();this.renderScheduledAtthis.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(mZe.current||yTt(),this.shouldReduceMotion=g1e.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var s;this.projection&&this.projection.unmount(),_w(this.notifyUpdate),_w(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(s=this.parent)==null||s.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(s){this.children.add(s),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(s)}removeChild(s){this.children.delete(s),this.enteringChildren&&this.enteringChildren.delete(s)}bindToMotionValue(s,r){if(this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)(),r.accelerate&&ZKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:p}=r.accelerate,f=new WKe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:yf(p)}),g=l(f);this.valueSubscriptions.set(s,()=>{g(),f.cancel()});return}const n=oE.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Ol.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,s,r)),this.valueSubscriptions.set(s,()=>{a(),o&&o(),r.owner&&r.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in Zoe){const r=Zoe[s];if(!r)continue;const{isEnabled:n,Feature:a}=r;if(!this.features[s]&&a&&n(this.props)&&(this.features[s]=new a(this)),this.features[s]){const o=this.features[s];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):xu()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,r){this.latestValues[s]=r}update(s,r){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(s)}addValue(s,r){const n=this.values.get(s);r!==n&&(n&&this.removeValue(s),this.bindToMotionValue(s,r),this.values.set(s,r),this.latestValues[s]=r.get())}removeValue(s){this.values.delete(s);const r=this.valueSubscriptions.get(s);r&&(r(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,r){if(this.props.values&&this.props.values[s])return this.props.values[s];let n=this.values.get(s);return n===void 0&&r!==void 0&&(n=XT(r===null?void 0:r,{owner:this}),this.addValue(s,n)),n}readValue(s,r){let n=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:this.getBaseTargetFromProps(this.props,s)??this.readValueFromInstance(this.current,s,this.options);return n!=null&&(typeof n=="string"&&(mKe(n)||fKe(n))?n=parseFloat(n):!pTt(n)&&ry.test(r)&&(n=iZe(s,r)),this.setBaseTarget(s,kh(n)?n.get():n)),kh(n)?n.get():n}setBaseTarget(s,r){this.baseTarget[s]=r}getBaseTarget(s){var o;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const l=eNe(this.props,r,(o=this.presenceContext)==null?void 0:o.custom);l&&(n=l[s])}if(r&&n!==void 0)return n;const a=this.getBaseTargetFromProps(this.props,s);return a!==void 0&&!kh(a)?a:this.initialValues[s]!==void 0&&n===void 0?void 0:this.baseTarget[s]}on(s,r){return this.events[s]||(this.events[s]=new qje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){nNe.render(this.render)}}class fZe extends bTt{constructor(){super(...arguments),this.KeyframeResolver=KMt}sortInstanceNodePosition(s,r){return s.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(s,r){const n=s.style;return n?n[r]:void 0}removeValueFromRenderState(s,{vars:r,style:n}){delete r[s],delete n[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;kh(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class zw{constructor(s){this.isMounted=!1,this.node=s}update(){}}function xZe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function _Tt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function wTt(t,s){if(!s)return t;const r=s({x:t.left,y:t.top}),n=s({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function Zxe(t){return t===void 0||t===1}function y1e({scale:t,scaleX:s,scaleY:r}){return!Zxe(t)||!Zxe(s)||!Zxe(r)}function d4(t){return y1e(t)||gZe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function gZe(t){return fPe(t.x)||fPe(t.y)}function fPe(t){return t&&t!=="0%"}function Yoe(t,s,r){const n=t-r,a=s*n;return r+a}function xPe(t,s,r,n,a){return a!==void 0&&(t=Yoe(t,a,n)),Yoe(t,r,n)+s}function v1e(t,s=0,r=1,n,a){t.min=xPe(t.min,s,r,n,a),t.max=xPe(t.max,s,r,n,a)}function yZe(t,{x:s,y:r}){v1e(t.x,s.translate,s.scale,s.originPoint),v1e(t.y,r.translate,r.scale,r.originPoint)}const gPe=.999999999999,yPe=1.0000000000001;function jTt(t,s,r,n=!1){var i;const a=r.length;if(!a)return;s.x=s.y=1;let o,l;for(let c=0;cgPe&&(s.x=1),s.ygPe&&(s.y=1)}function r0(t,s){t.min+=s,t.max+=s}function vPe(t,s,r,n,a=.5){const o=Sc(t.min,t.max,a);v1e(t,s,r,o,n)}function bPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function Aie(t,s,r){const n=r??t;vPe(t.x,bPe(s.x,n.x),s.scaleX,s.scale,s.originX),vPe(t.y,bPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function vZe(t,s){return xZe(wTt(t.getBoundingClientRect(),s))}function NTt(t,s,r){const n=vZe(t,r),{scroll:a}=s;return a&&(r0(n.x,a.offset.x),r0(n.y,a.offset.y)),n}const kTt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},STt=iE.length;function CTt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(la.test(t))t=parseFloat(t);else return t;const r=_Pe(t,s.target.x),n=_Pe(t,s.target.y);return`${r}% ${n}%`}},MTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=ry.parse(t);if(a.length>5)return n;const o=ry.createTransformer(t),l=typeof a[0]!="number"?1:0,i=r.x.scale*s.x,c=r.y.scale*s.y;a[0+l]/=i,a[1+l]/=c;const u=Sc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},b1e={borderRadius:{...tI,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:tI,borderTopRightRadius:tI,borderBottomLeftRadius:tI,borderBottomRightRadius:tI,boxShadow:MTt};function _Ze(t,{layout:s,layoutId:r}){return oE.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!b1e[t]||t==="opacity")}function dNe(t,s,r){var l;const n=t.style,a=s==null?void 0:s.style,o={};if(!n)return o;for(const i in n)(kh(n[i])||a&&kh(a[i])||_Ze(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function TTt(t){return window.getComputedStyle(t)}class ATt extends fZe{constructor(){super(...arguments),this.type="html",this.renderInstance=bZe}readValueFromInstance(s,r){var n;if(oE.has(r))return(n=this.projection)!=null&&n.isProjecting?i1e(r):Y5t(s,r);{const a=TTt(s),o=(AKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return vZe(s,r)}build(s,r,n){cNe(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return dNe(s,r,n)}}const ETt={offset:"stroke-dashoffset",array:"stroke-dasharray"},PTt={offset:"strokeDashoffset",array:"strokeDasharray"};function ITt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?ETt:PTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const LTt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function wZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,p){if(cNe(t,i,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:g}=t;f.transform&&(g.transform=f.transform,delete f.transform),(g.transform||f.transformOrigin)&&(g.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),g.transform&&(g.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const v of LTt)f[v]!==void 0&&(g[v]=f[v],delete f[v]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&ITt(f,a,o,l,!1)}const jZe=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"]),NZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function DTt(t,s,r,n){bZe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(jZe.has(a)?a:tNe(a),s.attrs[a])}function kZe(t,s,r){const n=dNe(t,s,r);for(const a in t)if(kh(t[a])||kh(s[a])){const o=iE.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class OTt extends fZe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=xu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(oE.has(r)){const n=aZe(r);return n&&n.default||0}return r=jZe.has(r)?r:tNe(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return kZe(s,r,n)}build(s,r,n){wZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){DTt(s,r,n,a)}mount(s){this.isSVGTag=NZe(s.tagName),super.mount(s)}}const RTt=lNe.length;function SZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?SZe(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const s={};for(let r=0;rPromise.all(s.map(({animation:r,options:n})=>RMt(t,r,n)))}function $Tt(t){let s=BTt(t),r=wPe(),n=!0,a=!1;const o=u=>(p,f)=>{var v;const g=kS(t,f,u==="exit"?(v=t.presenceContext)==null?void 0:v.custom:void 0);if(g){const{transition:_,transitionEnd:w,...j}=g;p={...p,...j,...w}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=SZe(t.parent)||{},g=[],v=new Set;let _={},w=1/0;for(let k=0;kw&&P,V=!1;const X=Array.isArray(L)?L:[L];let Y=X.reduce(o(S),{});O===!1&&(Y={});const{prevResolvedValues:ee={}}=M,Q={...ee,...Y},ce=oe=>{B=!0,v.has(oe)&&(V=!0,v.delete(oe)),M.needsAnimating[oe]=!0;const fe=t.getValue(oe);fe&&(fe.liveStyle=!1)};for(const oe in Q){const fe=Y[oe],ge=ee[oe];if(_.hasOwnProperty(oe))continue;let ue=!1;h1e(fe)&&h1e(ge)?ue=!CZe(fe,ge):ue=fe!==ge,ue?fe!=null?ce(oe):v.add(oe):fe!==void 0&&v.has(oe)?ce(oe):M.protectedKeys[oe]=!0}M.prevProp=L,M.prevResolvedValues=Y,M.isActive&&(_={..._,...Y}),(n||a)&&t.blockInitialAnimation&&(B=!1);const ne=$&&U;B&&(!ne||V)&&g.push(...X.map(oe=>{const fe={type:S};if(typeof oe=="string"&&(n||a)&&!ne&&t.manuallyAnimateOnMount&&t.parent){const{parent:ge}=t,ue=kS(ge,oe);if(ge.enteringChildren&&ue){const{delayChildren:xe}=ue.transition||{};fe.delay=YKe(ge.enteringChildren,t,xe)}}return{animation:oe,options:fe}}))}if(v.size){const k={};if(typeof p.initial!="boolean"){const S=kS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(k.transition=S.transition)}v.forEach(S=>{const M=t.getBaseTarget(S),L=t.getValue(S);L&&(L.liveStyle=!0),k[S]=M??null}),g.push({animation:k})}let j=!!g.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(j=!1),n=!1,a=!1,j?s(g):Promise.resolve()}function c(u,p){var g;if(r[u].isActive===p)return Promise.resolve();(g=t.variantChildren)==null||g.forEach(v=>{var _;return(_=v.animationState)==null?void 0:_.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const v in r)r[v].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=wPe(),a=!0}}}function qTt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!CZe(s,t):!1}function V2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function wPe(){return{animate:V2(!0),whileInView:V2(),whileHover:V2(),whileTap:V2(),whileDrag:V2(),whileFocus:V2(),exit:V2()}}function _1e(t,s){t.min=s.min,t.max=s.max}function Cg(t,s){_1e(t.x,s.x),_1e(t.y,s.y)}function jPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const MZe=1e-4,UTt=1-MZe,VTt=1+MZe,TZe=.01,HTt=0-TZe,GTt=0+TZe;function Sm(t){return t.max-t.min}function WTt(t,s,r){return Math.abs(t-s)<=r}function NPe(t,s,r,n=.5){t.origin=n,t.originPoint=Sc(s.min,s.max,t.origin),t.scale=Sm(r)/Sm(s),t.translate=Sc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=UTt&&t.scale<=VTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=HTt&&t.translate<=GTt||isNaN(t.translate))&&(t.translate=0)}function o8(t,s,r,n){NPe(t.x,s.x,r.x,n?n.originX:void 0),NPe(t.y,s.y,r.y,n?n.originY:void 0)}function kPe(t,s,r,n=0){const a=n?Sc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Sm(s)}function KTt(t,s,r,n){kPe(t.x,s.x,r.x,n==null?void 0:n.x),kPe(t.y,s.y,r.y,n==null?void 0:n.y)}function SPe(t,s,r,n=0){const a=n?Sc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Sm(s)}function Qoe(t,s,r,n){SPe(t.x,s.x,r.x,n==null?void 0:n.x),SPe(t.y,s.y,r.y,n==null?void 0:n.y)}function CPe(t,s,r,n,a){return t-=s,t=Yoe(t,1/r,n),a!==void 0&&(t=Yoe(t,1/a,n)),t}function ZTt(t,s=0,r=1,n=.5,a,o=t,l=t){if(C0.test(s)&&(s=parseFloat(s),s=Sc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=Sc(o.min,o.max,n);t===o&&(i-=s),t.min=CPe(t.min,s,r,i,a),t.max=CPe(t.max,s,r,i,a)}function MPe(t,s,[r,n,a],o,l){ZTt(t,s[r],s[n],s[a],s.scale,o,l)}const YTt=["x","scaleX","originX"],QTt=["y","scaleY","originY"];function TPe(t,s,r,n){MPe(t.x,s,YTt,r?r.x:void 0,n?n.x:void 0),MPe(t.y,s,QTt,r?r.y:void 0,n?n.y:void 0)}function APe(t){return t.translate===0&&t.scale===1}function AZe(t){return APe(t.x)&&APe(t.y)}function EPe(t,s){return t.min===s.min&&t.max===s.max}function XTt(t,s){return EPe(t.x,s.x)&&EPe(t.y,s.y)}function PPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function EZe(t,s){return PPe(t.x,s.x)&&PPe(t.y,s.y)}function IPe(t){return Sm(t.x)/Sm(t.y)}function LPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Ky(t){return[t("x"),t("y")]}function JTt(t,s,r){let n="";const a=t.x.translate/s.x,o=t.y.translate/s.y,l=(r==null?void 0:r.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(s.x!==1||s.y!==1)&&(n+=`scale(${1/s.x}, ${1/s.y}) `),r){const{transformPerspective:u,rotate:p,rotateX:f,rotateY:g,skewX:v,skewY:_}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),v&&(n+=`skewX(${v}deg) `),_&&(n+=`skewY(${_}deg) `)}const i=t.x.scale*s.x,c=t.y.scale*s.y;return(i!==1||c!==1)&&(n+=`scale(${i}, ${c})`),n||"none"}const PZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],eAt=PZe.length,DPe=t=>typeof t=="string"?parseFloat(t):t,OPe=t=>typeof t=="number"||la.test(t);function tAt(t,s,r,n,a,o){a?(t.opacity=Sc(0,r.opacity??1,sAt(n)),t.opacityExit=Sc(s.opacity??1,0,rAt(n))):o&&(t.opacity=Sc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(pD(t,s,n))}function nAt(t,s,r){const n=kh(t)?t:XT(t);return n.start(Jje("",n,s,r)),n.animation}function gD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const aAt=(t,s)=>t.depth-s.depth;class iAt{constructor(){this.children=[],this.isDirty=!1}add(s){Bje(this.children,s),this.isDirty=!0}remove(s){Voe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(aAt),this.isDirty=!1,this.children.forEach(s)}}function oAt(t,s){const r=km.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(_w(n),t(o-s))};return Ol.setup(n,!0),()=>_w(n)}function Eie(t){return kh(t)?t.get():t}class lAt{constructor(){this.members=[]}add(s){Bje(this.members,s);for(let r=this.members.length-1;r>=0;r--){const n=this.members[r];if(n===s||n===this.lead||n===this.prevLead)continue;const a=n.instance;(!a||a.isConnected===!1)&&!n.snapshot&&(Voe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Voe(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(s){var r;for(let n=this.members.indexOf(s)-1;n>=0;n--){const a=this.members[n];if(a.isPresent!==!1&&((r=a.instance)==null?void 0:r.isConnected)!==!1)return this.promote(a),!0}return!1}promote(s,r){var a;const n=this.lead;if(s!==n&&(this.prevLead=n,this.lead=s,s.show(),n)){n.updateSnapshot(),s.scheduleRender();const{layoutDependency:o}=n.options,{layoutDependency:l}=s.options;(o===void 0||o!==l)&&(s.resumeFrom=n,r&&(n.preserveOpacity=!0),n.snapshot&&(s.snapshot=n.snapshot,s.snapshot.latestValues=n.animationValues||n.latestValues),(a=s.root)!=null&&a.isUpdating&&(s.isLayoutDirty=!0)),s.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(s=>{var r,n,a,o,l;(n=(r=s.options).onExitComplete)==null||n.call(r),(l=(a=s.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(s=>s.instance&&s.scheduleRender(!1))}removeLeadSnapshot(){var s;(s=this.lead)!=null&&s.snapshot&&(this.lead.snapshot=void 0)}}const Pie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Yxe=["","X","Y","Z"],cAt=1e3;let dAt=0;function Qxe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function LZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=tZe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Ol,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&LZe(n)}function DZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=dAt++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(mAt),this.nodes.forEach(vAt),this.nodes.forEach(bAt),this.nodes.forEach(pAt)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=i?i.root||i:this,this.path=i?[...i.path,i]:[],this.parent=i,this.depth=i?i.depth+1:0;for(let c=0;cthis.root.updateBlockedByResize=!1;Ol.read(()=>{f=window.innerWidth}),t(l,()=>{const v=window.innerWidth;v!==f&&(f=v,this.root.updateBlockedByResize=!0,p&&p(),p=oAt(g,250),Pie.hasAnimatedSinceResize&&(Pie.hasAnimatedSinceResize=!1,this.nodes.forEach(BPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:v})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||u.getDefaultTransition()||kAt,{onLayoutAnimationStart:w,onLayoutAnimationComplete:j}=u.getProps(),k=!this.targetLayout||!EZe(this.targetLayout,v),S=!f&&g;if(this.options.layoutRoot||this.resumeFrom||S||f&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Xje(_,"layout"),onPlay:w,onComplete:j};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(p,S)}else f||BPe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=v})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),_w(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(_At),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&LZe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Sm(this.snapshot.measuredBox.x)&&!Sm(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c{const P=L/1e3;$Pe(f.x,l.x,P),$Pe(f.y,l.y,P),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qoe(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),jAt(this.relativeTarget,this.relativeTargetOrigin,g,P),M&&XTt(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=xu()),Cg(M,this.relativeTarget)),w&&(this.animationValues=p,tAt(p,u,this.latestValues,P,S,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,c,u;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(u=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||u.stop(),this.pendingAnimation&&(_w(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ol.update(()=>{Pie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=XT(0)),this.motionValue.jump(0,!1),this.currentAnimation=nAt(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.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 l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(cAt),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:c,layout:u,latestValues:p}=l;if(!(!i||!c||!u)){if(this!==l&&this.layout&&u&&OZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||xu();const f=Sm(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const g=Sm(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+g}Cg(i,c),Aie(i,p),o8(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new lAt),this.sharedNodes.get(l).add(i);const u=i.options.initialPromotionConfig;i.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(i):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var i;const{layoutId:l}=this.options;return l?((i=this.getStack())==null?void 0:i.lead)||this:this}getPrevLead(){var i;const{layoutId:l}=this.options;return l?(i=this.getStack())==null?void 0:i.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:i,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),l&&(this.projectionDelta=void 0,this.needsReset=!0),i&&this.setOptions({transition:i})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let i=!1;const{latestValues:c}=l;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(i=!0),!i)return;const u={};c.z&&Qxe("z",l,u,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(FPe),this.root.sharedNodes.clear()}}}function uAt(t){t.updateLayout()}function hAt(t){var r;const s=((r=t.resumeFrom)==null?void 0:r.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&s&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=t.layout,{animationType:o}=t.options,l=s.source!==t.layout.source;if(o==="size")Ky(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],v=Sm(g);g.min=n[f].min,g.max=g.min+v});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";_1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else OZe(o,s.layoutBox,n)&&Ky(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],v=Sm(n[f]);g.max=g.min+v,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+v)});const i=gM();o8(i,n,s.layoutBox);const c=gM();l?o8(c,t.applyTransform(a,!0),s.measuredBox):o8(c,n,s.layoutBox);const u=!AZe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:v}=f;if(g&&v){const _=t.options.layoutAnchor||void 0,w=xu();Qoe(w,s.layoutBox,g.layoutBox,_);const j=xu();Qoe(j,n,v.layoutBox,_),EZe(w,j)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=j,t.relativeTargetOrigin=w,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:c,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function mAt(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function pAt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function fAt(t){t.clearSnapshot()}function FPe(t){t.clearMeasurements()}function xAt(t){t.isLayoutDirty=!0,t.updateLayout()}function zPe(t){t.isLayoutDirty=!1}function gAt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function yAt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function BPe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function vAt(t){t.resolveTargetDelta()}function bAt(t){t.calcProjection()}function _At(t){t.resetSkewAndRotation()}function wAt(t){t.removeLeadSnapshot()}function $Pe(t,s,r){t.translate=Sc(s.translate,0,r),t.scale=Sc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function qPe(t,s,r,n){t.min=Sc(s.min,r.min,n),t.max=Sc(s.max,r.max,n)}function jAt(t,s,r,n){qPe(t.x,s.x,r.x,n),qPe(t.y,s.y,r.y,n)}function NAt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const kAt={duration:.45,ease:[.4,0,.1,1]},UPe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),VPe=UPe("applewebkit/")&&!UPe("chrome/")?Math.round:Px;function HPe(t){t.min=VPe(t.min),t.max=VPe(t.max)}function SAt(t){HPe(t.x),HPe(t.y)}function OZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!WTt(IPe(s),IPe(r),.2)}function CAt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const MAt=DZe({attachResizeListener:(t,s)=>gD(t,"resize",s),measureScroll:()=>{var t,s;return{x:document.documentElement.scrollLeft||((t=document.body)==null?void 0:t.scrollLeft)||0,y:document.documentElement.scrollTop||((s=document.body)==null?void 0:s.scrollTop)||0}},checkIsScrollRoot:()=>!0}),Xxe={current:void 0},RZe=DZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Xxe.current){const t=new MAt({});t.mount(window),t.setOptions({layoutScroll:!0}),Xxe.current=t}return Xxe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),uNe=N.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function GPe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function TAt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=GPe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:v,height:_,top:w,left:j,right:k,bottom:S}=c.current;if(s||o===!1||!i.current||!v||!_)return;const M=r==="left"?`left: ${j}`:`right: ${k}`,L=n==="bottom"?`bottom: ${S}`:`top: ${w}`;i.current.dataset.motionPopId=l;const P=document.createElement("style");u&&(P.nonce=u);const O=a??document.head;return O.appendChild(P),P.sheet&&P.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${v}px !important; height: ${_}px !important; ${M}px !important; ${L}px !important; } `),()=>{var $;($=i.current)==null||$.removeAttribute("data-motion-pop-id"),O.contains(P)&&O.removeChild(P)}},[s]),e.jsx(EAt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:N.cloneElement(t,{ref:f})})}const IAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const p=zje(LAt),f=N.useId();let g=!0,v=N.useMemo(()=>(g=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:_=>{p.set(_,!0);for(const w of p.values())if(!w)return;n&&n()},register:_=>(p.set(_,!1),()=>p.delete(_))}),[r,p,n]);return o&&g&&(v={...v}),N.useMemo(()=>{p.forEach((_,w)=>p.set(w,!1))},[r]),N.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(PAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(gue.Provider,{value:v,children:t})};function LAt(){return new Map}function FZe(t=!0){const s=N.useContext(gue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=N.useId();N.useEffect(()=>{if(t)return a(o)},[t]);const l=N.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const yz=t=>t.key||"";function WPe(t){const s=[];return N.Children.forEach(t,r=>{N.isValidElement(r)&&s.push(r)}),s}const zZe=({children:t,custom:s,initial:r=!0,onExitComplete:n,presenceAffectsLayout:a=!0,mode:o="sync",propagate:l=!1,anchorX:i="left",anchorY:c="top",root:u})=>{const[p,f]=FZe(l),g=N.useMemo(()=>WPe(t),[t]),v=l&&!p?[]:g.map(yz),_=N.useRef(!0),w=N.useRef(g),j=zje(()=>new Map),k=N.useRef(new Set),[S,M]=N.useState(g),[L,P]=N.useState(g);hKe(()=>{_.current=!1,w.current=g;for(let U=0;U{const B=yz(U),V=l&&!p?!1:g===L||v.includes(B),X=()=>{if(k.current.has(B))return;if(j.has(B))k.current.add(B),j.set(B,!0);else return;let Y=!0;j.forEach(ee=>{ee||(Y=!1)}),Y&&($==null||$(),P(w.current),l&&(f==null||f()),n&&n())};return e.jsx(IAt,{isPresent:V,initial:!_.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:X,anchorX:i,anchorY:c,children:U},B)})})},BZe=N.createContext({strict:!1}),KPe={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"]};let ZPe=!1;function DAt(){if(ZPe)return;const t={};for(const s in KPe)t[s]={isEnabled:r=>KPe[s].some(n=>!!r[n])};pZe(t),ZPe=!0}function $Ze(){return DAt(),vTt()}function OAt(t){const s=$Ze();for(const r in t)s[r]={...s[r],...t[r]};pZe(s)}const RAt=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","propagate","ignoreStrict","viewport"]);function Xoe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||RAt.has(t)}let qZe=t=>!Xoe(t);function FAt(t){typeof t=="function"&&(qZe=s=>s.startsWith("on")?!Xoe(s):t(s))}try{FAt(require("@emotion/is-prop-valid").default)}catch{}function zAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||kh(t[a])||(qZe(a)||r===!0&&Xoe(a)||!s&&!Xoe(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const _ue=N.createContext({});function BAt(t,s){if(bue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||xD(r)?r:void 0,animate:xD(n)?n:void 0}}return t.inherit!==!1?s:{}}function $At(t){const{initial:s,animate:r}=BAt(t,N.useContext(_ue));return N.useMemo(()=>({initial:s,animate:r}),[YPe(s),YPe(r)])}function YPe(t){return Array.isArray(t)?t.join(" "):t}const hNe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function UZe(t,s,r){for(const n in s)!kh(s[n])&&!_Ze(n,r)&&(t[n]=s[n])}function qAt({transformTemplate:t},s){return N.useMemo(()=>{const r=hNe();return cNe(r,s,t),Object.assign({},r.vars,r.style)},[s])}function UAt(t,s){const r=t.style||{},n={};return UZe(n,r,t),Object.assign(n,qAt(t,s)),n}function VAt(t,s){const r={},n=UAt(t,s);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const VZe=()=>({...hNe(),attrs:{}});function HAt(t,s,r,n){const a=N.useMemo(()=>{const o=VZe();return wZe(o,s,NZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};UZe(o,t.style,t),a.style={...o,...a.style}}return a}const GAt=["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 mNe(t){return typeof t!="string"||t.includes("-")?!1:!!(GAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function WAt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??mNe(t)?HAt:VAt)(s,n,a,t),u=zAt(s,typeof t=="string",o),p=t!==N.Fragment?{...u,...c,ref:r}:{},{children:f}=s,g=N.useMemo(()=>kh(f)?f.get():f,[f]);return N.createElement(t,{...p,children:g})}function KAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:ZAt(r,n,a,t),renderState:s()}}function ZAt(t,s,r,n){const a={},o=n(t,{});for(const g in o)a[g]=Eie(o[g]);let{initial:l,animate:i}=t;const c=bue(t),u=hZe(t);s&&u&&!c&&t.inherit!==!1&&(l===void 0&&(l=s.initial),i===void 0&&(i=s.animate));let p=r?r.initial===!1:!1;p=p||l===!1;const f=p?i:l;if(f&&typeof f!="boolean"&&!vue(f)){const g=Array.isArray(f)?f:[f];for(let v=0;v(s,r)=>{const n=N.useContext(_ue),a=N.useContext(gue),o=()=>KAt(t,s,n,a);return r?o():zje(o)},YAt=HZe({scrapeMotionValuesFromProps:dNe,createRenderState:hNe}),QAt=HZe({scrapeMotionValuesFromProps:kZe,createRenderState:VZe}),XAt=Symbol.for("motionComponentSymbol");function JAt(t,s,r){const n=N.useRef(r);N.useInsertionEffect(()=>{n.current=r});const a=N.useRef(null);return N.useCallback(o=>{var i;o&&((i=t.onMount)==null||i.call(t,o));const l=n.current;if(typeof l=="function")if(o){const c=l(o);typeof c=="function"&&(a.current=c)}else a.current?(a.current(),a.current=null):l(o);else l&&(l.current=o);s&&(o?s.mount(o):s.unmount())},[s])}const GZe=N.createContext({});function K5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function eEt(t,s,r,n,a,o){var M,L;const{visualElement:l}=N.useContext(_ue),i=N.useContext(BZe),c=N.useContext(gue),u=N.useContext(uNe),p=u.reducedMotion,f=u.skipAnimations,g=N.useRef(null),v=N.useRef(!1);n=n||i.renderer,!g.current&&n&&(g.current=n(t,{visualState:s,parent:l,props:r,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),v.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const _=g.current,w=N.useContext(GZe);_&&!_.projection&&a&&(_.type==="html"||_.type==="svg")&&tEt(g.current,r,a,w);const j=N.useRef(!1);N.useInsertionEffect(()=>{_&&j.current&&_.update(r,c)});const k=r[eZe],S=N.useRef(!!k&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,k))&&((L=window.MotionHasOptimisedAnimation)==null?void 0:L.call(window,k)));return hKe(()=>{v.current=!0,_&&(j.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),S.current&&_.animationState&&_.animationState.animateChanges())}),N.useEffect(()=>{_&&(!S.current&&_.animationState&&_.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var P;(P=window.MotionHandoffMarkAsComplete)==null||P.call(window,k)}),S.current=!1),_.enteringChildren=void 0)}),_}function tEt(t,s,r,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:c,layoutRoot:u,layoutAnchor:p,layoutCrossfade:f}=s;t.projection=new r(t.latestValues,s["data-framer-portal-id"]?void 0:WZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&K5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:p})}function WZe(t){if(t)return t.options.allowProjection!==!1?t.projection:WZe(t.parent)}function Jxe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&OAt(n);const o=r?r==="svg":mNe(t),l=o?QAt:YAt;function i(u,p){let f;const g={...N.useContext(uNe),...u,layoutId:sEt(u)},{isStatic:v}=g,_=$At(u),w=l(u,v);if(!v&&typeof window<"u"){rEt();const j=nEt(g);f=j.MeasureLayout,_.visualElement=eEt(t,w,g,a,j.ProjectionNode,o)}return e.jsxs(_ue.Provider,{value:_,children:[f&&_.visualElement?e.jsx(f,{visualElement:_.visualElement,...g}):null,WAt(t,u,JAt(w,_.visualElement,p),w,v,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=N.forwardRef(i);return c[XAt]=t,c}function sEt({layoutId:t}){const s=N.useContext(Fje).id;return s&&t!==void 0?s+"-"+t:t}function rEt(t,s){N.useContext(BZe).strict}function nEt(t){const s=$Ze(),{drag:r,layout:n}=s;if(!r&&!n)return{};const a={...r,...n};return{MeasureLayout:r!=null&&r.isEnabled(t)||n!=null&&n.isEnabled(t)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function aEt(t,s){if(typeof Proxy>"u")return Jxe;const r=new Map,n=(o,l)=>Jxe(o,l,t,s),a=(o,l)=>n(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?n:(r.has(l)||r.set(l,Jxe(l,void 0,t,s)),r.get(l))})}const iEt=(t,s)=>s.isSVG??mNe(t)?new OTt(s):new ATt(s,{allowProjection:t!==N.Fragment});class oEt extends zw{constructor(s){super(s),s.animationState||(s.animationState=$Tt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();vue(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:r}=this.node.prevProps||{};s!==r&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)==null||s.call(this)}}let lEt=0;class cEt extends zw{constructor(){super(...arguments),this.id=lEt++,this.isExitComplete=!1}update(){var o;if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===n)return;if(s&&n===!1){if(this.isExitComplete){const{initial:l,custom:i}=this.node.getProps();if(typeof l=="string"){const c=kS(this.node,l,i);if(c){const{transition:u,transitionEnd:p,...f}=c;for(const g in f)(o=this.node.getValue(g))==null||o.jump(f[g])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const a=this.node.animationState.setActive("exit",!s);r&&!s&&a.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:s,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),s&&(this.unmount=s(this.id))}unmount(){}}const dEt={animation:{Feature:oEt},exit:{Feature:cEt}};function YO(t){return{point:{x:t.pageX,y:t.pageY}}}const uEt=t=>s=>aNe(s)&&t(s,YO(s));function l8(t,s,r,n){return gD(t,s,uEt(r),n)}const KZe=({current:t})=>t?t.ownerDocument.defaultView:null,QPe=(t,s)=>Math.abs(t-s);function hEt(t,s){const r=QPe(t.x,s.x),n=QPe(t.y,s.y);return Math.sqrt(r**2+n**2)}const XPe=new Set(["auto","scroll"]);class ZZe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=v=>{this.handleScroll(v.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=vz(this.lastRawMoveEventInfo,this.transformPagePoint));const v=ege(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,w=hEt(v.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!w)return;const{point:j}=v,{timestamp:k}=_h;this.history.push({...j,timestamp:k});const{onStart:S,onMove:M}=this.handlers;_||(S&&S(this.lastMoveEvent,v),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,v)},this.handlePointerMove=(v,_)=>{this.lastMoveEvent=v,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=vz(_,this.transformPagePoint),Ol.update(this.updatePoint,!0)},this.handlePointerUp=(v,_)=>{this.end();const{onEnd:w,onSessionEnd:j,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=ege(v.type==="pointercancel"?this.lastMoveEventInfo:vz(_,this.transformPagePoint),this.history);this.startEvent&&w&&w(v,S),j&&j(v,S)},!aNe(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=YO(s),u=vz(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=_h;this.history=[{...p,timestamp:f}];const{onSessionStart:g}=r;g&&g(s,ege(u,this.history)),this.removeListeners=WO(l8(this.contextWindow,"pointermove",this.handlePointerMove),l8(this.contextWindow,"pointerup",this.handlePointerUp),l8(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(XPe.has(n.overflowX)||XPe.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(s){const r=this.scrollPositions.get(s);if(!r)return;const n=s===window,a=n?{x:window.scrollX,y:window.scrollY}:{x:s.scrollLeft,y:s.scrollTop},o={x:a.x-r.x,y:a.y-r.y};o.x===0&&o.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(s,a),Ol.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),_w(this.updatePoint)}}function vz(t,s){return s?{point:s(t.point)}:t}function JPe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function ege({point:t},s){return{point:t,delta:JPe(t,YZe(s)),offset:JPe(t,mEt(s)),velocity:pEt(s,.1)}}function mEt(t){return t[0]}function YZe(t){return t[t.length-1]}function pEt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=YZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>yf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>yf(s)*2&&(n=t[1]);const o=wx(a.timestamp-n.timestamp);if(o===0)return{x:0,y:0};const l={x:(a.x-n.x)/o,y:(a.y-n.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}function fEt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?Sc(r,t,n.max):Math.min(t,r)),t}function eIe(t,s,r){return{min:s!==void 0?t.min+s:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function xEt(t,{top:s,left:r,bottom:n,right:a}){return{x:eIe(t.x,r,a),y:eIe(t.y,s,n)}}function tIe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=pD(s.min,s.max-n,t.min):n>a&&(r=pD(t.min,t.max-a,s.min)),I0(0,1,r)}function vEt(t,s){const r={};return s.min!==void 0&&(r.min=s.min-t.min),s.max!==void 0&&(r.max=s.max-t.min),r}const w1e=.35;function bEt(t=w1e){return t===!1?t=0:t===!0&&(t=w1e),{x:sIe(t,"left","right"),y:sIe(t,"top","bottom")}}function sIe(t,s,r){return{min:rIe(t,s),max:rIe(t,r)}}function rIe(t,s){return typeof t=="number"?t:t[s]||0}const _Et=new WeakMap;class wEt{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=xu(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=f=>{r&&this.snapToCursor(YO(f).point),this.stopAnimation()},l=(f,g)=>{const{drag:v,dragPropagation:_,onDragStart:w}=this.getProps();if(v&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ZMt(v),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=g,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ky(k=>{let S=this.getAxisMotionValue(k).get()||0;if(C0.test(S)){const{projection:M}=this.visualElement;if(M&&M.layout){const L=M.layout.layoutBox[k];L&&(S=Sm(L)*(parseFloat(S)/100))}}this.originPoint[k]=S}),w&&Ol.update(()=>w(f,g),!1,!0),m1e(this.visualElement,"transform");const{animationState:j}=this.visualElement;j&&j.setActive("whileDrag",!0)},i=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:v,dragDirectionLock:_,onDirectionLock:w,onDrag:j}=this.getProps();if(!v&&!this.openDragLock)return;const{offset:k}=g;if(_&&this.currentDirection===null){this.currentDirection=NEt(k),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",g.point,k),this.updateAxis("y",g.point,k),this.visualElement.render(),j&&Ol.update(()=>j(f,g),!1,!0)},c=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g,this.stop(f,g),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new ZZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:KZe(this.visualElement),element:this.visualElement.current})}stop(s,r){const n=s||this.latestPointerEvent,a=r||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!a||!n)return;const{velocity:l}=a;this.startAnimation(l);const{onDragEnd:i}=this.getProps();i&&Ol.postRender(()=>i(n,a))}cancel(){this.isDragging=!1;const{projection:s,animationState:r}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(s,r,n){const{drag:a}=this.getProps();if(!n||!bz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=fEt(l,this.constraints[s],this.elastic[s])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:s,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,a=this.constraints;s&&K5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=xEt(n.layoutBox,s):this.constraints=!1,this.elastic=bEt(r),a!==this.constraints&&!K5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Ky(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=vEt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!K5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=NTt(n,a.root,this.visualElement.getTransformPagePoint());let l=gEt(a.layout.layoutBox,o);if(r){const i=r(_Tt(l));this.hasMutatedConstraints=!!i,i&&(l=xZe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Ky(p=>{if(!bz(p,r,this.currentDirection))return;let f=c&&c[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const g=a?200:1e6,v=a?40:1e7,_={type:"inertia",velocity:n?s[p]:0,bounceStiffness:g,bounceDamping:v,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,_)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return m1e(this.visualElement,s),n.start(Jje(s,n,0,r,this.visualElement,!1))}stopAnimation(){Ky(s=>this.getAxisMotionValue(s).stop())}getAxisMotionValue(s){const r=`_drag${s.toUpperCase()}`,n=this.visualElement.getProps(),a=n[r];return a||this.visualElement.getValue(s,(n.initial?n.initial[s]:void 0)||0)}snapToCursor(s){Ky(r=>{const{drag:n}=this.getProps();if(!bz(r,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(r);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[r],c=o.get()||0;o.set(s[r]-Sc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!K5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Ky(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=yEt({min:c,max:c},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ky(l=>{if(!bz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(Sc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;_Et.set(this.visualElement,this);const s=this.visualElement.current,r=l8(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),g=u.target,v=g!==s&&tTt(g);p&&f&&!v&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();K5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=jEt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Ol.read(a);const i=gD(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Ky(f=>{const g=this.getAxisMotionValue(f);g&&(this.originPoint[f]+=u[f].translate,g.set(g.get()+u[f].translate))}),this.visualElement.render())});return()=>{i(),r(),l(),c&&c(),n&&n()}}getProps(){const s=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=w1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function nIe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function jEt(t,s,r){const n=uPe(t,nIe(r)),a=uPe(s,nIe(r));return()=>{n(),a()}}function bz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function NEt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class kEt extends zw{constructor(s){super(s),this.removeGroupControls=Px,this.removeListeners=Px,this.controls=new wEt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Px}update(){const{dragControls:s}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};s!==r&&(this.removeGroupControls(),s&&(this.removeGroupControls=s.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const tge=t=>(s,r)=>{t&&Ol.update(()=>t(s,r),!1,!0)};class SEt extends zw{constructor(){super(...arguments),this.removePointerDownListener=Px}onPointerDown(s){this.session=new ZZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:KZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:tge(s),onStart:tge(r),onMove:tge(n),onEnd:(o,l)=>{delete this.session,a&&Ol.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=l8(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let sge=!1;class CEt extends N.Component{componentDidMount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=s;o&&(r.group&&r.group.add(o),n&&n.register&&a&&n.register(o),sge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Pie.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:r,visualElement:n,drag:a,isPresent:o}=this.props,{projection:l}=n;return l&&(l.isPresent=o,s.layoutDependency!==r&&l.setOptions({...l.options,layoutDependency:r}),sge=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Ol.postRender(()=>{const i=l.getStack();(!i||!i.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:s,layoutAnchor:r}=this.props,{projection:n}=s;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),nNe.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;sge=!0,a&&(a.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(a),n&&n.deregister&&n.deregister(a))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function QZe(t){const[s,r]=FZe(),n=N.useContext(Fje);return e.jsx(CEt,{...t,layoutGroup:n,switchLayoutGroup:N.useContext(GZe),isPresent:s,safeToRemove:r})}const MEt={pan:{Feature:SEt},drag:{Feature:kEt,ProjectionNode:RZe,MeasureLayout:QZe}};function aIe(t,s,r){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",r==="Start");const a="onHover"+r,o=n[a];o&&Ol.postRender(()=>o(s,YO(s)))}class TEt extends zw{mount(){const{current:s}=this.node;s&&(this.unmount=QMt(s,(r,n)=>(aIe(this.node,n,"Start"),a=>aIe(this.node,a,"End"))))}unmount(){}}class AEt extends zw{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!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=WO(gD(this.node.current,"focus",()=>this.onFocus()),gD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function iIe(t,s,r){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",r==="Start");const a="onTap"+(r==="End"?"":r),o=n[a];o&&Ol.postRender(()=>o(s,YO(s)))}class EEt extends zw{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=rTt(s,(a,o)=>(iIe(this.node,o,"Start"),(l,{success:i})=>iIe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const j1e=new WeakMap,rge=new WeakMap,PEt=t=>{const s=j1e.get(t.target);s&&s(t)},IEt=t=>{t.forEach(PEt)};function LEt({root:t,...s}){const r=t||document;rge.has(r)||rge.set(r,{});const n=rge.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(IEt,{root:t,...s})),n[a]}function DEt(t,s,r){const n=LEt(s);return j1e.set(t,r),n.observe(t),()=>{j1e.delete(t),n.unobserve(t)}}const OEt={some:0,all:1};class REt extends zw{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:s={}}=this.node.getProps(),{root:r,margin:n,amount:a="some",once:o}=s,l={root:r?r.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:OEt[a]},i=u=>{const{isIntersecting:p}=u;if(this.isInView===p||(this.isInView=p,o&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:f,onViewportLeave:g}=this.node.getProps(),v=p?f:g;v&&v(u)};this.stopObserver=DEt(this.node.current,l,i)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:r}=this.node;["amount","margin","root"].some(FEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function FEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const zEt={inView:{Feature:REt},tap:{Feature:EEt},focus:{Feature:AEt},hover:{Feature:TEt}},BEt={layout:{ProjectionNode:RZe,MeasureLayout:QZe}},$Et={...dEt,...zEt,...MEt,...BEt},ps=aEt($Et,iEt),qEt={some:0,all:1};function UEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=rNe(t),l=new WeakMap,i=u=>{u.forEach(p=>{const f=l.get(p.target);if(p.isIntersecting!==!!f)if(p.isIntersecting){const g=s(p.target,p);typeof g=="function"?l.set(p.target,g):c.unobserve(p.target)}else typeof f=="function"&&(f(p),l.delete(p.target))})},c=new IntersectionObserver(i,{root:r,rootMargin:n,threshold:typeof a=="number"?a:qEt[a]});return o.forEach(u=>c.observe(u)),()=>c.disconnect()}function k3(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=N.useState(o);return N.useEffect(()=>{if(!t.current||a&&l)return;const c=()=>(i(!0),a?void 0:()=>i(!1)),u={root:s&&s.current||void 0,margin:r,amount:n};return UEt(t.current,c,u)},[s,t,r,a,n]),l}function VEt(t){switch(t){case"buying":return{label:"Buying",emoji:"🏠",color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30"};case"selling":return{label:"Selling",emoji:"📋",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"};case"neighbor":return{label:"Neighbor",emoji:"👋",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"};case"browsing":return{label:"Browsing",emoji:"👀",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"};default:return{label:"Visitor",emoji:"🙂",color:"bg-slate-500/15 text-slate-300 border-slate-500/30"}}}function oIe(t){return t.visitor_intent==="buying"&&!t.has_agent}function HEt({token:t}={}){var _;const s=lo(),r=t||s.token,{data:n,isLoading:a,isError:o}=ACt(r),l=Xt(),i=(_=n==null?void 0:n.open_houses)==null?void 0:_.id,{data:c}=mt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:w,error:j}=await H.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(j)throw j;return w},enabled:!!i});if(N.useEffect(()=>{if(!i)return;const w=H.channel(`cohost-visitors-${i}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${i}`},()=>{l.invalidateQueries({queryKey:["cohost-visitors",i]})}).subscribe();return()=>{H.removeChannel(w)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(c==null?void 0:c.length)||0,f=(c==null?void 0:c.filter(w=>w.visitor_intent==="buying").length)||0,g=(c==null?void 0:c.filter(oIe).length)||0,v=w=>{if(!w)return"";const[j,k]=w.split(":"),S=parseInt(j);return`${S>12?S-12:S||12}:${k} ${S>=12?"PM":"AM"}`};return e.jsxs("div",{className:"fixed inset-0 bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col",children:[e.jsxs("div",{className:"border-b border-white/10 px-4 sm:px-6 py-3 flex items-center justify-between bg-black/30 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-xs font-medium text-emerald-400 uppercase tracking-wider",children:"Live · Co-Host View"})]}),e.jsx("h1",{className:"text-white font-bold text-sm sm:text-base truncate",children:u.property_address})]}),e.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 text-white/70",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(sh,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:g})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:f})]})]})]}),e.jsxs("div",{className:"px-4 sm:px-6 py-2 flex items-center gap-4 text-xs text-white/40 border-b border-white/5",children:[e.jsx("span",{children:ms(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[v(u.start_time),u.end_time?` – ${v(u.end_time)}`:""]})]}),e.jsx(Ki,{className:"flex-1 p-4 sm:p-6",children:c!=null&&c.length?e.jsx("div",{className:"space-y-2 max-w-3xl mx-auto",children:e.jsx(zZe,{children:c.map((w,j)=>{var M;const k=VEt(w.visitor_intent),S=oIe(w);return e.jsxs(ps.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:j*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(M=w.first_name[0])==null?void 0:M.toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-semibold text-white truncate",children:[w.first_name," ",w.last_name||""]}),S&&e.jsx(st,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),w.has_agent&&e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-yellow-500/40 text-yellow-400",children:"⚠️ Has Agent"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs(st,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${k.color}`,children:[k.emoji," ",k.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ms(new Date(w.created_at),"h:mm a")})]})]})]},w.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(x1,{className:"h-10 w-10 text-white/20"})}),e.jsx("h2",{className:"text-xl font-bold text-white/60 mb-1",children:"Waiting for visitors..."}),e.jsx("p",{className:"text-white/30 text-sm",children:"New sign-ins will appear here in real-time"})]})})]})}function GEt(){const s=dc().pathname.slice(1);if(N.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),s.startsWith("live/")){const r=s.slice(5);if(r)return e.jsx(HEt,{token:r})}return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),e.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),e.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):e.jsx(XWe,{slug:s})}function WEt({dealData:t,agentProfile:s,welcomeMessage:r,isWon:n}){var o;const a=t!=null&&t.property_address?`${t.property_address}, ${t.city||""}, ${t.state||""}`.replace(/,\s*,/g,",").replace(/,\s*$/,""):null;return e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white px-4 pt-10 pb-16",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"24px 24px"}}),e.jsxs("div",{className:"relative text-center max-w-lg mx-auto",children:[s&&e.jsxs("div",{className:"mb-6",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.name,className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 object-cover"}):e.jsx("div",{className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 bg-white/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl font-bold text-white/70",children:((o=s.name)==null?void 0:o.charAt(0))||"?"})}),e.jsx("p",{className:"text-sm font-medium text-white/90",children:s.name}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Your Real Estate Agent"})]}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 bg-white/10 backdrop-blur-sm rounded-full px-3 py-1 text-xs font-medium text-white/80 mb-3",children:[e.jsx(dn,{className:"w-3 h-3"}),(t==null?void 0:t.deal_type)==="listing"?"Listing":(t==null?void 0:t.deal_type)==="buy-side"?"Purchase":"Transaction"]}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight mb-1.5 font-serif",children:(t==null?void 0:t.deal_name)||"Your Transaction Portal"}),a&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-white/60 text-sm",children:[e.jsx(ia,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:a})]}),r&&e.jsx("p",{className:"mt-4 text-sm text-white/70 leading-relaxed max-w-sm mx-auto",children:r})]})]}),s&&e.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-8 relative z-10",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-4",children:e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Mn,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Call"})]}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(lr,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Email"})]}),s.phone&&e.jsxs("a",{href:`sms:${s.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(qc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function KEt({journeyStages:t,currentIndex:s}){return t.length===0?null:e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),e.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),e.jsx("div",{className:"relative",children:t.map((r,n)=>{const a=ns;return e.jsxs("div",{className:"flex items-start gap-3.5 relative",children:[n{var l,i;if(o.includes("youtube.com/watch")){const c=new URL(o).searchParams.get("v");return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("youtu.be/")){const c=(l=o.split("youtu.be/")[1])==null?void 0:l.split("?")[0];return c?`https://www.youtube.com/embed/${c}`:null}if(o.includes("loom.com/share/")){const c=(i=o.split("loom.com/share/")[1])==null?void 0:i.split("?")[0];return c?`https://www.loom.com/embed/${c}`:null}return o};return e.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[e.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sa,{className:"w-4 h-4 text-white/80"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-lg font-bold text-slate-800",children:t.label}),e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:t.description})]}),s&&e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),e.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:s})]}),r&&e.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),e.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:r})]}),n&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:e.jsx("iframe",{src:a(n)||n,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Next step video"})})]})]})}function Rl(t){const s=t.split(/[-/T]/);if(s.length>=3){const r=Number(s[0]);return r>99?new Date(r,Number(s[1])-1,Number(s[2])):new Date(Number(s[2]),Number(s[0])-1,Number(s[1]))}return new Date(`${t}T12:00:00`)}function QEt(t,s){const r=ms(s,"yyyyMMdd");return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:t,dates:`${r}/${r}`,details:"Added from your Client Portal"}).toString()}`}function XEt(t,s){const r=ms(s,"yyyyMMdd");return`data:text/calendar;charset=utf-8,${encodeURIComponent(`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:${r} DTEND;VALUE=DATE:${r} SUMMARY:${t} DESCRIPTION:Added from your Client Portal END:VEVENT END:VCALENDAR`)}`}function JEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:OM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:sn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:dn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:hn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const p=Rl(c);if(u==="google")window.open(QEt(i,p),"_blank");else{const f=XEt(i,p),g=document.createElement("a");g.href=f,g.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,g.click()}};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),e.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:c,icon:u,color:p})=>{const f=Rl(c),g=k0(f)&&!_u(f),v=_u(f),_=!g&&!v;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${v?"text-emerald-600":g?"text-slate-400":"text-slate-800"}`,children:[ms(f,"MMM d, yyyy"),v&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),g&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),_&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,c,"google"),className:"text-xs text-slate-400 hover:text-blue-500 transition-colors px-1.5 py-1 rounded hover:bg-blue-50",title:"Add to Google Calendar",children:e.jsx(V_,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>l(i,c,"apple"),className:"text-[10px] text-slate-400 hover:text-slate-600 transition-colors px-1.5 py-1 rounded hover:bg-slate-100",title:"Download .ics file",children:".ics"})]})]},i)})})]})}function e6t({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await H.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(wn,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(vi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function t6t({updates:t}){const s=r=>{var n,a;if(r.includes("youtube.com/watch")){const o=new URL(r).searchParams.get("v");return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("youtu.be/")){const o=(n=r.split("youtu.be/")[1])==null?void 0:n.split("?")[0];return o?`https://www.youtube.com/embed/${o}`:null}if(r.includes("loom.com/share/")){const o=(a=r.split("loom.com/share/")[1])==null?void 0:a.split("?")[0];return o?`https://www.loom.com/embed/${o}`:null}return r};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-4",children:"Updates from Your Agent"}),e.jsx("div",{className:"space-y-4",children:t.map((r,n)=>e.jsx("div",{className:`${n>0?"pt-4 border-t border-slate-100":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${r.is_stage_change?"bg-emerald-100":"bg-blue-100"}`,children:r.is_stage_change?e.jsx(_d,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Lm,{className:"w-3.5 h-3.5 text-blue-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium text-slate-800",children:r.title}),e.jsx("span",{className:"text-xs text-slate-400 flex-shrink-0",children:ms(new Date(r.created_at),"MMM d")})]}),r.content&&e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:r.content}),r.video_url&&e.jsx("div",{className:"mt-3 rounded-xl overflow-hidden bg-slate-900 aspect-video",children:e.jsx("iframe",{src:s(r.video_url)||r.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:r.title})})]})]})},r.id))})]})}function s6t({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var _,w;const[l,i]=N.useState({first_name:((_=t.client_name)==null?void 0:_.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[c,u]=N.useState({}),[p,f]=N.useState(!1),g=Lt({mutationFn:async()=>{const{error:j}=await H.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(c).length>0?c:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(j)throw j},onSuccess:o,onError:j=>{console.error("[PortalOnboarding] Submit failed:",j),me.error("Something went wrong. Please try again.")}}),v=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),v&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(ia,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:v.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),g.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:j=>i(k=>({...k,first_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:j=>i(k=>({...k,last_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:j=>i(k=>({...k,email:j.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.phone,onChange:j=>i(k=>({...k,phone:j.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(j=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,preferred_contact_method:j.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===j.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.label},j.value))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(j=>e.jsx("button",{type:"button",onClick:()=>i(k=>({...k,client_role:j})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===j?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),n.map(j=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs text-slate-600",children:[j.question_text," ",j.is_required&&"*"]}),j.field_type==="text"&&e.jsx(ze,{required:j.is_required,value:c[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 rounded-xl"}),j.field_type==="textarea"&&e.jsx("textarea",{required:j.is_required,value:c[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),j.field_type==="dropdown"&&e.jsxs("select",{required:j.is_required,value:c[j.id]||"",onChange:k=>u(S=>({...S,[j.id]:k.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(j.options||[]).map(k=>e.jsx("option",{value:k,children:k},k))]}),j.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(k=>e.jsx("button",{type:"button",onClick:()=>u(S=>({...S,[j.id]:k})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[j.id]===k?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:k},k))})]},j.id)),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:j=>i(k=>({...k,notes:j.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&e.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(ze,{value:l.spouse_first_name,onChange:j=>i(k=>({...k,spouse_first_name:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.spouse_last_name,onChange:j=>i(k=>({...k,spouse_last_name:j.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.spouse_email,onChange:j=>i(k=>({...k,spouse_email:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.spouse_phone,onChange:j=>i(k=>({...k,spouse_phone:j.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:g.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:g.isPending?"Submitting...":"Access My Portal"})]})]})}function r6t(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function n6t(t){return t==="buy-side"?"We're actively searching for homes that match your criteria.":t==="listing"?"Your property is now being marketed to potential buyers.":"Your transaction is actively moving forward."}const a6t={Lead:{label:"Getting Started",description:"We're beginning your home journey and preparing the next steps."},Consultation:{label:"Planning Your Move",description:"We're discussing your goals and building a plan for buying or selling."},"Agreement Signed":{label:"Officially Working Together",description:"We've signed the agreement and are moving forward together."},"Under Contract":{label:"Under Contract",description:"Your offer has been accepted and we are now moving through inspections and due diligence."},Closing:{label:"Final Steps to Closing",description:"We're finalizing documents and preparing for closing day."},"Closed Won":{label:"Closing Day",description:"Congratulations! Your transaction is complete. 🎉"}},XZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function pNe(t){return XZe.map(s=>{if(s==="Active")return{key:"Active",label:r6t(t),description:n6t(t)};const r=a6t[s];return{key:s,label:r.label,description:r.description}})}function lIe(t){if(!t)return 0;const s=XZe.indexOf(t);return s>=0?s:0}function i6t(t,s){return mt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function o6t(t){return mt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function JZe({slug:t}){var ee,Q,ce,ne,re,oe;const[s,r]=N.useState(!1),[n,a]=N.useState("primary"),[o]=N.useState(()=>{const fe=`portal_fp_${t}`;let ge=localStorage.getItem(fe);return ge||(ge=localStorage.getItem("portal_fp"),ge?localStorage.setItem(fe,ge):(ge=crypto.randomUUID(),localStorage.setItem(fe,ge),localStorage.setItem("portal_fp",ge))),ge});N.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=i6t(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=o6t(u),f=(ee=l==null?void 0:l.deal_pipeline)==null?void 0:ee.owner_user_id,{data:g}=mt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:fe,error:ge}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(ge)throw ge;return fe},enabled:!!f}),{data:v}=mt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:fe,error:ge}=await H.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(ge)throw ge;return fe},enabled:!!f}),_=n==="linked"&&p?p:l,w=_==null?void 0:_.id,{data:j}=mt({queryKey:["portal-updates-public",w],queryFn:async()=>{const{data:fe,error:ge}=await H.from("portal_updates").select("*").eq("portal_id",w).order("created_at",{ascending:!1});if(ge)throw ge;return fe},enabled:!!w}),k=(Q=_==null?void 0:_.deal_pipeline)==null?void 0:Q.id,{data:S}=mt({queryKey:["portal-documents",k],queryFn:async()=>{const{data:fe,error:ge}=await H.from("deal_files").select("*").eq("deal_id",k).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(ge)throw ge;return fe},enabled:!!k}),M=l==null?void 0:l.id,{data:L,isLoading:P}=mt({queryKey:["portal-onboarding-check",M,o],queryFn:async()=>{const{data:fe,error:ge}=await H.from("portal_onboarding_submissions").select("id").eq("portal_id",M).eq("device_fingerprint",o).maybeSingle();if(ge)throw ge;return fe},enabled:!!M&&!!(l!=null&&l.require_onboarding)}),{data:O}=mt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:fe,error:ge}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(ge)throw ge;return fe},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),$=!!L||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&P)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[e.jsx(vs,{className:"h-48 w-full rounded-2xl"}),e.jsx(vs,{className:"h-10 w-48 mx-auto"}),e.jsx(vs,{className:"h-32 w-full rounded-2xl"}),e.jsx(vs,{className:"h-24 w-full rounded-2xl"})]})});if(c||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!$){const fe=l==null?void 0:l.deal_pipeline;return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:e.jsx(s6t,{portal:l,dealData:fe,agentProfile:v,customQuestions:O||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const U=(ce=l==null?void 0:l.deal_pipeline)==null?void 0:ce.deal_type,B=(ne=p==null?void 0:p.deal_pipeline)==null?void 0:ne.deal_type,V=!!p,X=fe=>fe==="listing"?"Your Sale":fe==="buy-side"?"Your Purchase":"Transaction",Y=fe=>fe==="listing"?e.jsx(dn,{className:"w-3.5 h-3.5"}):e.jsx(Sp,{className:"w-3.5 h-3.5"});return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[e.jsx(WEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:v,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(oe=(re=_==null?void 0:_.deal_pipeline)==null?void 0:re.deal_pipeline_stages)==null?void 0:oe.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[V&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[Y(U),X(U)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[Y(B),X(B)]})]}),e.jsx(l6t,{portal:_,updates:j,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(Au,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),v&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:v.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function l6t({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,c=t.stage_mapping;let u=pNe(i);c&&c.length>0&&(u=c.map((v,_)=>{var w,j;return{key:`custom-${_}`,label:v.label||((w=u[_])==null?void 0:w.label)||`Stage ${_+1}`,description:v.description||((j=u[_])==null?void 0:j.description)||"",video_url:v.video_url||void 0}}));const p=c&&c.length>0?Math.min(lIe(o==null?void 0:o.name),u.length-1):lIe(o==null?void 0:o.name),f=u[p],g=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(ZEt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(KEt,{journeyStages:u,currentIndex:p}),f&&e.jsx(YEt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:g||t.next_step_video_url}),e.jsx(JEt,{targetCloseDate:a==null?void 0:a.target_close_date,contractDate:a==null?void 0:a.contract_date,inspectionDate:t.inspection_date,appraisalDate:t.appraisal_date,actualCloseDate:a==null?void 0:a.actual_close_date}),r&&r.length>0&&e.jsx(e6t,{documents:r}),s&&s.length>0&&e.jsx(t6t,{updates:s}),l&&t.show_post_close_tips&&e.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50 rounded-2xl p-6 border border-emerald-100 text-center",children:[e.jsx("span",{className:"text-4xl mb-3 block",children:"🎉"}),e.jsx("h3",{className:"text-lg font-bold text-emerald-900 mb-2",children:"Congratulations!"}),e.jsx("p",{className:"text-sm text-emerald-700",children:"Your transaction has been completed. Welcome to your new home!"}),t.review_url&&e.jsx("a",{href:t.review_url,target:"_blank",rel:"noopener noreferrer",className:"mt-4 inline-block bg-emerald-600 text-white text-sm font-medium px-6 py-2.5 rounded-full hover:bg-emerald-700 transition-colors",children:"Leave a Review ⭐"})]})]})}function c6t(){const s=dc().pathname.slice(1);return N.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),e.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):e.jsx(JZe,{slug:s})}const N1e="levelup_affiliate_ref",d6t=30,u6t=()=>{const[t]=uc();N.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(N1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},h6t=()=>{try{const t=localStorage.getItem(N1e);if(!t)return null;const s=JSON.parse(t),r=d6t*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(N1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},Joe="/assets/levelup-logo-header-_ZX7DvlA.png",m6t="/assets/scale-your-team-ku4MPatU.png";function p6t({open:t,onOpenChange:s}){return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(Ca,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Wr,{children:"Learn how LevelUp can empower your entire team"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/brokerinterestmeeting",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Brokerage Interest Meeting"})]})})}const Vu={individual_agent:{name:"Individual Agent",price:"$39",period:"/month",description:"Perfect for independent agents ready to level up",features:["Full dashboard access","300+ professional templates","Academy training library","Community & networking","Live events & workshops","Social media content","Newsletter resources","Email support"],trial:"7-day free trial"},brokerage_under_25:{name:"Brokerage",subtitle:"Under 25 Agents",price:"$299",period:"/month",description:"Empower your entire team to succeed",features:["Everything in Individual","Brokerage manager dashboard","Invite & manage up to 25 agents","Exclusive brokerage resources","Team performance analytics","Agent onboarding tools","Resource sharing","Priority support"]},brokerage_over_25:{name:"Brokerage",subtitle:"Over 25 Agents",price:"$499",period:"/month",description:"Scale your brokerage without limits",features:["Everything in Brokerage","Unlimited agents","Advanced team analytics","Dedicated account manager","Custom onboarding sessions","White-glove support"]}},f6t=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:qc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:wn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:So,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],x6t=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:fn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Mn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ah,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ia,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:yo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ya,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Yh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],g6t=[{name:"Sarah M.",role:"Top Producer, RE/MAX",quote:"LevelUp completely transformed how I run my business. The templates alone save me hours every week."},{name:"Mike T.",role:"Brokerage Owner",quote:"Onboarding new agents used to take weeks. Now they're productive from day one with all the training resources."},{name:"Jessica L.",role:"Team Lead",quote:"The community is incredible. I've learned more from other agents here than any conference I've attended."}],y6t=()=>{const{user:t,loading:s}=Os(),r=nr(),[n]=uc();N.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",U=window.location.pathname==="/";if($&&U){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=N.useState(null),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState(""),[j,k]=N.useState(!1),[S,M]=N.useState(!1),L=($,U=!1)=>{i({tier:$,skipTrial:U}),u(!0)};u6t(),N.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",U=location.pathname.startsWith("/public/");!s&&t&&!$&&!U&&r("/dashboard")},[t,s,r,location.pathname]),N.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const P=async($,U=!1)=>{if(!p){me.error("Please enter your email address");return}if(!g.trim()){me.error("Please enter your full name");return}k(!0),o($+(U?"_direct":""));const B=h6t();try{const{data:V,error:X}=await H.functions.invoke("create-checkout",{body:{tier:$,email:p,name:g.trim(),couponCode:_.trim()||void 0,skipTrial:U,referralCode:B}});if(X)throw X;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),me.error(V.message||"Failed to start checkout. Please try again.")}finally{k(!1),o(null),u(!1),i(null)}},O=()=>{l&&P(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:Joe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("free-trial"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Sa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("brokerage"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(Ca,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(Wi,{className:"mr-2 h-5 w-5"}),"Individual Membership"]})]})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:f6t.map(($,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx($.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},U))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(fn,{className:"w-4 h-4"}),"Included with Membership"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:x6t.map(($,U)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx($.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},U))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Sa,{className:"ml-2 w-5 h-5"})]})})]})]}),e.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-[#4a6b6d]/10 text-[#4a6b6d] text-sm font-medium",children:[e.jsx(Ca,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map(($,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ba,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:$})]},U))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(oa,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>M(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(hn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:m6t,alt:"Scale Your Team from 5 to 500 Agents",className:"w-full rounded-3xl shadow-lg"})})]})})})}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Agents Love ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"LevelUp"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what top producers are saying about the platform."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto",children:g6t.map(($,U)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(B=>e.jsx(Jn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},B))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',$.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.role})]})]})},U))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>L("individual_agent"),children:["Start Free Trial",e.jsx(Sa,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),e.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Choose the plan that fits your needs. All plans include everything you need to succeed."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Wi,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:Vu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Vu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Vu.individual_agent.period})]}),e.jsx(gr,{className:"text-base mt-2",children:Vu.individual_agent.description}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-500/10 text-green-600 text-sm font-medium mt-4",children:[e.jsx(un,{className:"w-4 h-4"}),Vu.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Vu.individual_agent.features.map(($,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},U))})}),e.jsxs(t8,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>L("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(Pt,{className:"pb-4 pt-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(Ca,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:Vu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vu.brokerage_under_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Vu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Vu.brokerage_under_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:Vu.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Vu.brokerage_under_25.features.map(($,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},U))})}),e.jsx(t8,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Ca,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-xl font-sans",children:Vu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vu.brokerage_over_25.subtitle})]})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Vu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Vu.brokerage_over_25.period})]}),e.jsx(gr,{className:"text-base mt-2",children:Vu.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Vu.brokerage_over_25.features.map(($,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},U))})}),e.jsx(t8,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>L("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx(Sa,{className:"ml-2 w-5 h-5"})]}),e.jsx(K,{size:"lg",onClick:()=>r("/auth"),className:"px-10 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#4a6b6d]",children:"Sign In"})]})]})})]}),e.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("img",{src:Joe,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("a",{href:"/privacy-policy",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Privacy Policy"}),e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Contact Support"})]})]})})}),e.jsx(p6t,{open:S,onOpenChange:M}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Wr,{children:(l==null?void 0:l.tier)==="individual_agent"&&!(l!=null&&l.skipTrial)?"Start your 7-day free trial":(l==null?void 0:l.tier)==="individual_agent"?"Subscribe to Individual Agent":(l==null?void 0:l.tier)==="brokerage_under_25"?"Subscribe to Brokerage (Under 25 Agents)":"Subscribe to Brokerage (Over 25 Agents)"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ze,{id:"dialog-name",type:"text",placeholder:"John Smith",value:g,onChange:$=>v($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ze,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:$=>f($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(be,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(ze,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:_,onChange:$=>w($.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:O,disabled:j,children:j?"Loading...":"Continue to Checkout"})]})})]})},v6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:"Privacy Policy | LevelUp"}),e.jsx("meta",{name:"description",content:"Privacy Policy for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Privacy Policy"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Introduction"}),e.jsx("p",{children:'Welcome to LevelUp ("we," "our," or "us"). We are committed to protecting your personal information and your right to privacy. This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you use our platform.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Information We Collect"}),e.jsx("p",{children:"We collect information that you provide directly to us, including:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Name and contact information (email address, phone number)"}),e.jsx("li",{children:"Account credentials"}),e.jsx("li",{children:"Profile information"}),e.jsx("li",{children:"Transaction and billing information"}),e.jsx("li",{children:"Communications you send to us"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. How We Use Your Information"}),e.jsx("p",{children:"We use the information we collect to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide, maintain, and improve our services"}),e.jsx("li",{children:"Process transactions and send related information"}),e.jsx("li",{children:"Send you technical notices and support messages"}),e.jsx("li",{children:"Respond to your comments and questions"}),e.jsx("li",{children:"Communicate with you about products, services, and events"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Information Sharing"}),e.jsx("p",{children:"We do not sell, trade, or otherwise transfer your personal information to third parties without your consent, except as described in this policy or as required by law."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Data Security"}),e.jsx("p",{children:"We implement appropriate technical and organizational measures to protect the security of your personal information. However, no method of transmission over the Internet is 100% secure."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Your Rights"}),e.jsx("p",{children:"You have the right to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Access your personal information"}),e.jsx("li",{children:"Correct inaccurate data"}),e.jsx("li",{children:"Request deletion of your data"}),e.jsx("li",{children:"Opt-out of marketing communications"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Third-Party Services"}),e.jsx("p",{children:"Our platform may integrate with third-party services such as Facebook and Instagram for social media posting features. When you connect these accounts, you are subject to their respective privacy policies."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Contact Us"}),e.jsxs("p",{children:["If you have questions about this Privacy Policy, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),b6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:"Terms of Service | LevelUp"}),e.jsx("meta",{name:"description",content:"Terms of Service for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Terms of Service"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Acceptance of Terms"}),e.jsx("p",{children:'By accessing or using the LevelUp platform ("Service"), you agree to be bound by these Terms of Service. If you do not agree to these terms, please do not use our Service.'})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Description of Service"}),e.jsx("p",{children:"LevelUp provides a platform for real estate professionals to access training, resources, marketing tools, and community features. We reserve the right to modify or discontinue the Service at any time."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. User Accounts"}),e.jsx("p",{children:"To use certain features, you must create an account. You agree to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Provide accurate and complete information"}),e.jsx("li",{children:"Maintain the security of your account credentials"}),e.jsx("li",{children:"Notify us immediately of any unauthorized access"}),e.jsx("li",{children:"Accept responsibility for all activities under your account"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Acceptable Use"}),e.jsx("p",{children:"You agree not to:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Violate any applicable laws or regulations"}),e.jsx("li",{children:"Infringe on the rights of others"}),e.jsx("li",{children:"Upload malicious code or interfere with the Service"}),e.jsx("li",{children:"Attempt to gain unauthorized access to any part of the Service"}),e.jsx("li",{children:"Use the Service for any unlawful purpose"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Intellectual Property"}),e.jsx("p",{children:"The Service and its original content, features, and functionality are owned by LevelUp and are protected by international copyright, trademark, and other intellectual property laws."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Third-Party Integrations"}),e.jsx("p",{children:"Our Service may integrate with third-party platforms such as Facebook and Instagram. Your use of these integrations is subject to the terms and policies of those third parties. We are not responsible for the content or practices of any third-party services."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Payment Terms"}),e.jsx("p",{children:"Certain features may require payment. By subscribing to paid features, you agree to pay all applicable fees. All payments are non-refundable unless otherwise specified."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Limitation of Liability"}),e.jsx("p",{children:"To the maximum extent permitted by law, LevelUp shall not be liable for any indirect, incidental, special, consequential, or punitive damages resulting from your use of the Service."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"9. Termination"}),e.jsx("p",{children:"We may terminate or suspend your account at any time, without prior notice, for conduct that we believe violates these Terms or is harmful to other users, us, or third parties."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"10. Changes to Terms"}),e.jsx("p",{children:"We reserve the right to modify these Terms at any time. We will notify you of significant changes by posting a notice on our platform. Continued use of the Service constitutes acceptance of the modified terms."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"11. Contact Us"}),e.jsxs("p",{children:["If you have questions about these Terms, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),_6t=()=>e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:"Data Deletion | LevelUp"}),e.jsx("meta",{name:"description",content:"Data deletion instructions for LevelUp platform"})]}),e.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Data Deletion Instructions"}),e.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"How to Request Data Deletion"}),e.jsx("p",{children:"If you wish to have your data deleted from LevelUp, you can request deletion through one of the following methods:"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 1: Email Request"}),e.jsxs("p",{children:["Send an email to"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})," ",'with the subject line "Data Deletion Request" and include:']}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your full name"}),e.jsx("li",{children:"The email address associated with your account"}),e.jsx("li",{children:"A clear statement requesting deletion of your data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 2: Account Settings"}),e.jsx("p",{children:"If you have an active account, you can request data deletion through your account settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Log in to your LevelUp account"}),e.jsx("li",{children:"Navigate to your Profile settings"}),e.jsx("li",{children:"Contact support through the Support page to request account deletion"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"What Data Will Be Deleted"}),e.jsx("p",{children:"Upon a valid deletion request, we will delete:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Your account information (name, email, profile data)"}),e.jsx("li",{children:"Any content you have created or uploaded"}),e.jsx("li",{children:"Your activity history and preferences"}),e.jsx("li",{children:"Connected social media account tokens and data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Data Retention"}),e.jsx("p",{children:"Some data may be retained for legal or legitimate business purposes, such as:"}),e.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Transaction records required for financial reporting"}),e.jsx("li",{children:"Data necessary to comply with legal obligations"}),e.jsx("li",{children:"Anonymized or aggregated data that cannot identify you"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Facebook/Instagram Data"}),e.jsx("p",{children:"If you have connected your Facebook or Instagram account to LevelUp, you can also manage your data through Facebook's settings:"}),e.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[e.jsx("li",{children:"Go to your Facebook Settings & Privacy → Settings"}),e.jsx("li",{children:'Click on "Apps and Websites"'}),e.jsx("li",{children:'Find LevelUp and click "Remove"'}),e.jsx("li",{children:"This will revoke our access to your Facebook/Instagram data"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Processing Time"}),e.jsx("p",{children:"We will process your data deletion request within 30 days of receiving it. You will receive a confirmation email once your data has been deleted."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Contact Us"}),e.jsxs("p",{children:["If you have questions about data deletion, please contact us at"," ",e.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),w6t=N3({email:_c().email("Invalid email address"),password:_c().min(6,"Password must be at least 6 characters")}),j6t=()=>{const{signIn:t,user:s}=Os(),r=nr(),[n,a]=N.useState(!1),[o,l]=N.useState({}),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState(!1);N.useEffect(()=>{if(s){const w=sessionStorage.getItem("redirectAfterLogin")||"/dashboard";sessionStorage.removeItem("redirectAfterLogin"),r(w)}},[s,r]);const v=async w=>{w.preventDefault(),l({}),a(!0);const j=new FormData(w.currentTarget),k=j.get("email"),S=j.get("password");try{w6t.parse({email:k,password:S}),await t(k,S)}catch(M){if(M instanceof P0){const L={};M.errors.forEach(P=>{P.path[0]&&(L[P.path[0]]=P.message)}),l(L)}}finally{a(!1)}},_=async()=>{if(!i){me.error("Please enter your email address");return}p(!0);try{const{error:w}=await H.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;me.success("Password reset email sent! Check your inbox."),g(!1),c("")}catch(w){me.error(w.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(pa,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Home"]})}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("div",{className:"bg-white rounded-xl p-4 shadow-2xl",children:e.jsx("img",{src:AGe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Pt,{className:"space-y-1 text-center pb-4",children:[e.jsx(Rt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(gr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(ze,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(ze,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&e.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),e.jsx(K,{type:"submit",className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white font-semibold py-6 text-lg transition-all duration-200 shadow-lg hover:shadow-xl",disabled:n,children:n?"Signing in...":"Sign In"}),e.jsxs(xs,{open:f,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(fs,{className:"bg-white",children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Wr,{className:"text-gray-600",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(ze,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>c(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{onClick:_,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(pa,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},N6t=()=>{const[t]=uc(),s=t.get("tier"),r=s==null?void 0:s.includes("brokerage");return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:e.jsx(gi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Rt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(gr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(lr,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:"Check your email to sign in"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We've sent you an email with a secure link to access your account. Click the link in your email to get started."})]}),r?e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Create and name your brokerage"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"4."}),"Start inviting agents to join your team"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:"What's next?"}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"2."}),"Set your password and complete your profile"]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-primary",children:"3."}),"Start exploring templates, training videos, and more!"]})]}),e.jsx("p",{className:"text-sm text-green-600 font-medium mt-4",children:"🎉 Your 7-day free trial has started!"})]}),e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Didn't receive the email? Check your spam folder or contact support."})})]})]})})},eYe=t=>{const[s,r]=N.useState(null),[n,a]=N.useState(!0);return N.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await H.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:c}=H.storage.from("avatars").getPublicUrl(`${t}/${i[0].name}`);r(`${c.publicUrl}?t=${Date.now()}`)}else r(null)}catch(i){console.error("Error fetching avatar:",i),r(null)}finally{a(!1)}})()},[t]),{avatarUrl:s,loading:n,refreshAvatar:async()=>{if(t)try{const{data:l}=await H.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},tYe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await H.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=H.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},k6t=t=>{const[s,r]=N.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return N.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await H.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(c=>({...c,loading:!1}));return}const l=(a==null?void 0:a.subscription_status)==="trialing"&&(a==null?void 0:a.subscription_end_date),i=(a==null?void 0:a.is_trial)&&(a==null?void 0:a.trial_expires_at);if(l){const c=new Date().getTime(),u=new Date(a.subscription_end_date).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.subscription_end_date,daysLeft:f?0:p,loading:!1})}else if(i){const c=new Date().getTime(),u=new Date(a.trial_expires_at).getTime(),p=Math.ceil((u-c)/(1e3*60*60*24)),f=p<=0;r({isTrial:!0,isExpired:f,expiresAt:a.trial_expires_at,daysLeft:f?0:p,loading:!1})}else r({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),r(o=>({...o,loading:!1}))}})()},[t]),s},sYe=()=>{const{data:t,isLoading:s}=mt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await H.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},cIe="community_last_seen_post_at";function S6t(){const{user:t}=Os(),s=dc(),[r,n]=N.useState(0),[a,o]=N.useState(null);N.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${cIe}_${t.id}`);o(i)},[t]),N.useEffect(()=>{if(!t)return;(async()=>{let c=H.from("community_posts").select("id",{count:"exact",head:!0});a&&(c=c.gt("created_at",a));const{data:u}=await H.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await c;!f&&p!==null&&n(p)})()},[t,a]),N.useEffect(()=>{if(!t)return;const i=H.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async c=>{const u=c.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(w=>w+1);const{data:f}=await H.from("profiles").select("name").eq("id",u.user_id).single(),g=(f==null?void 0:f.name)||"Someone",v=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),_=v.length>50?v.substring(0,50)+"...":v;p||me("New Community Post",{description:`${g}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{H.removeChannel(i)}},[t,s.pathname]);const l=N.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${cIe}_${t.id}`,i),o(i),n(0)},[t]);return N.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function C6t(){const{isAdmin:t}=Os(),{data:s=0}=mt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await H.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const lE=eue,fNe=bje,M6t=tue,rYe=N.forwardRef(({className:t,...s},r)=>e.jsx(sE,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));rYe.displayName=sE.displayName;const T6t=b3("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),S3=N.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(M6t,{children:[e.jsx(rYe,{}),e.jsxs(rE,{ref:a,className:It(T6t({side:t}),s),...n,children:[r,e.jsxs(VO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Mr,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));S3.displayName=rE.displayName;const cE=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});cE.displayName="SheetHeader";const dE=N.forwardRef(({className:t,...s},r)=>e.jsx(qO,{ref:r,className:It("text-lg font-semibold text-foreground",t),...s}));dE.displayName=qO.displayName;const nYe=N.forwardRef(({className:t,...s},r)=>e.jsx(UO,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));nYe.displayName=UO.displayName;var wue="Collapsible",[A6t]=od(wue),[E6t,xNe]=A6t(wue),aYe=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=oh({prop:n,defaultProp:a??!1,onChange:l,caller:wue});return e.jsx(E6t,{scope:r,disabled:o,contentId:Eu(),open:c,onOpenToggle:N.useCallback(()=>u(p=>!p),[u]),children:e.jsx(an.div,{"data-state":yNe(c),"data-disabled":o?"":void 0,...i,ref:s})})});aYe.displayName=wue;var iYe="CollapsibleTrigger",oYe=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=xNe(iYe,r);return e.jsx(an.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":yNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Lr(t.onClick,a.onOpenToggle)})});oYe.displayName=iYe;var gNe="CollapsibleContent",lYe=N.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=xNe(gNe,t.__scopeCollapsible);return e.jsx(zd,{present:r||a.open,children:({present:o})=>e.jsx(P6t,{...n,ref:s,present:o})})});lYe.displayName=gNe;var P6t=N.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=xNe(gNe,r),[i,c]=N.useState(n),u=N.useRef(null),p=Va(s,u),f=N.useRef(0),g=f.current,v=N.useRef(0),_=v.current,w=l.open||i,j=N.useRef(w),k=N.useRef(void 0);return N.useEffect(()=>{const S=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(S)},[]),jd(()=>{const S=u.current;if(S){k.current=k.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const M=S.getBoundingClientRect();f.current=M.height,v.current=M.width,j.current||(S.style.transitionDuration=k.current.transitionDuration,S.style.animationName=k.current.animationName),c(n)}},[l.open,n]),e.jsx(an.div,{"data-state":yNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:p,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...t.style},children:w&&a})});function yNe(t){return t?"open":"closed"}var I6t=aYe;const vf=I6t,bf=oYe,_f=lYe,L6t="/assets/levelup-logo-Eif24dqY.png",D6t="/assets/levelup-logo-icon-C-7iromj.png",O6t="/assets/levelup-logo-mobile-B9skSjUG.png";var QO=t=>t.type==="checkbox",C4=t=>t instanceof Date,jm=t=>t==null;const cYe=t=>typeof t=="object";var Fd=t=>!jm(t)&&!Array.isArray(t)&&cYe(t)&&!C4(t),dYe=t=>Fd(t)&&t.target?QO(t.target)?t.target.checked:t.target.value:t,R6t=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,uYe=(t,s)=>t.has(R6t(s)),F6t=t=>{const s=t.constructor&&t.constructor.prototype;return Fd(s)&&s.hasOwnProperty("isPrototypeOf")},vNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function fu(t){let s;const r=Array.isArray(t),n=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)s=new Date(t);else if(!(vNe&&(t instanceof Blob||n))&&(r||Fd(t)))if(s=r?[]:{},!r&&!F6t(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=fu(t[a]));else return t;return s}var jue=t=>/^\w*$/.test(t),Ed=t=>t===void 0,bNe=t=>Array.isArray(t)?t.filter(Boolean):[],_Ne=t=>bNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),En=(t,s,r)=>{if(!s||!Fd(t))return r;const n=(jue(s)?[s]:_Ne(s)).reduce((a,o)=>jm(a)?a:a[o],t);return Ed(n)||n===t?Ed(t[s])?r:t[s]:n},rf=t=>typeof t=="boolean",xl=(t,s,r)=>{let n=-1;const a=jue(s)?[s]:_Ne(s),o=a.length,l=o-1;for(;++nht.useContext(wNe),z6t=t=>{const{children:s,...r}=t;return ht.createElement(wNe.Provider,{value:r},s)};var hYe=(t,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const o in t)Object.defineProperty(a,o,{get:()=>{const l=o;return s._proxyFormState[l]!==Vg.all&&(s._proxyFormState[l]=!n||Vg.all),r&&(r[l]=!0),t[l]}});return a};const jNe=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function B6t(t){const s=Nue(),{control:r=s.control,disabled:n,name:a,exact:o}=t||{},[l,i]=ht.useState(r._formState),c=ht.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return jNe(()=>r._subscribe({name:a,formState:c.current,exact:o,callback:u=>{!n&&i({...r._formState,...u})}}),[a,n,o]),ht.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),ht.useMemo(()=>hYe(l,r,c.current,!1),[l,r])}var c0=t=>typeof t=="string",mYe=(t,s,r,n,a)=>c0(t)?(n&&s.watch.add(t),En(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),En(r,o))):(n&&(s.watchAll=!0),r),k1e=t=>jm(t)||!cYe(t);function Kv(t,s,r=new WeakSet){if(k1e(t)||k1e(s))return t===s;if(C4(t)&&C4(s))return t.getTime()===s.getTime();const n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;if(r.has(t)||r.has(s))return!0;r.add(t),r.add(s);for(const o of n){const l=t[o];if(!a.includes(o))return!1;if(o!=="ref"){const i=s[o];if(C4(l)&&C4(i)||Fd(l)&&Fd(i)||Array.isArray(l)&&Array.isArray(i)?!Kv(l,i,r):l!==i)return!1}}return!0}function $6t(t){const s=Nue(),{control:r=s.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=t||{},c=ht.useRef(a),u=ht.useRef(i),p=ht.useRef(void 0);u.current=i;const f=ht.useMemo(()=>r._getWatch(n,c.current),[r,n]),[g,v]=ht.useState(u.current?u.current(f):f);return jNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:_=>{if(!o){const w=mYe(n,r._names,_.values||r._formValues,!1,c.current);if(u.current){const j=u.current(w);Kv(j,p.current)||(v(j),p.current=j)}else v(w)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),g}function q6t(t){const s=Nue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=uYe(a._names.array,r),c=ht.useMemo(()=>En(a._formValues,r,En(a._defaultValues,r,l)),[a,r,l]),u=$6t({control:a,name:r,defaultValue:c,exact:!0}),p=B6t({control:a,name:r,exact:!0}),f=ht.useRef(t),g=ht.useRef(a.register(r,{...t.rules,value:u,...rf(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const v=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!En(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!En(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!En(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!En(p.validatingFields,r)},error:{enumerable:!0,get:()=>En(p.errors,r)}}),[p,r]),_=ht.useCallback(S=>g.current.onChange({target:{value:dYe(S),name:r},type:ele.CHANGE}),[r]),w=ht.useCallback(()=>g.current.onBlur({target:{value:En(a._formValues,r),name:r},type:ele.BLUR}),[r,a._formValues]),j=ht.useCallback(S=>{const M=En(a._fields,r);M&&S&&(M._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:L=>S.setCustomValidity(L),reportValidity:()=>S.reportValidity()})},[a._fields,r]),k=ht.useMemo(()=>({name:r,value:u,...rf(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:_,onBlur:w,ref:j}),[r,n,p.disabled,_,w,j,u]);return ht.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...rf(f.current.disabled)?{disabled:f.current.disabled}:{}});const M=(L,P)=>{const O=En(a._fields,L);O&&O._f&&(O._f.mount=P)};if(M(r,!0),S){const L=fu(En(a._options.defaultValues,r));xl(a._defaultValues,r,L),Ed(En(a._formValues,r))&&xl(a._formValues,r,L)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):M(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:k,formState:p,fieldState:v}),[k,p,v])}const U6t=t=>t.render(q6t(t));var pYe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},c8=t=>Array.isArray(t)?t:[t],dIe=()=>{let t=[];return{get observers(){return t},next:a=>{for(const o of t)o.next&&o.next(a)},subscribe:a=>(t.push(a),{unsubscribe:()=>{t=t.filter(o=>o!==a)}}),unsubscribe:()=>{t=[]}}},dp=t=>Fd(t)&&!Object.keys(t).length,NNe=t=>t.type==="file",Hg=t=>typeof t=="function",tle=t=>{if(!vNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},fYe=t=>t.type==="select-multiple",kNe=t=>t.type==="radio",V6t=t=>kNe(t)||QO(t),nge=t=>tle(t)&&t.isConnected;function H6t(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Hg(t[s]))return!0;return!1};function sle(t,s={}){const r=Array.isArray(t);if(Fd(t)||r)for(const n in t)Array.isArray(t[n])||Fd(t[n])&&!xYe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},sle(t[n],s[n])):jm(t[n])||(s[n]=!0);return s}function gYe(t,s,r){const n=Array.isArray(t);if(Fd(t)||n)for(const a in t)Array.isArray(t[a])||Fd(t[a])&&!xYe(t[a])?Ed(s)||k1e(r[a])?r[a]=Array.isArray(t[a])?sle(t[a],[]):{...sle(t[a])}:gYe(t[a],jm(s)?{}:s[a],r[a]):r[a]=!Kv(t[a],s[a]);return r}var sI=(t,s)=>gYe(t,s,sle(s));const uIe={value:!1,isValid:!1},hIe={value:!0,isValid:!0};var yYe=t=>{if(Array.isArray(t)){if(t.length>1){const s=t.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Ed(t[0].attributes.value)?Ed(t[0].value)||t[0].value===""?hIe:{value:t[0].value,isValid:!0}:hIe:uIe}return uIe},vYe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Ed(t)?t:s?t===""?NaN:t&&+t:r&&c0(t)?new Date(t):n?n(t):t;const mIe={isValid:!1,value:null};var bYe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,mIe):mIe;function pIe(t){const s=t.ref;return NNe(s)?s.files:kNe(s)?bYe(t.refs).value:fYe(s)?[...s.selectedOptions].map(({value:r})=>r):QO(s)?yYe(t.refs).value:vYe(Ed(s.value)?t.ref.value:s.value,t)}var W6t=(t,s,r,n)=>{const a={};for(const o of t){const l=En(s,o);l&&xl(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},rle=t=>t instanceof RegExp,rI=t=>Ed(t)?t:rle(t)?t.source:Fd(t)?rle(t.value)?t.value.source:t.value:t,fIe=t=>({isOnSubmit:!t||t===Vg.onSubmit,isOnBlur:t===Vg.onBlur,isOnChange:t===Vg.onChange,isOnAll:t===Vg.all,isOnTouch:t===Vg.onTouched});const xIe="AsyncFunction";var K6t=t=>!!t&&!!t.validate&&!!(Hg(t.validate)&&t.validate.constructor.name===xIe||Fd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===xIe)),Z6t=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),gIe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const d8=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=En(t,a);if(o){const{_f:l,...i}=o;if(l){if(l.refs&&l.refs[0]&&s(l.refs[0],a)&&!n)return!0;if(l.ref&&s(l.ref,l.name)&&!n)return!0;if(d8(i,s))break}else if(Fd(i)&&d8(i,s))break}}};function yIe(t,s,r){const n=En(t,r);if(n||jue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=En(s,o),i=En(t,o);if(l&&!Array.isArray(l)&&r!==o)return{name:r};if(i&&i.type)return{name:o,error:i};if(i&&i.root&&i.root.type)return{name:`${o}.root`,error:i.root};a.pop()}return{name:r}}var Y6t=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return dp(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Vg.all))},Q6t=(t,s,r)=>!t||!s||t===s||c8(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),X6t=(t,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||t):(r?n.isOnBlur:a.isOnBlur)?!t:(r?n.isOnChange:a.isOnChange)?t:!0,J6t=(t,s)=>!bNe(En(t,s)).length&&Wd(t,s),ePt=(t,s,r)=>{const n=c8(En(t,r));return xl(n,"root",s[r]),xl(t,r,n),t},Iie=t=>c0(t);function vIe(t,s,r="validate"){if(Iie(t)||Array.isArray(t)&&t.every(Iie)||rf(t)&&!t)return{type:r,message:Iie(t)?t:"",ref:s}}var A5=t=>Fd(t)&&!rle(t)?t:{value:t,message:""},bIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:p,min:f,max:g,pattern:v,validate:_,name:w,valueAsNumber:j,mount:k}=t._f,S=En(r,w);if(!k||s.has(w))return{};const M=i?i[0]:l,L=Y=>{a&&M.reportValidity&&(M.setCustomValidity(rf(Y)?"":Y||""),M.reportValidity())},P={},O=kNe(l),$=QO(l),U=O||$,B=(j||NNe(l))&&Ed(l.value)&&Ed(S)||tle(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,V=pYe.bind(null,w,n,P),X=(Y,ee,Q,ce=kv.maxLength,ne=kv.minLength)=>{const re=Y?ee:Q;P[w]={type:Y?ce:ne,message:re,ref:l,...V(Y?ce:ne,re)}};if(o?!Array.isArray(S)||!S.length:c&&(!U&&(B||jm(S))||rf(S)&&!S||$&&!yYe(i).isValid||O&&!bYe(i).isValid)){const{value:Y,message:ee}=Iie(c)?{value:!!c,message:c}:A5(c);if(Y&&(P[w]={type:kv.required,message:ee,ref:M,...V(kv.required,ee)},!n))return L(ee),P}if(!B&&(!jm(f)||!jm(g))){let Y,ee;const Q=A5(g),ce=A5(f);if(!jm(S)&&!isNaN(S)){const ne=l.valueAsNumber||S&&+S;jm(Q.value)||(Y=ne>Q.value),jm(ce.value)||(ee=nenew Date(new Date().toDateString()+" "+ge),oe=l.type=="time",fe=l.type=="week";c0(Q.value)&&S&&(Y=oe?re(S)>re(Q.value):fe?S>Q.value:ne>new Date(Q.value)),c0(ce.value)&&S&&(ee=oe?re(S)+Y.value,ce=!jm(ee.value)&&S.length<+ee.value;if((Q||ce)&&(X(Q,Y.message,ee.message),!n))return L(P[w].message),P}if(v&&!B&&c0(S)){const{value:Y,message:ee}=A5(v);if(rle(Y)&&!S.match(Y)&&(P[w]={type:kv.pattern,message:ee,ref:l,...V(kv.pattern,ee)},!n))return L(ee),P}if(_){if(Hg(_)){const Y=await _(S,r),ee=vIe(Y,M);if(ee&&(P[w]={...ee,...V(kv.validate,ee.message)},!n))return L(ee.message),P}else if(Fd(_)){let Y={};for(const ee in _){if(!dp(Y)&&!n)break;const Q=vIe(await _[ee](S,r),M,ee);Q&&(Y={...Q,...V(ee,Q.message)},L(Q.message),n&&(P[w]=Y))}if(!dp(Y)&&(P[w]={ref:M,...Y},!n))return P}}return L(!0),P};const tPt={mode:Vg.onSubmit,reValidateMode:Vg.onChange,shouldFocusError:!0};function sPt(t={}){let s={...tPt,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Hg(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Fd(s.defaultValues)||Fd(s.values)?fu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:fu(a),l={action:!1,mount:!1,watch:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,u=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let f={...p};const g={array:dIe(),state:dIe()},v=s.criteriaMode===Vg.all,_=He=>ct=>{clearTimeout(u),u=setTimeout(He,ct)},w=async He=>{if(!s.disabled&&(p.isValid||f.isValid||He)){const ct=s.resolver?dp((await $()).errors):await B(n,!0);ct!==r.isValid&&g.state.next({isValid:ct})}},j=(He,ct)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((He||Array.from(i.mount)).forEach(Ue=>{Ue&&(ct?xl(r.validatingFields,Ue,ct):Wd(r.validatingFields,Ue))}),g.state.next({validatingFields:r.validatingFields,isValidating:!dp(r.validatingFields)}))},k=(He,ct=[],Ue,Ze,Je=!0,Ge=!0)=>{if(Ze&&Ue&&!s.disabled){if(l.action=!0,Ge&&Array.isArray(En(n,He))){const et=Ue(En(n,He),Ze.argA,Ze.argB);Je&&xl(n,He,et)}if(Ge&&Array.isArray(En(r.errors,He))){const et=Ue(En(r.errors,He),Ze.argA,Ze.argB);Je&&xl(r.errors,He,et),J6t(r.errors,He)}if((p.touchedFields||f.touchedFields)&&Ge&&Array.isArray(En(r.touchedFields,He))){const et=Ue(En(r.touchedFields,He),Ze.argA,Ze.argB);Je&&xl(r.touchedFields,He,et)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=sI(a,o)),g.state.next({name:He,isDirty:X(He,ct),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else xl(o,He,ct)},S=(He,ct)=>{xl(r.errors,He,ct),g.state.next({errors:r.errors})},M=He=>{r.errors=He,g.state.next({errors:r.errors,isValid:!1})},L=(He,ct,Ue,Ze)=>{const Je=En(n,He);if(Je){const Ge=En(o,He,Ed(Ue)?En(a,He):Ue);Ed(Ge)||Ze&&Ze.defaultChecked||ct?xl(o,He,ct?Ge:pIe(Je._f)):Q(He,Ge),l.mount&&w()}},P=(He,ct,Ue,Ze,Je)=>{let Ge=!1,et=!1;const it={name:He};if(!s.disabled){if(!Ue||Ze){(p.isDirty||f.isDirty)&&(et=r.isDirty,r.isDirty=it.isDirty=X(),Ge=et!==it.isDirty);const Dt=Kv(En(a,He),ct);et=!!En(r.dirtyFields,He),Dt?Wd(r.dirtyFields,He):xl(r.dirtyFields,He,!0),it.dirtyFields=r.dirtyFields,Ge=Ge||(p.dirtyFields||f.dirtyFields)&&et!==!Dt}if(Ue){const Dt=En(r.touchedFields,He);Dt||(xl(r.touchedFields,He,Ue),it.touchedFields=r.touchedFields,Ge=Ge||(p.touchedFields||f.touchedFields)&&Dt!==Ue)}Ge&&Je&&g.state.next(it)}return Ge?it:{}},O=(He,ct,Ue,Ze)=>{const Je=En(r.errors,He),Ge=(p.isValid||f.isValid)&&rf(ct)&&r.isValid!==ct;if(s.delayError&&Ue?(c=_(()=>S(He,Ue)),c(s.delayError)):(clearTimeout(u),c=null,Ue?xl(r.errors,He,Ue):Wd(r.errors,He)),(Ue?!Kv(Je,Ue):Je)||!dp(Ze)||Ge){const et={...Ze,...Ge&&rf(ct)?{isValid:ct}:{},errors:r.errors,name:He};r={...r,...et},g.state.next(et)}},$=async He=>{j(He,!0);const ct=await s.resolver(o,s.context,W6t(He||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return j(He),ct},U=async He=>{const{errors:ct}=await $(He);if(He)for(const Ue of He){const Ze=En(ct,Ue);Ze?xl(r.errors,Ue,Ze):Wd(r.errors,Ue)}else r.errors=ct;return ct},B=async(He,ct,Ue={valid:!0})=>{for(const Ze in He){const Je=He[Ze];if(Je){const{_f:Ge,...et}=Je;if(Ge){const it=i.array.has(Ge.name),Dt=Je._f&&K6t(Je._f);Dt&&p.validatingFields&&j([Ze],!0);const Vt=await bIe(Je,i.disabled,o,v,s.shouldUseNativeValidation&&!ct,it);if(Dt&&p.validatingFields&&j([Ze]),Vt[Ge.name]&&(Ue.valid=!1,ct))break;!ct&&(En(Vt,Ge.name)?it?ePt(r.errors,Vt,Ge.name):xl(r.errors,Ge.name,Vt[Ge.name]):Wd(r.errors,Ge.name))}!dp(et)&&await B(et,ct,Ue)}}return Ue.valid},V=()=>{for(const He of i.unMount){const ct=En(n,He);ct&&(ct._f.refs?ct._f.refs.every(Ue=>!nge(Ue)):!nge(ct._f.ref))&&ke(He)}i.unMount=new Set},X=(He,ct)=>!s.disabled&&(He&&ct&&xl(o,He,ct),!Kv(ge(),a)),Y=(He,ct,Ue)=>mYe(He,i,{...l.mount?o:Ed(ct)?a:c0(He)?{[He]:ct}:ct},Ue,ct),ee=He=>bNe(En(l.mount?o:a,He,s.shouldUnregister?En(a,He,[]):[])),Q=(He,ct,Ue={})=>{const Ze=En(n,He);let Je=ct;if(Ze){const Ge=Ze._f;Ge&&(!Ge.disabled&&xl(o,He,vYe(ct,Ge)),Je=tle(Ge.ref)&&jm(ct)?"":ct,fYe(Ge.ref)?[...Ge.ref.options].forEach(et=>et.selected=Je.includes(et.value)):Ge.refs?QO(Ge.ref)?Ge.refs.forEach(et=>{(!et.defaultChecked||!et.disabled)&&(Array.isArray(Je)?et.checked=!!Je.find(it=>it===et.value):et.checked=Je===et.value||!!Je)}):Ge.refs.forEach(et=>et.checked=et.value===Je):NNe(Ge.ref)?Ge.ref.value="":(Ge.ref.value=Je,Ge.ref.type||g.state.next({name:He,values:fu(o)})))}(Ue.shouldDirty||Ue.shouldTouch)&&P(He,Je,Ue.shouldTouch,Ue.shouldDirty,!0),Ue.shouldValidate&&fe(He)},ce=(He,ct,Ue)=>{for(const Ze in ct){if(!ct.hasOwnProperty(Ze))return;const Je=ct[Ze],Ge=He+"."+Ze,et=En(n,Ge);(i.array.has(He)||Fd(Je)||et&&!et._f)&&!C4(Je)?ce(Ge,Je,Ue):Q(Ge,Je,Ue)}},ne=(He,ct,Ue={})=>{const Ze=En(n,He),Je=i.array.has(He),Ge=fu(ct);xl(o,He,Ge),Je?(g.array.next({name:He,values:fu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&Ue.shouldDirty&&g.state.next({name:He,dirtyFields:sI(a,o),isDirty:X(He,Ge)})):Ze&&!Ze._f&&!jm(Ge)?ce(He,Ge,Ue):Q(He,Ge,Ue),gIe(He,i)&&g.state.next({...r,name:He}),g.state.next({name:l.mount?He:void 0,values:fu(o)})},re=async He=>{l.mount=!0;const ct=He.target;let Ue=ct.name,Ze=!0;const Je=En(n,Ue),Ge=Dt=>{Ze=Number.isNaN(Dt)||C4(Dt)&&isNaN(Dt.getTime())||Kv(Dt,En(o,Ue,Dt))},et=fIe(s.mode),it=fIe(s.reValidateMode);if(Je){let Dt,Vt;const hs=ct.type?pIe(Je._f):dYe(He),As=He.type===ele.BLUR||He.type===ele.FOCUS_OUT,Ms=!Z6t(Je._f)&&!s.resolver&&!En(r.errors,Ue)&&!Je._f.deps||X6t(As,En(r.touchedFields,Ue),r.isSubmitted,it,et),cs=gIe(Ue,i,As);xl(o,Ue,hs),As?(Je._f.onBlur&&Je._f.onBlur(He),c&&c(0)):Je._f.onChange&&Je._f.onChange(He);const er=P(Ue,hs,As),xt=!dp(er)||cs;if(!As&&g.state.next({name:Ue,type:He.type,values:fu(o)}),Ms)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?As&&w():As||w()),xt&&g.state.next({name:Ue,...cs?{}:er});if(!As&&cs&&g.state.next({...r}),s.resolver){const{errors:Ps}=await $([Ue]);if(Ge(hs),Ze){const mr=yIe(r.errors,n,Ue),Tr=yIe(Ps,n,mr.name||Ue);Dt=Tr.error,Ue=Tr.name,Vt=dp(Ps)}}else j([Ue],!0),Dt=(await bIe(Je,i.disabled,o,v,s.shouldUseNativeValidation))[Ue],j([Ue]),Ge(hs),Ze&&(Dt?Vt=!1:(p.isValid||f.isValid)&&(Vt=await B(n,!0)));Ze&&(Je._f.deps&&fe(Je._f.deps),O(Ue,Vt,Dt,er))}},oe=(He,ct)=>{if(En(r.errors,ct)&&He.focus)return He.focus(),1},fe=async(He,ct={})=>{let Ue,Ze;const Je=c8(He);if(s.resolver){const Ge=await U(Ed(He)?He:Je);Ue=dp(Ge),Ze=He?!Je.some(et=>En(Ge,et)):Ue}else He?(Ze=(await Promise.all(Je.map(async Ge=>{const et=En(n,Ge);return await B(et&&et._f?{[Ge]:et}:et)}))).every(Boolean),!(!Ze&&!r.isValid)&&w()):Ze=Ue=await B(n);return g.state.next({...!c0(He)||(p.isValid||f.isValid)&&Ue!==r.isValid?{}:{name:He},...s.resolver||!He?{isValid:Ue}:{},errors:r.errors}),ct.shouldFocus&&!Ze&&d8(n,oe,He?Je:i.mount),Ze},ge=He=>{const ct={...l.mount?o:a};return Ed(He)?ct:c0(He)?En(ct,He):He.map(Ue=>En(ct,Ue))},ue=(He,ct)=>({invalid:!!En((ct||r).errors,He),isDirty:!!En((ct||r).dirtyFields,He),error:En((ct||r).errors,He),isValidating:!!En(r.validatingFields,He),isTouched:!!En((ct||r).touchedFields,He)}),xe=He=>{He&&c8(He).forEach(ct=>Wd(r.errors,ct)),g.state.next({errors:He?r.errors:{}})},_e=(He,ct,Ue)=>{const Ze=(En(n,He,{_f:{}})._f||{}).ref,Je=En(r.errors,He)||{},{ref:Ge,message:et,type:it,...Dt}=Je;xl(r.errors,He,{...Dt,...ct,ref:Ze}),g.state.next({name:He,errors:r.errors,isValid:!1}),Ue&&Ue.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},$e=(He,ct)=>Hg(He)?g.state.subscribe({next:Ue=>"values"in Ue&&He(Y(void 0,ct),Ue)}):Y(He,ct,!0),Me=He=>g.state.subscribe({next:ct=>{Q6t(He.name,ct.name,He.exact)&&Y6t(ct,He.formState||p,tt,He.reRenderRoot)&&He.callback({values:{...o},...r,...ct,defaultValues:a})}}).unsubscribe,Ie=He=>(l.mount=!0,f={...f,...He.formState},Me({...He,formState:f})),ke=(He,ct={})=>{for(const Ue of He?c8(He):i.mount)i.mount.delete(Ue),i.array.delete(Ue),ct.keepValue||(Wd(n,Ue),Wd(o,Ue)),!ct.keepError&&Wd(r.errors,Ue),!ct.keepDirty&&Wd(r.dirtyFields,Ue),!ct.keepTouched&&Wd(r.touchedFields,Ue),!ct.keepIsValidating&&Wd(r.validatingFields,Ue),!s.shouldUnregister&&!ct.keepDefaultValue&&Wd(a,Ue);g.state.next({values:fu(o)}),g.state.next({...r,...ct.keepDirty?{isDirty:X()}:{}}),!ct.keepIsValid&&w()},pe=({disabled:He,name:ct})=>{(rf(He)&&l.mount||He||i.disabled.has(ct))&&(He?i.disabled.add(ct):i.disabled.delete(ct))},we=(He,ct={})=>{let Ue=En(n,He);const Ze=rf(ct.disabled)||rf(s.disabled);return xl(n,He,{...Ue||{},_f:{...Ue&&Ue._f?Ue._f:{ref:{name:He}},name:He,mount:!0,...ct}}),i.mount.add(He),Ue?pe({disabled:rf(ct.disabled)?ct.disabled:s.disabled,name:He}):L(He,!0,ct.value),{...Ze?{disabled:ct.disabled||s.disabled}:{},...s.progressive?{required:!!ct.required,min:rI(ct.min),max:rI(ct.max),minLength:rI(ct.minLength),maxLength:rI(ct.maxLength),pattern:rI(ct.pattern)}:{},name:He,onChange:re,onBlur:re,ref:Je=>{if(Je){we(He,ct),Ue=En(n,He);const Ge=Ed(Je.value)&&Je.querySelectorAll&&Je.querySelectorAll("input,select,textarea")[0]||Je,et=V6t(Ge),it=Ue._f.refs||[];if(et?it.find(Dt=>Dt===Ge):Ge===Ue._f.ref)return;xl(n,He,{_f:{...Ue._f,...et?{refs:[...it.filter(nge),Ge,...Array.isArray(En(a,He))?[{}]:[]],ref:{type:Ge.type,name:He}}:{ref:Ge}}}),L(He,!1,void 0,Ge)}else Ue=En(n,He,{}),Ue._f&&(Ue._f.mount=!1),(s.shouldUnregister||ct.shouldUnregister)&&!(uYe(i.array,He)&&l.action)&&i.unMount.add(He)}}},Le=()=>s.shouldFocusError&&d8(n,oe,i.mount),Qe=He=>{rf(He)&&(g.state.next({disabled:He}),d8(n,(ct,Ue)=>{const Ze=En(n,Ue);Ze&&(ct.disabled=Ze._f.disabled||He,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(Je=>{Je.disabled=Ze._f.disabled||He}))},0,!1))},Te=(He,ct)=>async Ue=>{let Ze;Ue&&(Ue.preventDefault&&Ue.preventDefault(),Ue.persist&&Ue.persist());let Je=fu(o);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:Ge,values:et}=await $();r.errors=Ge,Je=fu(et)}else await B(n);if(i.disabled.size)for(const Ge of i.disabled)Wd(Je,Ge);if(Wd(r.errors,"root"),dp(r.errors)){g.state.next({errors:{}});try{await He(Je,Ue)}catch(Ge){Ze=Ge}}else ct&&await ct({...r.errors},Ue),Le(),setTimeout(Le);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:dp(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},pt=(He,ct={})=>{En(n,He)&&(Ed(ct.defaultValue)?ne(He,fu(En(a,He))):(ne(He,ct.defaultValue),xl(a,He,fu(ct.defaultValue))),ct.keepTouched||Wd(r.touchedFields,He),ct.keepDirty||(Wd(r.dirtyFields,He),r.isDirty=ct.defaultValue?X(He,fu(En(a,He))):X()),ct.keepError||(Wd(r.errors,He),p.isValid&&w()),g.state.next({...r}))},ye=(He,ct={})=>{const Ue=He?fu(He):a,Ze=fu(Ue),Je=dp(He),Ge=Je?a:Ze;if(ct.keepDefaultValues||(a=Ue),!ct.keepValues){if(ct.keepDirtyValues){const et=new Set([...i.mount,...Object.keys(sI(a,o))]);for(const it of Array.from(et))En(r.dirtyFields,it)?xl(Ge,it,En(o,it)):ne(it,En(Ge,it))}else{if(vNe&&Ed(He))for(const et of i.mount){const it=En(n,et);if(it&&it._f){const Dt=Array.isArray(it._f.refs)?it._f.refs[0]:it._f.ref;if(tle(Dt)){const Vt=Dt.closest("form");if(Vt){Vt.reset();break}}}}if(ct.keepFieldsRef)for(const et of i.mount)ne(et,En(Ge,et));else n={}}o=s.shouldUnregister?ct.keepDefaultValues?fu(a):{}:fu(Ge),g.array.next({values:{...Ge}}),g.state.next({values:{...Ge}})}i={mount:ct.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ct.keepIsValid||!!ct.keepDirtyValues,l.watch=!!s.shouldUnregister,g.state.next({submitCount:ct.keepSubmitCount?r.submitCount:0,isDirty:Je?!1:ct.keepDirty?r.isDirty:!!(ct.keepDefaultValues&&!Kv(He,a)),isSubmitted:ct.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Je?{}:ct.keepDirtyValues?ct.keepDefaultValues&&o?sI(a,o):r.dirtyFields:ct.keepDefaultValues&&He?sI(a,He):ct.keepDirty?r.dirtyFields:{},touchedFields:ct.keepTouched?r.touchedFields:{},errors:ct.keepErrors?r.errors:{},isSubmitSuccessful:ct.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},qe=(He,ct)=>ye(Hg(He)?He(o):He,ct),at=(He,ct={})=>{const Ue=En(n,He),Ze=Ue&&Ue._f;if(Ze){const Je=Ze.refs?Ze.refs[0]:Ze.ref;Je.focus&&(Je.focus(),ct.shouldSelect&&Hg(Je.select)&&Je.select())}},tt=He=>{r={...r,...He}},rt={control:{register:we,unregister:ke,getFieldState:ue,handleSubmit:Te,setError:_e,_subscribe:Me,_runSchema:$,_focusError:Le,_getWatch:Y,_getDirty:X,_setValid:w,_setFieldArray:k,_setDisabledField:pe,_setErrors:M,_getFieldArray:ee,_reset:ye,_resetDefaultValues:()=>Hg(s.defaultValues)&&s.defaultValues().then(He=>{qe(He,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:Qe,_subjects:g,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(He){l=He},get _defaultValues(){return a},get _names(){return i},set _names(He){i=He},get _formState(){return r},get _options(){return s},set _options(He){s={...s,...He}}},subscribe:Ie,trigger:fe,register:we,handleSubmit:Te,watch:$e,setValue:ne,getValues:ge,reset:qe,resetField:pt,clearErrors:xe,unregister:ke,setError:_e,setFocus:at,getFieldState:ue};return{...rt,formControl:rt}}function kue(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:Hg(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Hg(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Hg(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=sPt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,jNe(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>a({...o._formState}),reRenderRoot:!0});return a(i=>({...i,isReady:!0})),o._formState.isReady=!0,l},[o]),ht.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),ht.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),ht.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),ht.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),ht.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==n.isDirty&&o._subjects.state.next({isDirty:l})}},[o,n.isDirty]),ht.useEffect(()=>{t.values&&!Kv(t.values,r.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),r.current=t.values,a(l=>({...l}))):o._resetDefaultValues()},[o,t.values]),ht.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),s.current.formState=hYe(n,o),s.current}const _Ie=(t,s,r)=>{if(t&&"reportValidity"in t){const n=En(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},_Ye=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?_Ie(n.ref,r,t):n.refs&&n.refs.forEach(a=>_Ie(a,r,t))}},rPt=(t,s)=>{s.shouldUseNativeValidation&&_Ye(t,s);const r={};for(const n in t){const a=En(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(nPt(s.names||Object.keys(t),n)){const l=Object.assign({},En(r,n));xl(l,"root",o),xl(r,n,l)}else xl(r,n,o)}return r},nPt=(t,s)=>t.some(r=>r.startsWith(s+"."));var aPt=function(t,s){for(var r={};t.length;){var n=t[0],a=n.code,o=n.message,l=n.path.join(".");if(!r[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];r[l]={message:i.message,type:i.code}}else r[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(f){return t.push(f)})}),s){var c=r[l].types,u=c&&c[n.code];r[l]=pYe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},Sue=function(t,s,r){return r===void 0&&(r={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var c=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(u){return o.shouldUseNativeValidation&&_Ye({},o),{errors:{},values:r.raw?n:u}})}catch(u){return i(u)}return c&&c.then?c.then(void 0,i):c}(0,function(l){if(function(i){return Array.isArray(i==null?void 0:i.errors)}(l))return{values:{},errors:rPt(aPt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Cue=z6t,wYe=N.createContext({}),Yc=({...t})=>e.jsx(wYe.Provider,{value:{name:t.name},children:e.jsx(U6t,{...t})}),Mue=()=>{const t=N.useContext(wYe),s=N.useContext(jYe),{getFieldState:r,formState:n}=Nue(),a=r(t.name,n);if(!t)throw new Error("useFormField should be used within ");const{id:o}=s;return{id:o,name:t.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},jYe=N.createContext({}),Dc=N.forwardRef(({className:t,...s},r)=>{const n=N.useId();return e.jsx(jYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:It("space-y-2",t),...s})})});Dc.displayName="FormItem";const Oc=N.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=Mue();return e.jsx(be,{ref:r,className:It(n&&"text-destructive",t),htmlFor:a,...s})});Oc.displayName="FormLabel";const Rc=N.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=Mue();return e.jsx(j2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Rc.displayName="FormControl";const Lie=N.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=Mue();return e.jsx("p",{ref:r,id:n,className:It("text-sm text-muted-foreground",t),...s})});Lie.displayName="FormDescription";const Cm=N.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=Mue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:It("text-sm font-medium text-destructive",t),...r,children:l}):null});Cm.displayName="FormMessage";const iPt=N3({category:QWe(["general","technology","crm","marketing"]),subject:_c().min(5,"Subject must be at least 5 characters").max(200),description:_c().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),oPt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function S1e({trigger:t}){const[s,r]=N.useState(!1),[n,a]=N.useState(!1),{user:o}=Os(),l=kue({resolver:Sue(iPt),defaultValues:{category:"general",subject:"",description:""}}),i=async c=>{if(!o){me.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:u}=await H.from("support_tickets").insert({user_id:o.id,category:c.category,subject:c.subject,description:c.description});if(u)throw u;try{await H.functions.invoke("support-ticket-notify",{body:{category:oPt[c.category],subject:c.subject}})}catch(p){console.log("Notification send attempted:",p)}me.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),me.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return e.jsxs(xs,{open:s,onOpenChange:r,children:[e.jsx(qi,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(SL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(fs,{className:"sm:max-w-[500px]",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Need Help?"}),e.jsx(Wr,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",e.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),e.jsx(Cue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Yc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Category"}),e.jsxs(Ks,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Rc,{children:e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a category"})})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Subject"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"Brief description of your issue",...c})}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Description"}),e.jsx(Rc,{children:e.jsx(Pr,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(Cm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const lPt=()=>{const{user:t}=Os(),s=nr(),[r,n]=N.useState([]),[a,o]=N.useState(0),[l,i]=N.useState(!1),[c,u]=N.useState(null);N.useEffect(()=>{if(!t)return;const _=`notification_last_read_${t.id}`;let w=c;if(!w){const S=localStorage.getItem(_);S&&(w=S,u(S))}(async()=>{const{data:S,error:M}=await H.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!M&&S){n(S);const L=w?new Date(w):null,P=S.filter(O=>L?new Date(O.created_at)>L:!0);o(P.length)}})();const k=H.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const M=S.new;n(P=>[M,...P].slice(0,20));const L=w?new Date(w):null;(!L||new Date(M.created_at)>L)&&o(P=>P+1),Notification.permission==="granted"&&new Notification(M.title,{body:M.body,icon:"/favicon.ico"})}).subscribe();return()=>{H.removeChannel(k)}},[t,c]);const p=_=>{const w=_.toLowerCase();return w.includes("community")||w.includes("post")?so:w.includes("academy")||w.includes("video")?Cn:w.includes("template")?Bl:w.includes("event")?hn:w.includes("newsletter")?m1:w.includes("brokerage")?th:w.includes("swag")||w.includes("social")?So:w.includes("toolbox")||w.includes("tool")?sy:w.includes("brief")?fn:so},f=_=>{i(!1),_.url&&_.url!=="/"&&s(_.url)},g=()=>{if(!t)return;const _=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,_),u(_),o(0)},v=_=>{i(_),_&&a>0&&g()};return e.jsxs(ou,{open:l,onOpenChange:v,children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Lm,{className:"h-5 w-5"}),a>0&&e.jsx(st,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:a>9?"9+":a})]})}),e.jsxs(Bd,{align:"end",className:"w-80",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[e.jsx("span",{className:"font-semibold",children:"Notifications"}),r.length>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:g,children:"Mark all read"})]}),e.jsx(Ki,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(_=>{const w=p(_.title);return e.jsxs(Aa,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(_),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:_.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:_.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Vc(new Date(_.created_at),{addSuffix:!0})})]})]},_.id)})})]})]})};var wIe=1,cPt=.9,dPt=.8,uPt=.17,age=.1,ige=.999,hPt=.9999,mPt=.99,pPt=/[\\\/_+.#"@\[\(\{&]/,fPt=/[\\\/_+.#"@\[\(\{&]/g,xPt=/[\s-]/,NYe=/[\s-]/g;function C1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?wIe:mPt;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var c=n.charAt(o),u=r.indexOf(c,a),p=0,f,g,v,_;u>=0;)f=C1e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=wIe:pPt.test(t.charAt(u-1))?(f*=dPt,v=t.slice(a,u-1).match(fPt),v&&a>0&&(f*=Math.pow(ige,v.length))):xPt.test(t.charAt(u-1))?(f*=cPt,_=t.slice(a,u-1).match(NYe),_&&a>0&&(f*=Math.pow(ige,_.length))):(f*=uPt,a>0&&(f*=Math.pow(ige,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=hPt)),(ff&&(f=g*age)),f>p&&(p=f),u=r.indexOf(c,u+1);return l[i]=p,p}function jIe(t){return t.toLowerCase().replace(NYe," ")}function gPt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,C1e(t,s,jIe(t),jIe(s),0,0,{})}var nI='[cmdk-group=""]',oge='[cmdk-group-items=""]',yPt='[cmdk-group-heading=""]',kYe='[cmdk-item=""]',NIe=`${kYe}:not([aria-disabled="true"])`,M1e="cmdk-item-select",Z5="data-value",vPt=(t,s,r)=>gPt(t,s,r),SYe=N.createContext(void 0),XO=()=>N.useContext(SYe),CYe=N.createContext(void 0),SNe=()=>N.useContext(CYe),MYe=N.createContext(void 0),TYe=N.forwardRef((t,s)=>{let r=Y5(()=>{var xe,_e;return{search:"",value:(_e=(xe=t.value)!=null?xe:t.defaultValue)!=null?_e:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=Y5(()=>new Set),a=Y5(()=>new Map),o=Y5(()=>new Map),l=Y5(()=>new Set),i=AYe(t),{label:c,children:u,value:p,onValueChange:f,filter:g,shouldFilter:v,loop:_,disablePointerSelection:w=!1,vimBindings:j=!0,...k}=t,S=Eu(),M=Eu(),L=Eu(),P=N.useRef(null),O=APt();XS(()=>{if(p!==void 0){let xe=p.trim();r.current.value=xe,$.emit()}},[p]),XS(()=>{O(6,ee)},[]);let $=N.useMemo(()=>({subscribe:xe=>(l.current.add(xe),()=>l.current.delete(xe)),snapshot:()=>r.current,setState:(xe,_e,$e)=>{var Me,Ie,ke,pe;if(!Object.is(r.current[xe],_e)){if(r.current[xe]=_e,xe==="search")Y(),V(),O(1,X);else if(xe==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let we=document.getElementById(L);we?we.focus():(Me=document.getElementById(S))==null||Me.focus()}if(O(7,()=>{var we;r.current.selectedItemId=(we=Q())==null?void 0:we.id,$.emit()}),$e||O(5,ee),((Ie=i.current)==null?void 0:Ie.value)!==void 0){let we=_e??"";(pe=(ke=i.current).onValueChange)==null||pe.call(ke,we);return}}$.emit()}},emit:()=>{l.current.forEach(xe=>xe())}}),[]),U=N.useMemo(()=>({value:(xe,_e,$e)=>{var Me;_e!==((Me=o.current.get(xe))==null?void 0:Me.value)&&(o.current.set(xe,{value:_e,keywords:$e}),r.current.filtered.items.set(xe,B(_e,$e)),O(2,()=>{V(),$.emit()}))},item:(xe,_e)=>(n.current.add(xe),_e&&(a.current.has(_e)?a.current.get(_e).add(xe):a.current.set(_e,new Set([xe]))),O(3,()=>{Y(),V(),r.current.value||X(),$.emit()}),()=>{o.current.delete(xe),n.current.delete(xe),r.current.filtered.items.delete(xe);let $e=Q();O(4,()=>{Y(),($e==null?void 0:$e.getAttribute("id"))===xe&&X(),$.emit()})}),group:xe=>(a.current.has(xe)||a.current.set(xe,new Set),()=>{o.current.delete(xe),a.current.delete(xe)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:L,labelId:M,listInnerRef:P}),[]);function B(xe,_e){var $e,Me;let Ie=(Me=($e=i.current)==null?void 0:$e.filter)!=null?Me:vPt;return xe?Ie(xe,r.current.search,_e):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let xe=r.current.filtered.items,_e=[];r.current.filtered.groups.forEach(Me=>{let Ie=a.current.get(Me),ke=0;Ie.forEach(pe=>{let we=xe.get(pe);ke=Math.max(we,ke)}),_e.push([Me,ke])});let $e=P.current;ce().sort((Me,Ie)=>{var ke,pe;let we=Me.getAttribute("id"),Le=Ie.getAttribute("id");return((ke=xe.get(Le))!=null?ke:0)-((pe=xe.get(we))!=null?pe:0)}).forEach(Me=>{let Ie=Me.closest(oge);Ie?Ie.appendChild(Me.parentElement===Ie?Me:Me.closest(`${oge} > *`)):$e.appendChild(Me.parentElement===$e?Me:Me.closest(`${oge} > *`))}),_e.sort((Me,Ie)=>Ie[1]-Me[1]).forEach(Me=>{var Ie;let ke=(Ie=P.current)==null?void 0:Ie.querySelector(`${nI}[${Z5}="${encodeURIComponent(Me[0])}"]`);ke==null||ke.parentElement.appendChild(ke)})}function X(){let xe=ce().find($e=>$e.getAttribute("aria-disabled")!=="true"),_e=xe==null?void 0:xe.getAttribute(Z5);$.setState("value",_e||void 0)}function Y(){var xe,_e,$e,Me;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ie=0;for(let ke of n.current){let pe=(_e=(xe=o.current.get(ke))==null?void 0:xe.value)!=null?_e:"",we=(Me=($e=o.current.get(ke))==null?void 0:$e.keywords)!=null?Me:[],Le=B(pe,we);r.current.filtered.items.set(ke,Le),Le>0&&Ie++}for(let[ke,pe]of a.current)for(let we of pe)if(r.current.filtered.items.get(we)>0){r.current.filtered.groups.add(ke);break}r.current.filtered.count=Ie}function ee(){var xe,_e,$e;let Me=Q();Me&&(((xe=Me.parentElement)==null?void 0:xe.firstChild)===Me&&(($e=(_e=Me.closest(nI))==null?void 0:_e.querySelector(yPt))==null||$e.scrollIntoView({block:"nearest"})),Me.scrollIntoView({block:"nearest"}))}function Q(){var xe;return(xe=P.current)==null?void 0:xe.querySelector(`${kYe}[aria-selected="true"]`)}function ce(){var xe;return Array.from(((xe=P.current)==null?void 0:xe.querySelectorAll(NIe))||[])}function ne(xe){let _e=ce()[xe];_e&&$.setState("value",_e.getAttribute(Z5))}function re(xe){var _e;let $e=Q(),Me=ce(),Ie=Me.findIndex(pe=>pe===$e),ke=Me[Ie+xe];(_e=i.current)!=null&&_e.loop&&(ke=Ie+xe<0?Me[Me.length-1]:Ie+xe===Me.length?Me[0]:Me[Ie+xe]),ke&&$.setState("value",ke.getAttribute(Z5))}function oe(xe){let _e=Q(),$e=_e==null?void 0:_e.closest(nI),Me;for(;$e&&!Me;)$e=xe>0?MPt($e,nI):TPt($e,nI),Me=$e==null?void 0:$e.querySelector(NIe);Me?$.setState("value",Me.getAttribute(Z5)):re(xe)}let fe=()=>ne(ce().length-1),ge=xe=>{xe.preventDefault(),xe.metaKey?fe():xe.altKey?oe(1):re(1)},ue=xe=>{xe.preventDefault(),xe.metaKey?ne(0):xe.altKey?oe(-1):re(-1)};return N.createElement(an.div,{ref:s,tabIndex:-1,...k,"cmdk-root":"",onKeyDown:xe=>{var _e;(_e=k.onKeyDown)==null||_e.call(k,xe);let $e=xe.nativeEvent.isComposing||xe.keyCode===229;if(!(xe.defaultPrevented||$e))switch(xe.key){case"n":case"j":{j&&xe.ctrlKey&&ge(xe);break}case"ArrowDown":{ge(xe);break}case"p":case"k":{j&&xe.ctrlKey&&ue(xe);break}case"ArrowUp":{ue(xe);break}case"Home":{xe.preventDefault(),ne(0);break}case"End":{xe.preventDefault(),fe();break}case"Enter":{xe.preventDefault();let Me=Q();if(Me){let Ie=new Event(M1e);Me.dispatchEvent(Ie)}}}}},N.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:PPt},c),Tue(t,xe=>N.createElement(CYe.Provider,{value:$},N.createElement(SYe.Provider,{value:U},xe))))}),bPt=N.forwardRef((t,s)=>{var r,n;let a=Eu(),o=N.useRef(null),l=N.useContext(MYe),i=XO(),c=AYe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;XS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=EYe(a,o,[t.value,t.children,o],t.keywords),f=SNe(),g=ww(O=>O.value&&O.value===p.current),v=ww(O=>u||i.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);N.useEffect(()=>{let O=o.current;if(!(!O||t.disabled))return O.addEventListener(M1e,_),()=>O.removeEventListener(M1e,_)},[v,t.onSelect,t.disabled]);function _(){var O,$;w(),($=(O=c.current).onSelect)==null||$.call(O,p.current)}function w(){f.setState("value",p.current,!0)}if(!v)return null;let{disabled:j,value:k,onSelect:S,forceMount:M,keywords:L,...P}=t;return N.createElement(an.div,{ref:P1(o,s),...P,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!g,"data-disabled":!!j,"data-selected":!!g,onPointerMove:j||i.getDisablePointerSelection()?void 0:w,onClick:j?void 0:_},t.children)}),_Pt=N.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Eu(),i=N.useRef(null),c=N.useRef(null),u=Eu(),p=XO(),f=ww(v=>a||p.filter()===!1?!0:v.search?v.filtered.groups.has(l):!0);XS(()=>p.group(l),[]),EYe(l,i,[t.value,t.heading,c]);let g=N.useMemo(()=>({id:l,forceMount:a}),[a]);return N.createElement(an.div,{ref:P1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&N.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),Tue(t,v=>N.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},N.createElement(MYe.Provider,{value:g},v))))}),wPt=N.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=N.useRef(null),o=ww(l=>!l.search);return!r&&!o?null:N.createElement(an.div,{ref:P1(a,s),...n,"cmdk-separator":"",role:"separator"})}),jPt=N.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=SNe(),l=ww(u=>u.search),i=ww(u=>u.selectedItemId),c=XO();return N.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),N.createElement(an.input,{ref:s,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":i,id:c.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),NPt=N.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=N.useRef(null),l=N.useRef(null),i=ww(u=>u.selectedItemId),c=XO();return N.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,g=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let v=u.offsetHeight;p.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return g.observe(u),()=>{cancelAnimationFrame(f),g.unobserve(u)}}},[]),N.createElement(an.div,{ref:P1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},Tue(t,u=>N.createElement("div",{ref:P1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),kPt=N.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return N.createElement(eue,{open:r,onOpenChange:n},N.createElement(tue,{container:l},N.createElement(sE,{"cmdk-overlay":"",className:a}),N.createElement(rE,{"aria-label":t.label,"cmdk-dialog":"",className:o},N.createElement(TYe,{ref:s,...i}))))}),SPt=N.forwardRef((t,s)=>ww(r=>r.filtered.count===0)?N.createElement(an.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),CPt=N.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return N.createElement(an.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Tue(t,l=>N.createElement("div",{"aria-hidden":!0},l)))}),Ep=Object.assign(TYe,{List:NPt,Item:bPt,Input:jPt,Group:_Pt,Separator:wPt,Dialog:kPt,Empty:SPt,Loading:CPt});function MPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function TPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function AYe(t){let s=N.useRef(t);return XS(()=>{s.current=t}),s}var XS=typeof window>"u"?N.useEffect:N.useLayoutEffect;function Y5(t){let s=N.useRef();return s.current===void 0&&(s.current=t()),s}function ww(t){let s=SNe(),r=()=>t(s.snapshot());return N.useSyncExternalStore(s.subscribe,r,r)}function EYe(t,s,r,n=[]){let a=N.useRef(),o=XO();return XS(()=>{var l;let i=(()=>{var u;for(let p of r){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(u=p.current.textContent)==null?void 0:u.trim():a.current}})(),c=n.map(u=>u.trim());o.value(t,i,c),(l=s.current)==null||l.setAttribute(Z5,i),a.current=i}),a}var APt=()=>{let[t,s]=N.useState(),r=Y5(()=>new Map);return XS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function EPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function Tue({asChild:t,children:s},r){return t&&N.isValidElement(s)?N.cloneElement(EPt(s),{ref:s.ref},r(s.props.children)):r(s)}var PPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Rx=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep,{ref:r,className:It("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Rx.displayName=Ep.displayName;const IPt=({children:t,...s})=>e.jsx(xs,{...s,children:e.jsx(fs,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Rx,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),Fx=N.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(sn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ep.Input,{ref:r,className:It("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));Fx.displayName=Ep.Input.displayName;const zx=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.List,{ref:r,className:It("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));zx.displayName=Ep.List.displayName;const Bx=N.forwardRef((t,s)=>e.jsx(Ep.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Bx.displayName=Ep.Empty.displayName;const $x=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Group,{ref:r,className:It("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));$x.displayName=Ep.Group.displayName;const LPt=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Separator,{ref:r,className:It("-mx-1 h-px bg-border",t),...s}));LPt.displayName=Ep.Separator.displayName;const bp=N.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Item,{ref:r,className:It("group relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-primary/80 data-[selected=true]:text-primary-foreground data-[disabled=true]:opacity-50",t),...s}));bp.displayName=Ep.Item.displayName;const DPt={event:{label:"Events",icon:Od,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Bl,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Zh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:sy,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:fn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},kIe=()=>{const[t,s]=N.useState(!1),[r,n]=N.useState(""),[a,o]=N.useState([]),[l,i]=N.useState(!1),c=nr();N.useEffect(()=>{const g=v=>{v.key==="k"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),s(_=>!_))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const u=N.useCallback(async g=>{if(!g.trim()){o([]);return}i(!0);const v=`%${g}%`;try{const[_,w,j,k,S]=await Promise.all([H.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${v},description.ilike.${v}`).limit(5),H.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${v},description.ilike.${v}`).limit(5),H.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${v},description.ilike.${v}`).limit(5),H.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${v},description.ilike.${v}`).limit(5),H.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${v},description.ilike.${v}`).limit(5)]),M=[];_.data&&_.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"event",date:L.event_date,path:`/event/${L.id}`})}),w.data&&w.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"template",date:L.publish_date,path:`/templates/${L.id}`})}),j.data&&j.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"academy",date:L.publish_date,path:`/academy/${L.id}`})}),k.data&&k.data.forEach(L=>{M.push({id:L.id,title:L.name,description:L.description,type:"toolbox",date:L.publish_date,path:`/toolbox/${L.id}`})}),S.data&&S.data.forEach(L=>{M.push({id:L.id,title:L.title,description:L.description,type:"social-swag",date:L.publish_date,path:`/social-swag/${L.id}`})}),o(M)}catch(_){console.error("Search error:",_)}finally{i(!1)}},[]);N.useEffect(()=>{const g=setTimeout(()=>{u(r)},300);return()=>clearTimeout(g)},[r,u]);const p=g=>{s(!1),n(""),c(g)},f=a.reduce((g,v)=>(g[v.type]||(g[v.type]=[]),g[v.type].push(v),g),{});return e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-9 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>s(!0),children:[e.jsx(sn,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex text-muted-foreground text-sm",children:"Search..."}),e.jsxs("kbd",{className:"pointer-events-none absolute right-1.5 top-1.5 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsxs(IPt,{open:t,onOpenChange:s,children:[e.jsx(Fx,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(zx,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Bx,{children:['No results found for "',r,'"']}),!l&&!r&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across all content..."}),Object.entries(f).map(([g,v])=>{const _=DPt[g],w=_.icon;return e.jsx($x,{heading:_.label,children:v.map(j=>e.jsxs(bp,{value:`${j.type}-${j.id}-${j.title}`,onSelect:()=>p(j.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${_.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:j.title}),j.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:j.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:_.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Vc(new Date(j.date),{addSuffix:!0})})]})]},`${j.type}-${j.id}`))},g)})]})]})]})},OPt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=N.useState(null),o=nr();if(N.useEffect(()=>{const u=()=>{const f=new Date().getTime(),v=new Date(t).getTime()-f;if(v<=0){a({days:0,hours:0,minutes:0});return}const _=Math.floor(v/(1e3*60*60*24)),w=Math.floor(v%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(v%(1e3*60*60)/(1e3*60));a({days:_,hours:w,minutes:j})};u();const p=setInterval(u,6e4);return()=>clearInterval(p)},[t]),!n)return null;const l=n.days===0&&n.hours===0&&n.minutes===0,i=n.days<=1,c=n.days<=3&&!i;return l?e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",s),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yu,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(fn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:It("flex items-center justify-between gap-3 px-4 py-2 rounded-lg border transition-colors",i?"bg-destructive/10 border-destructive/20":c?"bg-amber-500/10 border-amber-500/20":"bg-primary/10 border-primary/20",s),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(un,{className:It("h-4 w-4",i?"text-destructive":c?"text-amber-500":"text-primary")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:It("text-sm font-medium",i?"text-destructive":c?"text-amber-600":"text-primary"),children:"Free Trial:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:It("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:It("text-xs",i?"text-destructive/70":c?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":c?"default":"outline",className:It("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(fn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},RPt=()=>{const t=nr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Yu,{className:"h-8 w-8 text-destructive"})}),e.jsx(Rt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(gr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ca,{className:"h-6 w-6 text-amber-600"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),e.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(Ca,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),e.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(lr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},FPt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:It("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Ph,{className:"h-5 w-5"}),t&&e.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsx(ec,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var Aue="Checkbox",[zPt]=od(Aue),[BPt,CNe]=zPt(Aue);function $Pt(t){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:c,required:u,value:p="on",internal_do_not_use_render:f}=t,[g,v]=oh({prop:r,defaultProp:a??!1,onChange:c,caller:Aue}),[_,w]=N.useState(null),[j,k]=N.useState(null),S=N.useRef(!1),M=_?!!l||!!_.closest("form"):!0,L={checked:g,disabled:o,setChecked:v,control:_,setControl:w,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:rw(a)?!1:a,isFormControl:M,bubbleInput:j,setBubbleInput:k};return e.jsx(BPt,{scope:s,...L,children:qPt(f)?f(L):n})}var PYe="CheckboxTrigger",IYe=N.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:r,...n},a)=>{const{control:o,value:l,disabled:i,checked:c,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:g,isFormControl:v,bubbleInput:_}=CNe(PYe,t),w=Va(a,p),j=N.useRef(c);return N.useEffect(()=>{const k=o==null?void 0:o.form;if(k){const S=()=>f(j.current);return k.addEventListener("reset",S),()=>k.removeEventListener("reset",S)}},[o,f]),e.jsx(an.button,{type:"button",role:"checkbox","aria-checked":rw(c)?"mixed":c,"aria-required":u,"data-state":FYe(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:Lr(s,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Lr(r,k=>{f(S=>rw(S)?!0:!S),_&&v&&(g.current=k.isPropagationStopped(),g.current||k.stopPropagation())})})});IYe.displayName=PYe;var MNe=N.forwardRef((t,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:c,onCheckedChange:u,form:p,...f}=t;return e.jsx($Pt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:c,internal_do_not_use_render:({isFormControl:g})=>e.jsxs(e.Fragment,{children:[e.jsx(IYe,{...f,ref:s,__scopeCheckbox:r}),g&&e.jsx(RYe,{__scopeCheckbox:r})]})})});MNe.displayName=Aue;var LYe="CheckboxIndicator",DYe=N.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=CNe(LYe,r);return e.jsx(zd,{present:n||rw(o.checked)||o.checked===!0,children:e.jsx(an.span,{"data-state":FYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});DYe.displayName=LYe;var OYe="CheckboxBubbleInput",RYe=N.forwardRef(({__scopeCheckbox:t,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:c,name:u,value:p,form:f,bubbleInput:g,setBubbleInput:v}=CNe(OYe,t),_=Va(r,v),w=HO(o),j=PO(n);N.useEffect(()=>{const S=g;if(!S)return;const M=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(M,"checked").set,O=!a.current;if(w!==o&&P){const $=new Event("click",{bubbles:O});S.indeterminate=rw(o),P.call(S,rw(o)?!1:o),S.dispatchEvent($)}},[g,w,o,a]);const k=N.useRef(rw(o)?!1:o);return e.jsx(an.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??k.current,required:i,disabled:c,name:u,value:p,form:f,...s,tabIndex:-1,ref:_,style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});RYe.displayName=OYe;function qPt(t){return typeof t=="function"}function rw(t){return t==="indeterminate"}function FYe(t){return rw(t)?"indeterminate":t?"checked":"unchecked"}const Oo=N.forwardRef(({className:t,...s},r)=>e.jsx(MNe,{ref:r,className:It("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(DYe,{className:It("flex items-center justify-center text-current"),children:e.jsx(ba,{className:"h-4 w-4"})})}));Oo.displayName=MNe.displayName;var TNe="Radio",[UPt,zYe]=od(TNe),[VPt,HPt]=UPt(TNe),BYe=N.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:c,form:u,...p}=t,[f,g]=N.useState(null),v=Va(s,j=>g(j)),_=N.useRef(!1),w=f?u||!!f.closest("form"):!0;return e.jsxs(VPt,{scope:r,checked:a,disabled:l,children:[e.jsx(an.button,{type:"button",role:"radio","aria-checked":a,"data-state":VYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:v,onClick:Lr(t.onClick,j=>{a||c==null||c(),w&&(_.current=j.isPropagationStopped(),_.current||j.stopPropagation())})}),w&&e.jsx(UYe,{control:f,bubbles:!_.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});BYe.displayName=TNe;var $Ye="RadioIndicator",qYe=N.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=HPt($Ye,r);return e.jsx(zd,{present:n||o.checked,children:e.jsx(an.span,{"data-state":VYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});qYe.displayName=$Ye;var GPt="RadioBubbleInput",UYe=N.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=N.useRef(null),i=Va(l,o),c=HO(r),u=PO(s);return N.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&v){const _=new Event("click",{bubbles:n});v.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx(an.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});UYe.displayName=GPt;function VYe(t){return t?"checked":"unchecked"}var WPt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Eue="RadioGroup",[KPt]=od(Eue,[Dw,zYe]),HYe=Dw(),GYe=zYe(),[ZPt,YPt]=KPt(Eue),WYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:c,dir:u,loop:p=!0,onValueChange:f,...g}=t,v=HYe(r),_=Lw(u),[w,j]=oh({prop:o,defaultProp:a??null,onChange:f,caller:Eue});return e.jsx(ZPt,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:j,children:e.jsx(Gde,{asChild:!0,...v,orientation:c,dir:_,loop:p,children:e.jsx(an.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...g,ref:s})})})});WYe.displayName=Eue;var KYe="RadioGroupItem",ZYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=YPt(KYe,r),l=o.disabled||n,i=HYe(r),c=GYe(r),u=N.useRef(null),p=Va(s,u),f=o.value===a.value,g=N.useRef(!1);return N.useEffect(()=>{const v=w=>{WPt.includes(w.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",_)}},[]),e.jsx(Wde,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(BYe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Lr(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Lr(a.onFocus,()=>{var v;g.current&&((v=u.current)==null||v.click())})})})});ZYe.displayName=KYe;var QPt="RadioGroupIndicator",YYe=N.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=GYe(r);return e.jsx(qYe,{...a,...n,ref:s})});YYe.displayName=QPt;var QYe=WYe,XYe=ZYe,XPt=YYe;const ANe=N.forwardRef(({className:t,...s},r)=>e.jsx(QYe,{className:It("grid gap-2",t),...s,ref:r}));ANe.displayName=QYe.displayName;const nle=N.forwardRef(({className:t,...s},r)=>e.jsx(XYe,{ref:r,className:It("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(XPt,{className:"flex items-center justify-center",children:e.jsx(wd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));nle.displayName=XYe.displayName;const JPt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Os(),[o,l]=N.useState({}),[i,c]=N.useState({}),[u,p]=N.useState([]);N.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const j=t.polls.map(S=>S.id),{data:k}=await H.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",j);if(k){const S={};k.forEach(M=>{S[M.poll_id]||(S[M.poll_id]=[]),S[M.poll_id].push(M.option_id)}),c(S)}},g=(j,k)=>{l(S=>({...S,[j]:k}))},v=(j,k,S)=>{l(M=>{const L=M[j]||[];return S?{...M,[j]:[...L,k]}:{...M,[j]:L.filter(P=>P!==k)}})},_=async j=>{if(!a)return;const k=o[j];if(!k||Array.isArray(k)&&k.length===0){me.error("Please select an option");return}p(S=>[...S,j]);try{await H.from("levelup_brief_poll_responses").delete().eq("poll_id",j).eq("user_id",a.id);const S=Array.isArray(k)?k:[k],M=S.map(P=>({poll_id:j,option_id:P,user_id:a.id})),{error:L}=await H.from("levelup_brief_poll_responses").insert(M);if(L)throw L;c(P=>({...P,[j]:S})),me.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),me.error("Failed to submit response")}finally{p(S=>S.filter(M=>M!==j))}},w=j=>(j.includes("mediadelivery.net")||j.includes("bunny"),j);return e.jsx(xs,{open:s,onOpenChange:j=>!j&&r(),children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:e.jsx(Mr,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:e.jsx(Ph,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(st,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(_s,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Ki,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(j=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(j.url,"_blank"),className:"gap-2",children:[e.jsx(en,{className:"h-4 w-4"}),j.title]},j.id))})]}),t.polls.map(j=>{var M,L;const k=((M=i[j.id])==null?void 0:M.length)>0,S=u.includes(j.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:j.question}),k&&e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(sa,{className:"h-3 w-3"}),"Responded"]})]}),j.poll_type==="single"?e.jsx(ANe,{value:o[j.id]||((L=i[j.id])==null?void 0:L[0])||"",onValueChange:P=>g(j.id,P),className:"space-y-2",children:j.options.map(P=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(nle,{value:P.id,id:P.id}),e.jsx(be,{htmlFor:P.id,className:"cursor-pointer",children:P.option_text})]},P.id))}):e.jsx("div",{className:"space-y-2",children:j.options.map(P=>{const $=(o[j.id]||i[j.id]||[]).includes(P.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:P.id,checked:$,onCheckedChange:U=>v(j.id,P.id,U)}),e.jsx(be,{htmlFor:P.id,className:"cursor-pointer",children:P.option_text})]},P.id)})}),e.jsx(K,{size:"sm",onClick:()=>_(j.id),disabled:S,children:S?"Submitting...":k?"Update Response":"Submit"})]},j.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(K,{onClick:r,className:"w-full max-w-xs",children:"Got it!"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},eIt=()=>{const{user:t}=Os(),[s,r]=N.useState(null),[n,a]=N.useState(!1),[o,l]=N.useState(!0),[i,c]=N.useState(!1),u=N.useCallback(async()=>{if(!t){l(!1);return}try{const{data:_,error:w}=await H.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!_){l(!1);return}const{data:j}=await H.from("levelup_brief_views").select("*").eq("brief_id",_.id).eq("user_id",t.id).maybeSingle(),[k,S]=await Promise.all([H.from("levelup_brief_links").select("*").eq("brief_id",_.id).order("sort_order"),H.from("levelup_brief_polls").select("*").eq("brief_id",_.id).order("sort_order")]),M=[];if(S.data)for(const U of S.data){const{data:B}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",U.id).order("sort_order");M.push({...U,options:B||[]})}const L={brief:_,links:k.data||[],polls:M};r(L);const P=!!j,O=(j==null?void 0:j.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${_.id}`)==="true";if(O||$)c(!1),a(!1);else if(!P)a(!0),c(!0);else if(_.show_frequency==="every_login")a(!0),c(!0);else if(_.show_frequency==="daily"){const U=new Date(j.viewed_at);(new Date().getTime()-U.getTime())/(1e3*60*60)>=24&&(a(!0),c(!0))}else c(!1)}catch(_){console.error("Error fetching brief:",_)}finally{l(!1)}},[t]);N.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:_}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();_?await H.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",_.id):await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(_){console.error("Error marking brief as viewed:",_)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),c(!1);try{const{data:_,error:w}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),_){const{error:j}=await H.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",_.id).eq("user_id",t.id);j&&console.error("Error updating brief dismiss:",j)}else{const{error:j}=await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});j&&console.error("Error inserting brief dismiss:",j)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(_){console.error("Error dismissing brief:",_),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function tIt(){const[t,s]=N.useState(!1),[r,n]=N.useState(!1),[a,o]=N.useState(null);N.useEffect(()=>{if(localStorage.getItem("install-banner-dismissed")||window.matchMedia("(display-mode: standalone)").matches||!/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))return;const f=/iPhone|iPad|iPod/i.test(navigator.userAgent);n(f),s(!0);const g=v=>{v.preventDefault(),o(v)};return window.addEventListener("beforeinstallprompt",g),()=>{window.removeEventListener("beforeinstallprompt",g)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),s(!1)},i=async()=>{if(a){await a.prompt();const{outcome:c}=await a.userChoice;c==="accepted"&&l(),o(null)}};return t?e.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 p-4 bg-primary text-primary-foreground shadow-lg animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:e.jsx(vi,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),r?e.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",e.jsx($L,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):e.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&a&&e.jsx(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(Mr,{className:"h-4 w-4"})})]})]})}):null}const sIt=({children:t,onRefresh:s})=>{const[r,n]=N.useState(!1),[a,o]=N.useState(0),[l,i]=N.useState(!1),c=N.useRef(null),u=N.useRef(0),p=Xt(),f=80,g=120,v=N.useCallback(S=>{const M=c.current;M&&M.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),_=N.useCallback(S=>{if(!r||l)return;const M=c.current;if(!M||M.scrollTop>0){n(!1),o(0);return}const P=S.touches[0].clientY-u.current;if(P>0){const $=Math.min(P*.5,g);o($),$>10&&S.preventDefault()}},[r,l]),w=N.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),j=Math.min(a/f,1),k=j*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:v,onTouchMove:_,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:j},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${k}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Wo,{className:"h-5 w-5 text-primary"})})}),e.jsx("div",{style:{transform:a>0?`translateY(${Math.max(0,a-60)}px)`:void 0,transition:r?void 0:"transform 0.2s ease-out"},children:t})]})},JYe=()=>{const{user:t}=Os(),[s,r]=N.useState(!1),[n,a]=N.useState(!1),[o,l]=N.useState(0),[i,c]=N.useState(!0);N.useEffect(()=>{(async()=>{if(!t){c(!1);return}try{const{data:v}=await H.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(v){a(!0),r(!1),c(!1);return}const{data:_}=await H.from("profiles").select("login_count").eq("id",t.id).single(),w=(_==null?void 0:_.login_count)||0;l(w);const j=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!j)}catch(v){console.error("Error checking review eligibility:",v)}finally{c(!1)}})()},[t]);const u=N.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=N.useCallback(async(g,v)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:_}=await H.from("membership_reviews").insert({user_id:t.id,rating:g,review_text:v});if(_)throw _;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(_){return console.error("Error submitting review:",_),{success:!1,error:_.message}}},[t]),f=N.useCallback(async()=>{if(t)try{await H.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(g){console.error("Error updating Google review status:",g)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},rIt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",nIt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=JYe(),[o,l]=N.useState(!1),[i,c]=N.useState("review"),[u,p]=N.useState(0),[f,g]=N.useState(0),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!1);if(s||!t&&!k)return null;const M=async()=>{if(u===0){jn({title:"Please select a rating",variant:"destructive"});return}j(!0);const O=await n(u,v);j(!1),O.success?(S(!0),jn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):jn({title:"Error submitting review",description:O.error,variant:"destructive"})},L=async O=>{O&&(await navigator.clipboard.writeText(v||`${u} star rating for LevelUp!`),jn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(rIt,"_blank")),l(!1),r()},P=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Jn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(xs,{open:o,onOpenChange:P,children:e.jsx(fs,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Wr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(O=>e.jsx("button",{type:"button",onClick:()=>p(O),onMouseEnter:()=>g(O),onMouseLeave:()=>g(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Jn,{className:It("h-8 w-8 transition-colors",(f||u)>=O?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},O))}),e.jsx(Pr,{placeholder:"Tell us about your experience (optional)",value:v,onChange:O=>_(O.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:P,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:M,disabled:w||u===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Wr,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>L(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function aIt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const w="vapid_public_key";let j=localStorage.getItem(w);if(!j){const{data:M,error:L}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(L)throw L;if(j=(M==null?void 0:M.vapidPublicKey)??null,!j)throw new Error("Missing VAPID public key");localStorage.setItem(w,j)}p(j);const k=await navigator.serviceWorker.register("/push-sw.js",{scope:"/push-notifications/"});c(k),r(Notification.permission);const S=await k.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[f]);const g=N.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return me.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const _=await i.pushManager.getSubscription();if(_){try{await _.unsubscribe()}catch(L){console.warn("Failed to unsubscribe existing push subscription:",L)}const{error:M}=await H.from("push_subscriptions").delete().eq("user_id",t.id);M&&console.warn("Failed to cleanup push_subscriptions rows:",M)}if(Notification.permission!=="granted"){const M=await Notification.requestPermission();if(r(M),M!=="granted")return M==="denied"?me.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):me.error("Notification permission was dismissed. Please try again."),!1}const w=aIt(u);let j;try{j=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(M){console.error("PushManager.subscribe() failed:",M);const L=(M==null?void 0:M.message)||String(M);return L.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):L.includes("key")||L.includes("VAPID")?me.error("Push configuration error. Please contact support."):L.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${L}`),!1}const k=j.toJSON(),{error:S}=await H.from("push_subscriptions").upsert({user_id:t.id,endpoint:k.endpoint,p256dh_key:k.keys.p256dh,auth_key:k.keys.auth},{onConflict:"user_id,endpoint"});if(S)throw console.error("Error saving subscription:",S),me.error("Failed to save notification preferences. Please try again."),S;return a(!0),me.success("Push notifications enabled!"),!0}catch(_){if(console.error("Error subscribing to push notifications:",_),!(_ instanceof Error&&_.message.includes("toast"))){const w=_ instanceof Error?_.message:"Unknown error";me.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[f,i,t,u]),v=N.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const _=await i.pushManager.getSubscription();return _&&await _.unsubscribe(),await H.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),me.success("Push notifications disabled"),!0}catch(_){console.error("Error unsubscribing:",_);const w=_ instanceof Error?_.message:"Unknown error";return me.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:g,unsubscribe:v}}const lge="push_notification_prompt_dismissed",iIt=["/dashboard","/admin"],oIt=()=>{const{user:t}=Os(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=eQe(),o=dc(),[l,i]=N.useState(!1),[c,u]=N.useState(!1),p=iIt.some(v=>o.pathname===v||o.pathname.startsWith(`${v}/`));N.useEffect(()=>{if(p){i(!1);return}if(!t||!s||r||n||localStorage.getItem(`${lge}_${t.id}`))return;const _=setTimeout(()=>{i(!0)},2e3);return()=>clearTimeout(_)},[t,s,r,n,p]);const f=async()=>{u(!0);const v=await a();u(!1),v&&(t&&localStorage.setItem(`${lge}_${t.id}`,"true"),i(!1))},g=()=>{t&&localStorage.setItem(`${lge}_${t.id}`,"true"),i(!1)};return!s||r||p?null:e.jsx(xs,{open:l,onOpenChange:v=>!v&&g(),children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Lm,{className:"h-6 w-6 text-primary"})}),e.jsx(_s,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Wr,{className:"text-center",children:"Enable push notifications to get alerted when:"})]}),e.jsxs("ul",{className:"my-4 space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New events go live"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Fresh templates are added"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New toolbox resources drop"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Social swag updates"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," New newsletters arrive"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-primary",children:"•"})," Posts in your community groups"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(K,{onClick:f,disabled:c,className:"w-full",children:c?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:g,className:"w-full",children:"Not Now"})]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},SIe=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const g=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(v=>v(s,g))}},a=()=>s,i={setState:n,getState:a,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=s=t(n,a,i);return i},lIt=t=>t?SIe(t):SIe,cIt=t=>t;function dIt(t,s=cIt){const r=ht.useSyncExternalStore(t.subscribe,ht.useCallback(()=>s(t.getState()),[t,s]),ht.useCallback(()=>s(t.getInitialState()),[t,s]));return ht.useDebugValue(r),r}const CIe=t=>{const s=lIt(t),r=n=>dIt(s,n);return Object.assign(r,s),r},uIt=t=>t?CIe(t):CIe;function hIt(t,s){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=c=>c===null?null:JSON.parse(c,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const T1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return T1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return T1e(n)(r)}}}},mIt=(t,s)=>(r,n,a)=>{let o={storage:hIt(()=>localStorage),partialize:w=>w,version:0,merge:(w,j)=>({...j,...w}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const p=()=>{const w=o.partialize({...n()});return u.setItem(o.name,{state:w,version:o.version})},f=a.setState;a.setState=(w,j)=>(f(w,j),p());const g=t((...w)=>(r(...w),p()),n,a);a.getInitialState=()=>g;let v;const _=()=>{var w,j;if(!u)return;l=!1,i.forEach(S=>{var M;return S((M=n())!=null?M:g)});const k=((j=o.onRehydrateStorage)==null?void 0:j.call(o,(w=n())!=null?w:g))||void 0;return T1e(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const M=o.migrate(S.state,S.version);return M instanceof Promise?M.then(L=>[!0,L]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var M;const[L,P]=S;if(v=o.merge(P,(M=n())!=null?M:g),r(v,!0),L)return p()}).then(()=>{k==null||k(v,void 0),v=n(),l=!0,c.forEach(S=>S(v))}).catch(S=>{k==null||k(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>_(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},o.skipHydration||_(),v||g},pIt=mIt,Pue=uIt()(pIt((t,s)=>({cartItems:[],addToCart:(r,n,a=1,o)=>{t(l=>{const i=l.cartItems.findIndex(c=>{var u;return c.product.id===r.id&&((u=c.variant)==null?void 0:u.id)===(n==null?void 0:n.id)});if(i>=0){const c=[...l.cartItems];return c[i].quantity+=a,o&&(c[i].artworkUrl=o),{cartItems:c}}return{cartItems:[...l.cartItems,{product:r,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(r,n)=>{t(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===r&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(r,n,a)=>{t(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===r&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>t({cartItems:[]}),getItemPrice:r=>{const n=Number(r.product.base_price),a=r.variant?Number(r.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:r,getItemPrice:n}=s();return r.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:r}=s();return r.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:r,getShippingTotal:n}=s();return r()+n()}}),{name:"marketplace-cart",partialize:t=>({cartItems:t.cartItems})}));function uE(){const{user:t}=Os(),{data:s,isLoading:r}=mt({queryKey:["agent-lead-site",t==null?void 0:t.id],queryFn:async()=>{const{data:n,error:a}=await H.from("lead_sites").select("id, subdomain_slug, site_title, is_active").eq("agent_id",t.id).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(a)throw a;return n},enabled:!!t,staleTime:5*60*1e3});return{leadSite:s??null,hasLeadSite:!!s,isLoading:r,siteUrl:s?`https://${s.subdomain_slug}.thelocalmove.com`:null}}const tQe=N.createContext({onlineUsers:[],totalOnline:0}),fIt=async t=>{try{const{data:s}=await H.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=H.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},xIt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Os(),[a,o]=N.useState([]),[l,i]=N.useState(null);N.useEffect(()=>{if(!s)return;const u=H.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([g,v])=>{if(v&&v.length>0){const _=v[0];f.push({id:g,name:_.name||"Unknown",avatarUrl:_.avatarUrl,brokerageId:_.brokerageId,onlineSince:_.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:g}=await H.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),v=await fIt(s.id);await u.track({name:(g==null?void 0:g.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:v,brokerageId:g==null?void 0:g.brokerage_id,onlineSince:new Date().toISOString()})}}),i(u),()=>{u.unsubscribe()}},[s]);const c=a.filter(u=>u.id===(s==null?void 0:s.id)?!1:!!(n||r&&u.brokerageId===r||!r&&!u.brokerageId));return e.jsx(tQe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},sQe=()=>N.useContext(tQe),MIe="dashboard-sidebar-collapsed",Ts=({children:t,title:s})=>{var pt;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Os(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=oje(),{isImpersonating:p}=Vde(),g=(i&&!!c?40:0)+(p?40:0),{avatarUrl:v}=eYe(r==null?void 0:r.id),{isTrial:_,isExpired:w,expiresAt:j}=k6t(r==null?void 0:r.id),{isMarketplaceEnabled:k}=sYe(),{currentBrief:S,shouldShowPopup:M,hasUnseenBrief:L,openBrief:P,closeBrief:O,dismissBrief:$}=eIt(),{unreadCount:U}=S6t(),{openCount:B}=C6t(),{data:V}=Ux(),X=!!V,ee=Pue(ye=>ye.cartItems).reduce((ye,qe)=>ye+qe.quantity,0),{leadSite:Q,hasLeadSite:ce,siteUrl:ne}=uE(),re=nr(),oe=dc(),[fe,ge]=N.useState(null);N.useEffect(()=>{r!=null&&r.id&&H.from("profiles").select("name").eq("id",r.id).single().then(({data:ye})=>{ye!=null&&ye.name&&ge(ye.name)})},[r==null?void 0:r.id]);const ue=fe||((pt=r==null?void 0:r.user_metadata)==null?void 0:pt.name)||(r==null?void 0:r.email)||"User",[xe,_e]=N.useState(()=>typeof window<"u"?localStorage.getItem(MIe)==="true":!1);N.useEffect(()=>{localStorage.setItem(MIe,String(xe))},[xe]);const[$e,Me]=N.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Ie=ye=>{Me(qe=>({...qe,[ye]:!qe[ye]}))},ke=ye=>ye.split(" ").map(qe=>qe[0]).join("").toUpperCase().slice(0,2),pe=ye=>oe.pathname===ye,we=ye=>ye.some(qe=>oe.pathname===qe),Le=({path:ye,icon:qe,label:at,badgeCount:tt})=>{const Ae=e.jsxs(K,{variant:"ghost",size:"sm",className:It("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",pe(ye)&&"bg-sidebar-accent text-sidebar-accent-foreground",xe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>re(ye),children:[e.jsxs("div",{className:"relative",children:[e.jsx(qe,{className:"h-4 w-4 shrink-0"}),xe&&tt!=null&&tt>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!xe&&at,!xe&&tt!=null&&tt>0&&e.jsx("span",{className:"ml-auto flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:tt>9?"9+":tt})]});return xe?e.jsxs(Nc,{delayDuration:0,children:[e.jsx(kc,{asChild:!0,children:Ae}),e.jsxs(ec,{side:"right",className:"flex items-center gap-2",children:[at,tt!=null&&tt>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:tt>9?"9+":tt})]})]}):Ae},Qe=({id:ye,label:qe,icon:at,children:tt,activePaths:Ae,showBetaBadge:rt,defaultPath:He,badgeCount:ct})=>{if(xe){const Ue=He||Ae[0];return e.jsxs(Nc,{delayDuration:0,children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",we(Ae)&&"text-primary"),onClick:()=>re(Ue),children:e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"h-4 w-4"}),ct!=null&&ct>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),e.jsxs(ec,{side:"right",className:"flex items-center gap-2",children:[qe,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600",children:"Beta"}),ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct})]})]})}return e.jsxs(vf,{open:$e[ye],onOpenChange:()=>Ie(ye),children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we(Ae)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(at,{className:"h-4 w-4"}),qe,rt&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[ct!=null&&ct>0&&e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground text-xs font-medium border border-muted-foreground/20",children:ct>9?"9+":ct}),e.jsx(oo,{className:It("h-4 w-4 transition-transform duration-200",$e[ye]&&"rotate-180")})]})]})}),e.jsx(_f,{className:"pl-4 space-y-1 mt-1",children:tt})]})},Te=({isMobile:ye=!1})=>{const qe=ye?!1:xe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:It("p-3 border-b border-sidebar-border",qe?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[qe?e.jsx("img",{src:D6t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:L6t,alt:"LevelUp",className:"h-8 w-auto"}),!ye&&e.jsxs(Nc,{delayDuration:0,children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>_e(!qe),children:e.jsx(Xo,{className:It("h-4 w-4 transition-transform duration-300",qe&&"rotate-180")})})}),e.jsx(ec,{side:"right",children:qe?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Ki,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:It("p-3 space-y-1",qe&&"flex flex-col items-center"),children:[e.jsx(Le,{path:"/dashboard",icon:cS,label:"Dashboard"}),e.jsx(Le,{path:"/apps",icon:ix,label:"Apps & Tools"}),xe?e.jsxs(Nc,{delayDuration:0,children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Zh,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsxs(ec,{side:"right",className:"flex items-center gap-2",children:["LevelUp U",e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1 py-0.5",children:"New"})]})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Zh,{className:"h-4 w-4 shrink-0"}),"LevelUp U",e.jsx("span",{className:"ml-auto text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1.5 py-0.5",children:"New"})]}),e.jsx(Le,{path:"/events",icon:Od,label:"Events"}),e.jsxs(Qe,{id:"agentos",label:"Agent OS",icon:LM,activePaths:["/mission-control","/mission-control/contacts","/mission-control/plans","/mission-control/popbys","/mission-control/video-library","/mission-control/scorecard","/mission-control/listings","/mission-control/pipeline","/mission-control/tasks","/mission-control/smart-drips","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"],showBetaBadge:!0,defaultPath:"/mission-control",children:[u("contacts")&&e.jsx(Le,{path:"/mission-control",icon:Ya,label:"Mission Control"}),u("contacts")&&!qe&&e.jsxs(vf,{open:$e.contacts,onOpenChange:()=>Ie("contacts"),children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",we(["/mission-control/contacts","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"])&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(oo,{className:It("h-3.5 w-3.5 transition-transform duration-200",$e.contacts&&"rotate-180")})]})}),e.jsxs(_f,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Le,{path:"/mission-control/contacts",icon:hr,label:"All Contacts"}),e.jsx(Le,{path:"/mission-control/relationship-scorecard",icon:Ch,label:"Relationship Report"}),e.jsx(Le,{path:"/mission-control/sphere-gaps",icon:zL,label:"Sphere Gaps"}),e.jsx(Le,{path:"/mission-control/connect-page",icon:ml,label:"Connect Page"})]})]}),u("contacts")&&qe&&e.jsx(Le,{path:"/mission-control/contacts",icon:hr,label:"Contacts"}),u("contacts")&&e.jsx(Le,{path:"/mission-control/plans",icon:Od,label:"TouchPlans"}),u("pipeline")&&e.jsx(Le,{path:"/mission-control/pipeline",icon:f0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Le,{path:"/mission-control/tasks",icon:Vv,label:"Tasks"}),u("popbys")&&e.jsx(Le,{path:"/mission-control/popbys",icon:So,label:"Popbys"}),u("videos")&&e.jsx(Le,{path:"/mission-control/video-library",icon:Cn,label:"Video Library"}),u("scorecard")&&e.jsx(Le,{path:"/mission-control/scorecard",icon:yo,label:"Scorecard"}),u("listings")&&e.jsx(Le,{path:"/mission-control/listings",icon:Ca,label:"Listing Exchange"}),!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/mission-control/smart-drips"),children:[e.jsx(Yh,{className:"h-4 w-4"}),"Smart Drips",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),qe&&e.jsx(Le,{path:"/mission-control/smart-drips",icon:Yh,label:"Smart Drips"})]}),ce&&Q&&e.jsxs(Qe,{id:"website",label:"My Website",icon:ru,activePaths:[`/admin/lead-sites/${Q.id}/edit`],defaultPath:`/admin/lead-sites/${Q.id}/edit`,children:[qe?e.jsxs(Nc,{delayDuration:0,children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ne||"#","_blank"),children:e.jsx(Dn,{className:"h-4 w-4"})})}),e.jsx(ec,{side:"right",children:"View Site"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open(ne||"#","_blank"),children:[e.jsx(Dn,{className:"h-4 w-4"}),"View Site",e.jsx(en,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx(Le,{path:`/my-website/${Q.id}/edit`,icon:za,label:"Edit Website"}),e.jsx(Le,{path:"/my-website/mls-listings",icon:dn,label:"MLS Listings"}),e.jsx(Le,{path:"/my-website/market-report",icon:yo,label:"Market Reports"}),e.jsx(Le,{path:"/mission-control/website-activity",icon:Ch,label:"Website Activity"}),e.jsx(Le,{path:"/m",icon:_0,label:"Mobile Command"})]}),e.jsxs(Qe,{id:"marketing",label:"Marketing",icon:Ph,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Le,{path:"/templates",icon:Bl,label:"Templates"}),e.jsx(Le,{path:"/social-swag-2",icon:_0,label:"Social Swag"}),e.jsx(Le,{path:"/newsletters",icon:m1,label:"Newsletters"})]}),e.jsxs(Qe,{id:"learning",label:"Learning",icon:Th,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Le,{path:"/academy",icon:Zh,label:"Academy"}),e.jsx(Le,{path:"/toolbox",icon:sy,label:"Toolbox"})]}),e.jsxs(Qe,{id:"community",label:"Community",icon:so,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:U,children:[e.jsx(Le,{path:"/community",icon:hr,label:"Community",badgeCount:U}),e.jsx(Le,{path:"/wishlist",icon:Z_,label:"Wishlist",badgeCount:B}),!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(en,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Qe,{id:"goods",label:"The Goods",icon:vp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[k&&!qe&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",oe.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/marketplace"),children:[e.jsx(vp,{className:"h-4 w-4"}),"Marketplace",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),k&&qe&&e.jsx(Le,{path:"/marketplace",icon:vp,label:"Marketplace"}),e.jsx(Le,{path:"/reward-store",icon:vo,label:"Reward Store"})]}),e.jsxs(Qe,{id:"help",label:"Help & Services",icon:Bv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Le,{path:"/support",icon:VM,label:"Support"}),e.jsx(Le,{path:"/additional-services",icon:fn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!qe&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),qe?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Le,{path:"/admin",icon:Eh,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",oe.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/admin"),children:[e.jsx(Eh,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!qe&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),qe?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{path:"/my-brokerage",icon:Ca,label:"My Brokerage"}),e.jsx(Le,{path:"/brokerage-content",icon:Th,label:"Brokerage Content"})]}),X&&!o&&e.jsx(Le,{path:"/my-team",icon:hr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Le,{path:"/brokerage/dashboard",icon:Qo,label:"Manage Brokerages"}),e.jsx(Le,{path:"/brokerage/teams",icon:hr,label:"Teams"}),e.jsx(Le,{path:"/brokerage/recruiting",icon:Ph,label:"Recruiting"}),e.jsx(Le,{path:"/brokerage-resources",icon:th,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-brokerage"),children:[e.jsx(Ca,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-content"),children:[e.jsx(Th,{className:"h-4 w-4"}),"Brokerage Content"]})]}),X&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-team"),children:[e.jsx(hr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/dashboard"),children:[e.jsx(Qo,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/teams"),children:[e.jsx(hr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/recruiting"),children:[e.jsx(Ph,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-resources"),children:[e.jsx(th,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),e.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:It("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/profile"),children:[e.jsx(Wi,{className:"h-4 w-4"}),"Profile"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:n,children:[e.jsx(hS,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(xIt,{children:e.jsx(G1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[_&&w&&e.jsx(RPt,{}),typeof document<"u"&&yp.createPortal(e.jsx("aside",{className:It("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",xe?"w-16":"w-56"),style:{top:`${g}px`,height:`calc(100vh - ${g}px)`},children:e.jsx(Te,{})}),document.body),e.jsxs("div",{className:It("flex-1 flex flex-col overflow-hidden transition-all duration-300",xe?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${g}px)`,marginTop:`${g}px`},children:[e.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[e.jsxs(lE,{children:[e.jsx(fNe,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(pS,{className:"h-5 w-5"})})}),e.jsx(S3,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(Te,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:O6t,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(kIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[_&&!w&&j&&e.jsx(OPt,{expiresAt:j,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(kIe,{})}),S&&e.jsx(FPt,{hasUnseenBrief:L,onClick:P}),k&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>re("/marketplace/cart"),children:[e.jsx(vp,{className:"h-5 w-5"}),ee>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-primary text-primary-foreground text-xs font-medium flex items-center justify-center",children:ee>99?"99+":ee})]}),e.jsx(lPt,{}),e.jsx(S1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",ue.split(" ")[0],"!"]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:e.jsxs(kn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Ua,{src:v||void 0}),e.jsx(Sn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:ke(ue)})]})})}),e.jsxs(Bd,{align:"end",className:"w-48",children:[e.jsxs(Aa,{onClick:()=>re("/profile"),className:"cursor-pointer",children:[e.jsx(Wi,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Aa,{onClick:()=>re("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(PL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(xw,{}),e.jsxs(Aa,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(hS,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(sIt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(JPt,{brief:S,open:M,onClose:O,onDismiss:$}),e.jsx(tIt,{}),e.jsx(nIt,{}),e.jsx(oIt,{})]})]})})})},gIt=()=>{const{user:t}=Os(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(""),i=async f=>{var g;if(!(t!=null&&t.email)){me.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:v,error:_}=await H.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((g=t.user_metadata)==null?void 0:g.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(_)throw _;if(v!=null&&v.url)window.open(v.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(v){console.error("Checkout error:",v),me.error(v.message||"Failed to start checkout. Please try again.")}finally{r(!1),a(null)}},c=["Unlimited access to all marketing templates","Complete Academy training library","AI-powered tools and resources","Community forums and support","Exclusive member events and workshops","Deal pipeline & scorecard tracking","Listing exchange access","Social media content library"],u=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return e.jsx(Ts,{children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[e.jsx(be,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(ze,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:f=>l(f.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[e.jsxs(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 bg-primary text-primary-foreground text-xs px-3 py-1 rounded-bl-lg font-medium",children:"Popular"}),e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-7 w-7 text-primary"})}),e.jsx(Rt,{className:"text-xl",children:"Individual Agent"}),e.jsx(gr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:c.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ba,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(Ca,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage"}),e.jsx(gr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ba,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:s,children:[s&&n==="brokerage_under_25"?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ca,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:e.jsx(Ca,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Rt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(gr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,g)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ba,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},g))}),e.jsxs(K,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:s,children:[s&&n==="brokerage_over_25"?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ca,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{children:"1-866-527-8668"})]}),e.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(lr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},yIt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Os(),a=nr(),[o,l]=N.useState(""),[i,c]=N.useState(!1),[u,p]=N.useState(!1);N.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),N.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){me.error("Please enter a brokerage name");return}const{data:g}=await H.auth.getSession(),v=g.session;if(!t||!v){me.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!v,userId:t==null?void 0:t.id});const{data:_,error:w}=await H.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:_,error:w}),w)throw w;if(!(_!=null&&_.ok))throw new Error((_==null?void 0:_.error)||"Failed to create brokerage");c(!1),p(!0),me.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(_){console.error("Error creating brokerage:",_),me.error(_.message||"Failed to create brokerage"),c(!1)}};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(bs,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Rt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(gi,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"Brokerage created"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(bs,{className:"w-5 h-5 animate-spin text-primary"}),e.jsx("span",{children:"Assigning you as manager..."})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-4",children:"You'll be redirected to complete your profile setup in a moment."})]})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-background via-primary/5 to-secondary/10 flex items-center justify-center p-4",children:e.jsxs(Ee,{className:"max-w-lg w-full",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Ca,{className:"w-10 h-10 text-primary"})}),e.jsx(Rt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(gr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:g=>l(g.target.value),onKeyDown:g=>g.key==="Enter"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(hr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),e.jsxs(K,{onClick:f,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",e.jsx(Sa,{className:"w-4 h-4 ml-2"})]})]})]})})},TIe=()=>{const t=nr(),[s,r]=N.useState("verifying"),[n,a]=N.useState("");N.useEffect(()=>{(async()=>{try{const{data:{session:i},error:c}=await H.auth.getSession();if(c)throw c;if(i!=null&&i.user){const{data:u}=await H.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await H.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"space-y-1 text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[s==="verifying"&&e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),s==="success"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s==="already_claimed"&&e.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),s==="error"&&e.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),e.jsxs(Rt,{className:"text-2xl",children:[s==="verifying"&&"Claiming Your Account...",s==="success"&&"Account Claimed!",s==="already_claimed"&&"Account Already Claimed",s==="error"&&"Claim Failed"]}),e.jsxs(gr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},vIt=()=>{const t=nr(),[s]=uc(),[r,n]=N.useState(s.get("code")||""),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(!1),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(!1),[S,M]=N.useState(null),[L,P]=N.useState(null),[O,$]=N.useState(null),[U,B]=N.useState(null);N.useEffect(()=>{const ee=s.get("code");ee&&(n(ee),V(ee))},[s]);const V=async ee=>{w(!0);const{data:Q,error:ce}=await H.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",ee.toUpperCase().trim()).single();if(ce||!Q){me.error("Invalid invite code"),w(!1);return}if(!Q.is_active){me.error("This invite code is no longer active"),w(!1);return}if(Q.max_uses&&Q.uses_count>=Q.max_uses){me.error("This invite code has reached its maximum uses"),w(!1);return}if(Q.expires_at&&new Date(Q.expires_at){ee.preventDefault(),V(r)},Y=async ee=>{var Q;if(ee.preventDefault(),!c.trim()){me.error("Please enter your name");return}if(l.length<6){me.error("Password must be at least 6 characters");return}v(!0);try{const ce=`${window.location.origin}/`,{data:ne,error:re}=await H.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:ce,data:{name:c.trim()}}});if(re){re.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(re.message);return}ne.user&&(await H.rpc("add_default_signup_tag",{user_id:ne.user.id}),L?await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,brokerageId:L}}):U?await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,trialDays:U}}):await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,grandfathered:!0}}),S&&await H.from("invite_codes").update({uses_count:((Q=(await H.from("invite_codes").select("uses_count").eq("id",S).single()).data)==null?void 0:Q.uses_count)+1}).eq("id",S),me.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),me.error("An unexpected error occurred")}finally{v(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsx(Rt,{className:"text-2xl font-bold text-primary",children:O?`Join ${O}`:"Join LevelUp"}),e.jsx(gr,{children:j?O?`Create your account to join ${O}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:j?e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Full Name"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Doe",value:c,onChange:ee=>u(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:ee=>o(ee.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:ee=>i(ee.target.value),required:!0,minLength:6}),e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>f(!p),children:p?e.jsx(kp,{className:"h-4 w-4"}):e.jsx(Dn,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(ze,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:ee=>n(ee.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},bIt="/assets/testimonial-avatar-1-BsCQFauB.jpg",_It="/assets/testimonial-avatar-2-B6VPVc2t.jpg",wIt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",jIt="/assets/testimonial-avatar-4-98iKMtkB.jpg",NIt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",kIt=[bIt,_It,wIt,jIt,NIt],SIt=N3({name:_c().trim().min(2,"Name must be at least 2 characters").max(100),email:_c().trim().email("Please enter a valid email address").max(255),phone:_c().trim().min(10,"Please enter a valid phone number").max(20).optional().or($oe("")),brokerage:_c().trim().max(200).optional().or($oe(""))}),CIt=[{icon:pp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Bl,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:hn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:qc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:wn,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:So,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],MIt=[{icon:hr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:fn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Mn,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Ah,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:ia,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:yo,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ya,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Yh,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],TIt=[{name:"Sarah M.",role:"Top Producer, RE/MAX",quote:"LevelUp completely transformed how I run my business. The templates alone save me hours every week."},{name:"Mike T.",role:"Brokerage Owner",quote:"Onboarding new agents used to take weeks. Now they're productive from day one with all the training resources."},{name:"Jessica L.",role:"Team Lead",quote:"The community is incredible. I've learned more from other agents here than any conference I've attended."}],AIt=()=>{const t=nr(),[s,r]=N.useState(!1),[n,a]=N.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=N.useState({}),i=async c=>{var p,f;c.preventDefault(),l({});const u=SIt.safeParse(n);if(!u.success){const g={};u.error.errors.forEach(v=>{v.path[0]&&(g[v.path[0]]=v.message)}),l(g);return}r(!0);try{const{data:g,error:v}=await H.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(v){console.error("Trial signup error:",v),me.error(v.message||"Something went wrong. Please try again.");return}if(g!=null&&g.error){me.error(g.error);return}me.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(g){console.error("Trial signup error:",g),me.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:"Start Your Free 7-Day Trial | LevelUp Dashboard"}),e.jsx("meta",{name:"description",content:"Take LevelUp for a free 7-day test drive. No credit card required. The all-in-one platform for real estate agents and brokerages."}),e.jsx("meta",{property:"og:title",content:"Start Your Free 7-Day Trial | LevelUp"}),e.jsx("meta",{property:"og:description",content:"Take LevelUp for a free 7-day test drive. No credit card required."}),e.jsx("meta",{property:"og:type",content:"website"})]}),e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:Joe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var c;return(c=document.getElementById("features"))==null?void 0:c.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[e.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[e.jsx("div",{className:"flex justify-center lg:justify-start",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium",children:[e.jsx(fn,{className:"h-4 w-4 text-yellow-400"}),e.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),e.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",e.jsx("span",{className:"italic",children:"Free Test Drive"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-white/80 max-w-xl mx-auto lg:mx-0 font-sans",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"No credit card required"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(sa,{className:"h-5 w-5 text-green-400"}),e.jsx("span",{children:"Full access to all features"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 justify-center lg:justify-start pt-4",children:[e.jsx("div",{className:"flex -space-x-3",children:kIt.map((c,u)=>e.jsx("img",{src:c,alt:`Agent ${u+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},u))}),e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(c=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},c))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(v0,{className:"h-8 w-8 text-white"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground font-sans",children:"Start Your Free Trial"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Get instant access • No credit card needed"})]}),e.jsxs("form",{onSubmit:i,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Full Name *"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:c=>a({...n,name:c.target.value}),required:!0}),o.name&&e.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email Address *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:c=>a({...n,email:c.target.value}),required:!0}),o.email&&e.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone Number"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:c=>a({...n,phone:c.target.value})}),o.phone&&e.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:c=>a({...n,brokerage:c.target.value})}),o.brokerage&&e.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Sa,{className:"ml-2 h-5 w-5"})]})}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["By signing up, you agree to our"," ",e.jsx("a",{href:"/terms-of-service",className:"text-[#4a6b6d] hover:underline",children:"Terms"})," ","and"," ",e.jsx("a",{href:"/privacy-policy",className:"text-[#4a6b6d] hover:underline",children:"Privacy Policy"})]})]})]})})})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."})]})})}),e.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:CIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Pt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(c.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Rt,{className:"text-xl font-sans",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:c.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(fn,{className:"w-4 h-4"}),"Included with Your Trial"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:MIt.map((c,u)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx(c.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Rt,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:c.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:TIt.map((c,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Jn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),e.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',c.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:c.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.role})]})]})},u))})]})}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Au,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Secure & Private"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bank-level encryption"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(Yh,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Fast Setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Expert Support"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),e.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(Ee,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx(Sa,{className:"ml-2 h-5 w-5"})]})]})]})})}),e.jsx("footer",{className:"bg-[#1e3a4c] py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-6",children:[e.jsx("img",{src:_je,alt:"LevelUp",className:"h-8"}),e.jsxs("div",{className:"flex gap-6 text-sm text-white/60",children:[e.jsx("a",{href:"/privacy-policy",className:"hover:text-white transition-colors",children:"Privacy Policy"}),e.jsx("a",{href:"/terms-of-service",className:"hover:text-white transition-colors",children:"Terms of Service"})]}),e.jsx("p",{className:"text-sm text-white/40",children:"© 2025 LevelUp Consulting Group. All rights reserved."})]})})})]})]})},EIt=()=>{const t=nr();return e.jsxs(e.Fragment,{children:[e.jsx($l,{children:e.jsx("title",{children:"Welcome to LevelUp! | Check Your Email"})}),e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:Joe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Ee,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(sa,{className:"h-12 w-12 text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-10 h-10 rounded-full bg-yellow-500 flex items-center justify-center animate-bounce",children:e.jsx(nu,{className:"h-5 w-5 text-white"})})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4 font-sans",children:"You're In! 🎉"}),e.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your 7-day LevelUp adventure starts now!"}),e.jsxs("div",{className:"bg-[#4a6b6d]/10 rounded-xl p-6 mb-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/20 flex items-center justify-center",children:e.jsx(lr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Check Your Inbox"})]}),e.jsx("p",{className:"text-muted-foreground",children:"We just sent you a magic link to claim your account and set up your password. Click the link in your email to get started!"})]}),e.jsxs("div",{className:"text-left space-y-3 mb-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium uppercase tracking-wide",children:"What happens next:"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"1"})}),e.jsx("p",{className:"text-foreground",children:"Check your email for the welcome message"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"2"})}),e.jsx("p",{className:"text-foreground",children:'Click "Claim Your Account" to set your password'})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-white",children:"3"})}),e.jsx("p",{className:"text-foreground",children:"Start exploring all the features!"})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive the email? Check your spam folder or"," ",e.jsx("button",{onClick:()=>t("/trial"),className:"text-[#4a6b6d] hover:underline font-medium",children:"try again"})]}),e.jsxs(K,{onClick:()=>t("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",e.jsx(Sa,{className:"ml-2 h-4 w-4"})]})]})})})})]}),e.jsx("footer",{className:"bg-[#1e3a4c] py-8",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("img",{src:_je,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},PIt=N3({viewerName:_c().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:_c().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:_c().max(20,"Phone must be less than 20 characters").optional(),message:_c().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function IIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(null),u=kue({resolver:Sue(PIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),c(null);try{const{data:g,error:v}=await H.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(v)throw new Error(v.message);if(!(g!=null&&g.success))throw new Error((g==null?void 0:g.error)||"Failed to send reply");l(!0)}catch(g){console.error("Failed to submit reply:",g),c(g.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(sa,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),e.jsxs("p",{className:"text-muted-foreground",children:[s?`${s} will`:"They'll"," get back to you soon."]})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(qc,{className:"h-5 w-5 text-primary"}),e.jsx(Rt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(gr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(Cue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Yc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Your Name *"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"John Smith",...f})}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Email *"}),e.jsx(Rc,{children:e.jsx(ze,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(Cm,{})]})})]}),!r&&e.jsx(Yc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Phone (optional)"}),e.jsx(Rc,{children:e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Message *"}),e.jsx(Rc,{children:e.jsx(Pr,{placeholder:r?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...f})}),e.jsx(Cm,{})]})}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(K,{type:"submit",className:"w-full gap-2",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const LIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),e.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),e.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),e.jsx(Jn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Jn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Jn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(d1,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),DIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-500/5 via-transparent to-blue-500/5"}),e.jsxs("div",{className:"absolute top-[10%] left-[15%] w-32 h-32",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-400/20 animate-ping",style:{animationDuration:"3s"}}),e.jsx(fn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Jn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(fn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Jn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),e.jsx(d1,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),OIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-200/20 via-rose-100/10 to-purple-200/15"}),e.jsx("div",{className:"absolute top-[5%] left-[5%] opacity-20",children:e.jsx(Kg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Kg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Kg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Kg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Ya,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Ya,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-300/40 fill-pink-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Ya,{className:"absolute top-[10%] left-[60%] w-4 h-4 text-rose-400/30 fill-rose-400/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx("div",{className:"absolute top-[8%] left-[45%] w-8 h-8 rounded-full bg-pink-300/10 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[30%] w-6 h-6 rounded-full bg-rose-300/10 blur-sm"})]}),RIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),e.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:e.jsxs("div",{className:"w-12 h-24 relative",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 w-0 h-0 border-l-[20px] border-r-[20px] border-t-[60px] border-l-transparent border-r-transparent border-t-blue-500"})]})}),e.jsx(tc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Jn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(tc,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),e.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),e.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),e.jsx(Jn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),FIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-100/20 via-purple-100/15 to-sky-100/20"}),e.jsx("div",{className:"absolute top-[5%] left-[8%] w-12 h-16 rounded-full bg-gradient-to-b from-pink-300/25 to-pink-400/18 rotate-12"}),e.jsx("div",{className:"absolute top-[8%] right-[12%] w-10 h-14 rounded-full bg-gradient-to-b from-purple-300/25 to-purple-400/18 -rotate-6"}),e.jsx("div",{className:"absolute bottom-[18%] left-[15%] w-11 h-15 rounded-full bg-gradient-to-b from-sky-300/20 to-sky-400/12 rotate-6"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-12 h-16 rounded-full bg-gradient-to-b from-yellow-300/20 to-yellow-400/12 -rotate-12"}),e.jsx("div",{className:"absolute top-[10%] left-[10%] w-6 h-1 bg-white/30 rounded-full rotate-12"}),e.jsx("div",{className:"absolute top-[12%] right-[15%] w-5 h-1 bg-white/25 rounded-full -rotate-6"}),e.jsx(Kg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Kg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(RM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),zIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(iS,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(iS,{className:"absolute top-[10%] right-[12%] w-12 h-12 text-purple-400/20 animate-pulse"}),e.jsxs("div",{className:"absolute bottom-[18%] left-[8%]",children:[e.jsx("div",{className:"w-14 h-12 rounded-full bg-orange-500/20"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-4 bg-green-600/25 rounded-t-full"})]}),e.jsxs("div",{className:"absolute bottom-[22%] right-[12%]",children:[e.jsx("div",{className:"w-12 h-10 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-1.5 h-3 bg-green-600/20 rounded-t-full"})]}),e.jsx("div",{className:"absolute top-[15%] left-[40%] opacity-20",children:e.jsx("svg",{viewBox:"0 0 24 12",className:"w-10 h-5 text-slate-800 fill-current",children:e.jsx("path",{d:"M12 6c-2-4-6-6-12-6 4 2 6 4 6 6s-2 4-6 6c6 0 10-2 12-6zm0 0c2-4 6-6 12-6-4 2-6 4-6 6s2 4 6 6c-6 0-10-2-12-6z"})})}),e.jsx(fn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(fn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),BIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(j0,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(j0,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(j0,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(o0,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(o0,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(o0,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(o0,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),e.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),e.jsx(Jn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),$It=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/10 via-amber-800/6 to-red-900/10"}),e.jsx("div",{className:"absolute top-[5%] left-[10%] w-10 h-8 rounded-full bg-orange-500/25 rotate-45"}),e.jsx("div",{className:"absolute top-[10%] right-[15%] w-8 h-6 rounded-full bg-red-500/20 -rotate-12"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-7 h-5 rounded-full bg-amber-500/22 rotate-30"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-10 h-7 rounded-full bg-yellow-600/18 -rotate-45"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-9 h-6 rounded-full bg-orange-600/15 rotate-12"}),e.jsxs("div",{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2",children:[e.jsx("div",{className:"w-16 h-14 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-5 bg-green-600/18 rounded-t-full"})]}),e.jsx(Ya,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Ya,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),qIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),e.jsx(Jn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Jn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Jn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Jn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(fn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(nu,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(nu,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),UIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",e.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),e.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),e.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),e.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),e.jsx("div",{className:"absolute bottom-[45%] left-1/2 -translate-x-1/2 w-4 h-5 bg-yellow-400/35 rounded-full blur-sm"}),e.jsx(Jn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(fn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(fn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),VIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Jv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Jv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Jv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Jv,{className:"absolute bottom-[22%] right-[10%] w-11 h-11 text-emerald-400/18"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-6 h-6 rounded-full bg-yellow-500/30 border-2 border-yellow-600/25"}),e.jsx("div",{className:"absolute top-[20%] right-[28%] w-5 h-5 rounded-full bg-amber-500/25 border-2 border-amber-600/20"}),e.jsx("div",{className:"absolute bottom-[28%] left-[45%] w-5 h-5 rounded-full bg-yellow-400/25 border-2 border-yellow-500/20"}),e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 opacity-12 rounded-bl-full overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-bl from-red-400/60 via-yellow-400/60 to-green-400/60"})}),e.jsxs("div",{className:"absolute bottom-[10%] right-[5%] opacity-15",children:[e.jsx("div",{className:"w-12 h-8 bg-slate-700 rounded-b-full"}),e.jsx("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-10 h-3 bg-slate-600 rounded-full"}),e.jsxs("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 flex gap-0.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"})]})]})]}),HIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),e.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),e.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),e.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),e.jsx(Jn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Jn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(tc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(tc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(d1,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),GIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(Ah,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-amber-400/18"}),e.jsxs("div",{className:"absolute top-[5%] left-[15%]",children:[e.jsx("div",{className:"w-12 h-14 rounded-full bg-rose-400/25"}),e.jsx("div",{className:"w-0.5 h-10 bg-rose-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[3%] left-[25%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-sky-400/25"}),e.jsx("div",{className:"w-0.5 h-12 bg-sky-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[8%] right-[18%]",children:[e.jsx("div",{className:"w-11 h-13 rounded-full bg-purple-400/25"}),e.jsx("div",{className:"w-0.5 h-9 bg-purple-400/18 mx-auto"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[10%]",children:[e.jsx("div",{className:"w-10 h-12 rounded-full bg-amber-400/25"}),e.jsx("div",{className:"w-0.5 h-11 bg-amber-400/18 mx-auto"})]}),e.jsx("div",{className:"absolute top-[20%] left-[35%] w-3 h-3 bg-pink-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[18%] right-[40%] w-2.5 h-2.5 bg-emerald-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-2 h-2 bg-amber-400/35 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[30%] w-2.5 h-2.5 bg-sky-400/35 rounded-full"}),e.jsx(nu,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(So,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),WIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(Ya,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Ya,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Ya,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Ya,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Ya,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Ya,{className:"absolute top-[20%] right-[35%] w-5 h-5 text-rose-300/35 fill-rose-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Ya,{className:"absolute top-[12%] left-[55%] w-5 h-5 text-red-300/30 fill-red-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Ya,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),KIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsxs("div",{className:"absolute top-[5%] right-[12%]",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-yellow-400/25 blur-sm"}),e.jsx(v1,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-14 h-14 text-amber-400/45"})]}),e.jsx("div",{className:"absolute bottom-[12%] left-[20%] w-20 h-10 bg-slate-800/12 rounded-full blur-md"}),e.jsx(v1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(fn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(v1,{className:"absolute bottom-[22%] right-[25%] w-8 h-8 text-orange-400/25"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[15%] bg-gradient-to-t from-amber-900/10 to-transparent"})]}),ZIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),e.jsx(dn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(dn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(Sp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(Sp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Ya,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Ya,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(fn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(nu,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),YIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(nu,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(nu,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(Sp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(dn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(fn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(fn,{className:"absolute top-[20%] right-[32%] w-7 h-7 text-cyan-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-3 h-3 bg-amber-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-2.5 h-2.5 bg-teal-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[28%] left-[35%] w-2 h-2 bg-emerald-400/30 rounded-full"})]}),QIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),e.jsx(Sp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(Sp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(Sp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(dn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(nu,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(fn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Jn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),XIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-emerald-900/6 to-green-900/10"}),e.jsx(dn,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-teal-500/22"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-12 h-10 bg-amber-400/18 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[20%] left-[20%] w-10 h-8 bg-orange-400/15 rounded-sm"}),e.jsx("div",{className:"absolute bottom-[16%] right-[15%] w-11 h-9 bg-amber-300/18 rounded-sm"}),e.jsx(Sp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Ya,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(fn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(l1,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),AIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute top-4 left-[10%] w-3 h-3 bg-amber-400/60 rounded-full animate-pulse"}),e.jsx("div",{className:"absolute top-12 right-[15%] w-2 h-2 bg-rose-400/60 rounded-full animate-pulse delay-100"}),e.jsx("div",{className:"absolute top-8 left-[30%] w-2.5 h-2.5 bg-sky-400/60 rounded-full animate-pulse delay-200"}),e.jsx("div",{className:"absolute top-16 right-[25%] w-2 h-2 bg-emerald-400/60 rounded-full animate-pulse delay-300"})]}),JIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Ya,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Ya,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Ya,{className:"absolute top-4 left-[40%] w-2.5 h-2.5 text-rose-400/40 fill-rose-400/20 animate-pulse delay-300"}),e.jsx(Ya,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),eLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(l1,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(fn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(dn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),tLt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(nS,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(HM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(nS,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),aI=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(fn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(nu,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(fn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),EIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(dn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(fn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(dn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),A1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(fn,{className:"h-5 w-5"}),category:"general",headerText:()=>"Video Message",subText:"A personal video just for you",gradientClasses:"from-background to-muted/30",accentColor:"primary"},{id:"thank_you",name:"Thank You",description:"Express your gratitude",icon:e.jsx(Ya,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You, ${t}!`:"Thank You!",subText:"Your support means the world to me",gradientClasses:"from-rose-50/70 via-pink-50/50 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(JIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(lL,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thinking of You, ${t}`:"Thinking of You",subText:"Just wanted to reach out and say hello",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(aI,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(nS,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"Just checking in to see how you're doing",gradientClasses:"from-amber-50/70 via-orange-50/50 to-yellow-50/40 dark:from-amber-950/30 dark:via-orange-950/20 dark:to-yellow-950/20",accentColor:"amber",decorativeElement:e.jsx(tLt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(yo,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Market Update for ${t}`:"Market Update",subText:"The latest insights from your local market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue"},{id:"referral_thank_you",name:"Referral Thank You",description:"Thank someone for a referral",icon:e.jsx(hr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(aI,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(tc,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"So proud of your accomplishment",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(AIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(ia,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Welcome to the Neighborhood, ${t}!`:"Welcome to the Neighborhood!",subText:"So excited to have you as our new neighbor",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-sky-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-sky-950/20",accentColor:"teal",decorativeElement:e.jsx(EIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(HM,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"No reason needed – just wanted to connect",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(aI,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Ah,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Birthday, ${t}!`:"Happy Birthday!",subText:"Wishing you an amazing year ahead",gradientClasses:"from-amber-50/80 via-rose-50/60 to-purple-50/40 dark:from-amber-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"amber",decorativeElement:e.jsx(GIt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Ya,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Valentine's Day, ${t}!`:"Happy Valentine's Day!",subText:"A heartfelt message from your real estate professional",gradientClasses:"from-rose-50/80 via-pink-50/60 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(WIt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(v1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Groundhog Day, ${t}!`:"Happy Groundhog Day!",subText:"Wishing you an early spring!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(KIt,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Jn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy New Year, ${t}!`:"Happy New Year!",subText:"Wishing you a year full of success and happiness",gradientClasses:"from-yellow-50/70 via-amber-50/50 to-orange-50/40 dark:from-yellow-950/30 dark:via-amber-950/20 dark:to-orange-950/20",accentColor:"yellow",decorativeElement:e.jsx(qIt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(RM,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Easter, ${t}!`:"Happy Easter!",subText:"Wishing you a joyful celebration",gradientClasses:"from-pink-50/70 via-purple-50/50 to-sky-50/40 dark:from-pink-950/30 dark:via-purple-950/20 dark:to-sky-950/20",accentColor:"pink",decorativeElement:e.jsx(FIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Kg,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Mother's Day, ${t}!`:"Happy Mother's Day!",subText:"Celebrating the wonderful mothers in our lives",gradientClasses:"from-pink-50/70 via-rose-50/50 to-purple-50/40 dark:from-pink-950/30 dark:via-rose-950/20 dark:to-purple-950/20",accentColor:"pink",decorativeElement:e.jsx(OIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(tc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Father's Day, ${t}!`:"Happy Father's Day!",subText:"Celebrating the wonderful fathers in our lives",gradientClasses:"from-blue-50/70 via-sky-50/50 to-indigo-50/40 dark:from-blue-950/30 dark:via-sky-950/20 dark:to-indigo-950/20",accentColor:"blue",decorativeElement:e.jsx(RIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(d1,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Memorial Day, ${t}`:"Happy Memorial Day",subText:"Honoring those who served our country",gradientClasses:"from-red-50/60 via-white to-blue-50/60 dark:from-red-950/30 dark:via-slate-950/20 dark:to-blue-950/30",accentColor:"blue",decorativeElement:e.jsx(LIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(sh,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy 4th of July, ${t}!`:"Happy 4th of July!",subText:"Celebrating freedom and independence",gradientClasses:"from-red-50/70 via-white to-blue-50/70 dark:from-red-950/30 dark:via-slate-950/10 dark:to-blue-950/30",accentColor:"red",decorativeElement:e.jsx(DIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(tc,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Labor Day, ${t}!`:"Happy Labor Day!",subText:"Celebrating the hard work that builds our communities",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(HIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(iS,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Halloween, ${t}!`:"Happy Halloween!",subText:"Have a spooktacular day!",gradientClasses:"from-orange-50/70 via-amber-50/50 to-purple-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-purple-950/30",accentColor:"orange",decorativeElement:e.jsx(zIt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Ya,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Thanksgiving, ${t}!`:"Happy Thanksgiving!",subText:"Grateful for you and your friendship",gradientClasses:"from-orange-50/70 via-amber-50/50 to-red-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-red-950/20",accentColor:"orange",decorativeElement:e.jsx($It,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(j0,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Merry Christmas, ${t}!`:"Merry Christmas!",subText:"Wishing you joy and peace this holiday season",gradientClasses:"from-red-50/70 via-green-50/40 to-emerald-50/40 dark:from-red-950/30 dark:via-green-950/20 dark:to-emerald-950/20",accentColor:"red",decorativeElement:e.jsx(BIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(fn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Hanukkah, ${t}!`:"Happy Hanukkah!",subText:"Wishing you eight nights of light and joy",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(UIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Jv,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy St. Patrick's Day, ${t}!`:"Happy St. Patrick's Day!",subText:"Wishing you the luck of the Irish!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(VIt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(dn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Happy Home Anniversary, ${t}!`:"Happy Home Anniversary!",subText:"Celebrating another year in your beautiful home",gradientClasses:"from-teal-50/70 via-cyan-50/50 to-emerald-50/40 dark:from-teal-950/30 dark:via-cyan-950/20 dark:to-emerald-950/20",accentColor:"teal",decorativeElement:e.jsx(ZIt,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(nu,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're under contract – exciting times ahead!",gradientClasses:"from-emerald-50/70 via-teal-50/50 to-cyan-50/40 dark:from-emerald-950/30 dark:via-teal-950/20 dark:to-cyan-950/20",accentColor:"emerald",decorativeElement:e.jsx(YIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(EIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(hl,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Just Sold!",subText:"Another successful transaction completed",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(aI,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(_S,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Great News, ${t}!`:"Price Reduced!",subText:"This property just became more affordable",gradientClasses:"from-orange-50/70 via-amber-50/50 to-yellow-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-yellow-950/20",accentColor:"orange"},{id:"open_house",name:"Open House",description:"Invite to an open house event",icon:e.jsx(l1,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`You're Invited, ${t}!`:"You're Invited!",subText:"Join us for an exclusive open house",gradientClasses:"from-sky-50/70 via-blue-50/50 to-indigo-50/40 dark:from-sky-950/30 dark:via-blue-950/20 dark:to-indigo-950/20",accentColor:"sky",decorativeElement:e.jsx(eLt,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(Sp,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"It's official – the keys are yours!",gradientClasses:"from-amber-50/70 via-yellow-50/50 to-orange-50/40 dark:from-amber-950/30 dark:via-yellow-950/20 dark:to-orange-950/20",accentColor:"amber",decorativeElement:e.jsx(QIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(dn,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Welcome Home, ${t}!`:"Welcome Home!",subText:"Wishing you all the best in your new home",gradientClasses:"from-teal-50/70 via-emerald-50/50 to-green-50/40 dark:from-teal-950/30 dark:via-emerald-950/20 dark:to-green-950/20",accentColor:"teal",decorativeElement:e.jsx(XIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(nh,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Amazing News, ${t}!`:"Offer Accepted!",subText:"Your offer has been accepted – congratulations!",gradientClasses:"from-green-50/70 via-emerald-50/50 to-teal-50/40 dark:from-green-950/30 dark:via-emerald-950/20 dark:to-teal-950/20",accentColor:"green",decorativeElement:e.jsx(aI,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(tc,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Congratulations, ${t}!`:"Congratulations!",subText:"You're pre-approved and ready to find your dream home",gradientClasses:"from-violet-50/70 via-purple-50/50 to-indigo-50/40 dark:from-violet-950/30 dark:via-purple-950/20 dark:to-indigo-950/20",accentColor:"violet",decorativeElement:e.jsx(AIe,{})}],sLt=[{id:"general",name:"General Touch",description:"Everyday connection templates"},{id:"holidays",name:"Holidays",description:"Seasonal and holiday greetings"},{id:"transactional",name:"Transactional",description:"Real estate milestone templates"}];function rLt(t){return A1e.filter(s=>s.category===t)}function iT(t){return A1e.find(s=>s.id===t)||A1e[0]}function PIe(){const{shareToken:t,recipientToken:s}=lo(),[r,n]=N.useState(null),[a,o]=N.useState(null),[l,i]=N.useState(null),[c,u]=N.useState(!0),[p,f]=N.useState(null),[g,v]=N.useState(!0),_=N.useRef(null),w=N.useRef(0),j=N.useRef(0),k=(()=>{const Y=new URLSearchParams(window.location.search);return s||Y.get("rt")||null})(),S=N.useCallback((Y,ee=!1)=>{if(!k||Y<=0)return;const Q=Math.max(1,Math.round(Y));if(Q<=j.current)return;const ne=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(k)}&e=watch&ws=${Q}`;ee&&navigator.sendBeacon?navigator.sendBeacon(ne):fetch(ne,{method:"GET",keepalive:ee}).catch(()=>{}),j.current=Math.max(j.current,Q)},[k]);N.useEffect(()=>{var oe;if(!g||!(r!=null&&r.playback_url)||!k)return;let Y=!1;const ee=()=>{w.current>0&&S(w.current,!0)},Q=()=>{document.visibilityState==="hidden"&&ee()},ce=()=>{ee()},ne=()=>{var ge;if(Y||!_.current||!((ge=window.playerjs)!=null&&ge.Player))return;const fe=new window.playerjs.Player(_.current);fe.on("timeupdate",ue=>{const xe=Math.floor(Number((ue==null?void 0:ue.seconds)??0));!Number.isFinite(xe)||xe<=0||(w.current=Math.max(w.current,xe))}),fe.on("pause",()=>{w.current>0&&S(w.current)}),fe.on("ended",()=>{w.current>0&&S(w.current,!0)})},re=document.querySelector('script[data-bunny-playerjs="true"]');if((oe=window.playerjs)!=null&&oe.Player)ne();else if(re)re.addEventListener("load",ne,{once:!0});else{const fe=document.createElement("script");fe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",fe.async=!0,fe.defer=!0,fe.dataset.bunnyPlayerjs="true",fe.onload=ne,document.body.appendChild(fe)}return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",ce),()=>{Y=!0,document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",ce),ee()}},[g,r==null?void 0:r.playback_url,k,S]),N.useEffect(()=>{w.current=0,j.current=0},[k,t]),N.useEffect(()=>{const Y=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="msgsndr"]',"[data-chat-widget]"].forEach(ne=>{document.querySelectorAll(ne).forEach(re=>{re.style.display="none"})})};Y();const ee=[setTimeout(Y,500),setTimeout(Y,1500),setTimeout(Y,3e3)],Q=new MutationObserver(Y);return Q.observe(document.body,{childList:!0,subtree:!0}),()=>{ee.forEach(clearTimeout),Q.disconnect()}},[]),N.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:ee,error:Q}=await H.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(Q||!ee){f("Video not found or has been removed"),u(!1);return}n(ee);try{await H.rpc("log_video_view",{p_video_id:ee.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ce){console.warn("Failed to log video view:",ce)}if(ee.owner_user_id){const{data:ce}=await H.from("profiles").select("id, name, email, phone").eq("id",ee.owner_user_id).single();if(ce){o(ce);try{const{data:ne}=await H.storage.from("avatars").list(`${ee.owner_user_id}`);if(ne&&ne.length>0){const{data:re}=H.storage.from("avatars").getPublicUrl(`${ee.owner_user_id}/${ne[0].name}`);i(re.publicUrl)}}catch{}}}u(!1)})()},[t]);const M=Y=>{if(!Y)return"0:00";const ee=Math.floor(Y/60),Q=Y%60;return`${ee}:${Q.toString().padStart(2,"0")}`},L=Y=>Y.includes("iframe.mediadelivery.net/play/")?Y.replace("/play/","/embed/")+"?autoplay=true&responsive=true":Y,P=Y=>{if(!Y)return"?";const ee=Y.split(" ");return ee.length>=2?`${ee[0][0]}${ee[1][0]}`.toUpperCase():Y.substring(0,2).toUpperCase()},O=iT((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,U=O.headerText($),V=`https://dashboard.relevelup.com/share/video/${t}`;if(c)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const X=O.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsx("title",{children:U}),e.jsx("meta",{name:"description",content:O.subText}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:O.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:U}),e.jsx("meta",{name:"twitter:description",content:O.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:It("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",O.gradientClasses),children:[X&&O.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[X&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:It("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",O.accentColor==="primary"&&"bg-primary/10 text-primary",O.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",O.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",O.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",O.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",O.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",O.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",O.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",O.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",O.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",O.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",O.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",O.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:O.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:U}),e.jsx("p",{className:"text-muted-foreground",children:O.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(kn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Ua,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(Sn,{className:"bg-primary/10 text-primary font-semibold",children:P(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:X?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(Mn,{className:"h-4 w-4"})})}),a.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`mailto:${a.email}`,"aria-label":"Email agent",children:e.jsx(lr,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{className:"overflow-hidden shadow-lg",children:g&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:_,src:L(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>v(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:Y=>{var Q;Y.currentTarget.style.display="none";const ee=(Q=Y.currentTarget.parentElement)==null?void 0:Q.querySelector(".video-fallback");ee&&(ee.style.display="flex")}}):null,e.jsx("div",{className:"video-fallback w-full h-full items-center justify-center bg-gradient-to-br from-primary/20 to-primary/5",style:{display:r.preview_url||r.thumbnail_url?"none":"flex"},children:e.jsx(Cn,{className:"h-16 w-16 text-primary/50"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 group-hover:bg-black/40 transition-colors",children:e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/90 flex items-center justify-center shadow-lg transform group-hover:scale-105 transition-transform",children:e.jsx(il,{className:"h-10 w-10 text-primary ml-1"})})}),r.duration_seconds&&e.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:M(r.duration_seconds)})]})}),!X&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>v(!0),className:"gap-2",children:[e.jsx(il,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(IIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function nLt(){return N.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(A1t,{})}function aLt(){const{token:t}=lo();return N.useEffect(()=>{if(!t)return;const s=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${t}`;window.location.replace(s)},[t]),e.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(bs,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const iLt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},oLt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},E5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function lLt(){var Q,ce,ne,re;const{slugOrId:t}=lo(),[s]=uc(),{data:r,isLoading:n}=xWe(t||""),a=gWe(),o=_kt(),l=s.get("ref"),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(null),[P,O]=N.useState(!1);N.useEffect(()=>{l&&o.mutate(l)},[l]);const $=oe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(oe),U=async oe=>{if(oe.preventDefault(),!(!i.trim()||!f.trim()||!r)){j(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:v.trim(),shareToken:l}),S(!0),me.success("Thanks! The agent will be in touch soon.")}catch(fe){console.error("Lead submission error:",fe),me.error(`Failed to submit: ${fe.message||"Please try again"}`)}finally{j(!1)}}},B=(r==null?void 0:r.photos)||[],V=B.find(oe=>oe.is_primary)||B[0],X=()=>{M!==null&&L(M===0?B.length-1:M-1)},Y=()=>{M!==null&&L(M===B.length-1?0:M+1)};if(n)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(vs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(vs,{className:"h-10 w-48 mb-6"}),e.jsx(vs,{className:"aspect-video mb-6"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(vs,{className:"h-12 w-48"}),e.jsx(vs,{className:"h-6 w-full"}),e.jsx(vs,{className:"h-6 w-3/4"})]}),e.jsx(vs,{className:"h-64"})]})]})]});if(!r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(pa,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Loe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(dn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx(pa,{to:"/public/listings",children:"Browse All Listings"})})]})]});const ee=r.property_address?`${r.property_address} - ${r.city}, ${r.state}`:`${r.city}, ${r.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsxs("title",{children:[ee," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${E5[r.property_type]} in ${r.city}, ${r.state}. ${((Q=r.description)==null?void 0:Q.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:ee}),e.jsx("meta",{property:"og:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${E5[r.property_type]} in ${r.city}, ${r.state}. View photos, details, and contact the listing agent.`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${r.slug||r.id}`}),V&&e.jsx("meta",{property:"og:image",content:V.photo_url}),V&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${E5[r.property_type]} for sale`}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ee}),e.jsx("meta",{name:"twitter:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${E5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:B.map(oe=>oe.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(ce=r.agent.brokerage)!=null&&ce.name?{"@type":"RealEstateAgent",name:r.agent.brokerage.name}:void 0}:void 0})})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(pa,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:Loe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(pa,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),B.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>L(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${E5[r.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:B.slice(1,5).map((oe,fe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>L(fe+1),children:[e.jsx("img",{src:oe.photo_url,alt:`${r.property_address||r.city} - Photo ${fe+2} of ${B.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),fe===3&&B.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",B.length-5," more"]})]},oe.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(st,{className:`${iLt[r.status]} text-white border-0`,children:oLt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:$(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),r.city,", ",r.state,r.neighborhood&&` • ${r.neighborhood}`]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[r.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Mh,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bedrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),r.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(su,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.bathrooms}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),r.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(w0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),E5[r.property_type]]}),r.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Ee,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>O(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(Cn,{className:"h-12 w-12 text-primary"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 group-hover:bg-black/40 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-white/90 group-hover:bg-white flex items-center justify-center transition-colors shadow-lg",children:e.jsx(il,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>O(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(il,{className:"h-4 w-4"}),"Watch Video Tour"]}),r.video.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:r.video.title})]})]})}),r.agent&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Wi,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:r.agent.name}),((ne=r.agent.brokerage)==null?void 0:ne.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:k?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(lr,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:U,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:oe=>c(oe.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:oe=>p(oe.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:oe=>g(oe.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:v,onChange:oe=>_(oe.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(xs,{open:M!==null,onOpenChange:()=>L(null),children:e.jsxs(fs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(js,{className:"sr-only",children:e.jsx(_s,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>L(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Mr,{className:"h-5 w-5"})}),M!==null&&B[M]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:B[M].photo_url,alt:`Photo ${M+1}`,className:"w-full max-h-[80vh] object-contain"}),B.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:X,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx("button",{onClick:Y,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(oa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[M+1," / ",B.length]})]})]})]})}),e.jsx(xs,{open:P,onOpenChange:O,children:e.jsxs(fs,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(js,{className:"sr-only",children:e.jsx(_s,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>O(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Mr,{className:"h-5 w-5"})}),((re=r==null?void 0:r.video)==null?void 0:re.playback_url)&&e.jsx("div",{className:"aspect-video w-full",children:e.jsx("iframe",{src:r.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function cLt(){var o;const{slug:t}=lo(),{data:s,isLoading:r,error:n}=_We(t);if(N.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),N.useEffect(()=>{s!=null&&s.id&&go(s.id,"card_view")},[s==null?void 0:s.id]),r)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(vs,{className:"h-28 w-28 rounded-full"}),e.jsx(vs,{className:"h-6 w-48"}),e.jsx(vs,{className:"h-4 w-36"})]}),e.jsx(vs,{className:"h-12 w-full"}),e.jsx(vs,{className:"h-12 w-full"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=s.profile)==null?void 0:o.name)||"Agent";return e.jsxs(e.Fragment,{children:[e.jsxs($l,{children:[e.jsxs("title",{children:[a," | Real Estate Agent"]}),e.jsx("meta",{name:"description",content:s.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),e.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),e.jsx("meta",{property:"og:description",content:s.positioning_statement||`Connect with ${a}`}),s.avatar_url&&e.jsx("meta",{property:"og:image",content:s.avatar_url})]}),e.jsx(jje,{card:s})]})}function rQe({slugOverride:t}={}){var Ae;const{slug:s}=lo(),r=t||s,[n]=uc(),a=n.get("t"),[o,l]=N.useState(!0),[i,c]=N.useState(null),[u,p]=N.useState(null),f=N.useRef(null),g=N.useRef(null),[v,_]=N.useState(null),[w,j]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[P,O]=N.useState(0),[$,U]=N.useState(!1),[B,V]=N.useState(""),[X,Y]=N.useState(""),[ee,Q]=N.useState(""),[ce,ne]=N.useState(""),[re,oe]=N.useState(""),[fe,ge]=N.useState(""),[ue,xe]=N.useState(""),[_e,$e]=N.useState(""),[Me,Ie]=N.useState(""),[ke,pe]=N.useState(""),[we,Le]=N.useState(""),[Qe,Te]=N.useState("");N.useEffect(()=>{pt()},[r,a]);const pt=async()=>{if(!r)return;l(!0);const{data:rt,error:He}=await H.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(He||!rt){U(!0),l(!1);return}p(rt),g.current=rt;const{data:ct}=await H.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",rt.user_id).single();if(ct){let Ue;if(ct.brokerage_id){const{data:Ge}=await H.from("brokerages").select("name").eq("id",ct.brokerage_id).single();Ue=(Ge==null?void 0:Ge.name)||void 0}let Ze=ct.avatar_url||null;if(!Ze){const{data:Ge}=H.storage.from("avatars").getPublicUrl(`${rt.user_id}/avatar.jpg`);Ge!=null&&Ge.publicUrl&&(Ze=`${Ge.publicUrl}?t=${Date.now()}`)}const Je={...ct,avatar_url:Ze,brokerage_name:Ue};c(Je),f.current=Je}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",rt.id);const{data:Ue,error:Ze}=await H.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:rt.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:Ue,resolveErr:Ze}),!Ze&&(Ue!=null&&Ue.contact_id)){j(Ue.contact_id);const Je=Ue.contact;Je&&(_(Je),V(Je.first_name||""),Y(Je.last_name||""),Q(Je.email||""),ne(Je.phone||""),oe(Je.address||""),ge(Je.city||""),xe(Je.state||""),$e(Je.zip||""),Ie(Je.birthday||""),pe(Je.home_anniversary||""))}}catch(Ue){console.error("Failed to resolve token:",Ue)}l(!1)},ye=async()=>{var rt,He;if(!B.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}L(!0);try{let ct=(rt=g.current)==null?void 0:rt.id,Ue=(He=g.current)==null?void 0:He.user_id;if(!ct||!Ue){const{data:Je}=await H.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Je){me.error("This page is no longer active. Please contact the agent directly."),L(!1);return}ct=Je.id,Ue=Je.user_id}const{error:Ze}=await H.from("contact_intake_submissions").insert({intake_page_id:ct,agent_user_id:Ue,existing_contact_id:w,first_name:B.trim(),last_name:X.trim()||null,email:ee.trim()||null,phone:ce.trim()||null,address:re.trim()||null,city:fe.trim()||null,state:ue.trim()||null,zip:_e.trim()||null,birthday:Me||null,home_anniversary:ke||null,real_estate_interest:we||null,message:Qe.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ze}),Ze)throw Ze;a&&await H.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Je=[B.trim(),X.trim()].filter(Boolean).join(" ");await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/connect-page-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentUserId:Ue,contactName:Je,contactEmail:ee.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(Je){console.warn("Connect page notification failed (non-blocking):",Je)}S(!0)}catch(ct){console.error(ct),me.error("Something went wrong. Please try again.")}finally{L(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-slate-400"})});if($)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(k)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx($l,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(ps.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"max-w-md w-full text-center space-y-6 p-8",children:[e.jsx(ps.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(sa,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(Ya,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const qe=!!a&&!!v,at=3,tt=[{title:qe?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:B,onChange:rt=>V(rt.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:X,onChange:rt=>Y(rt.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:ee,onChange:rt=>Q(rt.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:ce,onChange:rt=>ne(rt.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:re,onChange:rt=>oe(rt.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:fe,onChange:rt=>ge(rt.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:ue,onChange:rt=>xe(rt.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:_e,onChange:rt=>$e(rt.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:Me,onChange:rt=>Ie(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Home Anniversary"}),e.jsx("input",{type:"date",value:ke,onChange:rt=>pe(rt.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(rt=>e.jsxs("button",{type:"button",onClick:()=>Le(we===rt.value?"":rt.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${we===rt.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:rt.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:rt.desc})]},rt.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:Qe,onChange:rt=>Te(rt.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs($l,{children:[e.jsxs("title",{children:["Connect with ",(i==null?void 0:i.name)||"Agent"]}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-8 sm:py-12",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Ae=i==null?void 0:i.name)==null?void 0:Ae.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(Mn,{className:"h-4.5 w-4.5"})}),(i==null?void 0:i.email)&&e.jsx("a",{href:`mailto:${i.email}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Email agent",children:e.jsx(lr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(ps.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:at}).map((rt,He)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${He<=P?"bg-blue-500":"bg-slate-200"}`},He))}),e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-100 p-6 sm:p-8",children:[e.jsx(zZe,{mode:"wait",children:e.jsxs(ps.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(fn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:tt[P].title})]}),tt[P].fields]},P)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[P>0?e.jsx("button",{type:"button",onClick:()=>O(rt=>rt-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),P{if(P===0&&!B.trim()){me.error("Please enter your first name");return}O(rt=>rt+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>ye(),disabled:M,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm disabled:opacity-50 flex items-center gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),P>0&&PO(rt=>rt+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(Ya,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}const hE=()=>({trackEngagement:N.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await H.auth.getUser();if(!o)return;await H.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])});function iI({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=N.useState(0),[o,l]=N.useState(!1),{trackEngagement:i}=hE(),c=N.useCallback(v=>{i("newsletter",v.id,v.title,"click_link")},[i]),u=N.useCallback(()=>{a(v=>(v+1)%t.length)},[t.length]),p=N.useCallback(()=>{a(v=>(v-1+t.length)%t.length)},[t.length]),f=N.useCallback(v=>{a(v)},[]);if(N.useEffect(()=>{if(t.length<=1||o)return;const v=setInterval(u,s);return()=>clearInterval(v)},[t.length,o,s,u]),!t||t.length===0)return null;const g=t[n];return e.jsxs("div",{className:It("relative w-full overflow-hidden rounded-xl",r),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[e.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[e.jsx("img",{src:g.image_url,alt:g.title,className:"w-full h-full object-cover rounded-t-xl"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:It("absolute left-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:p,children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:It("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:u,children:e.jsx(oa,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((v,_)=>e.jsx("button",{onClick:()=>f(_),className:It("w-2 h-2 rounded-full transition-all duration-300",_===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${_+1}`},_))})]}),e.jsxs("div",{className:"bg-foreground rounded-b-xl px-5 py-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm md:text-base font-semibold text-background truncate",children:g.title}),g.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:g.description})]}),g.link_url&&e.jsx("a",{href:g.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",onClick:()=>c(g),children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:g.link_text||"Learn More"})})]})]})}function dLt(t){return"EST"}function yD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=dLt();return`${r} ${n}`}function oT(t){const s=new Date,r=new Date(t),n=pM(r,-15),a=pM(r,30);return s>a?"ended":Bg(s,{start:r,end:a})?"live":Bg(s,{start:n,end:r})?"starting_soon":"upcoming"}function ENe(t){const s=oT(t);return s==="starting_soon"||s==="live"}const IIe=ENe,uLt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=N.useState(new Date);N.useEffect(()=>{const v=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(v)},[]);const o=t.filter(v=>ENe(v.event_date));if(o.length===0)return null;const l=o[0],i=oT(l.event_date),c=s.find(v=>v.event_id===l.id),u=(c==null?void 0:c.zoom_join_url)||l.zoom_link,p=!!c,f=i==="live",g=f?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return e.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${g.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${g.pulse} to-transparent animate-pulse`}),e.jsx("div",{className:"relative p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full ${g.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${g.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${g.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(x1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-4 w-4"}),"Starting Soon"]})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?`Started at ${yD(new Date(l.event_date))}`:`Starts at ${yD(new Date(l.event_date))}`})]}),e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs(K,{onClick:()=>window.open(u,"_blank"),className:`${g.button} text-white gap-2`,children:[e.jsx(en,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${g.outlineButton} gap-2`,children:[e.jsx(hr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var PNe="Progress",INe=100,[hLt]=od(PNe),[mLt,pLt]=hLt(PNe),nQe=N.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=fLt,...l}=t;(a||a===0)&&!LIe(a)&&console.error(xLt(`${a}`,"Progress"));const i=LIe(a)?a:INe;n!==null&&!DIe(n,i)&&console.error(gLt(`${n}`,"Progress"));const c=DIe(n,i)?n:null,u=ale(c)?o(c,i):void 0;return e.jsx(mLt,{scope:r,value:c,max:i,children:e.jsx(an.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":ale(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":oQe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});nQe.displayName=PNe;var aQe="ProgressIndicator",iQe=N.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=pLt(aQe,r);return e.jsx(an.div,{"data-state":oQe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});iQe.displayName=aQe;function fLt(t,s){return`${Math.round(t/s*100)}%`}function oQe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function ale(t){return typeof t=="number"}function LIe(t){return ale(t)&&!isNaN(t)&&t>0}function DIe(t,s){return ale(t)&&!isNaN(t)&&t<=s&&t>=0}function xLt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${INe}\`.`}function gLt(t,s){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${s}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${INe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var lQe=nQe,yLt=iQe;const Bi=N.forwardRef(({className:t,value:s,...r},n)=>e.jsx(lQe,{ref:n,className:It("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(yLt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Bi.displayName=lQe.displayName;function vLt(){const{user:t,isBrokerageManager:s}=Os(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState(!1),[c,u]=N.useState(!0),p=s?"brokerage_manager":"agent";N.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:L,error:P}=await H.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(P)throw P;const{data:O,error:$}=await H.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:U,error:B}=await H.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(B)throw B;n(L||[]),o(O||[]),i(!!U),L&&L.length>0&&await g(L,O||[])}catch(L){console.error("Error fetching checklist data:",L)}finally{u(!1)}},g=async(L,P)=>{var pe,we;if(!(t!=null&&t.id))return;const O=P.map(Le=>Le.item_id),$=L.filter(Le=>!O.includes(Le.id));if($.length===0)return;const[U,B,V,X,Y,ee,Q,ce,ne,re,oe,fe,ge,ue,xe]=await Promise.all([H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),H.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),H.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),H.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),H.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),H.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),H.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),H.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),H.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),_e={},$e=(pe=U.data)==null?void 0:pe.brokerage_id;_e.share_resource=(B.count||0)>0,_e.post_community=(V.count||0)>0,_e.register_event=(X.count||0)>0,_e.view_template=(Y.count||0)>0,_e.watch_academy=(ee.count||0)>0,_e.use_toolbox=(Q.count||0)>0,_e.launch_app=(ce.count||0)>0,_e.add_contact=(ne.count||0)>0,_e.create_video=(re.count||0)>0,_e.complete_touch=(oe.count||0)>0,_e.add_transaction=(fe.count||0)>0,_e.add_listing=(ge.count||0)>0,_e.add_deal=(xe.count||0)>0;const Me=((we=ue.data)==null?void 0:we.map(Le=>Le.id))||[],Ie=[];$e?Ie.push(H.from("profiles").select("id").eq("brokerage_id",$e).neq("id",t.id).then(Le=>{var Qe;_e.add_agent=(((Qe=Le.data)==null?void 0:Qe.length)||0)>0})):_e.add_agent=!1,Me.length>0?(Ie.push(H.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Me).then(Le=>{_e.add_plan=(Le.count||0)>0})),Ie.push(H.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Me).then(Le=>{_e.schedule_popby=(Le.count||0)>0}))):(_e.add_plan=!1,_e.schedule_popby=!1),await Promise.all(Ie);const ke=$.filter(Le=>_e[Le.action_type]);if(ke.length>0){const Le=ke.map(Te=>({user_id:t.id,item_id:Te.id})),{error:Qe}=await H.from("onboarding_checklist_progress").upsert(Le,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!Qe){const Te=ke.map(pt=>({item_id:pt.id,completed_at:new Date().toISOString()}));o(pt=>[...pt,...Te])}}},v=async L=>{if(t!=null&&t.id)try{const{error:P}=await H.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:L});if(P)throw P;o(O=>[...O,{item_id:L,completed_at:new Date().toISOString()}])}catch(P){console.error("Error marking item complete:",P)}},_=async()=>{if(t!=null&&t.id)try{const{error:L}=await H.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(L)throw L;i(!0)}catch(L){console.error("Error dismissing checklist:",L)}},w=a.length,j=r.length,k=j>0&&w>=j,S=j>0?w/j*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:w,totalCount:j,isComplete:k,progressPercentage:S,isItemComplete:L=>a.some(P=>P.item_id===L),markComplete:v,dismiss:_,refetch:f}}const bLt={add_agent:e.jsx(hr,{className:"h-4 w-4"}),share_resource:e.jsx(nd,{className:"h-4 w-4"}),post_community:e.jsx(so,{className:"h-4 w-4"}),register_event:e.jsx(hn,{className:"h-4 w-4"}),view_template:e.jsx(qv,{className:"h-4 w-4"}),watch_academy:e.jsx(Zh,{className:"h-4 w-4"}),use_toolbox:e.jsx(sy,{className:"h-4 w-4"}),launch_app:e.jsx(sL,{className:"h-4 w-4"}),add_deal:e.jsx(f0,{className:"h-4 w-4"}),add_listing:e.jsx(dn,{className:"h-4 w-4"})},_Lt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function wLt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=vLt(),p=nr(),[f,g]=N.useState(!0);return r||s||a===0||o?null:e.jsxs(Ee,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(v0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Get Started with LevelUp"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>g(!f),className:"h-8 w-8 p-0",children:f?e.jsx(xf,{className:"h-4 w-4"}):e.jsx(oo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Mr,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),e.jsx(Bi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(v=>{const _=i(v.id);return e.jsxs("div",{className:It("flex items-start gap-3 p-3 rounded-lg transition-colors",_?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(_)return;const w=_Lt[v.action_type];w?p(w):c(v.id)},children:[e.jsx("div",{className:"mt-0.5",children:_?e.jsx(sa,{className:"h-5 w-5 text-primary"}):e.jsx(wd,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:bLt[v.action_type]||e.jsx(wd,{className:"h-4 w-4"})}),e.jsx("span",{className:It("font-medium",_&&"line-through text-muted-foreground"),children:v.title})]}),v.description&&e.jsx("p",{className:It("text-sm text-muted-foreground mt-1",_&&"line-through"),children:v.description})]})]},v.id)})})})]})}const Gx=()=>mt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Wm=t=>{const s=ri(),r=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:c}=await a.range(l,l+r-1);if(c)throw c;const u=i??[];if(o.push(...u),u.length{let a=H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},jLt=t=>mt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),cQe=()=>{const t=ri();return mt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},Iue=()=>{const t=Xt(),s=ri();return Lt({mutationFn:async r=>{const{tagIds:n,...a}=r,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:s},{data:l,error:i}=await H.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:c}=await H.from("innercircle_contact_tags").insert(n.map(u=>({contact_id:l.id,relationship_type_id:u})));if(c)throw c}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),jn({title:"Contact created successfully"})},onError:r=>{jn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},LNe=()=>{const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{tagIds:n,tags:a,...o}=r,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:c}=await H.from("innercircle_contacts").update(l).eq("id",s).select().single();if(c)throw c;if(n!==void 0&&(await H.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await H.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),jn({title:"Contact updated successfully"})},onError:s=>{jn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},dQe=()=>{const t=Xt();return Lt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await H.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await H.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await H.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await H.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),jn({title:"Spouse link updated"})},onError:s=>{jn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},DNe=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),jn({title:"Contact deleted successfully"})},onError:s=>{jn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},JO=()=>mt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await H.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),NLt=t=>mt({queryKey:["action-scripts",t],queryFn:async()=>{let s=H.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),kLt=()=>mt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),SLt=()=>{const t=Xt(),s=ri();return Lt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),jn({title:"Plan created successfully"})},onError:r=>{jn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},CLt=()=>{const t=Xt(),s=ri();return Lt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await H.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const c=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:u}=await H.from("touchpoint_plan_items").insert(c);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),jn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{jn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},MLt=()=>{const t=Xt();return Lt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await H.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),jn({title:"Plan updated successfully"})}})},TLt=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),jn({title:"Plan deleted successfully"})}})},ALt=()=>{const t=Xt();return Lt({mutationFn:async({planId:s,items:r})=>{if(await H.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await H.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),jn({title:"Plan schedule updated"})}})},ELt=()=>{const t=Xt();return Lt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await H.auth.getUser(),{data:i,error:c}=await H.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),jn({title:"Script created successfully"})},onError:s=>{jn({title:"Error creating script",description:s.message,variant:"destructive"})}})},PLt=()=>{const t=ri();return mt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await H.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},ILt=()=>{const t=Xt(),s=ri();return Lt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await H.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await H.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await H.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),jn({title:"Plan enrollment updated"})}})},eR=(t=7)=>{const s=ri();return mt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await H.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},uQe=()=>{const t=ri();return mt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},LLt=(t=90)=>{const{data:s}=Wm(),{data:r}=uQe();if(!s||!r)return{contacts:[],count:0};const n=new Date;n.setDate(n.getDate()-t);const a=s.filter(o=>{const l=r[o.id];return l?new Date(l){const t=Xt(),s=ri();return Lt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:c}=await H.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(c)throw c;return i},onSuccess:async(r,n)=>{var a,o;t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),t.invalidateQueries({queryKey:["today-actions"]}),jn({title:"Action completed!"});try{const[l,i]=await Promise.all([H.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),H.from("action_types").select("name").eq("id",n.actionTypeId).single()]),c=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";c&&H.functions.invoke("boldtrail-sync",{body:{action:"push_touch",contact_email:c,touch_type:u,touch_notes:n.notes||null,touch_date:n.completedAt||r.completed_at}}).catch(()=>{})}catch{}}})},hQe="agentos_weekly_touch_goal",OIe=20,ile=()=>{if(typeof window>"u")return OIe;const t=localStorage.getItem(hQe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return OIe},mQe=t=>{localStorage.setItem(hQe,t.toString())},RNe=()=>{const{data:t}=eR(7),s=new Date;s.setHours(0,0,0,0);const r=new Date(s);r.setDate(s.getDate()-s.getDay());const n=(t==null?void 0:t.filter(l=>new Date(l.completed_at)>=r).length)||0;let a=0;if(t&&t.length>0){const l=new Set(t.map(c=>new Date(c.completed_at).toDateString()));let i=new Date(s);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=ile();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},DLt=()=>{const t=ri();return mt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},OLt=()=>{const t=Xt();return ri(),Lt({mutationFn:async()=>{const{data:s}=await H.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await H.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await H.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const c=s.find(u=>u.relationship_type_id===i.relationship_type_id);c&&!a.has(`${l.id}-${c.plan_id}`)&&o.push({contact_id:l.id,plan_id:c.plan_id,relationship_type_id:i.relationship_type_id})}if(o.length>0){const{error:l}=await H.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&jn({title:`${s} contact(s) enrolled in plans`})}})},pQe=()=>{const t=ri(),{data:s}=DLt(),{data:r}=eR(30);return mt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var _;if(!s||s.length===0)return[];const{data:n}=await H.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((_=w.plan)!=null&&_.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const j=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-j.getTime())/(30.44*24*60*60*1e3))%12+1,M=w.plan.items.find(L=>L.month_number===S);if(M&&M.action_type){const L=`${w.contact_id}-${M.action_type_id}`;if(!c.has(L)){const{data:P}=await H.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:M.action_type,script:M.default_script||void 0,planName:w.plan.name,relationshipTypeName:(P==null?void 0:P.name)||"",monthNumber:S})}}}const u=5,p=o.getDate(),f=l.sort((w,j)=>w.contact.first_name.localeCompare(j.contact.first_name)),g=(p-1)%Math.max(1,f.length);return[...f.slice(g),...f.slice(0,g)].slice(0,u)},enabled:!!t&&!!s})};function RLt(){const t=nr(),{data:s,isLoading:r}=pQe(),{data:n}=Wm(),a=RNe(),[o,l]=N.useState(ile()),[i,c]=N.useState(""),[u,p]=N.useState(!1);N.useEffect(()=>{l(ile())},[]);const f=()=>{const O=parseInt(i,10);if(isNaN(O)||O<1){jn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(O),mQe(O),p(!1),jn({title:"Goal updated",description:`Weekly touch goal set to ${O}`})},g=()=>{c(o.toString()),p(!0)},v=$m(new Date),_=Il(v,7),w=O=>{if(!O)return null;const $=O.split(/[-/T]/);if($.length<3)return null;const U=parseInt($[1],10)-1,B=parseInt($[2],10);return isNaN(U)||isNaN(B)?null:new Date(v.getFullYear(),U,B)},j=(n==null?void 0:n.map(O=>{const $=w(O.birthday),U=w(O.home_anniversary),B=[];return $&&$>=v&&$<=_&&B.push({contact:O,type:"birthday",date:$,isToday:Tl($,v)}),U&&U>=v&&U<=_&&B.push({contact:O,type:"anniversary",date:U,isToday:Tl(U,v)}),B}).flat().sort((O,$)=>O.date.getTime()-$.date.getTime()).slice(0,3))||[],k=(n==null?void 0:n.filter(O=>{const $=w(O.birthday),U=w(O.home_anniversary);return $&&Tl($,v)||U&&Tl(U,v)}).length)||0,S=(s==null?void 0:s.length)||0,M=k+S,L=(a==null?void 0:a.actionsThisWeek)||0,P=(a==null?void 0:a.streak)||0;return r?e.jsx(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:P>0&&e.jsxs(st,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(sh,{className:"h-3 w-3"}),P," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[M," tasks"]})," for today"]}):"No tasks for today",L>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:L})," touches this week"]})]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(El,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control")},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:O=>{O.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:O=>{O.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(ia,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:O=>{O.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(f0,{className:"h-3.5 w-3.5"}),"Pipeline"]})]}),e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(xs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:g,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Qo,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(fs,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Set Weekly Goal"}),e.jsx(Wr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:O=>c(O.target.value),placeholder:"20",onKeyDown:O=>{O.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:L}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Bi,{value:Math.min(L/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),L>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),L0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-L," more to hit your weekly goal"]})]}),j.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ah,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:j.map((O,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${O.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:U=>{U.stopPropagation(),t(`/mission-control/contacts/${O.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[O.type==="birthday"?e.jsx(Ah,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(dn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[O.contact.first_name," ",O.contact.last_name]}),O.isToday&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.isToday?O.type==="birthday"?"🎂":"🏠":ms(O.date,"EEE, MMM d")}),e.jsx(oa,{className:"h-3 w-3"})]})]},`${O.contact.id}-${O.type}-${$}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Sa,{className:"h-4 w-4"})]})]})]})}function FLt(t){return mt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function zLt(t,s){return mt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function BLt(t,s=4){return mt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await H.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function $Lt(t){const s=Xt();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function qLt(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function ULt(t){const s=Xt();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function VLt(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function HLt(t){const s=Xt();return Lt({mutationFn:async()=>{const r=[{name:"Events",icon:"📅",sort_order:0,is_default:!0,brokerage_id:t},{name:"Videos",icon:"🎥",sort_order:1,is_default:!0,brokerage_id:t},{name:"Documents",icon:"📄",sort_order:2,is_default:!0,brokerage_id:t},{name:"Resources",icon:"🔗",sort_order:3,is_default:!0,brokerage_id:t},{name:"Graphics",icon:"🎨",sort_order:4,is_default:!0,brokerage_id:t}],{error:n}=await H.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const GLt={video:il,pdf:wn,link:ml,event:hn,graphic:Bl},WLt={video:"bg-red-500/10 text-red-600 dark:text-red-400",pdf:"bg-blue-500/10 text-blue-600 dark:text-blue-400",link:"bg-green-500/10 text-green-600 dark:text-green-400",event:"bg-purple-500/10 text-purple-600 dark:text-purple-400",graphic:"bg-amber-500/10 text-amber-600 dark:text-amber-400"};function KLt(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function ZLt(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function YLt({item:t}){const s=nr(),r=GLt[t.content_type]||ml,n=WLt[t.content_type]||"",[a,o]=N.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?KLt(t.url):null);N.useEffect(()=>{l||!t.url||t.content_type!=="video"||!ZLt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(c=>c.ok?c.json():null).then(c=>{c!=null&&c.thumbnail_url&&o(c.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(st,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${n}`,children:[e.jsx(r,{className:"h-3 w-3 mr-0.5"}),t.content_type]})}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:t.title}),t.content_type==="event"&&t.event_date&&e.jsx("p",{className:"text-xs text-primary mt-1 font-medium",children:ms(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function QLt(){const{brokerageId:t}=Os(),s=nr(),{data:r=[],isLoading:n}=BLt(t,4);return!t||n||r.length===0?null:e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Brokerage Content"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/brokerage-content"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(a=>e.jsx(YLt,{item:a},a.id))})]})}const fQe=()=>mt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),xQe=t=>{const{user:s,brokerageId:r}=Os();return mt({queryKey:["listings",t,r],queryFn:async()=>{let n=H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await H.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const c=i.map(f=>f.id);let u=H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",c);t!=null&&t.status&&(u=u.eq("status",t.status)),t!=null&&t.propertyType&&(u=u.eq("property_type",t.propertyType)),t!=null&&t.city&&(u=u.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(u=u.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(u=u.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(u=u.eq("open_to_referrals",!0));const{data:p}=await u;if(p){const f=new Set(l.map(v=>v.id)),g=p.filter(v=>!f.has(v.id));l=[...l,...g]}}}switch(t==null?void 0:t.sortBy){case"updated":l.sort((i,c)=>new Date(c.updated_at).getTime()-new Date(i.updated_at).getTime());break;case"price_asc":l.sort((i,c)=>i.price-c.price);break;case"price_desc":l.sort((i,c)=>c.price-i.price);break;default:l.sort((i,c)=>new Date(c.created_at).getTime()-new Date(i.created_at).getTime())}return l}})},gQe=()=>{const{user:t}=Os();return mt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},yQe=t=>{const{user:s}=Os();return mt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await H.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},XLt=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},JLt=()=>{const t=Xt();return Lt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await H.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},e8t=()=>{const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},vQe=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},t8t=()=>{const t=Xt();return Lt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await H.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},s8t=()=>{const t=Xt();return Lt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},r8t=()=>{const t=Xt();return Lt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>H.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},n8t=()=>{const t=Xt();return Lt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await H.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await H.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},a8t=()=>{const{user:t}=Os();return mt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},bQe=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await H.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},_Qe=t=>{const{user:s}=Os();return mt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},i8t=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await H.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await H.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await H.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},o8t=t=>{const{user:s}=Os();return mt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await H.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},l8t=()=>{const{user:t}=Os();return Lt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await H.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},c8t=()=>{const{user:t}=Os();return mt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([H.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),H.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},d8t=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async({listingId:r,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!s)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},u8t=()=>mt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await H.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const c=s.get(i);c?c.count++:s.set(i,{name:((u=l.profiles)==null?void 0:u.name)||"Unknown",count:1})});const r=Array.from(s.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await H.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var c;const i=a.get(l.agent_id);i?i.count++:a.set(l.agent_id,{name:((c=l.agent)==null?void 0:c.name)||"Unknown",count:1})});const o=Array.from(a.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10);return{topSharers:r,topListers:o}}}),h8t=()=>{const{user:t,brokerageId:s}=Os();return mt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await H.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await H.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},wQe=({className:t,variant:s="default"})=>e.jsx(st,{variant:"outline",className:It("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",s==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",t),children:"Beta"}),m8t={coming_soon:"bg-amber-500/10 text-amber-600 border-amber-200",active:"bg-emerald-500/10 text-emerald-600 border-emerald-200",under_contract:"bg-blue-500/10 text-blue-600 border-blue-200",sold:"bg-purple-500/10 text-purple-600 border-purple-200",withdrawn:"bg-muted text-muted-foreground border-border"},p8t={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function f8t(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function x8t(){const t=nr(),{data:s,isLoading:r}=fQe(),{data:n,isLoading:a}=xQe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),c=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(wQe,{})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(dn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),e.jsx(K,{variant:"link",size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:c.map(p=>{var g,v;const f=((g=p.photos)==null?void 0:g.find(_=>_.is_primary))||((v=p.photos)==null?void 0:v[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(dn,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&e.jsx("div",{className:"absolute top-1.5 left-1.5",children:e.jsxs(st,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(st,{className:`text-[10px] px-1.5 py-0.5 ${m8t[p.status]}`,children:p8t[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:f8t(p.price)}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function jQe(t=10,s){return mt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await H.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(g=>g.user_id))||[]);let a=null;if(s){const{data:g}=await H.from("profiles").select("id").eq("brokerage_id",s);a=new Set((g==null?void 0:g.map(v=>v.id))||[])}const{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(g=>!n.has(g.user_id));a&&(i=i.filter(g=>a.has(g.user_id)));const c=i.slice(0,t),u=c.map(g=>g.user_id),{data:p}=await H.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(g=>[g.id,{name:g.name}]))||[]);return c.map(g=>({user_id:g.user_id,total_points:g.total_points,total_events_attended:g.total_events_attended,current_streak:g.current_streak,profile:f.get(g.user_id)||null}))}})}function NQe(t){return mt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function kQe(t){return mt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function SQe(t,s){return mt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await H.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await H.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(c=>c.user_id))||[]),{data:o,error:l}=await H.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(c=>!a.has(c.user_id)))||[];if(s){const{data:c}=await H.from("profiles").select("id").eq("brokerage_id",s),u=new Set((c==null?void 0:c.map(p=>p.id))||[]);i=i.filter(p=>u.has(p.user_id))}return i.length+1},enabled:!!t})}function g8t(){const{user:t,brokerageId:s,isAdmin:r}=Os();nr();const n=!!s,[a,o]=N.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=jQe(5,l()),{data:u}=NQe(t==null?void 0:t.id),{data:p}=SQe(t==null?void 0:t.id,l()),{data:f}=kQe(t==null?void 0:t.id),g=r||n,v=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),v()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(g?5:3)].map((w,j)=>e.jsx(vs,{className:"h-10 w-full"},j))})})]});const _=w=>w===0?e.jsx(vo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(g){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),v()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((j,k)=>{var S,M,L;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${j.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":k===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:_(k)}),e.jsx(kn,{className:"h-6 w-6",children:e.jsx(Sn,{className:"text-xs",children:((M=(S=j.profile)==null?void 0:S.name)==null?void 0:M.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((L=j.profile)==null?void 0:L.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:j.total_points})]},j.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(pa,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(So,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(oa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),e.jsxs("span",{className:"font-bold text-orange-500",children:[u.current_streak," 🔥"]})]}),f&&f.length>0&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(tc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(pa,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(So,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(oa,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Jn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(pa,{to:"/reward-store",className:"mt-3 inline-flex items-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[e.jsx(So,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(oa,{className:"h-4 w-4"})]})]})})]})}const mE=()=>mt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await H.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),FNe=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{data:n}=await H.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await H.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source added")},onError:r=>{me.error("Failed to add lead source"),console.error(r)}})},y8t=()=>{const t=Xt();return Lt({mutationFn:async({id:s,name:r})=>{const{error:n}=await H.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source updated")},onError:s=>{me.error(s.message||"Failed to update lead source")}})},v8t=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source removed")},onError:s=>{me.error(s.message||"Failed to remove lead source")}})},zNe=(t,s)=>{const{user:r,isAdmin:n}=Os(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},BNe=t=>{const{user:s,isAdmin:r}=Os(),n=r&&t?t:s==null?void 0:s.id;return mt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",n).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!n})},Lue=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction added")},onError:r=>{me.error("Failed to add transaction"),console.error(r)}})},b8t=()=>{const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction updated")},onError:s=>{me.error("Failed to update transaction"),console.error(s)}})},_8t=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction deleted")},onError:s=>{me.error("Failed to delete transaction"),console.error(s)}})},CQe=(t,s)=>{const{user:r,isAdmin:n}=Os(),a=n&&s?s:r==null?void 0:r.id;return mt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await H.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},w8t=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),me.success("Goals saved")},onError:r=>{me.error("Failed to save goals"),console.error(r)}})},Due=()=>{const{user:t}=Os();return mt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},j8t=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{data:n,error:a}=await H.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),me.success("Settings saved")},onError:r=>{me.error("Failed to save settings"),console.error(r)}})},MQe=(t,s)=>{const{data:r,isLoading:n}=zNe(t,s),{data:a,isLoading:o}=BNe(s),{data:l}=Due(),i=(l==null?void 0:l.show_commission)??!0,c=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(P=>P.transaction_type==="buyer").length,f=u.filter(P=>P.transaction_type==="seller").length,g=u.reduce((P,O)=>P+Number(O.sale_price),0),v=u.reduce((P,O)=>P+(Number(O.commission_amount)||0),0),_=u.reduce((P,O)=>{const $=Number(O.commission_amount)||0;if(!$)return P;let U=$;return O.brokerage_split_pct&&(U-=$*(O.brokerage_split_pct/100)),O.team_split_pct&&(U-=$*(O.team_split_pct/100)),O.franchise_fee_pct&&(U-=$*(O.franchise_fee_pct/100)),O.referral_fee_pct&&(U-=$*(O.referral_fee_pct/100)),O.transaction_fee&&(U-=O.transaction_fee),P+Math.max(0,U)},0),w={};u.forEach(P=>{var $;const O=(($=P.lead_source)==null?void 0:$.name)||"Unknown";w[O]=(w[O]||0)+1});const j=Object.entries(w).map(([P,O])=>({name:P,count:O})).sort((P,O)=>O.count-P.count),k=j[0]||null,S={};u.forEach(P=>{const O=Rl(P.close_date).toLocaleString("default",{month:"short"});S[O]=(S[O]||0)+1});const L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(P=>({month:P,count:S[P]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:g,averagePrice:u.length>0?g/u.length:0,totalCommission:i?v:0,totalNetToAgent:i?_:0,topLeadSource:k,transactionsByMonth:L,leadSourceBreakdown:j}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},N8t=()=>{const{isAdmin:t}=Os();return mt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await H.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await H.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},e_={recency:40,touchpoints:30,transactions:20},RIe={warm:70,cooling:40};function k8t(t){return t===null?0:t<=14?e_.recency:t<=30?e_.recency*.85:t<=60?e_.recency*.65:t<=90?e_.recency*.4:t<=180?e_.recency*.2:e_.recency*.05}function S8t(t){const s=Math.min(t/12,1);return Math.round(e_.touchpoints*s)}function C8t(t){return t?e_.transactions:0}function M8t(){return 0}function T8t(t){return t>=RIe.warm?"warm":t>=RIe.cooling?"cooling":"at-risk"}function Oue(){const{data:t,isLoading:s}=Wm(),{data:r}=uQe(),{data:n}=eR(365),{data:a}=BNe(),o=N.useMemo(()=>{if(!t)return[];const i=new Date,c=N4(i,12),u={};n==null||n.forEach(f=>{new Date(f.completed_at)>=c&&(u[f.contact_id]=(u[f.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(f=>f.contact_id).map(f=>f.contact_id))||[]);return t.map(f=>{const g=(r==null?void 0:r[f.id])||null,v=g?cy(i,new Date(g)):null,_=u[f.id]||0,w=p.has(f.id),j=k8t(v),k=S8t(_),S=C8t(w),M=M8t(),L=Math.round(j+k+S+M),P={score:L,status:T8t(L),breakdown:{recency:Math.round(j),touchpoints:Math.round(k),transactions:Math.round(S),referrals:Math.round(M)},lastTouchDate:g,daysSinceTouch:v,touchCountLast12Months:_,hasTransaction:w};return{...f,relationshipScore:P}})},[t,r,n,a]),l=N.useMemo(()=>{const i=o.filter(g=>g.relationshipScore.status==="warm").length,c=o.filter(g=>g.relationshipScore.status==="cooling").length,u=o.filter(g=>g.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((g,v)=>g+v.relationshipScore.score,0)/p):0;return{warm:i,cooling:c,atRisk:u,total:p,averageScore:f}},[o]);return{contactsWithScores:o,stats:l,isLoading:s}}function TQe(){const t=nr(),{stats:s,contactsWithScores:r,isLoading:n}=Oue();if(n)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(vs,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(vs,{className:"h-20 w-full"}),e.jsx(vs,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(c=>c.relationshipScore.status==="at-risk").sort((c,u)=>c.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(Bi,{value:a,className:"h-2 bg-muted [&>div]:bg-emerald-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-amber-500"}),e.jsx("span",{children:"Cooling Off"})]}),e.jsxs("span",{className:"font-medium",children:[s.cooling," (",o,"%)"]})]}),e.jsx(Bi,{value:o,className:"h-2 bg-muted [&>div]:bg-amber-500"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500"}),e.jsx("span",{children:"At Risk"})]}),e.jsxs("span",{className:"font-medium",children:[s.atRisk," (",l,"%)"]})]}),e.jsx(Bi,{value:l,className:"h-2 bg-muted [&>div]:bg-red-500"})]})]}),i.length>0&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_S,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${c.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[c.first_name," ",c.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.relationshipScore.daysSinceTouch===null?"Never":`${c.relationshipScore.daysSinceTouch}d`}),e.jsx(oa,{className:"h-3 w-3"})]})]},c.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(oa,{className:"h-4 w-4 ml-1"})]})]})]})}const A8t=()=>{var ne;const{user:t,isAdmin:s}=Os(),r=nr(),[n,a]=N.useState([]),[o,l]=N.useState([]),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState([]),[v,_]=N.useState([]),[w,j]=N.useState(new Set),[k,S]=N.useState([]),[M,L]=N.useState([]),[P,O]=N.useState([]),[$,U]=N.useState(null),[B,V]=N.useState(!0);N.useEffect(()=>{X()},[t]);const X=async()=>{var re,oe,fe,ge,ue;try{const[xe,_e,$e,Me,Ie,ke,pe,we,Le,Qe,Te]=await Promise.all([H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),H.from("app_tiles").select("*").order("name"),H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("events").select("*").order("event_date",{ascending:!0}),H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),H.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),H.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),H.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),H.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(re=Te.data)!=null&&re.name&&U(Te.data.name);const pt=((oe=xe.data)==null?void 0:oe.map(rt=>rt.tag))||[],ye=new Set(((fe=$e.data)==null?void 0:fe.map(rt=>rt.app_id))||[]);j(ye);const at=(((ge=_e.data)==null?void 0:ge.filter(rt=>!rt.required_tags||rt.required_tags.length===0?!0:rt.required_tags.some(He=>pt.includes(He))))||[]).sort((rt,He)=>rt.name==="LevelUp Members Portal"?-1:He.name==="LevelUp Members Portal"?1:0);a(at.slice(0,6));const tt=((ue=Me.data)==null?void 0:ue.filter(rt=>oT(rt.event_date)!=="ended"))||[];l(tt.slice(0,4)),S(Ie.data||[]),c(ke.data||[]),p(pe.data||[]),g(we.data||[]),_(Le.data||[]);const Ae=Qe.data||[];L(Ae.filter(rt=>rt.placement==="top")),O(Ae.filter(rt=>rt.placement==="between"))}catch(xe){console.error("Error loading dashboard:",xe),me.error("Failed to load dashboard data")}finally{V(!1)}},Y=async re=>{var fe;const oe=window.open("about:blank","_blank");try{await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:re.app_id,app_name:re.name,user_agent:navigator.userAgent});const{data:ge,error:ue}=await H.functions.invoke("sso-launch",{body:{app_id:re.app_id}});if(ue)throw ue;ge!=null&&ge.redirect_url?oe&&!oe.closed?(oe.location.href=ge.redirect_url,(fe=oe.focus)==null||fe.call(oe)):window.location.assign(ge.redirect_url):(oe==null||oe.close(),me.error("Launch link unavailable"))}catch(ge){oe==null||oe.close(),console.error("Error launching app:",ge),me.error("Failed to launch app")}},ee=re=>k==null?void 0:k.some(oe=>oe.event_id===re),Q=re=>{const oe=k==null?void 0:k.find(fe=>fe.event_id===re);return oe==null?void 0:oe.zoom_join_url};if(B)return e.jsx(Ts,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const ce=re=>P.filter(oe=>oe.section_after===re);return e.jsxs(Ts,{title:"Dashboard",children:[e.jsx(uLt,{events:o,registrations:k,onNavigateToEvents:()=>r("/events")}),M.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(iI,{banners:M})}),e.jsx(wLt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((ne=t==null?void 0:t.user_metadata)==null?void 0:ne.name)||"there").split(" ")[0],"!"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[e.jsx(RLt,{}),e.jsx(TQe,{}),e.jsx(g8t,{})]}),e.jsx(QLt,{}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(re=>{const oe=ee(re.id),fe=Q(re.id)||re.zoom_link;return e.jsxs("div",{className:`flex items-start gap-3 sm:gap-4 p-3 sm:p-4 hover:bg-muted/50 transition-colors cursor-pointer group ${IIe(re.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[IIe(re.event_date)?e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-red-500/10 flex flex-col items-center justify-center relative",children:[e.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),e.jsx(x1,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):e.jsxs("div",{className:"flex-shrink-0 w-12 h-12 sm:w-14 sm:h-14 rounded-lg bg-primary/10 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] sm:text-xs font-medium text-primary uppercase",children:new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"America/New_York"}).format(new Date(re.event_date))}),e.jsx("span",{className:"text-lg sm:text-xl font-bold text-primary",children:new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:"America/New_York"}).format(new Date(re.event_date))})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:re.title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground mt-0.5",children:[new Intl.DateTimeFormat("en-US",{weekday:"long",timeZone:"America/New_York"}).format(new Date(re.event_date))," at ",yD(new Date(re.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:oe?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:ge=>{ge.stopPropagation(),window.open(fe,"_blank")},children:[e.jsx(en,{className:"h-3.5 w-3.5"}),"Join"]}):e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Register"}),e.jsx(oa,{className:"h-4 w-4"})]})})]},re.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{banners:ce("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(re=>e.jsxs("div",{onClick:()=>r(`/academy/${re.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[re.thumbnail_url?e.jsx("img",{src:re.thumbnail_url,alt:re.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(pp,{className:"h-8 w-8 text-muted-foreground/50"})}),re.duration&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:re.duration})]}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:re.title})})]},re.id))})]}),ce("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{banners:ce("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:u.map(re=>e.jsxs("div",{onClick:()=>r(`/toolbox/${re.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:re.featured_image_url?e.jsx("img",{src:re.featured_image_url,alt:re.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Om,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:re.name})})]},re.id))})]}),ce("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{banners:ce("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G_,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(re=>e.jsxs("div",{onClick:()=>r("/templates"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:re.preview_image_url?e.jsx("img",{src:re.preview_image_url,alt:re.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(G_,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsx("div",{className:"p-3",children:e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:re.name})})]},re.id))})]}),ce("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(iI,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(x8t,{})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Sx,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(re=>{const oe=w.has(re.id);return e.jsxs("div",{onClick:()=>Y(re),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border cursor-pointer transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:re.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:re.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:re.description})]}),oe&&e.jsx(Sx,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},re.id)})})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Sa,{className:"h-4 w-4"})]})]}),v.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(fn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:v.map(re=>e.jsxs("div",{onClick:()=>window.open(re.signup_link_url,"_blank"),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:re.preview_image_url?e.jsx("img",{src:re.preview_image_url,alt:re.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(fn,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:re.name}),re.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:re.description})]})]},re.id))})]})]})};var AQe="AlertDialog",[E8t]=od(AQe,[mGe]),W1=mGe(),EQe=t=>{const{__scopeAlertDialog:s,...r}=t,n=W1(s);return e.jsx(eue,{...n,...r,modal:!0})};EQe.displayName=AQe;var P8t="AlertDialogTrigger",PQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W1(r);return e.jsx(bje,{...a,...n,ref:s})});PQe.displayName=P8t;var I8t="AlertDialogPortal",IQe=t=>{const{__scopeAlertDialog:s,...r}=t,n=W1(s);return e.jsx(tue,{...n,...r})};IQe.displayName=I8t;var L8t="AlertDialogOverlay",LQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W1(r);return e.jsx(sE,{...a,...n,ref:s})});LQe.displayName=L8t;var lT="AlertDialogContent",[D8t,O8t]=E8t(lT),R8t=Q$e("AlertDialogContent"),DQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=W1(r),l=N.useRef(null),i=Va(s,l),c=N.useRef(null);return e.jsx(INt,{contentName:lT,titleName:OQe,docsSlug:"alert-dialog",children:e.jsx(D8t,{scope:r,cancelRef:c,children:e.jsxs(rE,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Lr(a.onOpenAutoFocus,u=>{var p;u.preventDefault(),(p=c.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[e.jsx(R8t,{children:n}),e.jsx(z8t,{contentRef:l})]})})})});DQe.displayName=lT;var OQe="AlertDialogTitle",RQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W1(r);return e.jsx(qO,{...a,...n,ref:s})});RQe.displayName=OQe;var FQe="AlertDialogDescription",zQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W1(r);return e.jsx(UO,{...a,...n,ref:s})});zQe.displayName=FQe;var F8t="AlertDialogAction",BQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=W1(r);return e.jsx(VO,{...a,...n,ref:s})});BQe.displayName=F8t;var $Qe="AlertDialogCancel",qQe=N.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=O8t($Qe,r),o=W1(r),l=Va(s,a);return e.jsx(VO,{...o,...n,ref:l})});qQe.displayName=$Qe;var z8t=({contentRef:t})=>{const s=`\`${lT}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${lT}\` by passing a \`${FQe}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${lT}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return N.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},B8t=EQe,$8t=PQe,q8t=IQe,UQe=LQe,VQe=DQe,HQe=BQe,GQe=qQe,WQe=RQe,KQe=zQe;const Mc=B8t,Mm=$8t,U8t=q8t,ZQe=N.forwardRef(({className:t,...s},r)=>e.jsx(UQe,{className:It("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:r}));ZQe.displayName=UQe.displayName;const sc=N.forwardRef(({className:t,...s},r)=>e.jsxs(U8t,{children:[e.jsx(ZQe,{}),e.jsx(VQe,{ref:r,className:It("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s})]}));sc.displayName=VQe.displayName;const rc=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col space-y-2 text-center sm:text-left",t),...s});rc.displayName="AlertDialogHeader";const nc=({className:t,...s})=>e.jsx("div",{className:It("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});nc.displayName="AlertDialogFooter";const ac=N.forwardRef(({className:t,...s},r)=>e.jsx(WQe,{ref:r,className:It("text-lg font-semibold",t),...s}));ac.displayName=WQe.displayName;const ic=N.forwardRef(({className:t,...s},r)=>e.jsx(KQe,{ref:r,className:It("text-sm text-muted-foreground",t),...s}));ic.displayName=KQe.displayName;const Fl=N.forwardRef(({className:t,...s},r)=>e.jsx(HQe,{ref:r,className:It(lD(),t),...s}));Fl.displayName=HQe.displayName;const oc=N.forwardRef(({className:t,...s},r)=>e.jsx(GQe,{ref:r,className:It(lD({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));oc.displayName=GQe.displayName;const V8t=[{key:"contacts",label:"Contacts",icon:Mn,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:cS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Om,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Cn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:dn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:H_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:ia,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Mx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Th,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:ty,description:"Create and manage smart presentations"}];function H8t(){var $;const{user:t}=Os(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState({email:"",name:"",password:""}),[v,_]=N.useState("create"),[w,j]=N.useState(!1),[k,S]=N.useState(null);N.useEffect(()=>{t&&M()},[t]);const M=async()=>{if(t){a(!0);try{const{data:U,error:B}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(B)throw B;if(U&&U.length>0){const V=U.map(ee=>ee.assistant_id),{data:X}=await H.from("profiles").select("id, name, email").in("id",V),Y=U.map(ee=>{const Q=X==null?void 0:X.find(ce=>ce.id===ee.assistant_id);return{...ee,permissions:ee.permissions,assistant_profile:Q?{name:Q.name||"",email:Q.email||""}:void 0}});r(Y)}else r([])}catch(U){console.error("Error loading assistants:",U)}finally{a(!1)}}},L=async()=>{if(t){if(v==="link"){if(!f.email.trim()){me.error("Please enter the assistant's email");return}j(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{data:B,error:V}=await H.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!B){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:X}=await H.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",B.id);if(X&&X.length>0){me.error("This assistant is already assigned to you");return}const Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:B.id,role:"assistant",action:"add",agentId:t.id})}),ee=await Y.json();if(!Y.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:B.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`${B.name||B.email} linked as your assistant`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error linking assistant:",U),me.error(U.message||"Failed to link assistant")}finally{j(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){me.error("Please fill in all fields");return}if(f.password.length<6){me.error("Password must be at least 6 characters");return}j(!0);try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await B.json();if(!B.ok)throw new Error(V.error||"Failed to create assistant account");const X=V.userId||V.id;if(!X)throw new Error("No user ID returned");const Y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:X,role:"assistant",action:"add",agentId:t.id})}),ee=await Y.json();if(!Y.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:X,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error adding assistant:",U),me.error(U.message||"Failed to add assistant")}finally{j(!1)}}},P=async()=>{if(!(!u||!t))try{const{data:{session:U}}=await H.auth.getSession();if(!U)throw new Error("Not authenticated");const{error:B}=await H.from("agent_assistant_assignments").delete().eq("id",u.id);if(B)throw B;const{data:V}=await H.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),c(!1),p(null),M()}catch(U){console.error("Error removing assistant:",U),me.error(U.message||"Failed to remove assistant")}},O=async(U,B,V)=>{S(U);try{const X=s.find(Q=>Q.id===U);if(!X)return;const Y={...X.permissions,[B]:V},{error:ee}=await H.from("agent_assistant_assignments").update({permissions:Y}).eq("id",U);if(ee)throw ee;r(Q=>Q.map(ce=>ce.id===U?{...ce,permissions:Y}:ce))}catch(X){console.error("Error updating permissions:",X),me.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(gr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{_("create"),l(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(U=>{var B,V,X,Y;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(kn,{className:"h-10 w-10",children:e.jsx(Sn,{children:((V=(B=U.assistant_profile)==null?void 0:B.name)==null?void 0:V.split(" ").map(ee=>ee[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=U.assistant_profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((Y=U.assistant_profile)==null?void 0:Y.email)||""})]}),e.jsxs(st,{variant:"secondary",className:"ml-2",children:[e.jsx(Au,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(U),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Permissions"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:V8t.map(ee=>{const Q=ee.icon;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:ee.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ee.description})]})]}),e.jsx(qr,{checked:U.permissions[ee.key]||!1,onCheckedChange:ce=>O(U.id,ee.key,ce),disabled:k===U.id})]},ee.key)})})]})]},U.id)})})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add Assistant"}),e.jsx(Wr,{children:v==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(K,{variant:v==="create"?"default":"outline",size:"sm",onClick:()=>_("create"),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:v==="link"?"default":"outline",size:"sm",onClick:()=>_("link"),children:[e.jsx(Bo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[v==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-name",children:"Name"}),e.jsx(ze,{id:"assistant-name",value:f.name,onChange:U=>g({...f,name:U.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-email",children:"Email"}),e.jsx(ze,{id:"assistant-email",type:"email",value:f.email,onChange:U=>g({...f,email:U.target.value}),placeholder:"assistant@email.com"})]}),v==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(ze,{id:"assistant-password",type:"password",value:f.password,onChange:U=>g({...f,password:U.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:L,disabled:w,children:[w&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),v==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(Mc,{open:i,onOpenChange:c,children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Remove Assistant?"}),e.jsxs(ic,{children:["This will remove ",($=u==null?void 0:u.assistant_profile)==null?void 0:$.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function bh(t){this.content=t}bh.prototype={constructor:bh,find:function(t){for(var s=0;s>1}};bh.from=function(t){if(t instanceof bh)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new bh(s)};function YQe(t,s,r){for(let n=0;;n++){if(n==t.childCount||n==s.childCount)return t.childCount==s.childCount?null:r;let a=t.child(n),o=s.child(n);if(a==o){r+=a.nodeSize;continue}if(!a.sameMarkup(o))return r;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)r++;return r}if(a.content.size||o.content.size){let l=YQe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function QQe(t,s,r,n){for(let a=t.childCount,o=s.childCount;;){if(a==0||o==0)return a==o?null:{a:r,b:n};let l=t.child(--a),i=s.child(--o),c=l.nodeSize;if(l==i){r-=c,n-=c;continue}if(!l.sameMarkup(i))return{a:r,b:n};if(l.isText&&l.text!=i.text){let u=0,p=Math.min(l.text.length,i.text.length);for(;us&&n(c,a+i,o||null,l)!==!1&&c.content.size){let p=i+1;c.nodesBetween(Math.max(0,s-p),Math.min(c.content.size,r-p),n,a+p)}i=u}}descendants(s){this.nodesBetween(0,this.size,s)}textBetween(s,r,n,a){let o="",l=!0;return this.nodesBetween(s,r,(i,c)=>{let u=i.isText?i.text.slice(Math.max(s,c)-c,r-c):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&u||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=u},0),o}append(s){if(!s.size)return this;if(!this.size)return s;let r=this.lastChild,n=s.firstChild,a=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(a[a.length-1]=r.withText(r.text+n.text),o=1);os)for(let o=0,l=0;ls&&((lr)&&(i.isText?i=i.cut(Math.max(0,s-l),Math.min(i.text.length,r-l)):i=i.cut(Math.max(0,s-l-1),Math.min(i.content.size,r-l-1))),n.push(i),a+=i.nodeSize),l=c}return new Or(n,a)}cutByIndex(s,r){return s==r?Or.empty:s==0&&r==this.content.length?this:new Or(this.content.slice(s,r))}replaceChild(s,r){let n=this.content[s];if(n==r)return this;let a=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return a[s]=r,new Or(a,o)}addToStart(s){return new Or([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Or(this.content.concat(s),this.size+s.nodeSize)}eq(s){if(this.content.length!=s.content.length)return!1;for(let r=0;rthis.size||s<0)throw new RangeError(`Position ${s} outside of fragment (${this})`);for(let r=0,n=0;;r++){let a=this.child(r),o=n+a.nodeSize;if(o>=s)return o==s?_z(r+1,o):_z(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(s=>s.toJSON()):null}static fromJSON(s,r){if(!r)return Or.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Or(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Or.empty;let r,n=0;for(let a=0;athis.type.rank&&(r||(r=s.slice(0,a)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=s.slice()),n||r.push(this),r}removeFromSet(s){for(let r=0;rn.type.rank-a.type.rank),r}};Dl.none=[];class lle extends Error{}class Nn{constructor(s,r,n){this.content=s,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(s,r){let n=JQe(this.content,s+this.openStart,r);return n&&new Nn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new Nn(XQe(this.content,s+this.openStart,r+this.openStart),this.openStart,this.openEnd)}eq(s){return this.content.eq(s.content)&&this.openStart==s.openStart&&this.openEnd==s.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let s={content:this.content.toJSON()};return this.openStart>0&&(s.openStart=this.openStart),this.openEnd>0&&(s.openEnd=this.openEnd),s}static fromJSON(s,r){if(!r)return Nn.empty;let n=r.openStart||0,a=r.openEnd||0;if(typeof n!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Nn(Or.fromJSON(s,r.content),n,a)}static maxOpen(s,r=!0){let n=0,a=0;for(let o=s.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=s.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)a++;return new Nn(s,n,a)}}Nn.empty=new Nn(Or.empty,0,0);function XQe(t,s,r){let{index:n,offset:a}=t.findIndex(s),o=t.maybeChild(n),{index:l,offset:i}=t.findIndex(r);if(a==s||o.isText){if(i!=r&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,s).append(t.cut(r))}if(n!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(n,o.copy(XQe(o.content,s-a-1,r-a-1)))}function JQe(t,s,r,n){let{index:a,offset:o}=t.findIndex(s),l=t.maybeChild(a);if(o==s||l.isText)return n&&!n.canReplace(a,a,r)?null:t.cut(0,s).append(r).append(t.cut(s));let i=JQe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function G8t(t,s,r){if(r.openStart>t.depth)throw new lle("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new lle("Inconsistent open depths");return eXe(t,s,r,0)}function eXe(t,s,r,n){let a=t.index(n),o=t.node(n);if(a==s.index(n)&&n=0&&t.isText&&t.sameMarkup(s[r])?s[r]=t.withText(s[r].text+t.text):s.push(t)}function u8(t,s,r,n){let a=(s||t).node(r),o=0,l=s?s.index(r):a.childCount;t&&(o=t.index(r),t.depth>r?o++:t.textOffset&&(SS(t.nodeAfter,n),o++));for(let i=o;ia&&P1e(t,s,a+1),l=n.depth>a&&P1e(r,n,a+1),i=[];return u8(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(tXe(o,l),SS(CS(o,sXe(t,s,r,n,a+1)),i)):(o&&SS(CS(o,cle(t,s,a+1)),i),u8(s,r,a,i),l&&SS(CS(l,cle(r,n,a+1)),i)),u8(n,null,a,i),new Or(i)}function cle(t,s,r){let n=[];if(u8(null,t,r,n),t.depth>r){let a=P1e(t,s,r+1);SS(CS(a,cle(t,s,r+1)),n)}return u8(s,null,r,n),new Or(n)}function W8t(t,s){let r=s.depth-t.openStart,a=s.node(r).copy(t.content);for(let o=r-1;o>=0;o--)a=s.node(o).copy(Or.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class vD{constructor(s,r,n){this.pos=s,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(s){return s==null?this.depth:s<0?this.depth+s:s}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(s){return this.path[this.resolveDepth(s)*3]}index(s){return this.path[this.resolveDepth(s)*3+1]}indexAfter(s){return s=this.resolveDepth(s),this.index(s)+(s==this.depth&&!this.textOffset?0:1)}start(s){return s=this.resolveDepth(s),s==0?0:this.path[s*3-1]+1}end(s){return s=this.resolveDepth(s),this.start(s)+this.node(s).content.size}before(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position before the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]}after(s){if(s=this.resolveDepth(s),!s)throw new RangeError("There is no position after the top-level node");return s==this.depth+1?this.pos:this.path[s*3-1]+this.path[s*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let s=this.parent,r=this.index(this.depth);if(r==s.childCount)return null;let n=this.pos-this.path[this.path.length-1],a=s.child(r);return n?s.child(r).cut(n):a}get nodeBefore(){let s=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(s).cut(0,r):s==0?null:this.parent.child(s-1)}posAtIndex(s,r){r=this.resolveDepth(r);let n=this.path[r*3],a=r==0?0:this.path[r*3-1]+1;for(let o=0;o0;r--)if(this.start(r)<=s&&this.end(r)>=s)return r;return 0}blockRange(s=this,r){if(s.pos=0;n--)if(s.pos<=this.end(n)&&(!r||r(this.node(n))))return new dle(this,s,n);return null}sameParent(s){return this.pos-this.parentOffset==s.pos-s.parentOffset}max(s){return s.pos>this.pos?s:this}min(s){return s.pos=0&&r<=s.content.size))throw new RangeError("Position "+r+" out of range");let n=[],a=0,o=r;for(let l=s;;){let{index:i,offset:c}=l.content.findIndex(o),u=o-c;if(n.push(l,i,a+c),!u||(l=l.child(i),l.isText))break;o=u-1,a+=c+1}return new vD(r,n,o)}static resolveCached(s,r){let n=FIe.get(s);if(n)for(let o=0;os&&this.nodesBetween(s,r,o=>(n.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let s=this.type.name;return this.content.size&&(s+="("+this.content.toStringInner()+")"),rXe(this.marks,s)}contentMatchAt(s){let r=this.type.contentMatch.matchFragment(this.content,0,s);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(s,r,n=Or.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let c=a;cr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let s={type:this.type.name};for(let r in this.attrs){s.attrs=this.attrs;break}return this.content.size&&(s.content=this.content.toJSON()),this.marks.length&&(s.marks=this.marks.map(r=>r.toJSON())),s}static fromJSON(s,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(s.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return s.text(r.text,n)}let a=Or.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};nw.prototype.text=void 0;class ule extends nw{constructor(s,r,n,a){if(super(s,r,null,a),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rXe(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(s,r){return this.text.slice(s,r)}get nodeSize(){return this.text.length}mark(s){return s==this.marks?this:new ule(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new ule(this.type,this.attrs,s,this.marks)}cut(s=0,r=this.text.length){return s==0&&r==this.text.length?this:this.withText(this.text.slice(s,r))}eq(s){return this.sameMarkup(s)&&this.text==s.text}toJSON(){let s=super.toJSON();return s.text=this.text,s}}function rXe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class JS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new Q8t(s,r);if(n.next==null)return JS.empty;let a=nXe(n);n.next&&n.err("Unexpected trailing text");let o=nDt(rDt(a));return aDt(o,n),o}matchType(s){for(let r=0;ru.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${s}th edge in this content match`);return this.next[s]}toString(){let s=[];function r(n){s.push(n);for(let a=0;a{let o=a+(n.validEnd?"*":" ")+" ";for(let l=0;l"+s.indexOf(n.next[l].next);return o}).join(` `)}}JS.empty=new JS(!0);class Q8t{constructor(s,r){this.string=s,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=s.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(s){return this.next==s&&(this.pos++||!0)}err(s){throw new SyntaxError(s+" (in content expression '"+this.string+"')")}}function nXe(t){let s=[];do s.push(X8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function X8t(t){let s=[];do s.push(J8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function J8t(t){let s=sDt(t);for(;;)if(t.eat("+"))s={type:"plus",expr:s};else if(t.eat("*"))s={type:"star",expr:s};else if(t.eat("?"))s={type:"opt",expr:s};else if(t.eat("{"))s=eDt(t,s);else break;return s}function zIe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function eDt(t,s){let r=zIe(t),n=r;return t.eat(",")&&(t.next!="}"?n=zIe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function tDt(t,s){let r=t.nodeTypes,n=r[s];if(n)return[n];let a=[];for(let o in r){let l=r[o];l.isInGroup(s)&&a.push(l)}return a.length==0&&t.err("No node type or group '"+s+"' found"),a}function sDt(t){if(t.eat("(")){let s=nXe(t);return t.eat(")")||t.err("Missing closing paren"),s}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let s=tDt(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,s.length==1?s[0]:{type:"choice",exprs:s}}}function rDt(t){let s=[[]];return a(o(t,0),r()),s;function r(){return s.push([])-1}function n(l,i,c){let u={term:c,to:i};return s[l].push(u),u}function a(l,i){l.forEach(c=>c.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((c,u)=>c.concat(o(u,i)),[]);if(l.type=="seq")for(let c=0;;c++){let u=o(l.exprs[c],i);if(c==l.exprs.length-1)return u;a(u,i=r())}else if(l.type=="star"){let c=r();return n(i,c),a(o(l.expr,c),c),[n(c)]}else if(l.type=="plus"){let c=r();return a(o(l.expr,i),c),a(o(l.expr,c),c),[n(c)]}else{if(l.type=="opt")return[n(i)].concat(o(l.expr,i));if(l.type=="range"){let c=i;for(let u=0;u{t[l].forEach(({term:i,to:c})=>{if(!i)return;let u;for(let p=0;p{u||a.push([i,u=[]]),u.indexOf(p)==-1&&u.push(p)})})});let o=s[n.join(",")]=new JS(n.indexOf(t.length-1)>-1);for(let l=0;l-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let s in this.attrs)if(this.attrs[s].isRequired)return!0;return!1}compatibleContent(s){return this==s||this.contentMatch.compatible(s.contentMatch)}computeAttrs(s){return!s&&this.defaultAttrs?this.defaultAttrs:oXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nw(this,this.computeAttrs(s),Or.from(r),Dl.setFrom(n))}createChecked(s=null,r,n){return r=Or.from(r),this.checkContent(r),new nw(this,this.computeAttrs(s),r,Dl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Or.from(r),r.size){let l=this.contentMatch.fillBefore(r);if(!l)return null;r=l.append(r)}let a=this.contentMatch.matchFragment(r),o=a&&a.fillBefore(Or.empty,!0);return o?new nw(this,s,r.append(o),Dl.setFrom(n)):null}validContent(s){let r=this.contentMatch.matchFragment(s);if(!r||!r.validEnd)return!1;for(let n=0;n-1}allowsMarks(s){if(this.markSet==null)return!0;for(let r=0;rn[o]=new dXe(o,r,l));let a=r.spec.topNode||"doc";if(!n[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function iDt(t,s,r){let n=r.split("|");return a=>{let o=a===null?"null":typeof a;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${s} on type ${t}, got ${o}`)}}class oDt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?iDt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Rue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=cXe(s,a.attrs),this.excluded=null;let o=iXe(this.attrs);this.instance=o?new Dl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new Dl(this,oXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new Rue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class uXe{constructor(s){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let a in s)r[a]=s[a];r.nodes=bh.from(s.nodes),r.marks=bh.from(s.marks||{}),this.nodes=$Ie.compile(this.spec.nodes,this),this.marks=Rue.compile(this.spec.marks,this);let n=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let o=this.nodes[a],l=o.spec.content||"",i=o.spec.marks;if(o.contentMatch=n[l]||(n[l]=JS.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=i=="_"?null:i?qIe(this,i.split(" ")):i==""||!o.inlineContent?[]:null}for(let a in this.marks){let o=this.marks[a],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:qIe(this,l.split(" "))}this.nodeFromJSON=a=>nw.fromJSON(this,a),this.markFromJSON=a=>Dl.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(s,r=null,n,a){if(typeof s=="string")s=this.nodeType(s);else if(s instanceof $Ie){if(s.schema!=this)throw new RangeError("Node type from different schema used ("+s.name+")")}else throw new RangeError("Invalid node type: "+s);return s.createChecked(r,n,a)}text(s,r){let n=this.nodes.text;return new ule(n,n.defaultAttrs,s,Dl.setFrom(r))}mark(s,r){return typeof s=="string"&&(s=this.marks[s]),s.create(r)}nodeType(s){let r=this.nodes[s];if(!r)throw new RangeError("Unknown node type: "+s);return r}}function qIe(t,s){let r=[];for(let n=0;n-1)&&r.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+s[n]+"'")}return r}function lDt(t){return t.tag!=null}function cDt(t){return t.style!=null}let h8=class L1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(lDt(a))this.tags.push(a);else if(cDt(a)){let o=/[^=]*/.exec(a.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=s.nodes[a.node];return o.contentMatch.matchType(o)})}parse(s,r={}){let n=new VIe(this,r,!1);return n.addAll(s,Dl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new VIe(this,r,!0);return n.addAll(s,Dl.none,r.from,r.to),Nn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let c=l.getAttrs(r);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=HIe(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in s.nodes){let o=s.nodes[a].spec.parseDOM;o&&o.forEach(l=>{n(l=HIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new L1e(s,L1e.schemaRules(s)))}};const hXe={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},dDt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},mXe={ol:!0,ul:!0},bD=1,D1e=2,m8=4;function UIe(t,s,r){return s!=null?(s?bD:0)|(s==="full"?D1e:0):t&&t.whitespace=="pre"?bD|D1e:r&~m8}class wz{constructor(s,r,n,a,o,l){this.type=s,this.attrs=r,this.marks=n,this.solid=a,this.options=l,this.content=[],this.activeMarks=Dl.none,this.match=o||(l&m8?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Or.from(s));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(s.type))?(this.match=n,a):null}}return this.match.findWrapping(s.type)}finish(s){if(!(this.options&bD)){let n=this.content[this.content.length-1],a;if(n&&n.isText&&(a=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let r=Or.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Or.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(s){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:s.parentNode&&!hXe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class VIe{constructor(s,r,n){this.parser=s,this.options=r,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let a=r.topNode,o,l=UIe(null,r.preserveWhitespace,0)|(n?m8:0);a?o=new wz(a.type,a.attrs,Dl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new wz(null,null,Dl.none,!0,null,l):o=new wz(s.schema.topNodeType,null,Dl.none,!0,null,l),this.nodes=[o],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(s,r){s.nodeType==3?this.addTextNode(s,r):s.nodeType==1&&this.addElement(s,r)}addTextNode(s,r){let n=s.nodeValue,a=this.top,o=a.options&D1e?"full":this.localPreserveWS||(a.options&bD)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(s)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(l.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(l.linebreakReplacement.create())){let i=n.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(u)):r=r.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)i=c;else break}}return r}addElementByRule(s,r,n,a){let o,l;if(r.node)if(l=this.parser.schema.nodes[r.node],l.isLeaf)this.insertNode(l.create(r.attrs),n,s.nodeName=="BR")||this.leafFallback(s,n);else{let c=this.enter(l,r.attrs||null,n,r.preserveWhitespace);c&&(o=!0,n=c)}else{let c=this.parser.schema.marks[r.mark];n=n.concat(c.create(r.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(s);else if(a)this.addElement(s,n,a);else if(r.getContent)this.findInside(s),r.getContent(s,this.parser.schema).forEach(c=>this.insertNode(c,n,!1));else{let c=s;typeof r.contentElement=="string"?c=s.querySelector(r.contentElement):typeof r.contentElement=="function"?c=r.contentElement(s):r.contentElement&&(c=r.contentElement),this.findAround(s,c,!0),this.addAll(c,n),this.findAround(s,c,!1)}o&&this.sync(i)&&this.open--}addAll(s,r,n,a){let o=n||0;for(let l=n?s.childNodes[n]:s.firstChild,i=a==null?null:s.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(s,o),this.addDOM(l,r);this.findAtPoint(s,o)}findPlace(s,r,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let c=this.nodes[l],u=c.findWrapping(s);if(u&&(!a||a.length>u.length+i)&&(a=u,o=c,!u.length))break;if(c.solid){if(n)break;i+=2}}if(!a)return null;this.sync(o);for(let l=0;l(l.type?l.type.allowsMarkType(u.type):GIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new wz(s,r,c,a,null,i)),this.open++,n}closeExtra(s=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(s));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(s){for(let r=this.open;r>=0;r--){if(this.nodes[r]==s)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=bD)}return!1}get currentPos(){this.closeExtra();let s=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let a=n.length-1;a>=0;a--)s+=n[a].nodeSize;r&&s++}return s}findAtPoint(s,r){if(this.find)for(let n=0;n-1)return s.split(/\s*\|\s*/).some(this.matchesContext,this);let r=s.split("/"),n=this.options.context,a=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(a?0:1),l=(i,c)=>{for(;i>=0;i--){let u=r[i];if(u==""){if(i==r.length-1||i==0)continue;for(;c>=o;c--)if(l(i-1,c))return!0;return!1}else{let p=c>0||c==0&&a?this.nodes[c].type:n&&c>=o?n.node(c-o).type:null;if(!p||p.name!=u&&!p.isInGroup(u))return!1;c--}}return!0};return l(r.length-1,this.open)}textblockFromContext(){let s=this.options.context;if(s)for(let r=s.depth;r>=0;r--){let n=s.node(r).contentMatchAt(s.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function uDt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&mXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function hDt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function HIe(t){let s={};for(let r in t)s[r]=t[r];return s}function GIe(t,s){let r=s.schema.nodes;for(let n in r){let a=r[n];if(!a.allowsMarkType(t))continue;let o=[],l=i=>{o.push(i);for(let c=0;c{if(o.length||l.marks.length){let i=0,c=0;for(;i=0;a--){let o=this.serializeMark(s.marks[a],s.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(s,r,n={}){let a=this.marks[s.type.name];return a&&Die(dge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return Die(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new C3(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=WIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return WIe(s.marks)}}function WIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function dge(t){return t.document||window.document}const KIe=new WeakMap;function mDt(t){let s=KIe.get(t);return s===void 0&&KIe.set(t,s=pDt(t)),s}function pDt(t){let s=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")s||(s=[]),s.push(n);else for(let a=0;a-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(r=a.slice(0,l),a=a.slice(l+1));let i,c=r?t.createElementNS(r,a):t.createElement(a),u=s[1],p=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){p=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=p;fp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:v,contentDOM:_}=Die(t,g,r,n);if(c.appendChild(v),_){if(i)throw new RangeError("Multiple content holes");i=_}}}return{dom:c,contentDOM:i}}const pXe=65535,fXe=Math.pow(2,16);function fDt(t,s){return t+s*fXe}function ZIe(t){return t&pXe}function xDt(t){return(t-(t&pXe))/fXe}const xXe=1,gXe=2,Oie=4,yXe=8;class O1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&yXe)>0}get deletedBefore(){return(this.delInfo&(xXe|Oie))>0}get deletedAfter(){return(this.delInfo&(gXe|Oie))>0}get deletedAcross(){return(this.delInfo&Oie)>0}}class cf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&cf.empty)return cf.empty}recover(s){let r=0,n=ZIe(s);if(!this.inverted)for(let a=0;as)break;let u=this.ranges[i+o],p=this.ranges[i+l],f=c+u;if(s<=f){let g=u?s==c?-1:s==f?1:r:r,v=c+a+(g<0?0:p);if(n)return v;let _=s==(r<0?c:f)?null:fDt(i/3,s-c),w=s==c?gXe:s==f?xXe:Oie;return(r<0?s!=c:s!=f)&&(w|=yXe),new O1e(v,w,_)}a+=p-u}return n?s+a:new O1e(s+a,0,null)}touches(s,r){let n=0,a=ZIe(r),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;is)break;let u=this.ranges[i+o],p=c+u;if(s<=p&&i==a*3)return!0;n+=this.ranges[i+l]-u}return!1}forEach(s){let r=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;r--){let a=s.getMirror(r);this.appendMap(s._maps[r].invert(),a!=null&&a>r?n-a-1:void 0)}}invert(){let s=new _D;return s.appendMappingInverted(this),s}map(s,r=1){if(this.mirror)return this._map(s,r,!0);for(let n=this.from;no&&c!l.isAtom||!i.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,o)}invert(){return new d0(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new P_(r.pos,n.pos,this.mark)}merge(s){return s instanceof P_&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new P_(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new P_(r.from,r.to,s.markFromJSON(r.mark))}}tm.jsonID("addMark",P_);class d0 extends tm{constructor(s,r,n){super(),this.from=s,this.to=r,this.mark=n}apply(s){let r=s.slice(this.from,this.to),n=new Nn($Ne(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return eu.fromReplace(s,this.from,this.to,n)}invert(){return new P_(this.from,this.to,this.mark)}map(s){let r=s.mapResult(this.from,1),n=s.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new d0(r.pos,n.pos,this.mark)}merge(s){return s instanceof d0&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new d0(Math.min(this.from,s.from),Math.max(this.to,s.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new d0(r.from,r.to,s.markFromJSON(r.mark))}}tm.jsonID("removeMark",d0);class I_ extends tm{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return eu.fromReplace(s,this.pos,this.pos+1,new Nn(Or.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new ah(r.pos,n.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let s={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(s.slice=this.slice.toJSON()),this.structure&&(s.structure=!0),s}static fromJSON(s,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ah(r.from,r.to,r.gapFrom,r.gapTo,Nn.fromJSON(s,r.slice),r.insert,!!r.structure)}}tm.jsonID("replaceAround",ah);function R1e(t,s,r){let n=t.resolve(s),a=r-s,o=n.depth;for(;a>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,a--;if(a>0){let l=n.node(o).maybeChild(n.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function gDt(t,s,r,n){let a=[],o=[],l,i;t.doc.nodesBetween(s,r,(c,u,p)=>{if(!c.isInline)return;let f=c.marks;if(!n.isInSet(f)&&p.type.allowsMarkType(n.type)){let g=Math.max(u,s),v=Math.min(u+c.nodeSize,r),_=n.addToSet(f);for(let w=0;wt.step(c)),o.forEach(c=>t.step(c))}function yDt(t,s,r,n){let a=[],o=0;t.doc.nodesBetween(s,r,(l,i)=>{if(!l.isInline)return;o++;let c=null;if(n instanceof Rue){let u=l.marks,p;for(;p=n.isInSet(u);)(c||(c=[])).push(p),u=p.removeFromSet(u)}else n?n.isInSet(l.marks)&&(c=[n]):c=l.marks;if(c&&c.length){let u=Math.min(i+l.nodeSize,r);for(let p=0;pt.step(new d0(l.from,l.to,l.style)))}function qNe(t,s,r,n=r.contentMatch,a=!0){let o=t.doc.nodeAt(s),l=[],i=s+1;for(let c=0;c=0;c--)t.step(l[c])}function vDt(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function pE(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,a=0,o=0;;--n){let l=t.$from.node(n),i=t.$from.index(n)+a,c=t.$to.indexAfter(n)-o;if(nr;_--)w||n.index(_)>0?(w=!0,p=Or.from(n.node(_).copy(p)),f++):c--;let g=Or.empty,v=0;for(let _=o,w=!1;_>r;_--)w||a.after(_+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Or.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new ah(a,o,a,o,new Nn(n,0,0),r.length,!0))}function NDt(t,s,r,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(s,r,(l,i)=>{let c=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,c)&&kDt(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let v=n.whitespace=="pre",_=!!n.contentMatch.matchType(n.schema.linebreakReplacement);v&&!_?u=!1:!v&&_&&(u=!0)}u===!1&&bXe(t,l,i,o),qNe(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),g=p.map(i+l.nodeSize,1);return t.step(new ah(f,g,f+1,g-1,new Nn(Or.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&vXe(t,l,i,o),!1}})}function vXe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let c=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(c,c+1,s.type.schema.linebreakReplacement.create())}}})}function bXe(t,s,r,n){s.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=t.mapping.slice(n).map(r+1+o);t.replaceWith(l,l+1,s.type.schema.text(` `))}})}function kDt(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function SDt(t,s,r,n,a){let o=t.doc.nodeAt(s);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let l=r.create(n,null,a||o.marks);if(o.isLeaf)return t.replaceWith(s,s+o.nodeSize,l);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new ah(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new Nn(Or.from(l),0,0),1,!0))}function b1(t,s,r=1,n){let a=t.resolve(s),o=a.depth-r,l=n&&n[n.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let u=a.depth-1,p=r-2;u>o;u--,p--){let f=a.node(u),g=a.index(u);if(f.type.spec.isolating)return!1;let v=f.content.cutByIndex(g,f.childCount),_=n&&n[p+1];_&&(v=v.replaceChild(0,_.type.create(_.attrs)));let w=n&&n[p]||f;if(!f.canReplace(g+1,f.childCount)||!w.type.validContent(v))return!1}let i=a.indexAfter(o),c=n&&n[0];return a.node(o).canReplaceWith(i,i,c?c.type:a.node(o+1).type)}function CDt(t,s,r=1,n){let a=t.doc.resolve(s),o=Or.empty,l=Or.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Or.from(a.node(i).copy(o));let p=n&&n[u];l=Or.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Qu(s,s,new Nn(o.append(l),r,r),!0))}function Bw(t,s){let r=t.resolve(s),n=r.index();return _Xe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function MDt(t,s){s.content.size||t.type.compatibleContent(s.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let a=0;a0?(o=n.node(a+1),i++,l=n.node(a).maybeChild(i)):(o=n.node(a).maybeChild(i-1),l=n.node(a+1)),o&&!o.isTextblock&&_Xe(o,l)&&n.node(a).canReplace(i,i+1))return s;if(a==0)break;s=r<0?n.before(a):n.after(a)}}function TDt(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);bXe(t,p.node(),p.before(),i)}l.inlineContent&&qNe(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let c=t.mapping.slice(i),u=c.map(s-r);if(t.step(new Qu(u,c.map(s+r,-1),Nn.empty,!0)),n===!0){let p=t.doc.resolve(u);vXe(t,p.node(),p.before(),t.steps.length)}return t}function ADt(t,s,r){let n=t.resolve(s);if(n.parent.canReplaceWith(n.index(),n.index(),r))return s;if(n.parentOffset==0)for(let a=n.depth-1;a>=0;a--){let o=n.index(a);if(n.node(a).canReplaceWith(o,o,r))return n.before(a+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let a=n.depth-1;a>=0;a--){let o=n.indexAfter(a);if(n.node(a).canReplaceWith(o,o,r))return n.after(a+1);if(o=0;l--){let i=l==n.depth?0:n.pos<=(n.start(l+1)+n.end(l+1))/2?-1:1,c=n.index(l)+(i>0?1:0),u=n.node(l),p=!1;if(o==1)p=u.canReplace(c,c,a);else{let f=u.contentMatchAt(c).findWrapping(a.firstChild.type);p=f&&u.canReplaceWith(c,c,f[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function zue(t,s,r=s,n=Nn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return jXe(a,o,n)?new Qu(s,r,n):new EDt(a,o,n).fit()}function jXe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class EDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Or.empty;for(let a=0;a<=s.depth;a++){let o=s.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(s.indexAfter(a))})}for(let a=s.depth;a>0;a--)this.placed=Or.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let c=new Nn(o,l,i);return s>-1?new ah(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Qu(n.pos,a.pos,c):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=hge(this.unplaced.content,n-1).firstChild,a=o.content):a=this.unplaced.content;let l=a.firstChild;for(let i=this.depth;i>=0;i--){let{type:c,match:u}=this.frontier[i],p,f=null;if(r==1&&(l?u.matchType(l.type)||(f=u.fillBefore(Or.from(l),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:f};if(r==2&&l&&(p=u.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&u.matchType(o.type))break}}}openMore(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=hge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new Nn(s,r+1,Math.max(n,a.size+r>=s.size-n?r+1:0)),!0)}dropNode(){let{content:s,openStart:r,openEnd:n}=this.unplaced,a=hge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new Nn(OI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new Nn(OI(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||c==0||w.content.size)&&(f=j,p.push(NXe(w.mark(g.allowedMarks(w.marks)),u==1?c:0,u==i.childCount?v:-1)))}let _=u==i.childCount;_||(v=-1),this.placed=RI(this.placed,r,Or.from(p)),this.frontier[r].match=f,_&&v<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=i;w1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:c,type:u}=this.frontier[i],p=mge(s,i,u,c,!0);if(!p||p.childCount)continue e}return{depth:r,fit:l,move:o?s.doc.resolve(s.after(r+1)):s}}}}close(s){let r=this.findCloseLevel(s);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=RI(this.placed,r.depth,r.fit)),s=r.move;for(let n=r.depth+1;n<=s.depth;n++){let a=s.node(n),o=a.type.contentMatch.fillBefore(a.content,!0,s.index(n));this.openFrontierNode(a.type,a.attrs,o)}return s}openFrontierNode(s,r=null,n){let a=this.frontier[this.depth];a.match=a.match.matchType(s),this.placed=RI(this.placed,this.depth,Or.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Or.empty,!0);r.childCount&&(this.placed=RI(this.placed,this.frontier.length,r))}}function OI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(OI(t.firstChild.content,s-1,r)))}function RI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(RI(t.lastChild.content,s-1,r)))}function hge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,NXe(n.firstChild,s-1,n.childCount==1?r-1:0))),s>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Or.empty,!0)))),t.copy(n)}function mge(t,s,r,n,a){let o=t.node(s),l=a?t.indexAfter(s):t.index(s);if(l==o.childCount&&!r.compatibleContent(o.type))return null;let i=n.fillBefore(o.content,!0,l);return i&&!PDt(r,o.content,l)?i:null}function PDt(t,s,r){for(let n=r;n0;g--,v--){let _=a.node(g).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(g)>-1?i=g:a.before(g)==v&&l.splice(1,0,-g)}let c=l.indexOf(i),u=[],p=n.openStart;for(let g=n.content,v=0;;v++){let _=g.firstChild;if(u.push(_),v==n.openStart)break;g=_.content}for(let g=p-1;g>=0;g--){let v=u[g],_=IDt(v.type);if(_&&!v.sameMarkup(a.node(Math.abs(i)-1)))p=g;else if(_||!v.type.isTextblock)break}for(let g=n.openStart;g>=0;g--){let v=(g+p+1)%(n.openStart+1),_=u[v];if(_)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>f));g--){let v=l[g];v<0||(s=a.before(v),r=o.after(v))}}function kXe(t,s,r,n,a){if(sn){let o=a.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(Or.empty,!0))}return t}function DDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=ADt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new Nn(Or.from(n),0,0))}function ODt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=SXe(n,a);for(let l=0;l0&&(c||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return t.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(s-n.start(l)==n.depth-l&&r>n.end(l)&&a.end(l)-r!=a.depth-l&&n.start(l-1)==a.start(l-1)&&n.node(l-1).canReplace(n.index(l-1),a.index(l-1)))return t.delete(n.before(l),r);t.delete(s,r)}function SXe(t,s){let r=[],n=Math.min(t.depth,s.depth);for(let a=n;a>=0;a--){let o=t.start(a);if(os.pos+(s.depth-a)||t.node(a).type.spec.isolating||s.node(a).type.spec.isolating)break;(o==s.start(a)||a==t.depth&&a==s.depth&&t.parent.inlineContent&&s.parent.inlineContent&&a&&s.start(a-1)==o-1)&&r.push(a)}return r}class cT extends tm{constructor(s,r,n){super(),this.pos=s,this.attr=r,this.value=n}apply(s){let r=s.nodeAt(this.pos);if(!r)return eu.fail("No node at attribute step's position");let n=Object.create(null);for(let o in r.attrs)n[o]=r.attrs[o];n[this.attr]=this.value;let a=r.type.create(n,null,r.marks);return eu.fromReplace(s,this.pos,this.pos+1,new Nn(Or.from(a),0,r.isLeaf?0:1))}getMap(){return cf.empty}invert(s){return new cT(this.pos,this.attr,s.nodeAt(this.pos).attrs[this.attr])}map(s){let r=s.mapResult(this.pos,1);return r.deletedAfter?null:new cT(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new cT(r.pos,r.attr,r.value)}}tm.jsonID("attr",cT);class wD extends tm{constructor(s,r){super(),this.attr=s,this.value=r}apply(s){let r=Object.create(null);for(let a in s.attrs)r[a]=s.attrs[a];r[this.attr]=this.value;let n=s.type.create(r,s.content,s.marks);return eu.ok(n)}getMap(){return cf.empty}invert(s){return new wD(this.attr,s.attrs[this.attr])}map(s){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(s,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new wD(r.attr,r.value)}}tm.jsonID("docAttr",wD);let JT=class extends Error{};JT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};JT.prototype=Object.create(Error.prototype);JT.prototype.constructor=JT;JT.prototype.name="TransformError";class VNe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new _D}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new JT(r.failed);return this}maybeStep(s){let r=s.apply(this.doc);return r.failed||this.addStep(s,r.doc),r}get docChanged(){return this.steps.length>0}addStep(s,r){this.docs.push(this.doc),this.steps.push(s),this.mapping.appendMap(s.getMap()),this.doc=r}replace(s,r=s,n=Nn.empty){let a=zue(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new Nn(Or.from(n),0,0))}delete(s,r){return this.replace(s,r,Nn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return LDt(this,s,r,n),this}replaceRangeWith(s,r,n){return DDt(this,s,r,n),this}deleteRange(s,r){return ODt(this,s,r),this}lift(s,r){return bDt(this,s,r),this}join(s,r=1){return TDt(this,s,r),this}wrap(s,r){return jDt(this,s,r),this}setBlockType(s,r=s,n,a=null){return NDt(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return SDt(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new cT(s,r,n)),this}setDocAttribute(s,r){return this.step(new wD(s,r)),this}addNodeMark(s,r){return this.step(new I_(s,r)),this}removeNodeMark(s,r){let n=this.doc.nodeAt(s);if(!n)throw new RangeError("No node at position "+s);if(r instanceof Dl)r.isInSet(n.marks)&&this.step(new e3(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new e3(s,o)),a=o.removeFromSet(a);for(let i=l.length-1;i>=0;i--)this.step(l[i])}return this}split(s,r=1,n){return CDt(this,s,r,n),this}addMark(s,r,n){return gDt(this,s,r,n),this}removeMark(s,r,n){return yDt(this,s,r,n),this}clearIncompatible(s,r,n){return qNe(this,s,r,n),this}}const pge=Object.create(null);class xi{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new CXe(s.min(r),s.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let s=this.ranges;for(let r=0;r=0;o--){let l=r<0?Q5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):Q5(s.node(0),s.node(o),s.after(o+1),s.index(o)+1,r,n);if(l)return l}return null}static near(s,r=1){return this.findFrom(s,r)||this.findFrom(s,-r)||new wf(s.node(0))}static atStart(s){return Q5(s,s,0,0,1)||new wf(s)}static atEnd(s){return Q5(s,s,s.content.size,s.childCount,-1)||new wf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=pge[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(s,r)}static jsonID(s,r){if(s in pge)throw new RangeError("Duplicate use of selection JSON ID "+s);return pge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return si.between(this.$anchor,this.$head).getBookmark()}}xi.prototype.visible=!0;class CXe{constructor(s,r){this.$from=s,this.$to=r}}let QIe=!1;function XIe(t){!QIe&&!t.parent.inlineContent&&(QIe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class si extends xi{constructor(s,r=s){XIe(s),XIe(r),super(s,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(s,r){let n=s.resolve(r.map(this.head));if(!n.parent.inlineContent)return xi.near(n);let a=s.resolve(r.map(this.anchor));return new si(a.parent.inlineContent?a:n,n)}replace(s,r=Nn.empty){if(super.replace(s,r),r==Nn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof si&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new Bue(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(s,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new si(s.resolve(r.anchor),s.resolve(r.head))}static create(s,r,n=r){let a=s.resolve(r);return new this(a,n==r?a:s.resolve(n))}static between(s,r,n){let a=s.pos-r.pos;if((!n||a)&&(n=a>=0?1:-1),!r.parent.inlineContent){let o=xi.findFrom(r,n,!0)||xi.findFrom(r,-n,!0);if(o)r=o.$head;else return xi.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(xi.findFrom(s,-n,!0)||xi.findFrom(s,n,!0)).$anchor,s.pos0?0:1);a>0?l=0;l+=a){let i=s.child(l);if(i.isAtom){if(!o&&Ka.isSelectable(i))return Ka.create(t,r-(a<0?i.nodeSize:0))}else{let c=Q5(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function JIe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(xi.near(t.doc.resolve(l),r))}const eLe=1,jz=2,tLe=4;class FDt extends VNe{constructor(s){super(s.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=s.selection,this.storedMarks=s.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(s){return this.storedMarks=s,this.updated|=jz,this}ensureMarks(s){return Dl.sameSet(this.storedMarks||this.selection.$from.marks(),s)||this.setStoredMarks(s),this}addStoredMark(s){return this.ensureMarks(s.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(s){return this.ensureMarks(s.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&jz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~jz,this.storedMarks=null}setTime(s){return this.time=s,this}replaceSelection(s){return this.selection.replace(this,s),this}replaceSelectionWith(s,r=!0){let n=this.selection;return r&&(s=s.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Dl.none))),n.replaceWith(this,s),this}deleteSelection(){return this.selection.replace(this),this}insertText(s,r,n){let a=this.doc.type.schema;if(r==null)return s?this.replaceSelectionWith(a.text(s),!0):this.deleteSelection();{if(n==null&&(n=r),!s)return this.deleteRange(r,n);let o=this.storedMarks;if(!o){let l=this.doc.resolve(r);o=n==r?l.marks():l.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,a.text(s,o)),!this.selection.empty&&this.selection.to==r+s.length&&this.setSelection(xi.near(this.selection.$to)),this}}setMeta(s,r){return this.meta[typeof s=="string"?s:s.key]=r,this}getMeta(s){return this.meta[typeof s=="string"?s:s.key]}get isGeneric(){for(let s in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=tLe,this}get scrolledIntoView(){return(this.updated&tLe)>0}}function sLe(t,s){return!s||!t?t:t.bind(s)}class FI{constructor(s,r,n){this.name=s,this.init=sLe(r.init,n),this.apply=sLe(r.apply,n)}}const zDt=[new FI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new FI("selection",{init(t,s){return t.selection||xi.atStart(s.doc)},apply(t){return t.selection}}),new FI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new FI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class fge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=zDt.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new FI(n.key,n.spec.state,n))})}}class yM{constructor(s){this.config=s}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(s){return this.applyTransaction(s).state}filterTransaction(s,r=-1){for(let n=0;nn.toJSON())),s&&typeof s=="object")for(let n in s){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=s[n],o=a.spec.state;o&&o.toJSON&&(r[n]=o.toJSON.call(a,this[a.key]))}return r}static fromJSON(s,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!s.schema)throw new RangeError("Required config field 'schema' missing");let a=new fge(s.schema,s.plugins),o=new yM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=nw.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=xi.fromJSON(o.doc,r.selection);else if(l.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(s.schema.markFromJSON));else{if(n)for(let i in n){let c=n[i],u=c.spec.state;if(c.key==l.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,i)){o[l.name]=u.fromJSON.call(c,s,r[i],o);return}}o[l.name]=l.init(s,o)}}),o}}function MXe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=MXe(a,s,{})),r[n]=a}return r}class Du{constructor(s){this.spec=s,this.props={},s.props&&MXe(s.props,this,this.props),this.key=s.key?s.key.key:TXe("plugin")}getState(s){return s[this.key]}}const xge=Object.create(null);function TXe(t){return t in xge?t+"$"+ ++xge[t]:(xge[t]=0,t+"$")}class sm{constructor(s="key"){this.key=TXe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const wh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},eA=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let F1e=null;const Rv=function(t,s,r){let n=F1e||(F1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},BDt=function(){F1e=null},t3=function(t,s,r,n){return r&&(rLe(t,s,r,n,-1)||rLe(t,s,r,n,1))},$Dt=/^(img|br|input|textarea|hr)$/i;function rLe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:yx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||tR(t)||$Dt.test(t.nodeName)||t.contentEditable=="false")return!1;s=wh(t)+(a<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[s+(a<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)s+=a;else return!1;else t=l,s=a<0?yx(t):0}else return!1}}function yx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qDt(t,s){for(;;){if(t.nodeType==3&&s)return t;if(t.nodeType==1&&s>0){if(t.contentEditable=="false")return null;t=t.childNodes[s-1],s=yx(t)}else if(t.parentNode&&!tR(t))s=wh(t),t=t.parentNode;else return null}}function UDt(t,s){for(;;){if(t.nodeType==3&&s2),ux=tA||(L0?/Mac/.test(L0.platform):!1),PXe=L0?/Win/.test(L0.platform):!1,e1=/Android \d/.test($w),sR=!!nLe&&"webkitFontSmoothing"in nLe.documentElement.style,WDt=sR?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function KDt(t){let s=t.defaultView&&t.defaultView.visualViewport;return s?{left:0,right:s.width,top:0,bottom:s.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Sv(t,s){return typeof t=="number"?t:t[s]}function ZDt(t){let s=t.getBoundingClientRect(),r=s.width/t.offsetWidth||1,n=s.height/t.offsetHeight||1;return{left:s.left,right:s.left+t.clientWidth*r,top:s.top,bottom:s.top+t.clientHeight*n}}function aLe(t,s,r){let n=t.someProp("scrollThreshold")||0,a=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=r||t.dom;l;){if(l.nodeType!=1){l=eA(l);continue}let i=l,c=i==o.body,u=c?KDt(o):ZDt(i),p=0,f=0;if(s.topu.bottom-Sv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+Sv(a,"top")-u.top:s.bottom-u.bottom+Sv(a,"bottom")),s.leftu.right-Sv(n,"right")&&(p=s.right-u.right+Sv(a,"right")),p||f)if(c)o.defaultView.scrollBy(p,f);else{let v=i.scrollLeft,_=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let w=i.scrollLeft-v,j=i.scrollTop-_;s={left:s.left-w,top:s.top-j,right:s.right-w,bottom:s.bottom-j}}let g=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:eA(l)}}function YDt(t){let s=t.dom.getBoundingClientRect(),r=Math.max(0,s.top),n,a;for(let o=(s.left+s.right)/2,l=r+1;l=r-20){n=i,a=c.top;break}}return{refDOM:n,refTop:a,stack:IXe(t.dom)}}function IXe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=eA(n));return s}function QDt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;LXe(r,n==0?0:n-s)}function LXe(t,s){for(let r=0;r=i){l=Math.max(_.bottom,l),i=Math.min(_.top,i);let w=_.left>s.left?_.left-s.left:_.right=(_.left+_.right)/2?1:0));continue}}else _.top>s.top&&!c&&_.left<=s.left&&_.right>=s.left&&(c=p,u={left:Math.max(_.left,Math.min(_.right,s.left)),top:_.top});!r&&(s.left>=_.right&&s.top>=_.top||s.left>=_.left&&s.top>=_.bottom)&&(o=f+1)}}return!r&&c&&(r=c,a=u,n=0),r&&r.nodeType==3?JDt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:DXe(r,a)}function JDt(t,s){let r=t.nodeValue.length,n=document.createRange(),a;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return n.detach(),a||{node:t,offset:0}}function GNe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function eOt(t,s){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&s.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(n,a,o)}function sOt(t,s,r,n){let a=-1;for(let o=s,l=!1;o!=t.dom;){let i=t.docView.nearestDesc(o,!0),c;if(!i)return null;if(i.dom.nodeType==1&&(i.node.isBlock&&i.parent||!i.contentDOM)&&((c=i.dom.getBoundingClientRect()).width||c.height)&&(i.node.isBlock&&i.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(i.dom.nodeName)&&(!l&&c.left>n.left||c.top>n.top?a=i.posBefore:(!l&&c.right-1?a:t.docView.posFromDOM(s,r,-1)}function OXe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;sR&&a&&n.nodeType==1&&(u=n.childNodes[a-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=s.top&&a--,n==t.dom&&a==n.childNodes.length-1&&n.lastChild.nodeType==1&&s.top>n.lastChild.getBoundingClientRect().bottom?i=t.state.doc.content.size:(a==0||n.nodeType!=1||n.childNodes[a-1].nodeName!="BR")&&(i=sOt(t,n,a,s))}i==null&&(i=tOt(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function iLe(t){return t.top=0&&a==n.nodeValue.length?(c--,p=1):r<0?c--:u++,oI(Zb(Rv(n,c,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==yx(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return gge(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==yx(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Rv(c,yx(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return oI(Zb(u,1),!1)}if(o==null&&a=0)}function oI(t,s){if(t.width==0)return t;let r=s?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function gge(t,s){if(t.height==0)return t;let r=s?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function FXe(t,s,r){let n=t.state,a=t.root.activeElement;n!=s&&t.updateState(s),a!=t.dom&&t.focus();try{return r()}finally{n!=s&&t.updateState(n),a!=t.dom&&a&&a.focus()}}function aOt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return FXe(t,s,()=>{let{node:o}=t.docView.domFromPos(a.pos,r=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(o,!0);if(!i)break;if(i.node.isBlock){o=i.contentDOM||i.dom;break}o=i.dom.parentNode}let l=RXe(t,a.pos,1);for(let i=o.firstChild;i;i=i.nextSibling){let c;if(i.nodeType==1)c=i.getClientRects();else if(i.nodeType==3)c=Rv(i,0,i.nodeValue.length).getClientRects();else continue;for(let u=0;up.top+1&&(r=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const iOt=/[\u0590-\u08ac]/;function oOt(t,s,r){let{$head:n}=s.selection;if(!n.parent.isTextblock)return!1;let a=n.parentOffset,o=!a,l=a==n.parent.content.size,i=t.domSelection();return i?!iOt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:FXe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),g=i.caretBidiLevel;i.modify("move",r,"character");let v=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:_,focusOffset:w}=t.domSelectionRange(),j=_&&!v.contains(_.nodeType==1?_:_.parentNode)||c==_&&u==w;try{i.collapse(p,f),c&&(c!=p||u!=f)&&i.extend&&i.extend(c,u)}catch{}return g!=null&&(i.caretBidiLevel=g),j}):n.pos==n.start()||n.pos==n.end()}let oLe=null,lLe=null,cLe=!1;function lOt(t,s,r){return oLe==s&&lLe==r?cLe:(oLe=s,lLe=r,cLe=r=="up"||r=="down"?aOt(t,s,r):oOt(t,s,r))}const Lx=0,dLe=1,M4=2,D0=3;class rR{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Lx,n.pmViewDesc=this}matchesWidget(s){return!1}matchesMark(s){return!1}matchesNode(s,r,n){return!1}matchesHack(s){return!1}parseRule(){return null}stopEvent(s){return!1}get size(){let s=0;for(let r=0;rwh(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=s.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&r==s.childNodes.length)for(let o=s;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??n>0?this.posAtEnd:this.posAtStart}nearestDesc(s,r=!1){for(let n=!0,a=s;a;a=a.parentNode){let o=this.getDesc(a),l;if(o&&(!r||o.node))if(n&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(s.nodeType==1?s:s.parentNode):l==s))n=!1;else return o}}getDesc(s){let r=s.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(s,r,n){for(let a=s;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(s,r,n)}return-1}descAt(s){for(let r=0,n=0;rs||l instanceof BXe){a=s-o;break}o=i}if(a)return this.children[n].domFromPos(a-this.children[n].border,r);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof zXe&&o.side>=0;n--);if(r<=0){let o,l=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,l=!1);return o&&r&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,r):{node:this.contentDOM,offset:o?wh(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&r<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(s,r,p);s=l;for(let f=i;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){a=wh(g.dom)+1;break}s-=g.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;p_&&lr){let _=i;i=c,c=_}let v=document.createRange();v.setEnd(c.node,c.offset),v.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(v)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,c=l-o.border;if(s>=i&&r<=c){this.dirty=s==n||r==l?M4:dLe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=D0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?M4:D0}n=l}this.dirty=M4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?M4:dLe;r.dirty{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!r.type.spec.raw){if(l.nodeType!=1){let i=document.createElement("span");i.appendChild(l),l=i}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(s,[],l,null),this.widget=r,this.widget=r,o=this}matchesWidget(s){return this.dirty==Lx&&s.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(s){let r=this.widget.spec.stopEvent;return r?r(s):!1}ignoreMutation(s){return s.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cOt extends rR{constructor(s,r,n,a){super(s,[],r,null),this.textDOM=n,this.text=a}get size(){return this.text.length}localPosFromDOM(s,r){return s!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(s){return{node:this.textDOM,offset:s}}ignoreMutation(s){return s.type==="characterData"&&s.target.nodeValue==s.oldValue}}class s3 extends rR{constructor(s,r,n,a,o){super(s,[],n,a),this.mark=r,this.spec=o}static create(s,r,n,a){let o=a.nodeViews[r.type.name],l=o&&o(r,a,n);return(!l||!l.dom)&&(l=C3.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new s3(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&D0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=D0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Lx){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=U1e(o,0,s,n));for(let i=0;i{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},n,a),p=u&&u.dom,f=u&&u.contentDOM;if(r.isText){if(!p)p=document.createTextNode(r.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:f}=C3.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!f&&!r.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),r.type.spec.draggable&&(p.draggable=!0));let g=p;return p=UXe(p,n,r),u?c=new dOt(s,r,n,a,p,f||null,g,u,o,l+1):r.isText?new que(s,r,n,a,p,g,o):new iw(s,r,n,a,p,f||null,g,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let s={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(s.preserveWhitespace="full"),!this.contentDOM)s.getContent=()=>this.node.content;else if(!this.contentLost)s.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){s.contentElement=n.dom.parentNode;break}}s.contentElement||(s.getContent=()=>Or.empty)}return s}matchesNode(s,r,n){return this.dirty==Lx&&s.eq(this.node)&&hle(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(s,r){let n=this.node.inlineContent,a=r,o=s.composing?this.localCompositionInfo(s,r):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,c=new hOt(this,l&&l.node,s);fOt(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,n,s):u.type.side>=0&&!f&&c.syncToMarks(p==this.node.childCount?Dl.none:this.node.child(p).marks,n,s),c.placeWidget(u,s,a)},(u,p,f,g)=>{c.syncToMarks(u.marks,n,s);let v;c.findNodeMatch(u,p,f,g)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,p,f,v,s)||c.updateNextNode(u,p,f,s,g,a)||c.addNode(u,p,f,s,a),a+=u.nodeSize}),c.syncToMarks([],n,s),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==M4)&&(l&&this.protectLocalComposition(s,l),$Xe(this.contentDOM,this.children,s),tA&&xOt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof si)||nr+this.node.content.size)return null;let o=s.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,i=gOt(this.node.content,l,n-r,a-r);return i<0?null:{node:o,pos:i,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(s,{node:r,pos:n,text:a}){if(this.getDesc(r))return;let o=r;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let l=new cOt(this,o,r,a);s.input.compositionNodes.push(l),this.children=U1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==D0||!s.sameMarkup(this.node)?!1:(this.updateInner(s,r,n,a),!0)}updateInner(s,r,n,a){this.updateOuterDeco(r),this.node=s,this.innerDeco=n,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Lx}updateOuterDeco(s){if(hle(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=qXe(this.dom,this.nodeDOM,q1e(this.outerDeco,this.node,r),q1e(s,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=s}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function uLe(t,s,r,n,a){UXe(n,s,t);let o=new iw(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class que extends iw{constructor(s,r,n,a,o,l,i){super(s,r,n,a,o,null,l,i,0)}parseRule(){let s=this.nodeDOM.parentNode;for(;s&&s!=this.dom&&!s.pmIsDeco;)s=s.parentNode;return{skip:s||!0}}update(s,r,n,a){return this.dirty==D0||this.dirty!=Lx&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Lx||s.text!=this.node.text)&&s.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=s.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=s,this.dirty=Lx,!0)}inParent(){let s=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==s)return!0;return!1}domFromPos(s){return{node:this.nodeDOM,offset:s}}localPosFromDOM(s,r,n){return s==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(s,r,n)}ignoreMutation(s){return s.type!="characterData"&&s.type!="selection"}slice(s,r,n){let a=this.node.cut(s,r),o=document.createTextNode(a.text);return new que(this.parent,a,this.outerDeco,this.innerDeco,o,o,n)}markDirty(s,r){super.markDirty(s,r),this.dom!=this.nodeDOM&&(s==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=D0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class BXe extends rR{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Lx&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class dOt extends iw{constructor(s,r,n,a,o,l,i,c,u,p){super(s,r,n,a,o,l,i,u,p),this.spec=c}update(s,r,n,a){if(this.dirty==D0)return!1;if(this.spec.update&&(this.node.type==s.type||this.spec.multiType)){let o=this.spec.update(s,r,n);return o&&this.updateInner(s,r,n,a),o}else return!this.contentDOM&&!s.isLeaf?!1:super.update(s,r,n,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(s,r,n,a){this.spec.setSelection?this.spec.setSelection(s,r,n.root):super.setSelection(s,r,n,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(s){return this.spec.stopEvent?this.spec.stopEvent(s):!1}ignoreMutation(s){return this.spec.ignoreMutation?this.spec.ignoreMutation(s):super.ignoreMutation(s)}}function $Xe(t,s,r){let n=t.firstChild,a=!1;for(let o=0;o>1,l=Math.min(o,s.length);for(;a-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let c=s3.create(this.top,s[o],r,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(s,r,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(s,r,n))o=this.top.children.indexOf(l,this.index);else for(let i=this.index,c=Math.min(this.top.children.length,i+5);i0;){let i;for(;;)if(n){let u=r.children[n-1];if(u instanceof s3)r=u,n=u.children.length;else{i=u,n--;break}}else{if(r==s)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=i.node;if(c){if(c!=t.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function pOt(t,s){return t.type.side-s.type.side}function fOt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let _=o+g.nodeSize;if(g.isText){let j=_;l!j.inline):i.slice();n(g,w,s.forChild(o,g),v),o=_}}function xOt(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let s=t.style.cssText;t.style.cssText=s+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=s}}function gOt(t,s,r,n){for(let a=0,o=0;a=r){if(o>=n&&c.slice(n-s.length-i,n-i)==s)return n-s.length;let u=i=0&&u+s.length+i>=r)return i+u;if(r==n&&c.length>=n+s.length-i&&c.slice(n-i,n-i+s.length)==s)return n}}return-1}function U1e(t,s,r,n,a){let o=[];for(let l=0,i=0;l=r||p<=s?o.push(c):(ur&&o.push(c.slice(r-u,c.size,n)))}return o}function WNe(t,s=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let a=t.docView.nearestDesc(r.focusNode),o=a&&a.size==0,l=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(l<0)return null;let i=n.resolve(l),c,u;if($ue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Ka.isSelectable(f)&&a.parent&&!(f.isInline&&VDt(r.focusNode,r.focusOffset,a.dom))){let g=a.posBefore;u=new Ka(l==g?i:n.resolve(g))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,g=l;for(let v=0;v{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!VXe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function vOt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,wh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Tp&&aw<=11&&(r.disabled=!0,r.disabled=!1)}function HXe(t,s){if(s instanceof Ka){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(xLe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else xLe(t)}function xLe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function KNe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||si.between(s,r,n)}function gLe(t){return t.editable&&!t.hasFocus()?!1:GXe(t)}function GXe(t){let s=t.domSelectionRange();if(!s.anchorNode)return!1;try{return t.dom.contains(s.anchorNode.nodeType==3?s.anchorNode.parentNode:s.anchorNode)&&(t.editable||t.dom.contains(s.focusNode.nodeType==3?s.focusNode.parentNode:s.focusNode))}catch{return!1}}function bOt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return t3(s.node,s.offset,r.anchorNode,r.anchorOffset)}function V1e(t,s){let{$anchor:r,$head:n}=t.selection,a=s>0?r.max(n):r.min(n),o=a.parent.inlineContent?a.depth?t.doc.resolve(s>0?a.after():a.before()):null:a;return o&&xi.findFrom(o,s)}function t_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function yLe(t,s,r){let n=t.state.selection;if(n instanceof si)if(r.indexOf("s")>-1){let{$head:a}=n,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=t.state.doc.resolve(a.pos+o.nodeSize*(s<0?-1:1));return t_(t,new si(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=V1e(t.state,s);return a&&a instanceof Ka?t_(t,a):!1}else if(!(ux&&r.indexOf("m")>-1)){let a=n.$head,o=a.textOffset?null:s<0?a.nodeBefore:a.nodeAfter,l;if(!o||o.isText)return!1;let i=s<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(l=t.docView.descAt(i))&&!l.contentDOM?Ka.isSelectable(o)?t_(t,new Ka(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):sR?t_(t,new si(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ka&&n.node.isInline)return t_(t,new si(s>0?n.$to:n.$from));{let a=V1e(t.state,s);return a?t_(t,a):!1}}}function mle(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function f8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function I5(t,s){return s<0?_Ot(t):wOt(t)}function _Ot(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Ix&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(f8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(WXe(r))break;{let i=r.previousSibling;for(;i&&f8(i,-1);)a=r.parentNode,o=wh(i),i=i.previousSibling;if(i)r=i,n=mle(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?H1e(t,r,n):a&&H1e(t,a,o)}function wOt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=mle(r),o,l;for(;;)if(n{t.state==a&&_1(t)},50)}function vLe(t,s){let r=t.state.doc.resolve(s);if(!(Ju||PXe)&&r.parent.inlineContent){let a=t.coordsAtPos(s);if(s>r.start()){let o=t.coordsAtPos(s-1),l=(o.top+o.bottom)/2;if(l>a.top&&l1)return o.lefta.top&&l1)return o.left>a.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function bLe(t,s,r){let n=t.state.selection;if(n instanceof si&&!n.empty||r.indexOf("s")>-1||ux&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=V1e(t.state,s);if(l&&l instanceof Ka)return t_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof wf?xi.near(l,s):xi.findFrom(l,s);return i?t_(t,i):!1}return!1}function _Le(t,s){if(!(t.state.selection instanceof si))return!0;let{$head:r,$anchor:n,empty:a}=t.state.selection;if(!r.sameParent(n))return!0;if(!a)return!1;if(t.endOfTextblock(s>0?"forward":"backward"))return!0;let o=!r.textOffset&&(s<0?r.nodeBefore:r.nodeAfter);if(o&&!o.isText){let l=t.state.tr;return s<0?l.delete(r.pos-o.nodeSize,r.pos):l.delete(r.pos,r.pos+o.nodeSize),t.dispatch(l),!0}return!1}function wLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function kOt(t){if(!Jh||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(s&&s.nodeType==1&&r==0&&s.firstChild&&s.firstChild.contentEditable=="false"){let n=s.firstChild;wLe(t,n,"true"),setTimeout(()=>wLe(t,n,"false"),20)}return!1}function SOt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function COt(t,s){let r=s.keyCode,n=SOt(s);if(r==8||ux&&r==72&&n=="c")return _Le(t,-1)||I5(t,-1);if(r==46&&!s.shiftKey||ux&&r==68&&n=="c")return _Le(t,1)||I5(t,1);if(r==13||r==27)return!0;if(r==37||ux&&r==66&&n=="c"){let a=r==37?vLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return yLe(t,a,n)||I5(t,a)}else if(r==39||ux&&r==70&&n=="c"){let a=r==39?vLe(t,t.state.selection.from)=="ltr"?1:-1:1;return yLe(t,a,n)||I5(t,a)}else{if(r==38||ux&&r==80&&n=="c")return bLe(t,-1,n)||I5(t,-1);if(r==40||ux&&r==78&&n=="c")return kOt(t)||bLe(t,1,n)||I5(t,1);if(n==(ux?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function ZNe(t,s){t.someProp("transformCopied",v=>{s=v(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let v=n.firstChild;r.push(v.type.name,v.attrs!=v.type.defaultAttrs?v.attrs:null),n=v.content}let l=t.someProp("clipboardSerializer")||C3.fromSchema(t.state.schema),i=JXe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=XXe[u.nodeName.toLowerCase()]);){for(let v=p.length-1;v>=0;v--){let _=i.createElement(p[v]);for(;c.firstChild;)_.appendChild(c.firstChild);c.appendChild(_),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let g=t.someProp("clipboardTextSerializer",v=>v(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:g,slice:s}}function KXe(t,s,r,n,a){let o=a.parent.type.spec.code,l,i;if(!r&&!s)return null;let c=!!s&&(n||o||!r);if(c){if(t.someProp("transformPastedText",g=>{s=g(s,o||n,t)}),o)return i=new Nn(Or.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",g=>{i=g(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",g=>g(s,a,n,t));if(f)i=f;else{let g=a.marks(),{schema:v}=t.state,_=C3.fromSchema(v);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=l.appendChild(document.createElement("p"));w&&j.appendChild(_.serializeNode(v.text(w,g)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=EOt(r),sR&&POt(l);let u=l&&l.querySelector("[data-pm-slice]"),p=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let f=+p[3];f>0;f--){let g=l.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;l=g}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||h8.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||p),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!MOt.test(g.parentNode.nodeName)?{ignore:!0}:null}})),p)i=IOt(jLe(i,+p[1],+p[2]),p[4]);else if(i=Nn.maxOpen(TOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,g=0;for(let v=i.content.firstChild;f{i=f(i,t,c)}),i}const MOt=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function TOt(t,s){if(t.childCount<2)return t;for(let r=s.depth;r>=0;r--){let a=s.node(r).contentMatchAt(s.index(r)),o,l=[];if(t.forEach(i=>{if(!l)return;let c=a.findWrapping(i.type),u;if(!c)return l=null;if(u=l.length&&o.length&&YXe(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=QXe(l[l.length-1],o.length));let p=ZXe(i,c);l.push(p),a=a.matchType(p.type),o=c}}),l)return Or.from(l)}return t}function ZXe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Or.from(t));return t}function YXe(t,s,r,n,a){if(a1&&(o=0),a=r&&(i=s<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(Or.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function jLe(t,s,r){return sr})),vge.createHTML(t)):t}function EOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=JXe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&XXe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=AOt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Or.from(c.create(n[i+1],a)),o++,l++}return new Nn(a,o,l)}const qm={},Um={},LOt={touchstart:!0,touchmove:!0};class DOt{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function OOt(t){for(let s in qm){let r=qm[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{FOt(t,n)&&!YNe(t,n)&&(t.editable||!(n.type in Um))&&r(t,n)},LOt[s]?{passive:!0}:void 0)}Jh&&t.dom.addEventListener("input",()=>null),W1e(t)}function L_(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function ROt(t){t.domObserver.stop();for(let s in t.input.eventHandlers)t.dom.removeEventListener(s,t.input.eventHandlers[s]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function W1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>YNe(t,n))})}function YNe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function FOt(t,s){if(!s.bubbles)return!0;if(s.defaultPrevented)return!1;for(let r=s.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(s))return!1;return!0}function zOt(t,s){!YNe(t,s)&&qm[s.type]&&(t.editable||!(s.type in Um))&&qm[s.type](t,s)}Um.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!tJe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(e1&&Ju&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),tA&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();t.input.lastIOSEnter=n,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==n&&(t.someProp("handleKeyDown",a=>a(t,x4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||COt(t,r)?r.preventDefault():L_(t,"key")};Um.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Um.keypress=(t,s)=>{let r=s;if(tJe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||ux&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof si)||!n.$from.sameParent(n.$to)){let a=String.fromCharCode(r.charCode),o=()=>t.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!t.someProp("handleTextInput",l=>l(t,n.$from.pos,n.$to.pos,a,o))&&t.dispatch(o()),r.preventDefault()}};function Uue(t){return{left:t.clientX,top:t.clientY}}function BOt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function QNe(t,s,r,n,a){if(n==-1)return!1;let o=t.state.doc.resolve(n);for(let l=o.depth+1;l>0;l--)if(t.someProp(s,i=>l>o.depth?i(t,r,o.nodeAfter,o.before(l),a,!0):i(t,r,o.node(l),o.before(l),a,!1)))return!0;return!1}function dT(t,s,r){if(t.focused||t.focus(),t.state.selection.eq(s))return;let n=t.state.tr.setSelection(s);n.setMeta("pointer",!0),t.dispatch(n)}function $Ot(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ka.isSelectable(n)?(dT(t,new Ka(r)),!0):!1}function qOt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ka&&(n=r.node);let o=t.state.doc.resolve(s);for(let l=o.depth+1;l>0;l--){let i=l>o.depth?o.nodeAfter:o.node(l);if(Ka.isSelectable(i)){n&&r.$from.depth>0&&l>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?a=o.before(r.$from.depth):a=o.before(l);break}}return a!=null?(dT(t,Ka.create(t.state.doc,a)),!0):!1}function UOt(t,s,r,n,a){return QNe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?qOt(t,r):$Ot(t,r))}function VOt(t,s,r,n){return QNe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function HOt(t,s,r,n){return QNe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||GOt(t,r,n)}function GOt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(dT(t,si.create(n,0,n.content.size)),!0):!1;let a=n.resolve(s);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o),i=a.before(o);if(l.inlineContent)dT(t,si.create(n,i+1,i+1+l.content.size));else if(Ka.isSelectable(l))dT(t,Ka.create(n,i));else continue;return!0}}function XNe(t){return ple(t)}const eJe=ux?"metaKey":"ctrlKey";qm.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=XNe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&BOt(r,t.input.lastClick)&&!r[eJe]&&t.input.lastClick.button==r.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:a,x:r.clientX,y:r.clientY,type:o,button:r.button};let l=t.posAtCoords(Uue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new WOt(t,l,r,!!n)):(o=="doubleClick"?VOt:HOt)(t,l.pos,l.inside,r)?r.preventDefault():L_(t,"pointer"))};class WOt{constructor(s,r,n,a){this.view=s,this.pos=r,this.event=n,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=s.state.doc,this.selectNode=!!n[eJe],this.allowDefault=n.shiftKey;let o,l;if(r.inside>-1)o=s.state.doc.nodeAt(r.inside),l=r.inside;else{let p=s.state.doc.resolve(r.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,c=i?s.docView.nearestDesc(i,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=s.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof Ka&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ix&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),s.root.addEventListener("mouseup",this.up=this.up.bind(this)),s.root.addEventListener("mousemove",this.move=this.move.bind(this)),L_(s,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>_1(this.view)),this.view.input.mouseDown=null}up(s){if(this.done(),!this.view.dom.contains(s.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(Uue(s))),this.updateAllowDefault(s),this.allowDefault||!r?L_(this.view,"pointer"):UOt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Jh&&this.mightDrag&&!this.mightDrag.node.isAtom||Ju&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(dT(this.view,xi.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):L_(this.view,"pointer")}move(s){this.updateAllowDefault(s),L_(this.view,"pointer"),s.buttons==0&&this.done()}updateAllowDefault(s){!this.allowDefault&&(Math.abs(this.event.x-s.clientX)>4||Math.abs(this.event.y-s.clientY)>4)&&(this.allowDefault=!0)}}qm.touchstart=t=>{t.input.lastTouch=Date.now(),XNe(t),L_(t,"pointer")};qm.touchmove=t=>{t.input.lastTouch=Date.now(),L_(t,"pointer")};qm.contextmenu=t=>XNe(t);function tJe(t,s){return t.composing?!0:Jh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const KOt=e1?5e3:-1;Um.compositionstart=Um.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof si&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Ju&&PXe&&ZOt(t)))t.markCursor=t.state.storedMarks||r.marks(),ple(t,!0),t.markCursor=null;else if(ple(t,!s.selection.empty),Ix&&s.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let a=n.focusNode,o=n.focusOffset;a&&a.nodeType==1&&o!=0;){let l=o<0?a.lastChild:a.childNodes[o-1];if(!l)break;if(l.nodeType==3){let i=t.domSelection();i&&i.collapse(l,l.nodeValue.length);break}else a=l,o=-1}}t.input.composing=!0}sJe(t,KOt)};function ZOt(t){let{focusNode:s,focusOffset:r}=t.domSelectionRange();if(!s||s.nodeType!=1||r>=s.childNodes.length)return!1;let n=s.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}Um.compositionend=(t,s)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=s.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,sJe(t,20))};function sJe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>ple(t),s))}function rJe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=QOt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function YOt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=qDt(s.focusNode,s.focusOffset),n=UDt(s.focusNode,s.focusOffset);if(r&&n&&r!=n){let a=n.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(r==o||n==o)return o;if(!a||!a.isText(n.nodeValue))return n;if(t.input.compositionNode==n){let l=r.pmViewDesc;if(!(!l||!l.isText(r.nodeValue)))return n}}return r||n}function QOt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ple(t,s=!1){if(!(e1&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),rJe(t),s||t.docView&&t.docView.dirty){let r=WNe(t),n=t.state.selection;return r&&!r.eq(n)?t.dispatch(t.state.tr.setSelection(r)):(t.markCursor||s)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function XOt(t,s){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(s),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),a=document.createRange();a.selectNodeContents(s),t.dom.blur(),n.removeAllRanges(),n.addRange(a),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()},50)}const jD=Tp&&aw<15||tA&&WDt<604;qm.copy=Um.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=jD?null:r.clipboardData,l=n.content(),{dom:i,text:c}=ZNe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):XOt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function JOt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eRt(t,s){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let a=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),n.parentNode&&n.parentNode.removeChild(n),r?ND(t,n.value,null,a,s):ND(t,n.textContent,n.innerHTML,a,s)},50)}function ND(t,s,r,n,a){let o=KXe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||Nn.empty)))return!0;if(!o)return!1;let l=JOt(o),i=l?t.state.tr.replaceSelectionWith(l,n):t.state.tr.replaceSelection(o);return t.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nJe(t){let s=t.getData("text/plain")||t.getData("Text");if(s)return s;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}Um.paste=(t,s)=>{let r=s;if(t.composing&&!e1)return;let n=jD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&ND(t,nJe(n),n.getData("text/html"),a,r)?r.preventDefault():eRt(t,r)};class aJe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const tRt=ux?"altKey":"ctrlKey";function iJe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[tRt]}qm.dragstart=(t,s)=>{let r=s,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let a=t.state.selection,o=a.empty?null:t.posAtCoords(Uue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ka?a.to-1:a.to))){if(n&&n.mightDrag)l=Ka.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let f=t.docView.nearestDesc(r.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(l=Ka.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:p}=ZNe(t,i);(!r.dataTransfer.files.length||!Ju||EXe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(jD?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",jD||r.dataTransfer.setData("text/plain",u),t.dragging=new aJe(p,iJe(t,r),l)};qm.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Um.dragover=Um.dragenter=(t,s)=>s.preventDefault();Um.drop=(t,s)=>{try{sRt(t,s,t.dragging)}finally{t.dragging=null}};function sRt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Uue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",v=>{o=v(o,t,!1)}):o=KXe(t,nJe(s.dataTransfer),jD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&iJe(t,s));if(t.someProp("handleDrop",v=>v(t,s,o||Nn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?wXe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:v}=r;v?v.replace(c):c.deleteSelection()}let u=c.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(p?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let g=c.doc.resolve(u);if(p&&Ka.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Ka(g));else{let v=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((_,w,j,k)=>v=k),c.setSelection(KNe(t,g,c.doc.resolve(v)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}qm.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&_1(t)},20))};qm.blur=(t,s)=>{let r=s;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};qm.beforeinput=(t,s)=>{if(Ju&&e1&&s.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,x4(8,"Backspace")))))return;let{$cursor:a}=t.state.selection;a&&a.pos>0&&t.dispatch(t.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let t in Um)qm[t]=Um[t];function kD(t,s){if(t==s)return!0;for(let r in t)if(t[r]!==s[r])return!1;for(let r in s)if(!(r in t))return!1;return!0}class fle{constructor(s,r){this.toDOM=s,this.spec=r||MS,this.side=this.spec.side||0}map(s,r,n,a){let{pos:o,deleted:l}=s.mapResult(r.from+a,this.side<0?-1:1);return l?null:new Tm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof fle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&kD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class ow{constructor(s,r){this.attrs=s,this.spec=r||MS}map(s,r,n,a){let o=s.map(r.from+a,this.spec.inclusiveStart?-1:1)-n,l=s.map(r.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new Tm(o,l,this)}valid(s,r){return r.from=s&&(!o||o(i.spec))&&n.push(i.copy(i.from+a,i.to+a))}for(let l=0;ls){let i=this.children[l]+1;this.children[l+2].findInner(s-i,r-i,n,a+i,o)}}map(s,r,n){return this==qh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||MS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,p;if(p=lJe(r,i,u)){for(a||(a=this.children.slice());oi&&f.to=s){this.children[i]==s&&(n=this.children[i+2]);break}let o=s+1,l=o+r.content.size;for(let i=0;io&&c.type instanceof ow){let u=Math.max(o,c.from)-o,p=Math.min(l,c.to)-o;ua.map(s,r,MS));return h_.from(n)}forChild(s,r){if(r.isLeaf)return gd.empty;let n=[];for(let a=0;ar instanceof gd)?s:s.reduce((r,n)=>r.concat(n instanceof gd?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let j=w-_-(v-g);for(let k=0;kS+p-f)continue;let M=i[k]+p-f;v>=M?i[k+1]=g<=M?-2:-1:g>=p&&j&&(i[k]+=j,i[k+1]+=j)}f+=j}),p=r.maps[u].map(p,-1)}let c=!1;for(let u=0;u=n.content.size){c=!0;continue}let g=r.map(t[u+1]+o,-1),v=g-a,{index:_,offset:w}=n.content.findIndex(f),j=n.maybeChild(_);if(j&&w==f&&w+j.nodeSize==v){let k=i[u+2].mapInner(r,j,p+1,t[u]+o+1,l);k!=qh?(i[u]=f,i[u+1]=v,i[u+2]=k):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=nRt(i,t,s,r,a,o,l),p=xle(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=lJe(t,i,c+r);if(u){o=!0;let p=xle(u,i,r+c+1,n);p!=qh&&a.push(c,c+i.nodeSize,p)}});let l=oJe(o?cJe(t):t,-r).sort(TS);for(let i=0;i0;)s++;t.splice(s,0,r)}function bge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=qh&&s.push(n)}),t.cursorWrapper&&s.push(gd.create(t.state.doc,[t.cursorWrapper.deco])),h_.from(s)}const aRt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},iRt=Tp&&aw<=11;class oRt{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(s){this.anchorNode=s.anchorNode,this.anchorOffset=s.anchorOffset,this.focusNode=s.focusNode,this.focusOffset=s.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(s){return s.anchorNode==this.anchorNode&&s.anchorOffset==this.anchorOffset&&s.focusNode==this.focusNode&&s.focusOffset==this.focusOffset}}class lRt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new oRt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let a=0;aa.type=="childList"&&a.removedNodes.length||a.type=="characterData"&&a.oldValue.length>a.target.nodeValue.length)?this.flushSoon():this.flush()}),iRt&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,aRt)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let s=this.observer.takeRecords();if(s.length){for(let r=0;rthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(gLe(this.view)){if(this.suppressingSelectionUpdates)return _1(this.view);if(Tp&&aw<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&t3(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(s){if(!s.focusNode)return!0;let r=new Set,n;for(let o=s.focusNode;o;o=eA(o))r.add(o);for(let o=s.anchorNode;o;o=eA(o))if(r.has(o)){n=o;break}let a=n&&this.view.docView.nearestDesc(n);if(a&&a.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let s of this.observer.takeRecords())this.queue.push(s);return this.queue}flush(){let{view:s}=this;if(!s.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=s.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&gLe(s)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,c=[];if(s.editable)for(let p=0;pf.nodeName=="BR");if(p.length==2){let[f,g]=p;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of p){let v=g.parentNode;v&&v.nodeName=="LI"&&(!f||uRt(s,f)!=v)&&g.remove()}}}else if((Ju||Jh)&&c.some(p=>p.nodeName=="BR")&&(s.input.lastKeyCode==8||s.input.lastKeyCode==46)){for(let p of c)if(p.nodeName=="BR"&&p.parentNode){let f=p.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&p.parentNode.removeChild(p)}}let u=null;o<0&&a&&s.input.lastFocus>Date.now()-200&&Math.max(s.input.lastTouch,s.input.lastClick.time)-1||a)&&(o>-1&&(s.docView.markDirty(o,l),cRt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||_1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;j--){let k=n.childNodes[j-1],S=k.pmViewDesc;if(k.nodeName=="BR"&&!S){o=j;break}if(!S||S.size)break}let f=t.state.doc,g=t.someProp("domParser")||h8.fromSchema(t.state.schema),v=f.resolve(l),_=null,w=g.parse(n,{topNode:v.parent,topMatch:v.parent.contentMatchAt(v.index()),topOpen:!0,from:a,to:o,preserveWhitespace:v.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:mRt,context:v});if(u&&u[0].pos!=null){let j=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=j),_={anchor:j+l,head:k+l}}return{doc:w,sel:_,from:l,to:i}}function mRt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Jh&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Jh&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const pRt=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function fRt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let $=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=WNe(t,$);if(U&&!t.state.selection.eq(U)){if(Ju&&e1&&t.input.lastKeyCode===13&&Date.now()-100V(t,x4(13,"Enter"))))return;let B=t.state.tr.setSelection(U);$=="pointer"?B.setMeta("pointer",!0):$=="key"&&B.scrollIntoView(),o&&B.setMeta("composition",o),t.dispatch(B)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let c=t.state.selection,u=hRt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),g,v;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||e1)&&a.some($=>$.nodeType==1&&!pRt.test($.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",$=>$(t,x4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(n&&c instanceof si&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))_={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let $=TLe(t,t.state.doc,u.sel);if($&&!$.eq(t.state.selection)){let U=t.state.tr.setSelection($);o&&U.setMeta("composition",o),t.dispatch(U)}}return}t.state.selection.fromt.state.selection.from&&_.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?_.start=t.state.selection.from:_.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(_.endB+=t.state.selection.to-_.endA,_.endA=t.state.selection.to)),Tp&&aw<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>u.from&&u.doc.textBetween(_.start-u.from-1,_.start-u.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let w=u.doc.resolveNoCache(_.start-u.from),j=u.doc.resolveNoCache(_.endB-u.from),k=p.resolve(_.start),S=w.sameParent(j)&&w.parent.inlineContent&&k.end()>=_.endA;if((tA&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!S&&w.pos$(t,x4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&gRt(p,_.start,_.endA,w,j)&&t.someProp("handleKeyDown",$=>$(t,x4(8,"Backspace")))){e1&&Ju&&t.domObserver.suppressSelectionUpdates();return}Ju&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),e1&&!S&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==_.endA&&(_.endB-=2,j=u.doc.resolveNoCache(_.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,x4(13,"Enter"))})},20));let M=_.start,L=_.endA,P=$=>{let U=$||t.state.tr.replace(M,L,u.doc.slice(_.start-u.from,_.endB-u.from));if(u.sel){let B=TLe(t,U.doc,u.sel);B&&!(Ju&&t.composing&&B.empty&&(_.start!=_.endB||t.input.lastChromeDelete_1(t),20));let $=P(t.state.tr.delete(M,L)),U=p.resolve(_.start).marksAcross(p.resolve(_.endA));U&&$.ensureMarks(U),t.dispatch($)}else if(_.endA==_.endB&&(O=xRt(w.parent.content.cut(w.parentOffset,j.parentOffset),k.parent.content.cut(k.parentOffset,_.endA-k.start())))){let $=P(t.state.tr);O.type=="add"?$.addMark(M,L,O.mark):$.removeMark(M,L,O.mark),t.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,j.parentOffset),U=()=>P(t.state.tr.insertText($,M,L));t.someProp("handleTextInput",B=>B(t,M,L,$,U))||t.dispatch(U())}else t.dispatch(P());else t.dispatch(P())}function TLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:KNe(t,s.resolve(r.anchor),s.resolve(r.head))}function xRt(t,s){let r=t.firstChild.marks,n=s.firstChild.marks,a=r,o=n,l,i,c;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",c=p=>p.mark(i.removeFromSet(p.marks));else return null;let u=[];for(let p=0;pr||_ge(l,!0,!1)0&&(s||t.indexAfter(n)==t.node(n).childCount);)n--,a++,s=!1;if(r){let o=t.node(n).maybeChild(t.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,a++}return a}function yRt(t,s,r,n,a){let o=t.findDiffStart(s,r);if(o==null)return null;let{a:l,b:i}=t.findDiffEnd(s,r+t.size,r+s.size);if(a=="end"){let c=Math.max(0,o-Math.min(l,i));n-=l+c-o}if(l=l?o-n:0;o-=c,o&&o=i?o-n:0;o-=c,o&&o=56320&&s<=57343&&r>=55296&&r<=56319}class dJe{constructor(s,r){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new DOt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(DLe),this.dispatch=this.dispatch.bind(this),this.dom=s&&s.mount||document.createElement("div"),s&&(s.appendChild?s.appendChild(this.dom):typeof s=="function"?s(this.dom):s.mount&&(this.mounted=!0)),this.editable=ILe(this),PLe(this),this.nodeViews=LLe(this),this.docView=uLe(this.state.doc,ELe(this),bge(this),this.dom,this),this.domObserver=new lRt(this,(n,a,o,l)=>fRt(this,n,a,o,l)),this.domObserver.start(),OOt(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let s=this._props;this._props={};for(let r in s)this._props[r]=s[r];this._props.state=this.state}return this._props}update(s){s.handleDOMEvents!=this._props.handleDOMEvents&&W1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(DLe),this.directPlugins=s.plugins),this.updateStateInner(s.state,r)}setProps(s){let r={};for(let n in this._props)r[n]=this._props[n];r.state=this.state;for(let n in s)r[n]=s[n];this.update(r)}updateState(s){this.updateStateInner(s,this._props)}updateStateInner(s,r){var n;let a=this.state,o=!1,l=!1;s.storedMarks&&this.composing&&(rJe(this),l=!0),this.state=s;let i=a.plugins!=s.plugins||this._props.plugins!=r.plugins;if(i||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let v=LLe(this);bRt(v,this.nodeViews)&&(this.nodeViews=v,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&W1e(this),this.editable=ILe(this),PLe(this);let c=bge(this),u=ELe(this),p=a.plugins!=s.plugins&&!a.doc.eq(s.doc)?"reset":s.scrollToSelection>a.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(s.doc,u,c);(f||!s.selection.eq(a.selection))&&(l=!0);let g=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&YDt(this);if(l){this.domObserver.stop();let v=f&&(Tp||Ju)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&vRt(a.selection,s.selection);if(f){let _=Ju?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=YOt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=uLe(s.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(v=!0)}v||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bOt(this))?_1(this,v):(HXe(this,s.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(s.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():g&&QDt(g)}scrollToSelection(){let s=this.domSelectionRange().focusNode;if(!(!s||!this.dom.contains(s.nodeType==1?s:s.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof Ka){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&aLe(this,r.getBoundingClientRect(),s)}else aLe(this,this.coordsAtPos(this.state.selection.head,1),s)}}destroyPluginViews(){let s;for(;s=this.pluginViews.pop();)s.destroy&&s.destroy()}updatePluginViews(s){if(!s||s.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let r=0;r0&&this.state.doc.nodeAt(o))==n.node&&(a=o)}this.dragging=new aJe(s.slice,s.move,a<0?void 0:Ka.create(this.state.doc,a))}someProp(s,r){let n=this._props&&this._props[s],a;if(n!=null&&(a=r?r(n):n))return a;for(let l=0;lr.ownerDocument.getSelection()),this._root=r}return s||document}updateRoot(){this._root=null}posAtCoords(s){return rOt(this,s)}coordsAtPos(s,r=1){return RXe(this,s,r)}domAtPos(s,r=0){return this.docView.domFromPos(s,r)}nodeDOM(s){let r=this.docView.descAt(s);return r?r.nodeDOM:null}posAtDOM(s,r,n=-1){let a=this.docView.posFromDOM(s,r,n);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(s,r){return lOt(this,r||this.state,s)}pasteHTML(s,r){return ND(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return ND(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return ZNe(this,s)}destroy(){this.docView&&(ROt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,BDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return zOt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Jh&&this.root.nodeType===11&&HDt(this.dom.ownerDocument)==this.dom&&dRt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}dJe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function ELe(t){let s=Object.create(null);return s.class="ProseMirror",s.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?s.class+=" "+r[n]:n=="style"?s.style=(s.style?s.style+";":"")+r[n]:!s[n]&&n!="contenteditable"&&n!="nodeName"&&(s[n]=String(r[n]))}),s.translate||(s.translate="no"),[Tm.node(0,t.state.doc.content.size,s)]}function PLe(t){if(t.markCursor){let s=document.createElement("img");s.className="ProseMirror-separator",s.setAttribute("mark-placeholder","true"),s.setAttribute("alt",""),t.cursorWrapper={dom:s,deco:Tm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ILe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function vRt(t,s){let r=Math.min(t.$anchor.sharedDepth(t.head),s.$anchor.sharedDepth(s.head));return t.$anchor.start(r)!=s.$anchor.start(r)}function LLe(t){let s=Object.create(null);function r(n){for(let a in n)Object.prototype.hasOwnProperty.call(s,a)||(s[a]=n[a])}return t.someProp("nodeViews",r),t.someProp("markViews",r),s}function bRt(t,s){let r=0,n=0;for(let a in t){if(t[a]!=s[a])return!0;r++}for(let a in s)n++;return r!=n}function DLe(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var jw={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gle={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_Rt=typeof navigator<"u"&&/Mac/.test(navigator.platform),wRt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var jh=0;jh<10;jh++)jw[48+jh]=jw[96+jh]=String(jh);for(var jh=1;jh<=24;jh++)jw[jh+111]="F"+jh;for(var jh=65;jh<=90;jh++)jw[jh]=String.fromCharCode(jh+32),gle[jh]=String.fromCharCode(jh);for(var wge in jw)gle.hasOwnProperty(wge)||(gle[wge]=jw[wge]);function jRt(t){var s=_Rt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||wRt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?gle:jw)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}const NRt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kRt=typeof navigator<"u"&&/Win/.test(navigator.platform);function SRt(t){let s=t.split(/-(?!$)/),r=s[s.length-1];r=="Space"&&(r=" ");let n,a,o,l;for(let i=0;it.selection.empty?!1:(s&&s(t.tr.deleteSelection().scrollIntoView()),!0);function uJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const hJe=(t,s,r)=>{let n=uJe(t,r);if(!n)return!1;let a=rke(n);if(!a){let l=n.blockRange(),i=l&&pE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(_Je(t,a,s,-1))return!0;if(n.parent.content.size==0&&(sA(o,"end")||Ka.isSelectable(o)))for(let l=n.depth;;l--){let i=zue(t.doc,n.before(l),n.after(l),Nn.empty);if(i&&i.slice.size1)break}return o.isAtom&&a.depth==n.depth-1?(s&&s(t.tr.delete(a.pos-o.nodeSize,a.pos).scrollIntoView()),!0):!1},TRt=(t,s,r)=>{let n=uJe(t,r);if(!n)return!1;let a=rke(n);return a?mJe(t,a,s):!1},ARt=(t,s,r)=>{let n=fJe(t,r);if(!n)return!1;let a=nke(n);return a?mJe(t,a,s):!1};function mJe(t,s,r){let n=s.nodeBefore,a=n,o=s.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=s.nodeAfter,i=l,c=s.pos+1;for(;!i.isTextblock;c++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let u=zue(t.doc,o,c,Nn.empty);if(!u||u.from!=o||u instanceof Qu&&u.slice.size>=c-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(si.create(p.doc,o)),r(p.scrollIntoView())}return!0}function sA(t,s,r=!1){for(let n=t;n;n=s=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(r&&n.childCount!=1)return!1}return!1}const pJe=(t,s,r)=>{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return!1;o=rke(n)}let l=o&&o.nodeBefore;return!l||!Ka.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ka.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function rke(t){if(!t.parent.type.spec.isolating)for(let s=t.depth-1;s>=0;s--){if(t.index(s)>0)return t.doc.resolve(t.before(s+1));if(t.node(s).type.spec.isolating)break}return null}function fJe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=fJe(t,r);if(!n)return!1;let a=nke(n);if(!a)return!1;let o=a.nodeAfter;if(_Je(t,a,s,1))return!0;if(n.parent.content.size==0&&(sA(o,"start")||Ka.isSelectable(o))){let l=zue(t.doc,n.before(),n.after(),Nn.empty);if(l&&l.slice.size{let{$head:n,empty:a}=t.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset=0;s--){let r=t.node(s);if(t.index(s)+1{let r=t.selection,n=r instanceof Ka,a;if(n){if(r.node.isTextblock||!Bw(t.doc,r.from))return!1;a=r.from}else if(a=Fue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ka.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},PRt=(t,s)=>{let r=t.selection,n;if(r instanceof Ka){if(r.node.isTextblock||!Bw(t.doc,r.to))return!1;n=r.to}else if(n=Fue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},IRt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&pE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},yJe=(t,s)=>{let{$head:r,$anchor:n}=t.selection;return!r.parent.type.spec.code||!r.sameParent(n)?!1:(s&&s(t.tr.insertText(` `).scrollIntoView()),!0)};function ake(t){for(let s=0;s{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return!1;let a=r.node(-1),o=r.indexAfter(-1),l=ake(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(s){let i=r.after(),c=t.tr.replaceWith(i,i,l.createAndFill());c.setSelection(xi.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},vJe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof wf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=ake(a.parent.contentMatchAt(a.indexAfter()));if(!o||!o.isTextblock)return!1;if(s){let l=(!n.parentOffset&&a.index(){let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let o=r.before();if(b1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&pE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function DRt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ka&&s.selection.node.isBlock)return!n.parentOffset||!b1(s.doc,n.pos)?!1:(r&&r(s.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,c=!1,u=!1;for(let v=n.depth;;v--)if(n.node(v).isBlock){c=n.end(v)==n.pos+(n.depth-v),u=n.start(v)==n.pos-(n.depth-v),i=ake(n.node(v-1).contentMatchAt(n.indexAfter(v-1))),o.unshift(c&&i?{type:i}:null),l=v;break}else{if(v==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof si||s.selection instanceof wf)&&p.deleteSelection();let f=p.mapping.map(n.pos),g=b1(p.doc,f,o.length,o);if(g||(o[0]=i?{type:i}:null,g=b1(p.doc,f,o.length,o)),!g)return!1;if(p.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let v=p.mapping.map(n.before(l)),_=p.doc.resolve(v);i&&n.node(l-1).canReplaceWith(_.index(),_.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const ORt=DRt(),RRt=(t,s)=>{let{$from:r,to:n}=t.selection,a,o=r.sharedDepth(n);return o==0?!1:(a=r.before(o),s&&s(t.tr.setSelection(Ka.create(t.doc,a))),!0)};function FRt(t,s,r){let n=s.nodeBefore,a=s.nodeAfter,o=s.index();return!n||!a||!n.type.compatibleContent(a.type)?!1:!n.content.size&&s.parent.canReplace(o-1,o)?(r&&r(t.tr.delete(s.pos-n.nodeSize,s.pos).scrollIntoView()),!0):!s.parent.canReplace(o,o+1)||!(a.isTextblock||Bw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function _Je(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&FRt(t,s,r))return!0;let u=!c&&s.parent.canReplace(s.index(),s.index()+1);if(u&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(r){let v=s.pos+o.nodeSize,_=Or.empty;for(let k=l.length-1;k>=0;k--)_=Or.from(l[k].create(null,_));_=Or.from(a.copy(_));let w=t.tr.step(new ah(s.pos-1,v,s.pos,v,new Nn(_,1,0),l.length,!0)),j=w.doc.resolve(v+2*l.length);j.nodeAfter&&j.nodeAfter.type==a.type&&Bw(w.doc,j.pos)&&w.join(j.pos),r(w.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&c?null:xi.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),g=f&&pE(f);if(g!=null&&g>=s.depth)return r&&r(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&sA(o,"start",!0)&&sA(a,"end")){let v=a,_=[];for(;_.push(v),!v.isTextblock;)v=v.lastChild;let w=o,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(v.canReplace(v.childCount,v.childCount,w.content)){if(r){let k=Or.empty;for(let M=_.length-1;M>=0;M--)k=Or.from(_[M].copy(k));let S=t.tr.step(new ah(s.pos-_.length,s.pos+o.nodeSize,s.pos+j,s.pos+o.nodeSize-j,new Nn(k,_.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function wJe(t){return function(s,r){let n=s.selection,a=t<0?n.$from:n.$to,o=a.depth;for(;a.node(o).isInline;){if(!o)return!1;o--}return a.node(o).isTextblock?(r&&r(s.tr.setSelection(si.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const zRt=wJe(-1),BRt=wJe(1);function $Rt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&UNe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function OLe(t,s=null){return function(r,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!c.isTextblock||c.hasMarkup(t,s)))if(c.type==t)a=!0;else{let p=r.doc.resolve(u),f=p.index();a=p.parent.canReplaceWith(f,f+1,t)}})}if(!a)return!1;if(n){let o=r.tr;for(let l=0;l=2&&s.$from.node(s.depth-1).type.compatibleContent(r)&&s.startIndex==0){if(s.$from.index(s.depth-1)==0)return!1;let c=l.resolve(s.start-2);o=new dle(c,c,s.depth),s.endIndex=0;p--)o=Or.from(r[p].type.create(r[p].attrs,o));t.step(new ah(s.start-(n?2:0),s.end,s.start,s.end,new Nn(o,0,0),r.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?GRt(s,r,t,o):WRt(s,r,o):!0:!1}}function GRt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;_--)v-=a.child(_).nodeSize,n.delete(v-1,v+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,c=r.endIndex==a.childCount,u=o.node(-1),p=o.index(-1);if(!u.canReplace(p+(i?0:1),p+1,l.content.append(c?Or.empty:Or.from(a))))return!1;let f=o.pos,g=f+l.nodeSize;return n.step(new ah(f-(i?1:0),g+(c?1:0),f+1,g-1,new Nn((i?Or.empty:Or.from(a.copy(Or.empty))).append(c?Or.empty:Or.from(a.copy(Or.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function KRt(t){return function(s,r){let{$from:n,$to:a}=s.selection,o=n.blockRange(a,u=>u.childCount>0&&u.firstChild.type==t);if(!o)return!1;let l=o.startIndex;if(l==0)return!1;let i=o.parent,c=i.child(l-1);if(c.type!=t)return!1;if(r){let u=c.lastChild&&c.lastChild.type==i.type,p=Or.from(u?t.create():null),f=new Nn(Or.from(t.create(null,Or.from(i.type.create(null,p)))),u?3:1,0),g=o.start,v=o.end;r(s.tr.step(new ah(g-(u?3:1),v,g,v,f,1,!0)).scrollIntoView())}return!0}}function Vue(t){const{state:s,transaction:r}=t;let{selection:n}=r,{doc:a}=r,{storedMarks:o}=r;return{...s,apply:s.apply.bind(s),applyTransaction:s.applyTransaction.bind(s),plugins:s.plugins,schema:s.schema,reconfigure:s.reconfigure.bind(s),toJSON:s.toJSON.bind(s),get storedMarks(){return o},get selection(){return n},get doc(){return a},get tr(){return n=r.selection,a=r.doc,o=r.storedMarks,r}}}class Hue{constructor(s){this.editor=s.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=s.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:s,editor:r,state:n}=this,{view:a}=r,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(s).map(([i,c])=>[i,(...p)=>{const f=c(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],c=!!s,u=s||o.tr,p=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(u),i.every(g=>g===!0)),f={...Object.fromEntries(Object.entries(n).map(([g,v])=>[g,(...w)=>{const j=this.buildProps(u,r),k=v(...w)(j);return i.push(k),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:Vue({state:o,transaction:s}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(s,r),can:()=>this.createCan(s),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...p)=>u(...p)(i)]))}};return i}}let ZRt=class{constructor(){this.callbacks={}}on(s,r){return this.callbacks[s]||(this.callbacks[s]=[]),this.callbacks[s].push(r),this}emit(s,...r){const n=this.callbacks[s];return n&&n.forEach(a=>a.apply(this,r)),this}off(s,r){const n=this.callbacks[s];return n&&(r?this.callbacks[s]=n.filter(a=>a!==r):delete this.callbacks[s]),this}once(s,r){const n=(...a)=>{this.off(s,n),r.apply(this,a)};return this.on(s,n)}removeAllListeners(){this.callbacks={}}};function ca(t,s,r){return t.config[s]===void 0&&t.parent?ca(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?ca(t.parent,s,r):null}):t.config[s]}function Gue(t){const s=t.filter(a=>a.type==="extension"),r=t.filter(a=>a.type==="node"),n=t.filter(a=>a.type==="mark");return{baseExtensions:s,nodeExtensions:r,markExtensions:n}}function jJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Gue(t),a=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},c=ca(l,"addGlobalAttributes",i);if(!c)return;c().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([g,v])=>{s.push({type:f,name:g,attribute:{...o,...v}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=ca(l,"addAttributes",i);if(!c)return;const u=c();Object.entries(u).forEach(([p,f])=>{const g={...o,...f};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,s.push({type:l.name,name:p,attribute:g})})}),s}function lh(t,s){if(typeof t=="string"){if(!s.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return s.nodes[t]}return t}function Gc(...t){return t.filter(s=>!!s).reduce((s,r)=>{const n={...s};return Object.entries(r).forEach(([a,o])=>{if(!n[a]){n[a]=o;return}if(a==="class"){const i=o?String(o).split(" "):[],c=n[a]?n[a].split(" "):[],u=i.filter(p=>!c.includes(p));n[a]=[...c,...u].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],c=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],u=new Map;c.forEach(p=>{const[f,g]=p.split(":").map(v=>v.trim());u.set(f,g)}),i.forEach(p=>{const[f,g]=p.split(":").map(v=>v.trim());u.set(f,g)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function K1e(t,s){return s.filter(r=>r.type===t.type.name).filter(r=>r.attribute.rendered).map(r=>r.attribute.renderHTML?r.attribute.renderHTML(t.attrs)||{}:{[r.name]:t.attrs[r.name]}).reduce((r,n)=>Gc(r,n),{})}function NJe(t){return typeof t=="function"}function to(t,s=void 0,...r){return NJe(t)?s?t.bind(s)(...r):t(...r):t}function YRt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function QRt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function RLe(t,s){return"style"in t?t:{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===!1)return!1;const a=s.reduce((o,l)=>{const i=l.attribute.parseHTML?l.attribute.parseHTML(r):QRt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function FLe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&YRt(r)?!1:r!=null))}function XRt(t,s){var r;const n=jJe(t),{nodeExtensions:a,markExtensions:o}=Gue(t),l=(r=a.find(u=>ca(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(k=>k.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((k,S)=>{const M=ca(S,"extendNodeSchema",f);return{...k,...M?M(u):{}}},{}),v=FLe({...g,content:to(ca(u,"content",f)),marks:to(ca(u,"marks",f)),group:to(ca(u,"group",f)),inline:to(ca(u,"inline",f)),atom:to(ca(u,"atom",f)),selectable:to(ca(u,"selectable",f)),draggable:to(ca(u,"draggable",f)),code:to(ca(u,"code",f)),whitespace:to(ca(u,"whitespace",f)),linebreakReplacement:to(ca(u,"linebreakReplacement",f)),defining:to(ca(u,"defining",f)),isolating:to(ca(u,"isolating",f)),attrs:Object.fromEntries(p.map(k=>{var S;return[k.name,{default:(S=k==null?void 0:k.attribute)===null||S===void 0?void 0:S.default}]}))}),_=to(ca(u,"parseHTML",f));_&&(v.parseDOM=_.map(k=>RLe(k,p)));const w=ca(u,"renderHTML",f);w&&(v.toDOM=k=>w({node:k,HTMLAttributes:K1e(k,p)}));const j=ca(u,"renderText",f);return j&&(v.toText=j),[u.name,v]})),c=Object.fromEntries(o.map(u=>{const p=n.filter(j=>j.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((j,k)=>{const S=ca(k,"extendMarkSchema",f);return{...j,...S?S(u):{}}},{}),v=FLe({...g,inclusive:to(ca(u,"inclusive",f)),excludes:to(ca(u,"excludes",f)),group:to(ca(u,"group",f)),spanning:to(ca(u,"spanning",f)),code:to(ca(u,"code",f)),attrs:Object.fromEntries(p.map(j=>{var k;return[j.name,{default:(k=j==null?void 0:j.attribute)===null||k===void 0?void 0:k.default}]}))}),_=to(ca(u,"parseHTML",f));_&&(v.parseDOM=_.map(j=>RLe(j,p)));const w=ca(u,"renderHTML",f);return w&&(v.toDOM=j=>w({mark:j,HTMLAttributes:K1e(j,p)})),[u.name,v]}));return new uXe({topNode:l,nodes:i,marks:c})}function Nge(t,s){return s.nodes[t]||s.marks[t]||null}function zLe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function oke(t,s){const r=C3.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const JRt=(t,s=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-s),n,(a,o,l,i)=>{var c,u;const p=((u=(c=a.type.spec).toText)===null||u===void 0?void 0:u.call(c,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";r+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),r};function lke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Wue{constructor(s){this.find=s.find,this.handler=s.handler}}const eFt=(t,s)=>{if(lke(s))return s.exec(t);const r=s(t);if(!r)return null;const n=[r.text];return n.index=r.index,n.input=t,n.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(r.replaceWith)),n};function Nz(t){var s;const{editor:r,from:n,to:a,text:o,rules:l,plugin:i}=t,{view:c}=r;if(c.composing)return!1;const u=c.state.doc.resolve(n);if(u.parent.type.spec.code||!((s=u.nodeBefore||u.nodeAfter)===null||s===void 0)&&s.marks.find(g=>g.type.spec.code))return!1;let p=!1;const f=JRt(u)+o;return l.forEach(g=>{if(p)return;const v=eFt(f,g.find);if(!v)return;const _=c.state.tr,w=Vue({state:c.state,transaction:_}),j={from:n-(v[0].length-o.length),to:a},{commands:k,chain:S,can:M}=new Hue({editor:r,state:w});g.handler({state:w,range:j,match:v,commands:k,chain:S,can:M})===null||!_.steps.length||(_.setMeta(i,{transform:_,from:n,to:a,text:o}),c.dispatch(_),p=!0)}),p}function tFt(t){const{editor:s,rules:r}=t,n=new Du({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const c=a.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:p}=c;typeof p=="string"?p=p:p=oke(Or.from(p),l.schema);const{from:f}=c,g=f+p.length;Nz({editor:s,from:f,to:g,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return Nz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&Nz({editor:s,from:o.pos,to:o.pos,text:"",rules:r,plugin:n})}),!1)},handleKeyDown(a,o){if(o.key!=="Enter")return!1;const{$cursor:l}=a.state.selection;return l?Nz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function sFt(t){return Object.prototype.toString.call(t).slice(8,-1)}function kz(t){return sFt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Kue(t,s){const r={...t};return kz(t)&&kz(s)&&Object.keys(s).forEach(n=>{kz(s[n])&&kz(t[n])?r[n]=Kue(t[n],s[n]):r[n]=s[n]}),r}class dy{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=to(ca(this,"addOptions",{name:this.name}))),this.storage=to(ca(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new dy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Kue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new dy(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=to(ca(r,"addOptions",{name:r.name})),r.storage=to(ca(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:s,mark:r}){const{tr:n}=s.state,a=s.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const c=l.find(u=>(u==null?void 0:u.type.name)===r.name);return c&&n.removeStoredMark(c),n.insertText(" ",a.pos),s.view.dispatch(n),!0}return!1}}function rFt(t){return typeof t=="number"}class nFt{constructor(s){this.find=s.find,this.handler=s.handler}}const aFt=(t,s,r)=>{if(lke(s))return[...t.matchAll(s)];const n=s(t,r);return n?n.map(a=>{const o=[a.text];return o.index=a.index,o.input=t,o.data=a.data,a.replaceWith&&(a.text.includes(a.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(a.replaceWith)),o}):[]};function iFt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:p}=new Hue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(v,_)=>{if(!v.isTextblock||v.type.spec.code)return;const w=Math.max(n,_),j=Math.min(a,_+v.content.size),k=v.textBetween(w-_,j-_,void 0,"");aFt(k,o.find,l).forEach(M=>{if(M.index===void 0)return;const L=w+M.index+1,P=L+M[0].length,O={from:r.tr.mapping.map(L),to:r.tr.mapping.map(P)},$=o.handler({state:r,range:O,match:M,commands:c,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push($)})}),f.every(v=>v!==null)}let Sz=null;const oFt=t=>{var s;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(s=r.clipboardData)===null||s===void 0||s.setData("text/html",t),r};function lFt(t){const{editor:s,rules:r}=t;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const c=({state:p,from:f,to:g,rule:v,pasteEvt:_})=>{const w=p.tr,j=Vue({state:p,transaction:w});if(!(!iFt({editor:s,state:j,from:Math.max(f-1,0),to:g.b-1,rule:v,pasteEvent:_,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(p=>new Du({view(f){const g=_=>{var w;n=!((w=f.dom.parentElement)===null||w===void 0)&&w.contains(_.target)?f.dom.parentElement:null,n&&(Sz=s)},v=()=>{Sz&&(Sz=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",v),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",v)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(o=n===f.dom.parentElement,i=g,!o){const v=Sz;v!=null&&v.isEditable&&setTimeout(()=>{const _=v.state.selection;_&&v.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,g)=>{var v;const _=(v=g.clipboardData)===null||v===void 0?void 0:v.getData("text/html");return l=g,a=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(f,g,v)=>{const _=f[0],w=_.getMeta("uiEvent")==="paste"&&!a,j=_.getMeta("uiEvent")==="drop"&&!o,k=_.getMeta("applyPasteRules"),S=!!k;if(!w&&!j&&!S)return;if(S){let{text:P}=k;typeof P=="string"?P=P:P=oke(Or.from(P),v.schema);const{from:O}=k,$=O+P.length,U=oFt(P);return c({rule:p,state:v,from:O,to:{b:$},pasteEvt:U})}const M=g.doc.content.findDiffStart(v.doc.content),L=g.doc.content.findDiffEnd(v.doc.content);if(!(!rFt(M)||!L||M===L.b))return c({rule:p,state:v,from:M,to:L,pasteEvt:l})}}))}function cFt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class vM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=vM.resolve(s),this.schema=XRt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=vM.sort(vM.flatten(s)),n=cFt(r.map(a=>a.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(a=>`'${a}'`).join(", ")}]. This can lead to issues.`),r}static flatten(s){return s.map(r=>{const n={name:r.name,options:r.options,storage:r.storage},a=ca(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=ca(n,"priority")||100,l=ca(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:Nge(r.name,this.schema)},a=ca(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=vM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:Nge(l.name,this.schema)},c=[],u=ca(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&ca(l,"exitable",i)&&(p.ArrowRight=()=>dy.handleExit({editor:s,mark:l})),u){const w=Object.fromEntries(Object.entries(u()).map(([j,k])=>[j,()=>k({editor:s})]));p={...p,...w}}const f=MRt(p);c.push(f);const g=ca(l,"addInputRules",i);zLe(l,s.options.enableInputRules)&&g&&n.push(...g());const v=ca(l,"addPasteRules",i);zLe(l,s.options.enablePasteRules)&&v&&a.push(...v());const _=ca(l,"addProseMirrorPlugins",i);if(_){const w=_();c.push(...w)}return c}).flat();return[tFt({editor:s,rules:n}),...lFt({editor:s,rules:a}),...o]}get attributes(){return jJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Gue(this.extensions);return Object.fromEntries(r.filter(n=>!!ca(n,"addNodeView")).map(n=>{const a=this.attributes.filter(c=>c.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:s,type:lh(n.name,this.schema)},l=ca(n,"addNodeView",o);if(!l)return[];const i=(c,u,p,f,g)=>{const v=K1e(c,a);return l()({node:c,view:u,getPos:p,decorations:f,innerDecorations:g,editor:s,extension:n,HTMLAttributes:v})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:Nge(s.name,this.schema)};s.type==="mark"&&(!((r=to(ca(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=ca(s,"onBeforeCreate",n),o=ca(s,"onCreate",n),l=ca(s,"onUpdate",n),i=ca(s,"onSelectionUpdate",n),c=ca(s,"onTransaction",n),u=ca(s,"onFocus",n),p=ca(s,"onBlur",n),f=ca(s,"onDestroy",n);a&&this.editor.on("beforeCreate",a),o&&this.editor.on("create",o),l&&this.editor.on("update",l),i&&this.editor.on("selectionUpdate",i),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),p&&this.editor.on("blur",p),f&&this.editor.on("destroy",f)})}}class Dh{constructor(s={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=to(ca(this,"addOptions",{name:this.name}))),this.storage=to(ca(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Dh(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Kue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Dh({...this.config,...s});return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=to(ca(r,"addOptions",{name:r.name})),r.storage=to(ca(r,"addStorage",{name:r.name,options:r.options})),r}}function kJe(t,s,r){const{from:n,to:a}=s,{blockSeparator:o=` `,textSerializers:l={}}=r||{};let i="";return t.nodesBetween(n,a,(c,u,p,f)=>{var g;c.isBlock&&u>n&&(i+=o);const v=l==null?void 0:l[c.type.name];if(v)return p&&(i+=v({node:c,pos:u,parent:p,index:f,range:s})),!1;c.isText&&(i+=(g=c==null?void 0:c.text)===null||g===void 0?void 0:g.slice(Math.max(n,u)-u,a-u))}),i}function SJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const dFt=Dh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Du({key:new sm("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:s,schema:r}=t,{doc:n,selection:a}=s,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),c=SJe(r);return kJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),uFt=()=>({editor:t,view:s})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(s.dom.blur(),(r=window==null?void 0:window.getSelection())===null||r===void 0||r.removeAllRanges())}),!0),hFt=(t=!1)=>({commands:s})=>s.setContent("",t),mFt=()=>({state:t,tr:s,dispatch:r})=>{const{selection:n}=s,{ranges:a}=n;return r&&a.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(i,c)=>{if(i.type.isText)return;const{doc:u,mapping:p}=s,f=u.resolve(p.map(c)),g=u.resolve(p.map(c+i.nodeSize)),v=f.blockRange(g);if(!v)return;const _=pE(v);if(i.type.isTextblock){const{defaultType:w}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(v.start,w)}(_||_===0)&&s.lift(v,_)})}),!0},pFt=t=>s=>t(s),fFt=()=>({state:t,dispatch:s})=>vJe(t,s),xFt=(t,s)=>({editor:r,tr:n})=>{const{state:a}=r,o=a.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const l=n.mapping.map(s);return n.insert(l,o.content),n.setSelection(new si(n.doc.resolve(Math.max(l-1,0)))),!0},gFt=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const a=t.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(s){const i=a.before(o),c=a.after(o);t.delete(i,c).scrollIntoView()}return!0}return!1},yFt=t=>({tr:s,state:r,dispatch:n})=>{const a=lh(t,r.schema),o=s.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const c=o.before(l),u=o.after(l);s.delete(c,u).scrollIntoView()}return!0}return!1},vFt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},bFt=()=>({state:t,dispatch:s})=>ske(t,s),_Ft=()=>({commands:t})=>t.keyboardShortcut("Enter"),wFt=()=>({state:t,dispatch:s})=>LRt(t,s);function yle(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:lke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function CJe(t,s,r={}){return t.find(n=>n.type===s&&yle(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function BLe(t,s,r={}){return!!CJe(t,s,r)}function cke(t,s,r){var n;if(!t||!s)return;let a=t.parent.childAfter(t.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===s))&&(a=t.parent.childBefore(t.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===s)||(r=r||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!CJe([...a.node.marks],s,r)))return;let l=a.index,i=t.start()+a.offset,c=l+1,u=i+a.node.nodeSize;for(;l>0&&BLe([...t.parent.child(l-1).marks],s,r);)l-=1,i-=t.parent.child(l).nodeSize;for(;c({tr:r,state:n,dispatch:a})=>{const o=qw(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:p}=i;if(a){const f=cke(c,o,s);if(f&&f.from<=u&&f.to>=p){const g=si.create(l,f.from,f.to);r.setSelection(g)}}return!0},NFt=t=>s=>{const r=typeof t=="function"?t(s):t;for(let n=0;n({editor:r,view:n,tr:a,dispatch:o})=>{s={scrollIntoView:!0,...s};const l=()=>{(dke()||kFt())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),s!=null&&s.scrollIntoView&&r.commands.scrollIntoView())})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!MJe(r.state.selection))return l(),!0;const i=TJe(a.doc,t)||r.state.selection,c=r.state.selection.eq(i);return o&&(c||a.setSelection(i),c&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},CFt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),MFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),AJe=t=>{const s=t.childNodes;for(let r=s.length-1;r>=0;r-=1){const n=s[r];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?t.removeChild(n):n.nodeType===1&&AJe(n)}return t};function Cz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return AJe(r)}function SD(t,s,r){if(t instanceof nw||t instanceof Or)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,a=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Or.fromArray(t.map(i=>s.nodeFromJSON(i)));const l=s.nodeFromJSON(t);return r.errorOnInvalidContent&&l.check(),l}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),SD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new uXe({topNode:s.spec.topNode,marks:s.spec.marks,nodes:s.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(l=!0,i=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?h8.fromSchema(c).parseSlice(Cz(t),r.parseOptions):h8.fromSchema(c).parse(Cz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=h8.fromSchema(s);return r.slice?o.parseSlice(Cz(t),r.parseOptions).content:o.parse(Cz(t),r.parseOptions)}return SD("",s,r)}function TFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(xi.near(t.doc.resolve(l),r))}const AFt=t=>!("type"in t),EFt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const c=j=>{o.emit("contentError",{editor:o,error:j,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{SD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(j){c(j)}try{i=SD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(j){return c(j),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,v=!0;if((AFt(i)?i:[i]).forEach(j=>{j.check(),g=g?j.isText&&j.marks.length===0:!1,v=v?j.isBlock:!1}),p===f&&v){const{parent:j}=n.doc.resolve(p);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(p-=1,f+=1)}let w;if(g){if(Array.isArray(s))w=s.map(j=>j.text||"").join("");else if(s instanceof Or){let j="";s.forEach(k=>{k.text&&(j+=k.text)}),w=j}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,p,f)}else w=i,n.replaceWith(p,f,w);r.updateSelection&&TFt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:w})}return!0},PFt=()=>({state:t,dispatch:s})=>ERt(t,s),IFt=()=>({state:t,dispatch:s})=>PRt(t,s),LFt=()=>({state:t,dispatch:s})=>hJe(t,s),DFt=()=>({state:t,dispatch:s})=>xJe(t,s),OFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Fue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},RFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Fue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},FFt=()=>({state:t,dispatch:s})=>TRt(t,s),zFt=()=>({state:t,dispatch:s})=>ARt(t,s);function EJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function BFt(t){const s=t.split(/-(?!$)/);let r=s[s.length-1];r==="Space"&&(r=" ");let n,a,o,l;for(let i=0;i({editor:s,view:r,tr:n,dispatch:a})=>{const o=BFt(t).split(/-(?!$)/),l=o.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),i=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=s.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,i))});return c==null||c.steps.forEach(u=>{const p=u.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function CD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?lh(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,g)=>{if(f.isText)return;const v=Math.max(n,g),_=Math.min(a,g+f.nodeSize);i.push({node:f,from:v,to:_})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>yle(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}const qFt=(t,s={})=>({state:r,dispatch:n})=>{const a=lh(t,r.schema);return CD(r,a,s)?IRt(r,n):!1},UFt=()=>({state:t,dispatch:s})=>bJe(t,s),VFt=t=>({state:s,dispatch:r})=>{const n=lh(t,s.schema);return HRt(n)(s,r)},HFt=()=>({state:t,dispatch:s})=>yJe(t,s);function Zue(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function $Le(t,s){const r=typeof s=="string"?[s]:s;return Object.keys(t).reduce((n,a)=>(r.includes(a)||(n[a]=t[a]),n),{})}const GFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Zue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=lh(t,n.schema)),i==="mark"&&(l=qw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,p)=>{o&&o===u.type&&r.setNodeMarkup(p,void 0,$Le(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create($Le(f.attrs,s)))})})}),!0):!1},WFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),KFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new wf(t.doc);t.setSelection(r)}return!0},ZFt=()=>({state:t,dispatch:s})=>pJe(t,s),YFt=()=>({state:t,dispatch:s})=>gJe(t,s),QFt=()=>({state:t,dispatch:s})=>RRt(t,s),XFt=()=>({state:t,dispatch:s})=>BRt(t,s),JFt=()=>({state:t,dispatch:s})=>zRt(t,s);function Z1e(t,s,r={},n={}){return SD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const e7t=(t,s=!1,r={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var c,u;const{doc:p}=o;if(r.preserveWhitespace!=="full"){const f=Z1e(t,a.schema,r,{errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,f).setMeta("preventUpdate",!s),!0}return l&&o.setMeta("preventUpdate",!s),i.insertContentAt({from:0,to:p.content.size},t,{parseOptions:r,errorOnInvalidContent:(u=n.errorOnInvalidContent)!==null&&u!==void 0?u:a.options.enableContentCheck})};function PJe(t,s){const r=qw(s,t.schema),{from:n,to:a,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,a,c=>{l.push(...c.marks)});const i=l.find(c=>c.type.name===r.name);return i?{...i.attrs}:{}}function t7t(t,s){const r=new VNe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function s7t(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function IJe(t,s){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(s(n))return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}function uke(t){return s=>IJe(s.$from,t)}function n7t(t,s){const r={from:0,to:t.content.size};return kJe(t,r,s)}function a7t(t,s){const r=lh(s,t.schema),{from:n,to:a}=t.selection,o=[];t.doc.nodesBetween(n,a,i=>{o.push(i)});const l=o.reverse().find(i=>i.type.name===r.name);return l?{...l.attrs}:{}}function LJe(t,s){const r=Zue(typeof s=="string"?s:s.name,t.schema);return r==="node"?a7t(t,s):r==="mark"?PJe(t,s):{}}function i7t(t,s=JSON.stringify){const r={};return t.filter(n=>{const a=s(n);return Object.prototype.hasOwnProperty.call(r,a)?!1:r[a]=!0})}function o7t(t){const s=i7t(t);return s.length===1?s:s.filter((r,n)=>!s.filter((o,l)=>l!==n).some(o=>r.oldRange.from>=o.oldRange.from&&r.oldRange.to<=o.oldRange.to&&r.newRange.from>=o.newRange.from&&r.newRange.to<=o.newRange.to))}function l7t(t){const{mapping:s,steps:r}=t,n=[];return s.maps.forEach((a,o)=>{const l=[];if(a.ranges.length)a.forEach((i,c)=>{l.push({from:i,to:c})});else{const{from:i,to:c}=r[o];if(i===void 0||c===void 0)return;l.push({from:i,to:c})}l.forEach(({from:i,to:c})=>{const u=s.slice(o).map(i,-1),p=s.slice(o).map(c),f=s.invert().map(u,-1),g=s.invert().map(p);n.push({oldRange:{from:f,to:g},newRange:{from:u,to:p}})})}),o7t(n)}function hke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=cke(o,a.type);l&&n.push({mark:a,...l})}):r.nodesBetween(t,s,(a,o)=>{!a||(a==null?void 0:a.nodeSize)===void 0||n.push(...a.marks.map(l=>({from:o,to:o+a.nodeSize,mark:l})))}),n}function Rie(t,s,r){return Object.fromEntries(Object.entries(r).filter(([n])=>{const a=t.find(o=>o.type===s&&o.name===n);return a?a.attribute.keepOnSplit:!1}))}function Y1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?qw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>yle(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:g})=>{const v=f.pos,_=g.pos;t.doc.nodesBetween(v,_,(w,j)=>{if(!w.isText&&!w.marks.length)return;const k=Math.max(v,j),S=Math.min(_,j+w.nodeSize),M=S-k;l+=M,i.push(...w.marks.map(L=>({mark:L,from:k,to:S})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>yle(f.mark.attrs,r,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=l}function c7t(t,s,r={}){if(!s)return CD(t,null,r)||Y1e(t,null,r);const n=Zue(s,t.schema);return n==="node"?CD(t,s,r):n==="mark"?Y1e(t,s,r):!1}function qLe(t,s){const{nodeExtensions:r}=Gue(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=to(ca(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function mke(t,{checkChildren:s=!0,ignoreWhitespace:r=!1}={}){var n;if(r){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((n=t.text)!==null&&n!==void 0?n:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(s){let a=!0;return t.content.forEach(o=>{a!==!1&&(mke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function d7t(t){return t instanceof Ka}function u7t(t,s,r){var n;const{selection:a}=s;let o=null;if(MJe(a)&&(o=a.$cursor),o){const i=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(i)||!i.some(c=>c.type.excludes(r))}const{ranges:l}=a;return l.some(({$from:i,$to:c})=>{let u=i.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(i.pos,c.pos,(p,f,g)=>{if(u)return!1;if(p.isInline){const v=!g||g.type.allowsMarkType(r),_=!!r.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(r));u=v&&_}return!u}),u})}const h7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=qw(t,n.schema);if(a)if(l){const u=PJe(n,c);r.addStoredMark(c.create({...u,...s}))}else i.forEach(u=>{const p=u.$from.pos,f=u.$to.pos;n.doc.nodesBetween(p,f,(g,v)=>{const _=Math.max(v,p),w=Math.min(v+g.nodeSize,f);g.marks.find(k=>k.type===c)?g.marks.forEach(k=>{c===k.type&&r.addMark(_,w,c.create({...k.attrs,...s}))}):r.addMark(_,w,c.create(s))})});return u7t(n,r,c)},m7t=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),p7t=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=lh(t,r.schema);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o.isTextblock?a().command(({commands:i})=>OLe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>OLe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},f7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=A4(t,0,n.content.size),o=Ka.create(n,a);s.setSelection(o)}return!0},x7t=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=si.atStart(n).from,i=si.atEnd(n).to,c=A4(a,l,i),u=A4(o,l,i),p=si.create(n,c,u);s.setSelection(p)}return!0},g7t=t=>({state:s,dispatch:r})=>{const n=lh(t,s.schema);return KRt(n)(s,r)};function ULe(t,s){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter(a=>s==null?void 0:s.includes(a.type.name));t.tr.ensureMarks(n)}}const y7t=({keepMarks:t=!0}={})=>({tr:s,state:r,dispatch:n,editor:a})=>{const{selection:o,doc:l}=s,{$from:i,$to:c}=o,u=a.extensionManager.attributes,p=Rie(u,i.node().type.name,i.node().attrs);if(o instanceof Ka&&o.node.isBlock)return!i.parentOffset||!b1(l,i.pos)?!1:(n&&(t&&ULe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=i.depth===0?void 0:s7t(i.node(-1).contentMatchAt(i.indexAfter(-1)));let v=f&&g?[{type:g,attrs:p}]:void 0,_=b1(s.doc,s.mapping.map(i.pos),1,v);if(!v&&!_&&b1(s.doc,s.mapping.map(i.pos),1,g?[{type:g}]:void 0)&&(_=!0,v=g?[{type:g,attrs:p}]:void 0),n){if(_&&(o instanceof si&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,v),g&&!f&&!i.parentOffset&&i.parent.type!==g)){const w=s.mapping.map(i.before()),j=s.doc.resolve(w);i.node(-1).canReplaceWith(j.index(),j.index()+1,g)&&s.setNodeMarkup(s.mapping.map(i.before()),g)}t&&ULe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return _},v7t=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=lh(t,n.schema),{$from:c,$to:u}=n.selection,p=n.selection.node;if(p&&p.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==i)return!1;const g=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==i||c.index(-2)!==c.node(-2).childCount-1)return!1;if(a){let k=Or.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let U=c.depth-S;U>=c.depth-3;U-=1)k=Or.from(c.node(U).copy(k));const M=c.indexAfter(-1){if($>-1)return!1;U.isTextblock&&U.content.size===0&&($=B+1)}),$>-1&&r.setSelection(si.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const v=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,_={...Rie(g,f.type.name,f.attrs),...s},w={...Rie(g,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const j=v?[{type:i,attrs:_},{type:v,attrs:w}]:[{type:i,attrs:_}];if(!b1(r.doc,c.pos,2))return!1;if(a){const{selection:k,storedMarks:S}=n,{splittableMarks:M}=o.extensionManager,L=S||k.$to.parentOffset&&k.$from.marks();if(r.split(c.pos,2,j).scrollIntoView(),!L||!a)return!0;const P=L.filter(O=>M.includes(O.type.name));r.ensureMarks(P)}return!0},kge=(t,s)=>{const r=uke(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&Bw(t.doc,r.pos)&&t.join(r.pos),!0},Sge=(t,s)=>{const r=uke(l=>l.type===s)(t.selection);if(!r)return!0;const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0)return!0;const a=t.doc.nodeAt(n);return r.node.type===(a==null?void 0:a.type)&&Bw(t.doc,n)&&t.join(n),!0},b7t=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:c,commands:u,can:p})=>{const{extensions:f,splittableMarks:g}=a.extensionManager,v=lh(t,l.schema),_=lh(s,l.schema),{selection:w,storedMarks:j}=l,{$from:k,$to:S}=w,M=k.blockRange(S),L=j||w.$to.parentOffset&&w.$from.marks();if(!M)return!1;const P=uke(O=>qLe(O.type.name,f))(w);if(M.depth>=1&&P&&M.depth-P.depth<=1){if(P.node.type===v)return u.liftListItem(_);if(qLe(P.node.type.name,f)&&v.validContent(P.node.content)&&i)return c().command(()=>(o.setNodeMarkup(P.pos,v),!0)).command(()=>kge(o,v)).command(()=>Sge(o,v)).run()}return!r||!L||!i?c().command(()=>p().wrapInList(v,n)?!0:u.clearNodes()).wrapInList(v,n).command(()=>kge(o,v)).command(()=>Sge(o,v)).run():c().command(()=>{const O=p().wrapInList(v,n),$=L.filter(U=>g.includes(U.type.name));return o.ensureMarks($),O?!0:u.clearNodes()}).wrapInList(v,n).command(()=>kge(o,v)).command(()=>Sge(o,v)).run()},_7t=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=qw(t,n.schema);return Y1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},w7t=(t,s,r={})=>({state:n,commands:a})=>{const o=lh(t,n.schema),l=lh(s,n.schema),i=CD(n,o,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),i?a.setNode(l,c):a.setNode(o,{...c,...r})},j7t=(t,s={})=>({state:r,commands:n})=>{const a=lh(t,r.schema);return CD(r,a,s)?n.lift(a):n.wrapIn(a,s)},N7t=()=>({state:t,dispatch:s})=>{const r=t.plugins;for(let n=0;n=0;c-=1)l.step(i.steps[c].invert(i.docs[c]));if(o.text){const c=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else l.delete(o.from,o.to)}return!0}}return!1},k7t=()=>({tr:t,dispatch:s})=>{const{selection:r}=t,{empty:n,ranges:a}=r;return n||s&&a.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},S7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=qw(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:g,to:v}=i;const _=(o=u.marks().find(j=>j.type===c))===null||o===void 0?void 0:o.attrs,w=cke(u,c,_);w&&(g=w.from,v=w.to),r.removeMark(g,v,c)}else f.forEach(g=>{r.removeMark(g.$from.pos,g.$to.pos,c)});return r.removeStoredMark(c),!0},C7t=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Zue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=lh(t,n.schema)),i==="mark"&&(l=qw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,p=c.$to.pos;let f,g,v,_;r.selection.empty?n.doc.nodesBetween(u,p,(w,j)=>{o&&o===w.type&&(v=Math.max(j,u),_=Math.min(j+w.nodeSize,p),f=j,g=w)}):n.doc.nodesBetween(u,p,(w,j)=>{j=u&&j<=p&&(o&&o===w.type&&r.setNodeMarkup(j,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(k=>{if(l===k.type){const S=Math.max(j,u),M=Math.min(j+w.nodeSize,p);r.addMark(S,M,l.create({...k.attrs,...s}))}}))}),g&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...g.attrs,...s}),l&&g.marks.length&&g.marks.forEach(w=>{l===w.type&&r.addMark(v,_,l.create({...w.attrs,...s}))}))}),!0):!1},M7t=(t,s={})=>({state:r,dispatch:n})=>{const a=lh(t,r.schema);return $Rt(a,s)(r,n)},T7t=(t,s={})=>({state:r,dispatch:n})=>{const a=lh(t,r.schema);return qRt(a,s)(r,n)};var A7t=Object.freeze({__proto__:null,blur:uFt,clearContent:hFt,clearNodes:mFt,command:pFt,createParagraphNear:fFt,cut:xFt,deleteCurrentNode:gFt,deleteNode:yFt,deleteRange:vFt,deleteSelection:bFt,enter:_Ft,exitCode:wFt,extendMarkRange:jFt,first:NFt,focus:SFt,forEach:CFt,insertContent:MFt,insertContentAt:EFt,joinBackward:LFt,joinDown:IFt,joinForward:DFt,joinItemBackward:OFt,joinItemForward:RFt,joinTextblockBackward:FFt,joinTextblockForward:zFt,joinUp:PFt,keyboardShortcut:$Ft,lift:qFt,liftEmptyBlock:UFt,liftListItem:VFt,newlineInCode:HFt,resetAttributes:GFt,scrollIntoView:WFt,selectAll:KFt,selectNodeBackward:ZFt,selectNodeForward:YFt,selectParentNode:QFt,selectTextblockEnd:XFt,selectTextblockStart:JFt,setContent:e7t,setMark:h7t,setMeta:m7t,setNode:p7t,setNodeSelection:f7t,setTextSelection:x7t,sinkListItem:g7t,splitBlock:y7t,splitListItem:v7t,toggleList:b7t,toggleMark:_7t,toggleNode:w7t,toggleWrap:j7t,undoInputRule:N7t,unsetAllMarks:k7t,unsetMark:S7t,updateAttributes:C7t,wrapIn:M7t,wrapInList:T7t});const E7t=Dh.create({name:"commands",addCommands(){return{...A7t}}}),P7t=Dh.create({name:"drop",addProseMirrorPlugins(){return[new Du({key:new sm("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),I7t=Dh.create({name:"editable",addProseMirrorPlugins(){return[new Du({key:new sm("editable"),props:{editable:()=>this.editor.options.editable}})]}}),L7t=new sm("focusEvents"),D7t=Dh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Du({key:L7t,props:{handleDOMEvents:{focus:(s,r)=>{t.isFocused=!0;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1},blur:(s,r)=>{t.isFocused=!1;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",!1);return s.dispatch(n),!1}}}})]}}),O7t=Dh.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:c,doc:u}=i,{empty:p,$anchor:f}=c,{pos:g,parent:v}=f,_=f.parent.isTextblock&&g>0?i.doc.resolve(g-1):f,w=_.parent.type.spec.isolating,j=f.pos-f.parentOffset,k=w&&_.parent.childCount===1?j===f.pos:xi.atStart(u).from===g;return!p||!v.type.isTextblock||v.textContent.length||!k||k&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return dke()||EJe()?o:a},addProseMirrorPlugins(){return[new Du({key:new sm("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=xi.atStart(s.doc).from,u=xi.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!mke(r.doc))return;const g=r.tr,v=Vue({state:r,transaction:g}),{commands:_}=new Hue({editor:this.editor,state:v});if(_.clearNodes(),!!g.steps.length)return g}})]}}),R7t=Dh.create({name:"paste",addProseMirrorPlugins(){return[new Du({key:new sm("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),F7t=Dh.create({name:"tabindex",addProseMirrorPlugins(){return[new Du({key:new sm("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class g4{get name(){return this.node.type.name}constructor(s,r,n=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=s,this.editor=r,this.currentNode=a}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var s;return(s=this.actualDepth)!==null&&s!==void 0?s:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(s){let r=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}r=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:r,to:n},s)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const s=this.resolvedPos.start(this.resolvedPos.depth-1),r=this.resolvedPos.doc.resolve(s);return new g4(r,this.editor)}get before(){let s=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.from-3)),new g4(s,this.editor)}get after(){let s=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return s.depth!==this.depth&&(s=this.resolvedPos.doc.resolve(this.to+3)),new g4(s,this.editor)}get children(){const s=[];return this.node.content.forEach((r,n)=>{const a=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,l=this.pos+n+(o?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const i=this.resolvedPos.doc.resolve(l);if(!a&&i.depth<=this.depth)return;const c=new g4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new g4(i,this.editor,a,a?r:null))}),s}get firstChild(){return this.children[0]||null}get lastChild(){const s=this.children;return s[s.length-1]||null}closest(s,r={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===s)if(Object.keys(r).length>0){const o=a.node.attrs,l=Object.keys(r);for(let i=0;i{n&&a.length>0||(l.node.type.name===s&&o.every(c=>r[c]===l.node.attrs[c])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(s,r,n))))}),a}setAttribute(s){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...s}),this.editor.view.dispatch(r)}}const z7t=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;function B7t(t,s,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const a=document.createElement("style");return s&&a.setAttribute("nonce",s),a.setAttribute("data-tiptap-style",""),a.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(a),a}class $7t extends ZRt{constructor(s={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(s),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:n,moved:a})=>this.options.onDrop(r,n,a)),this.on("paste",({event:r,slice:n})=>this.options.onPaste(r,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=B7t(z7t,this.options.injectNonce))}setOptions(s={}){this.options={...this.options,...s},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(s,r=!0){this.setOptions({editable:s}),r&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(s,r){const n=NJe(r)?r(s,[...this.state.plugins]):[...this.state.plugins,s],a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}unregisterPlugin(s){if(this.isDestroyed)return;const r=this.state.plugins;let n=r;if([].concat(s).forEach(o=>{const l=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(l))}),r.length===n.length)return;const a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}createExtensionManager(){var s,r;const a=[...this.options.enableCoreExtensions?[I7t,dFt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),E7t,D7t,O7t,F7t,P7t,R7t].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new vM(a,this)}createCommandManager(){this.commandManager=new Hue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=Z1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(l){if(!(l instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(l.message))throw l;this.emit("contentError",{editor:this,error:l,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(i=>i.name!=="collaboration"),this.createExtensionManager()}}),r=Z1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=TJe(r,this.options.autofocus);this.view=new dJe(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(s=this.options.editorProps)===null||s===void 0?void 0:s.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:yM.create({doc:r,selection:n||void 0})});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(s){this.isCapturingTransaction=!0,s(),this.isCapturingTransaction=!1;const r=this.capturedTransaction;return this.capturedTransaction=null,r}dispatchTransaction(s){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=s;return}s.steps.forEach(l=>{var i;return(i=this.capturedTransaction)===null||i===void 0?void 0:i.step(l)});return}const r=this.state.apply(s),n=!this.state.selection.eq(r.selection);this.emit("beforeTransaction",{editor:this,transaction:s,nextState:r}),this.view.updateState(r),this.emit("transaction",{editor:this,transaction:s}),n&&this.emit("selectionUpdate",{editor:this,transaction:s});const a=s.getMeta("focus"),o=s.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:s}),o&&this.emit("blur",{editor:this,event:o.event,transaction:s}),!(!s.docChanged||s.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:s})}getAttributes(s){return LJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return c7t(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return oke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return n7t(this.state.doc,{blockSeparator:r,textSerializers:{...SJe(this.schema),...n}})}get isEmpty(){return mke(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const s=this.view.dom;s&&s.editor&&delete s.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var s;return!(!((s=this.view)===null||s===void 0)&&s.docView)}$node(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(s,r))||null}$nodes(s,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(s,r))||null}$pos(s){const r=this.state.doc.resolve(s);return new g4(r,this)}get $doc(){return this.$pos(0)}}function rA(t){return new Wue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=to(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const c=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(hke(r.from,r.to,s.doc).filter(v=>v.mark.type.excluded.find(w=>w===t.type&&w!==v.mark.type)).filter(v=>v.to>u).length)return null;pr.from&&o.delete(r.from+c,u);const g=r.from+c+l.length;o.addMark(r.from+c,g,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function DJe(t){return new Wue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=to(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const c=t.type.create(a);if(n[1]){const u=n[0].lastIndexOf(n[1]);let p=l+u;p>i?p=i:i=p+n[1].length;const f=n[0][n[0].length-1];o.insertText(f,l+n[0].length-1),o.replaceWith(p,i,c)}else if(n[0]){const u=t.type.isInline?l:l-1;o.insert(u,t.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function Q1e(t){return new Wue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=to(t.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;s.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function MD(t){return new Wue({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=to(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&UNe(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=s,{splittableMarks:v}=t.editor.extensionManager,_=g||f.$to.parentOffset&&f.$from.marks();if(_){const w=_.filter(j=>v.includes(j.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&Bw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let rm=class X1e{constructor(s={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=to(ca(this,"addOptions",{name:this.name}))),this.storage=to(ca(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new X1e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Kue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new X1e(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=to(ca(r,"addOptions",{name:r.name})),r.storage=to(ca(r,"addStorage",{name:r.name,options:r.options})),r}};function r3(t){return new nFt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=to(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],c=n[0];let u=r.to;if(i){const p=c.search(/\S/),f=r.from+c.indexOf(i),g=f+i.length;if(hke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(j=>j===t.type&&j!==_.mark.type)).filter(_=>_.to>f).length)return null;gr.from&&l.delete(r.from+p,f),u=r.from+p+i.length,l.addMark(r.from+p,u,t.type.create(o||{})),l.removeStoredMark(t.type)}}})}function q7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ka){const o=n.index();return n.parent.canReplaceWith(o,o+1,s)}let a=n.depth;for(;a>=0;){const o=n.index(a);if(n.node(a).contentMatchAt(o).matchType(s))return!0;a-=1}return!1}function U7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var OJe={exports:{}},Cge={};/** * @license React * use-sync-external-store-shim.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var VLe;function V7t(){if(VLe)return Cge;VLe=1;var t=ht;function s(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,g){var v=g(),_=n({inst:{value:v,getSnapshot:g}}),w=_[0].inst,j=_[1];return o(function(){w.value=v,w.getSnapshot=g,c(w)&&j({inst:w})},[f,v,g]),a(function(){return c(w)&&j({inst:w}),f(function(){c(w)&&j({inst:w})})},[f]),l(v),v}function c(f){var g=f.getSnapshot;f=f.value;try{var v=g();return!r(f,v)}catch{return!0}}function u(f,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return Cge.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Cge}OJe.exports=V7t();var pke=OJe.exports;const H7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},G7t=({contentComponent:t})=>{const s=pke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function W7t(){const t=new Set;let s={};return{subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return s},getServerSnapshot(){return s},setRenderer(r,n){s={...s,[r]:w2e.createPortal(n.reactElement,n.element,r)},t.forEach(a=>a())},removeRenderer(r){const n={...s};delete n[r],s=n,t.forEach(a=>a())}}}class K7t extends ht.Component{constructor(s){var r;super(s),this.editorContentRef=ht.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((r=s.editor)===null||r===void 0)&&r.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const s=this.props.editor;if(s&&!s.isDestroyed&&s.options.element){if(s.contentComponent)return;const r=this.editorContentRef.current;r.append(...s.options.element.childNodes),s.setOptions({element:r}),s.contentComponent=W7t(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=s.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),s.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const s=this.props.editor;if(!s||(this.initialized=!1,s.isDestroyed||s.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),s.contentComponent=null,!s.options.element.firstChild))return;const r=document.createElement("div");r.append(...s.options.element.childNodes),s.setOptions({element:r})}render(){const{editor:s,innerRef:r,...n}=this.props;return ht.createElement(ht.Fragment,null,ht.createElement("div",{ref:H7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(G7t,{contentComponent:s.contentComponent}))}}const Z7t=N.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(K7t,{key:r,innerRef:s,...t})}),fke=ht.memo(Z7t);var Y7t=function t(s,r){if(s===r)return!0;if(s&&r&&typeof s=="object"&&typeof r=="object"){if(s.constructor!==r.constructor)return!1;var n,a,o;if(Array.isArray(s)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(!t(s[a],r[a]))return!1;return!0}if(s instanceof Map&&r instanceof Map){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;for(a of s.entries())if(!t(a[1],r.get(a[0])))return!1;return!0}if(s instanceof Set&&r instanceof Set){if(s.size!==r.size)return!1;for(a of s.entries())if(!r.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(s)&&ArrayBuffer.isView(r)){if(n=s.length,n!=r.length)return!1;for(a=n;a--!==0;)if(s[a]!==r[a])return!1;return!0}if(s.constructor===RegExp)return s.source===r.source&&s.flags===r.flags;if(s.valueOf!==Object.prototype.valueOf)return s.valueOf()===r.valueOf();if(s.toString!==Object.prototype.toString)return s.toString()===r.toString();if(o=Object.keys(s),n=o.length,n!==Object.keys(r).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[a]))return!1;for(a=n;a--!==0;){var l=o[a];if(!(l==="_owner"&&s.$$typeof)&&!t(s[l],r[l]))return!1}return!0}return s!==s&&r!==r},Q7t=U7t(Y7t),RJe={exports:{}},Mge={};/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var HLe;function X7t(){if(HLe)return Mge;HLe=1;var t=ht,s=pke;function r(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var n=typeof Object.is=="function"?Object.is:r,a=s.useSyncExternalStore,o=t.useRef,l=t.useEffect,i=t.useMemo,c=t.useDebugValue;return Mge.useSyncExternalStoreWithSelector=function(u,p,f,g,v){var _=o(null);if(_.current===null){var w={hasValue:!1,value:null};_.current=w}else w=_.current;_=i(function(){function k(O){if(!S){if(S=!0,M=O,O=g(O),v!==void 0&&w.hasValue){var $=w.value;if(v($,O))return L=$}return L=O}if($=L,n(M,O))return $;var U=g(O);return v!==void 0&&v($,U)?$:(M=O,L=U)}var S=!1,M,L,P=f===void 0?null:f;return[function(){return k(p())},P===null?void 0:function(){return k(P())}]},[p,f,g,v]);var j=a(u,_[0],_[1]);return l(function(){w.hasValue=!0,w.value=j},[j]),c(j),j},Mge}RJe.exports=X7t();var J7t=RJe.exports;const ezt=typeof window<"u"?N.useLayoutEffect:N.useEffect;class tzt{constructor(s){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=s,this.lastSnapshot={editor:s,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(s){return this.subscribers.add(s),()=>{this.subscribers.delete(s)}}watch(s){if(this.editor=s,this.editor){const r=()=>{this.transactionNumber+=1,this.subscribers.forEach(a=>a())},n=this.editor;return n.on("transaction",r),()=>{n.off("transaction",r)}}}}function szt(t){var s;const[r]=N.useState(()=>new tzt(t.editor)),n=J7t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:Q7t);return ezt(()=>r.watch(t.editor),[t.editor,r]),N.useDebugValue(n),n}const rzt=!1,J1e=typeof window>"u",nzt=J1e||!!(typeof window<"u"&&window.next);class xke{constructor(s){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=s,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(s){this.editor=s,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?J1e||nzt?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const s={...this.options.current,onBeforeCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(a,...n)},onBlur:(...n)=>{var a,o;return(o=(a=this.options.current).onBlur)===null||o===void 0?void 0:o.call(a,...n)},onCreate:(...n)=>{var a,o;return(o=(a=this.options.current).onCreate)===null||o===void 0?void 0:o.call(a,...n)},onDestroy:(...n)=>{var a,o;return(o=(a=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(a,...n)},onFocus:(...n)=>{var a,o;return(o=(a=this.options.current).onFocus)===null||o===void 0?void 0:o.call(a,...n)},onSelectionUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(a,...n)},onTransaction:(...n)=>{var a,o;return(o=(a=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(a,...n)},onUpdate:(...n)=>{var a,o;return(o=(a=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(a,...n)},onContentError:(...n)=>{var a,o;return(o=(a=this.options.current).onContentError)===null||o===void 0?void 0:o.call(a,...n)},onDrop:(...n)=>{var a,o;return(o=(a=this.options.current).onDrop)===null||o===void 0?void 0:o.call(a,...n)},onPaste:(...n)=>{var a,o;return(o=(a=this.options.current).onPaste)===null||o===void 0?void 0:o.call(a,...n)}};return new $7t(s)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(s){return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}static compareOptions(s,r){return Object.keys(s).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&s.extensions&&r.extensions?s.extensions.length!==r.extensions.length?!1:s.extensions.every((a,o)=>{var l;return a===((l=r.extensions)===null||l===void 0?void 0:l[o])}):s[n]===r[n])}onRender(s){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&s.length===0?xke.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(s),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(s){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=s;return}if(this.previousDeps.length===s.length&&this.previousDeps.every((n,a)=>n===s[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=s}scheduleDestroy(){const s=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===s){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===s&&this.setEditor(null))},1)}}function gke(t={},s=[]){const r=N.useRef(t);r.current=t;const[n]=N.useState(()=>new xke(r)),a=pke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return N.useDebugValue(a),N.useEffect(n.onRender(s)),szt({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const azt=N.createContext({editor:null});azt.Consumer;const izt=N.createContext({onDragStart:void 0}),ozt=()=>N.useContext(izt);ht.forwardRef((t,s)=>{const{onDragStart:r}=ozt(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const lzt=/^\s*>\s$/,czt=rm.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[MD({find:lzt,type:this.type})]}}),dzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,uzt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mzt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pzt=dy.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[rA({find:dzt,type:this.type}),rA({find:hzt,type:this.type})]},addPasteRules(){return[r3({find:uzt,type:this.type}),r3({find:mzt,type:this.type})]}}),fzt="listItem",GLe="textStyle",WLe=/^\s*([-+*])\s$/,xzt=rm.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(fzt,this.editor.getAttributes(GLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=MD({find:WLe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=MD({find:WLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(GLe),editor:this.editor})),[t]}}),gzt=/(^|[^`])`([^`]+)`(?!`)/,yzt=/(^|[^`])`([^`]+)`(?!`)/g,vzt=dy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[rA({find:gzt,type:this.type})]},addPasteRules(){return[r3({find:yzt,type:this.type})]}}),bzt=/^```([a-z]+)?[\s\n]$/,_zt=/^~~~([a-z]+)?[\s\n]$/,wzt=rm.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var s;const{languageClassPrefix:r}=this.options,o=[...((s=t.firstElementChild)===null||s===void 0?void 0:s.classList)||[]].filter(l=>l.startsWith(r)).map(l=>l.replace(r,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:s}){return["pre",Gc(this.options.HTMLAttributes,s),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:s})=>s.setNode(this.name,t),toggleCodeBlock:t=>({commands:s})=>s.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:s}=this.editor.state.selection,r=s.pos===1;return!t||s.parent.type.name!==this.name?!1:r||!s.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:s}=t,{selection:r}=s,{$from:n,empty:a}=r;if(!a||n.parent.type!==this.type)return!1;const o=n.parentOffset===n.parent.nodeSize-2,l=n.parent.textContent.endsWith(` `);return!o||!l?!1:t.chain().command(({tr:i})=>(i.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:s}=t,{selection:r,doc:n}=s,{$from:a,empty:o}=r;if(!o||a.parent.type!==this.type||!(a.parentOffset===a.parent.nodeSize-2))return!1;const i=a.after();return i===void 0?!1:n.nodeAt(i)?t.commands.command(({tr:u})=>(u.setSelection(xi.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[Q1e({find:bzt,type:this.type,getAttributes:t=>({language:t[1]})}),Q1e({find:_zt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Du({key:new sm("codeBlockVSCodeHandler"),props:{handlePaste:(t,s)=>{if(!s.clipboardData||this.editor.isActive(this.type.name))return!1;const r=s.clipboardData.getData("text/plain"),n=s.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!r||!o)return!1;const{tr:l,schema:i}=t.state,c=i.text(r.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},c)),l.selection.$from.parent.type!==this.type&&l.setSelection(si.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),jzt=rm.create({name:"doc",topNode:!0,content:"block+"});function Nzt(t={}){return new Du({view(s){return new kzt(s,t)}})}class kzt{constructor(s,r){var n;this.editorView=s,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return s.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:s,handler:r})=>this.editorView.dom.removeEventListener(s,r))}update(s,r){this.cursorPos!=null&&r.doc!=s.state.doc&&(this.cursorPos>s.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(s){s!=this.cursorPos&&(this.cursorPos=s,s==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let s=this.editorView.state.doc.resolve(this.cursorPos),r=!s.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(r){let f=s.nodeBefore,g=s.nodeAfter;if(f||g){let v=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(v){let _=v.getBoundingClientRect(),w=f?_.bottom:_.top;f&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*i;n={left:_.left,right:_.right,top:w-j,bottom:w+j}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*l;n={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,p;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,p=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,v=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,p=f.top-c.scrollTop*v}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=wXe(this.editorView.state.doc,l,this.editorView.dragging.slice);i!=null&&(l=i)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(s){this.editorView.dom.contains(s.relatedTarget)||this.setCursor(null)}}const Szt=Dh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Nzt(this.options)]}});class yd extends xi{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return yd.valid(n)?new yd(n):xi.near(n)}content(){return Nn.empty}eq(s){return s instanceof yd&&s.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(s,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new yd(s.resolve(r.pos))}getBookmark(){return new yke(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!Czt(s)||!Mzt(s))return!1;let n=r.type.spec.allowGapCursor;if(n!=null)return n;let a=r.contentMatchAt(s.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(s,r,n=!1){e:for(;;){if(!n&&yd.valid(s))return s;let a=s.pos,o=null;for(let l=s.depth;;l--){let i=s.node(l);if(r>0?s.indexAfter(l)0){o=i.child(r>0?s.indexAfter(l):s.index(l)-1);break}else if(l==0)return null;a+=r;let c=s.doc.resolve(a);if(yd.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ka.isSelectable(o)){s=s.doc.resolve(a+o.nodeSize*r),n=!1;continue e}break}o=l,a+=r;let i=s.doc.resolve(a);if(yd.valid(i))return i}return null}}}yd.prototype.visible=!1;yd.findFrom=yd.findGapCursorFrom;xi.jsonID("gapcursor",yd);class yke{constructor(s){this.pos=s}map(s){return new yke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return yd.valid(r)?new yd(r):xi.near(r)}}function FJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Czt(t){for(let s=t.depth;s>=0;s--){let r=t.index(s),n=t.node(s);if(r==0){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||FJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Mzt(t){for(let s=t.depth;s>=0;s--){let r=t.indexAfter(s),n=t.node(s);if(r==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(r);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||FJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function Tzt(){return new Du({props:{decorations:Izt,createSelectionBetween(t,s,r){return s.pos==r.pos&&yd.valid(r)?new yd(r):null},handleClick:Ezt,handleKeyDown:Azt,handleDOMEvents:{beforeinput:Pzt}}})}const Azt=tke({ArrowLeft:Mz("horiz",-1),ArrowRight:Mz("horiz",1),ArrowUp:Mz("vert",-1),ArrowDown:Mz("vert",1)});function Mz(t,s){const r=t=="vert"?s>0?"down":"up":s>0?"right":"left";return function(n,a,o){let l=n.selection,i=s>0?l.$to:l.$from,c=l.empty;if(l instanceof si){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=yd.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new yd(u))),!0):!1}}function Ezt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!yd.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ka.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new yd(n))),!0)}function Pzt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof yd))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let a=Or.empty;for(let l=n.length-1;l>=0;l--)a=Or.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new Nn(a,0,0));return o.setSelection(si.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function Izt(t){if(!(t.selection instanceof yd))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",gd.create(t.doc,[Tm.widget(t.selection.head,s,{key:"gapcursor"})])}const Lzt=Dh.create({name:"gapCursor",addProseMirrorPlugins(){return[Tzt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=to(ca(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),Dzt=rm.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Gc(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:s,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:a,storedMarks:o}=r;if(a.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:i}=n.extensionManager,c=o||a.$to.parentOffset&&a.$from.marks();return s().insertContent({type:this.name}).command(({tr:u,dispatch:p})=>{if(p&&c&&l){const f=c.filter(g=>i.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ozt=rm.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:s}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Gc(this.options.HTMLAttributes,s),0]},addCommands(){return{setHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.setNode(this.name,t):!1,toggleHeading:t=>({commands:s})=>this.options.levels.includes(t.level)?s.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,s)=>({...t,[`Mod-Alt-${s}`]:()=>this.editor.commands.toggleHeading({level:s})}),{})},addInputRules(){return this.options.levels.map(t=>Q1e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var vle=200,ih=function(){};ih.prototype.append=function(s){return s.length?(s=ih.from(s),!this.length&&s||s.length=r?ih.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};ih.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};ih.prototype.forEach=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length),r<=n?this.forEachInner(s,r,n,0):this.forEachInvertedInner(s,r,n,0)};ih.prototype.map=function(s,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length);var a=[];return this.forEach(function(o,l){return a.push(s(o,l))},r,n),a};ih.from=function(s){return s instanceof ih?s:s&&s.length?new zJe(s):ih.empty};var zJe=function(t){function s(n){t.call(this),this.values=n}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var r={length:{configurable:!0},depth:{configurable:!0}};return s.prototype.flatten=function(){return this.values},s.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new s(this.values.slice(a,o))},s.prototype.getInner=function(a){return this.values[a]},s.prototype.forEachInner=function(a,o,l,i){for(var c=o;c=l;c--)if(a(this.values[c],i+c)===!1)return!1},s.prototype.leafAppend=function(a){if(this.length+a.length<=vle)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=vle)return new s(a.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(s.prototype,r),s}(ih);ih.empty=new zJe([]);var Rzt=function(t){function s(r,n){t.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.depth)+1}return t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s,s.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},s.prototype.getInner=function(n){return ni&&this.right.forEachInner(n,Math.max(a-i,0),Math.min(this.length,o)-i,l+i)===!1)return!1},s.prototype.forEachInvertedInner=function(n,a,o,l){var i=this.left.length;if(a>i&&this.right.forEachInvertedInner(n,a-i,Math.max(o,i)-i,l+i)===!1||o=o?this.right.slice(n-o,a-o):this.left.slice(n,o).append(this.right.slice(0,a-o))},s.prototype.leafAppend=function(n){var a=this.right.leafAppend(n);if(a)return new s(this.left,a)},s.prototype.leafPrepend=function(n){var a=this.left.leafPrepend(n);if(a)return new s(a,this.right)},s.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new s(this.left,new s(this.right,n)):new s(this,n)},s}(ih);const Fzt=500;class Gg{constructor(s,r){this.items=s,this.eventCount=r}popEvent(s,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let a,o;r&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=s.tr,i,c,u=[],p=[];return this.items.forEach((f,g)=>{if(!f.step){a||(a=this.remapping(n,g+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new Zy(f.map));let v=f.step.map(a.slice(o)),_;v&&l.maybeStep(v).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],u.push(new Zy(_,void 0,void 0,u.length+p.length))),o--,_&&a.appendMap(_,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,c=new Gg(this.items.slice(0,n).append(p.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:l,selection:i}}addTransform(s,r,n,a){let o=[],l=this.eventCount,i=this.items,c=!a&&i.length?i.get(i.length-1):null;for(let p=0;pBzt&&(i=zzt(i,u),l-=u),new Gg(i.append(o),l)}remapping(s,r){let n=new _D;return this.items.forEach((a,o)=>{let l=a.mirrorOffset!=null&&o-a.mirrorOffset>=s?n.maps.length-a.mirrorOffset:void 0;n.appendMap(a.map,l)},s,r),n}addMaps(s){return this.eventCount==0?this:new Gg(this.items.append(s.map(r=>new Zy(r))),this.eventCount)}rebased(s,r){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-r),o=s.mapping,l=s.steps.length,i=this.eventCount;this.items.forEach(g=>{g.selection&&i--},a);let c=r;this.items.forEach(g=>{let v=o.getMirror(--c);if(v==null)return;l=Math.min(l,v);let _=o.maps[v];if(g.step){let w=s.steps[v].invert(s.docs[v]),j=g.selection&&g.selection.map(o.slice(c+1,v));j&&i++,n.push(new Zy(_,w,j))}else n.push(new Zy(_))},a);let u=[];for(let g=r;gFzt&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let c=l.step.map(r.slice(n)),u=c&&c.getMap();if(n--,u&&r.appendMap(u,n),c){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new Zy(u.invert(),c,p),g,v=a.length-1;(g=a.length&&a[v].merge(f))?a[v]=g:a.push(f)}}else l.map&&n--},this.items.length,0),new Gg(ih.from(a.reverse()),o)}}Gg.empty=new Gg(ih.empty,0);function zzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Zy{constructor(s,r,n,a){this.map=s,this.step=r,this.selection=n,this.mirrorOffset=a}merge(s){if(this.step&&s.step&&!s.selection){let r=s.step.merge(this.step);if(r)return new Zy(r.getMap().invert(),r,this.selection)}}}class s_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const Bzt=20;function $zt(t,s,r,n){let a=r.getMeta(AS),o;if(a)return a.historyState;r.getMeta(Vzt)&&(t=new s_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(AS))return l.getMeta(AS).redo?new s_(t.done.addTransform(r,void 0,n,Fie(s)),t.undone,KLe(r.mapping.maps),t.prevTime,t.prevComposition):new s_(t.done,t.undone.addTransform(r,void 0,n,Fie(s)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=r.getMeta("composition"),c=t.prevTime==0||!l&&t.prevComposition!=i&&(t.prevTime<(r.time||0)-n.newGroupDelay||!qzt(r,t.prevRanges)),u=l?Tge(t.prevRanges,r.mapping):KLe(r.mapping.maps);return new s_(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,Fie(s)),Gg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new s_(t.done.rebased(r,o),t.undone.rebased(r,o),Tge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new s_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),Tge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function qzt(t,s){if(!s)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach((n,a)=>{for(let o=0;o=s[o]&&(r=!0)}),r}function KLe(t){let s=[];for(let r=t.length-1;r>=0&&s.length==0;r--)t[r].forEach((n,a,o,l)=>s.push(o,l));return s}function Tge(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=AS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=Uzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const $Je=BJe(!1,!0),qJe=BJe(!0,!0),Gzt=Dh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>$Je(t,s),redo:()=>({state:t,dispatch:s})=>qJe(t,s)}},addProseMirrorPlugins(){return[Hzt(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Wzt=rm.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Gc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!q7t(s,s.schema.nodes[this.name]))return!1;const{selection:r}=s,{$from:n,$to:a}=r,o=t();return n.parentOffset===0?o.insertContentAt({from:Math.max(n.pos-1,0),to:a.pos},{type:this.name}):d7t(r)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var c;if(i){const{$to:u}=l.selection,p=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(si.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ka.create(l.doc,u.pos)):l.setSelection(si.create(l.doc,u.pos));else{const f=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();f&&(l.insert(p,f),l.setSelection(si.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[DJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Kzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Zzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Yzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Qzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Xzt=dy.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rA({find:Kzt,type:this.type}),rA({find:Yzt,type:this.type})]},addPasteRules(){return[r3({find:Zzt,type:this.type}),r3({find:Qzt,type:this.type})]}}),Jzt=rm.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Gc(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),e9t="listItem",YLe="textStyle",QLe=/^(\d+)\.\s$/,t9t=rm.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:s,...r}=t;return s===1?["ol",Gc(this.options.HTMLAttributes,r),0]:["ol",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:s})=>this.options.keepAttributes?s().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(e9t,this.editor.getAttributes(YLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=MD({find:QLe,type:this.type,getAttributes:s=>({start:+s[1]}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=MD({find:QLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(YLe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),s9t=rm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),r9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,n9t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,a9t=dy.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rA({find:r9t,type:this.type})]},addPasteRules(){return[r3({find:n9t,type:this.type})]}}),i9t=rm.create({name:"text",group:"inline"}),vke=Dh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(pzt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(czt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(xzt.configure(this.options.bulletList)),this.options.code!==!1&&t.push(vzt.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(wzt.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(jzt.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Szt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(Lzt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(Dzt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(Ozt.configure(this.options.heading)),this.options.history!==!1&&t.push(Gzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(Wzt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Xzt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(Jzt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(t9t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(s9t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(a9t.configure(this.options.strike)),this.options.text!==!1&&t.push(i9t.configure(this.options.text)),t}}),o9t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",l9t="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ebe="numeric",tbe="ascii",sbe="alpha",x8="asciinumeric",zI="alphanumeric",rbe="domain",UJe="emoji",c9t="scheme",d9t="slashscheme",Ege="whitespace";function u9t(t,s){return t in s||(s[t]=[]),s[t]}function E4(t,s,r){s[ebe]&&(s[x8]=!0,s[zI]=!0),s[tbe]&&(s[x8]=!0,s[sbe]=!0),s[x8]&&(s[zI]=!0),s[sbe]&&(s[zI]=!0),s[zI]&&(s[rbe]=!0),s[UJe]&&(s[rbe]=!0);for(const n in s){const a=u9t(n,r);a.indexOf(t)<0&&a.push(t)}}function h9t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function xp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xp.groups={};xp.prototype={accepts(){return!!this.t},go(t){const s=this,r=s.j[t];if(r)return r;for(let n=0;nt.ta(s,r,n,a),cd=(t,s,r,n,a)=>t.tr(s,r,n,a),XLe=(t,s,r,n,a)=>t.ts(s,r,n,a),Qr=(t,s,r,n,a)=>t.tt(s,r,n,a),Iv="WORD",nbe="UWORD",VJe="ASCIINUMERICAL",HJe="ALPHANUMERICAL",TD="LOCALHOST",abe="TLD",ibe="UTLD",zie="SCHEME",J5="SLASH_SCHEME",bke="NUM",obe="WS",_ke="NL",g8="OPENBRACE",y8="CLOSEBRACE",ble="OPENBRACKET",_le="CLOSEBRACKET",wle="OPENPAREN",jle="CLOSEPAREN",Nle="OPENANGLEBRACKET",kle="CLOSEANGLEBRACKET",Sle="FULLWIDTHLEFTPAREN",Cle="FULLWIDTHRIGHTPAREN",Mle="LEFTCORNERBRACKET",Tle="RIGHTCORNERBRACKET",Ale="LEFTWHITECORNERBRACKET",Ele="RIGHTWHITECORNERBRACKET",Ple="FULLWIDTHLESSTHAN",Ile="FULLWIDTHGREATERTHAN",Lle="AMPERSAND",Dle="APOSTROPHE",Ole="ASTERISK",r_="AT",Rle="BACKSLASH",Fle="BACKTICK",zle="CARET",m_="COLON",wke="COMMA",Ble="DOLLAR",Yy="DOT",$le="EQUALS",jke="EXCLAMATION",ax="HYPHEN",v8="PERCENT",qle="PIPE",Ule="PLUS",Vle="POUND",b8="QUERY",Nke="QUOTE",GJe="FULLWIDTHMIDDLEDOT",kke="SEMI",Qy="SLASH",_8="TILDE",Hle="UNDERSCORE",WJe="EMOJI",Gle="SYM";var KJe=Object.freeze({__proto__:null,ALPHANUMERICAL:HJe,AMPERSAND:Lle,APOSTROPHE:Dle,ASCIINUMERICAL:VJe,ASTERISK:Ole,AT:r_,BACKSLASH:Rle,BACKTICK:Fle,CARET:zle,CLOSEANGLEBRACKET:kle,CLOSEBRACE:y8,CLOSEBRACKET:_le,CLOSEPAREN:jle,COLON:m_,COMMA:wke,DOLLAR:Ble,DOT:Yy,EMOJI:WJe,EQUALS:$le,EXCLAMATION:jke,FULLWIDTHGREATERTHAN:Ile,FULLWIDTHLEFTPAREN:Sle,FULLWIDTHLESSTHAN:Ple,FULLWIDTHMIDDLEDOT:GJe,FULLWIDTHRIGHTPAREN:Cle,HYPHEN:ax,LEFTCORNERBRACKET:Mle,LEFTWHITECORNERBRACKET:Ale,LOCALHOST:TD,NL:_ke,NUM:bke,OPENANGLEBRACKET:Nle,OPENBRACE:g8,OPENBRACKET:ble,OPENPAREN:wle,PERCENT:v8,PIPE:qle,PLUS:Ule,POUND:Vle,QUERY:b8,QUOTE:Nke,RIGHTCORNERBRACKET:Tle,RIGHTWHITECORNERBRACKET:Ele,SCHEME:zie,SEMI:kke,SLASH:Qy,SLASH_SCHEME:J5,SYM:Gle,TILDE:_8,TLD:abe,UNDERSCORE:Hle,UTLD:ibe,UWORD:nbe,WORD:Iv,WS:obe});const Cv=/[a-z]/,lI=new RegExp("\\p{L}","u"),Pge=new RegExp("\\p{Emoji}","u"),Mv=/\d/,Ige=/\s/,JLe="\r",Lge=` `,m9t="️",p9t="‍",Dge="";let Tz=null,Az=null;function f9t(t=[]){const s={};xp.groups=s;const r=new xp;Tz==null&&(Tz=e8e(o9t)),Az==null&&(Az=e8e(l9t)),Qr(r,"'",Dle),Qr(r,"{",g8),Qr(r,"}",y8),Qr(r,"[",ble),Qr(r,"]",_le),Qr(r,"(",wle),Qr(r,")",jle),Qr(r,"<",Nle),Qr(r,">",kle),Qr(r,"(",Sle),Qr(r,")",Cle),Qr(r,"「",Mle),Qr(r,"」",Tle),Qr(r,"『",Ale),Qr(r,"』",Ele),Qr(r,"<",Ple),Qr(r,">",Ile),Qr(r,"&",Lle),Qr(r,"*",Ole),Qr(r,"@",r_),Qr(r,"`",Fle),Qr(r,"^",zle),Qr(r,":",m_),Qr(r,",",wke),Qr(r,"$",Ble),Qr(r,".",Yy),Qr(r,"=",$le),Qr(r,"!",jke),Qr(r,"-",ax),Qr(r,"%",v8),Qr(r,"|",qle),Qr(r,"+",Ule),Qr(r,"#",Vle),Qr(r,"?",b8),Qr(r,'"',Nke),Qr(r,"/",Qy),Qr(r,";",kke),Qr(r,"~",_8),Qr(r,"_",Hle),Qr(r,"\\",Rle),Qr(r,"・",GJe);const n=cd(r,Mv,bke,{[ebe]:!0});cd(n,Mv,n);const a=cd(n,Cv,VJe,{[x8]:!0}),o=cd(n,lI,HJe,{[zI]:!0}),l=cd(r,Cv,Iv,{[tbe]:!0});cd(l,Mv,a),cd(l,Cv,l),cd(a,Mv,a),cd(a,Cv,a);const i=cd(r,lI,nbe,{[sbe]:!0});cd(i,Cv),cd(i,Mv,o),cd(i,lI,i),cd(o,Mv,o),cd(o,Cv),cd(o,lI,o);const c=Qr(r,Lge,_ke,{[Ege]:!0}),u=Qr(r,JLe,obe,{[Ege]:!0}),p=cd(r,Ige,obe,{[Ege]:!0});Qr(r,Dge,p),Qr(u,Lge,c),Qr(u,Dge,p),cd(u,Ige,p),Qr(p,JLe),Qr(p,Lge),cd(p,Ige,p),Qr(p,Dge,p);const f=cd(r,Pge,WJe,{[UJe]:!0});Qr(f,"#"),cd(f,Pge,f),Qr(f,m9t,f);const g=Qr(f,p9t);Qr(g,"#"),cd(g,Pge,f);const v=[[Cv,l],[Mv,a]],_=[[Cv,null],[lI,i],[Mv,o]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?S[rbe]=!0:Cv.test(j)?Mv.test(j)?S[x8]=!0:S[tbe]=!0:S[ebe]=!0,XLe(r,j,j,S)}return XLe(r,"localhost",TD,{ascii:!0}),r.jd=new xp(Gle),{start:r,tokens:Object.assign({groups:s},KJe)}}function ZJe(t,s){const r=x9t(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,g++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=g,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function x9t(t){const s=[],r=t.length;let n=0;for(;n56319||n+1===r||(o=t.charCodeAt(n+1))<56320||o>57343?t[n]:t.slice(n,n+2);s.push(l),n+=l.length}return s}function $b(t,s,r,n,a){let o;const l=s.length;for(let i=0;i=0;)o++;if(o>0){s.push(r.join(""));for(let l=parseInt(t.substring(n,n+o),10);l>0;l--)r.pop();n+=o}else r.push(t[n]),n++}return s}const AD={defaultProtocol:"http",events:null,format:t8e,formatHref:t8e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ske(t,s=null){let r=Object.assign({},AD);t&&(r=Object.assign(r,t instanceof Ske?t.o:t));const n=r.ignoreTags,a=[];for(let o=0;or?n.substring(0,r)+"…":n},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=AD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const s=this,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),a=t.get("tagName",r,s),o=this.toFormattedString(t),l={},i=t.get("className",r,s),c=t.get("target",r,s),u=t.get("rel",r,s),p=t.getObj("attributes",r,s),f=t.getObj("events",r,s);return l.href=n,i&&(l.class=i),c&&(l.target=c),u&&(l.rel=u),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:f}}};function Yue(t,s){class r extends YJe{constructor(a,o){super(a,o),this.t=t}}for(const n in s)r.prototype[n]=s[n];return r.t=t,r}const s8e=Yue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),r8e=Yue("text"),g9t=Yue("nl"),Ez=Yue("url",{isLink:!0,toHref(t=AD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==TD&&t[1].t===m_}}),Xf=t=>new xp(t);function y9t({groups:t}){const s=t.domain.concat([Lle,Ole,r_,Rle,Fle,zle,Ble,$le,ax,bke,v8,qle,Ule,Vle,Qy,Gle,_8,Hle]),r=[Dle,m_,wke,Yy,jke,v8,b8,Nke,kke,Nle,kle,g8,y8,_le,ble,wle,jle,Sle,Cle,Mle,Tle,Ale,Ele,Ple,Ile],n=[Lle,Dle,Ole,Rle,Fle,zle,Ble,$le,ax,g8,y8,v8,qle,Ule,Vle,b8,Qy,Gle,_8,Hle],a=Xf(),o=Qr(a,_8);eo(o,n,o),eo(o,t.domain,o);const l=Xf(),i=Xf(),c=Xf();eo(a,t.domain,l),eo(a,t.scheme,i),eo(a,t.slashscheme,c),eo(l,n,o),eo(l,t.domain,l);const u=Qr(l,r_);Qr(o,r_,u),Qr(i,r_,u),Qr(c,r_,u);const p=Qr(o,Yy);eo(p,n,o),eo(p,t.domain,o);const f=Xf();eo(u,t.domain,f),eo(f,t.domain,f);const g=Qr(f,Yy);eo(g,t.domain,f);const v=Xf(s8e);eo(g,t.tld,v),eo(g,t.utld,v),Qr(u,TD,v);const _=Qr(f,ax);Qr(_,ax,_),eo(_,t.domain,f),eo(v,t.domain,f),Qr(v,Yy,g),Qr(v,ax,_);const w=Qr(v,m_);eo(w,t.numeric,s8e);const j=Qr(l,ax),k=Qr(l,Yy);Qr(j,ax,j),eo(j,t.domain,l),eo(k,n,o),eo(k,t.domain,l);const S=Xf(Ez);eo(k,t.tld,S),eo(k,t.utld,S),eo(S,t.domain,l),eo(S,n,o),Qr(S,Yy,k),Qr(S,ax,j),Qr(S,r_,u);const M=Qr(S,m_),L=Xf(Ez);eo(M,t.numeric,L);const P=Xf(Ez),O=Xf();eo(P,s,P),eo(P,r,O),eo(O,s,P),eo(O,r,O),Qr(S,Qy,P),Qr(L,Qy,P);const $=Qr(i,m_),U=Qr(c,m_),B=Qr(U,Qy),V=Qr(B,Qy);eo(i,t.domain,l),Qr(i,Yy,k),Qr(i,ax,j),eo(c,t.domain,l),Qr(c,Yy,k),Qr(c,ax,j),eo($,t.domain,P),Qr($,Qy,P),Qr($,b8,P),eo(V,t.domain,P),eo(V,s,P),Qr(V,Qy,P);const X=[[g8,y8],[ble,_le],[wle,jle],[Nle,kle],[Sle,Cle],[Mle,Tle],[Ale,Ele],[Ple,Ile]];for(let Y=0;Y=0&&g++,a++,p++;if(g<0)a-=p,a0&&(o.push(Oge(r8e,s,l)),l=[]),a-=g,p-=g;const v=f.t,_=r.slice(a-p,a);o.push(Oge(v,s,_))}}return l.length>0&&o.push(Oge(r8e,s,l)),o}function Oge(t,s,r){const n=r[0].s,a=r[r.length-1].e,o=s.slice(n,a);return new t(o,r)}const b9t=typeof console<"u"&&console&&console.warn||(()=>{}),_9t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",bc={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function w9t(){return xp.groups={},bc.scanner=null,bc.parser=null,bc.tokenQueue=[],bc.pluginQueue=[],bc.customSchemes=[],bc.initialized=!1,bc}function n8e(t,s=!1){if(bc.initialized&&b9t(`linkifyjs: already initialized - will not register custom scheme "${t}" ${_9t}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" 3. "-" cannot repeat`);bc.customSchemes.push([t,s])}function j9t(){bc.scanner=f9t(bc.customSchemes);for(let t=0;t{const a=s.some(u=>u.docChanged)&&!r.doc.eq(n.doc),o=s.some(u=>u.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=t7t(r.doc,[...s]);if(l7t(i).forEach(({newRange:u})=>{const p=r7t(n.doc,u,v=>v.isTextblock);let f,g;if(p.length>1)f=p[0],g=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const v=n.doc.textBetween(u.from,u.to," "," ");if(!k9t.test(v))return;f=p[0],g=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const v=g.split(N9t).filter(Boolean);if(v.length<=0)return!1;const _=v[v.length-1],w=f.pos+g.lastIndexOf(_);if(!_)return!1;const j=Cke(_).map(k=>k.toObject(t.defaultProtocol));if(!C9t(j))return!1;j.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+k.end+1})).filter(k=>n.schema.marks.code?!n.doc.rangeHasMark(k.from,k.to,n.schema.marks.code):!0).filter(k=>t.validate(k.value)).filter(k=>t.shouldAutoLink(k.value)).forEach(k=>{hke(k.from,k.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(k.from,k.to,t.type.create({href:k.href}))})}}),!!l.steps.length)return l}})}function T9t(t){return new Du({key:new sm("handleClickLink"),props:{handleClick:(s,r,n)=>{var a,o;if(n.button!==0||!s.editable)return!1;let l=n.target;const i=[];for(;l.nodeName!=="DIV";)i.push(l),l=l.parentNode;if(!i.find(g=>g.nodeName==="A"))return!1;const c=LJe(s.state,t.type.name),u=n.target,p=(a=u==null?void 0:u.href)!==null&&a!==void 0?a:c.href,f=(o=u==null?void 0:u.target)!==null&&o!==void 0?o:c.target;return u&&p?(window.open(p,f),!0):!1}}})}function A9t(t){return new Du({key:new sm("handlePasteLink"),props:{handlePaste:(s,r,n)=>{const{state:a}=s,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(u=>{i+=u.textContent});const c=QJe(i,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===i);return!i||!c?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function H2(t,s){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return s&&s.forEach(n=>{const a=typeof n=="string"?n:n.scheme;a&&r.push(a)}),!t||t.replace(S9t,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Tke=dy.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){n8e(t);return}n8e(t.scheme,t.optionalSlashes)})},onDestroy(){w9t()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,s)=>!!H2(t,s.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const s=t.getAttribute("href");return!s||!this.options.isAllowedUri(s,{defaultValidate:r=>!!H2(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:s=>!!H2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Gc(this.options.HTMLAttributes,t),0]:["a",Gc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!H2(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!H2(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?s().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[r3({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=QJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!H2(l,r),protocols:r,defaultProtocol:n}));a.length&&a.forEach(o=>s.push({text:o.value,data:{href:o.href},index:o.start}))}return s},type:this.type,getAttributes:t=>{var s;return{href:(s=t.data)===null||s===void 0?void 0:s.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:s,defaultProtocol:r}=this.options;return this.options.autolink&&t.push(M9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!H2(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(T9t({type:this.type})),this.options.linkOnPaste&&t.push(A9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Ake=Dh.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const s=t.style.textAlign;return this.options.alignments.includes(s)?s:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:s})=>this.options.alignments.includes(t)?this.options.types.map(r=>s.updateAttributes(r,{textAlign:t})).every(r=>r):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(s=>t.resetAttributes(s,"textAlign")).every(s=>s),toggleTextAlign:t=>({editor:s,commands:r})=>this.options.alignments.includes(t)?s.isActive({textAlign:t})?r.unsetTextAlign():r.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),E9t=t=>{if(!t.children.length)return;const s=t.querySelectorAll("span");s&&s.forEach(r=>{var n,a;const o=r.getAttribute("style"),l=(a=(n=r.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||a===void 0?void 0:a.getAttribute("style");r.setAttribute("style",`${l};${o}`)})},Eke=dy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&E9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:t})=>{const{selection:s}=t;return t.doc.nodesBetween(s.from,s.to,(r,n)=>{if(r.isTextblock)return!0;r.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(o=>!!o))||t.removeMark(n,n+r.nodeSize,this.type)}),!0}}}}),P9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,I9t=rm.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Gc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[DJe({find:P9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let lbe,cbe;if(typeof WeakMap<"u"){let t=new WeakMap;lbe=s=>t.get(s),cbe=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;lbe=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var vd=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:k-M});break}const L=a+M*s;for(let P=0;Pn&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function O9t(t,s,r){t.problems||(t.problems=[]);const n={};for(let a=0;a0;s--)if(t.node(s).type.spec.tableRole=="row")return t.node(0).resolve(t.before(s+1));return null}function F9t(t){for(let s=t.depth;s>0;s--){const r=t.node(s).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(s)}return null}function py(t){const s=t.selection.$head;for(let r=s.depth;r>0;r--)if(s.node(r).type.spec.tableRole=="row")return!0;return!1}function Que(t){const s=t.selection;if("$anchorCell"in s&&s.$anchorCell)return s.$anchorCell.pos>s.$headCell.pos?s.$anchorCell:s.$headCell;if("node"in s&&s.node&&s.node.type.spec.tableRole=="cell")return s.$anchor;const r=fE(s.$head)||z9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function z9t(t){for(let s=t.nodeAfter,r=t.pos;s;s=s.firstChild,r++){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r)}for(let s=t.nodeBefore,r=t.pos;s;s=s.lastChild,r--){const n=s.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r-s.nodeSize)}}function dbe(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function B9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Pke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function XJe(t,s,r){const n=t.node(-1),a=vd.get(n),o=t.start(-1),l=a.nextCell(t.pos-o,s,r);return l==null?null:t.node(0).resolve(o+l)}function n3(t,s,r=1){const n={...t,colspan:t.colspan-r};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(s,r),n.colwidth.some(a=>a>0)||(n.colwidth=null)),n}function JJe(t,s,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=r.pos-o);c.unshift(r.pos-o);const u=c.map(p=>{const f=n.nodeAt(p);if(!f)throw new RangeError(`No cell with offset ${p} found`);const g=o+p+1;return new CXe(i.resolve(g),i.resolve(g+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=s,this.$headCell=r}map(s,r){const n=s.resolve(r.map(this.$anchorCell.pos)),a=s.resolve(r.map(this.$headCell.pos));if(dbe(n)&&dbe(a)&&Pke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Lv.rowSelection(n,a):o&&this.isColSelection()?Lv.colSelection(n,a):new Lv(n,a)}return si.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=vd.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let c=a.top;c0||j>0){let k=_.attrs;if(w>0&&(k=n3(k,0,w)),j>0&&(k=n3(k,k.colspan-j,j)),v.lefta.bottom){const k={..._.attrs,rowspan:Math.min(v.bottom,a.bottom)-Math.max(v.top,a.top)};v.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=vd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.top<=i.top?(l.top>0&&(s=c.resolve(o+a.map[l.left])),i.bottom0&&(r=c.resolve(o+a.map[i.left])),l.bottom0)return!1;const l=a+this.$anchorCell.nodeAfter.attrs.colspan,i=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,i)==r.width}eq(s){return s instanceof Lv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=vd.get(n),o=s.start(-1),l=a.findCell(s.pos-o),i=a.findCell(r.pos-o),c=s.node(0);return l.left<=i.left?(l.left>0&&(s=c.resolve(o+a.map[l.top*a.width])),i.right0&&(r=c.resolve(o+a.map[i.top*a.width])),l.right{s.push(Tm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),gd.create(t.doc,s)}function V9t({$from:t,$to:s}){if(t.pos==s.pos||t.pos=0&&!(t.after(a+1)=0&&!(s.before(o+1)>s.start(o));o--,n--);return r==n&&/row|table/.test(t.node(a).type.spec.tableRole)}function H9t({$from:t,$to:s}){let r,n;for(let a=t.depth;a>0;a--){const o=t.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}for(let a=s.depth;a>0;a--){const o=s.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}return r!==n&&s.parentOffset===0}function G9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ka&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=cc.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=cc.rowSelection(i,i)}else if(!r){const i=vd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=cc.create(a,c+1,u)}}else n instanceof si&&V9t(n)?o=si.create(a,n.from):n instanceof si&&H9t(n)&&(o=si.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const W9t=new sm("fix-tables");function tet(t,s,r,n){const a=t.childCount,o=s.childCount;e:for(let l=0,i=0;l{a.type.spec.tableRole=="table"&&(r=K9t(t,a,o,r))};return s?s.doc!=t.doc&&tet(s.doc,t.doc,0,n):t.doc.descendants(n),r}function K9t(t,s,r,n){const a=vd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let v="cell";p.firstChild&&(v=p.firstChild.type.spec.tableRole);const _=[];for(let j=0;j0?-1:0;$9t(s,n,a+o)&&(o=a==0||a==s.width?null:0);for(let l=0;l0&&a0&&s.map[i-1]==c||a0?-1:0;J9t(s,n,a+i)&&(i=a==0||a==s.height?null:0);for(let u=0,p=s.width*a;u0&&a0&&f==s.map[p-s.width]){const g=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...g,rowspan:g.rowspan-1}),u+=g.colspan-1}else if(a0&&r[o]==r[o-1]||n.right0&&r[a]==r[a-t]||n.bottom0){const p=c+1+u.content.size,f=a8e(u)?c+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new cc(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function o8e(t,s){const r=em(t.schema);return aBt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function aBt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof cc){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=F9t(n.$from),!a)return!1;o=(l=fE(n.$from))===null||l===void 0?void 0:l.pos}if(a==null||o==null||a.attrs.colspan==1&&a.attrs.rowspan==1)return!1;if(r){let i=a.attrs;const c=[],u=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=V0(s),f=s.tr;for(let v=0;v{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function oBt(t){return function(s,r){if(!py(s))return!1;if(r){const n=em(s.schema),a=V0(s),o=s.tr,l=a.map.cellsInRect(t=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:t=="row"?{left:0,top:a.top,right:a.map.width,bottom:a.bottom}:a),i=l.map(c=>a.table.nodeAt(c));for(let c=0;c{const v=g+o.tableStart,_=l.doc.nodeAt(v);_&&l.setNodeMarkup(v,f,_.attrs)}),n(l)}return!0}}ED("row",{useDeprecatedLogic:!0});ED("column",{useDeprecatedLogic:!0});const lBt=ED("cell",{useDeprecatedLogic:!0});function cBt(t,s){if(s<0){const r=t.nodeBefore;if(r)return t.pos-r.nodeSize;for(let n=t.index(-1)-1,a=t.before();n>=0;n--){const o=t.node(-1).child(n),l=o.lastChild;if(l)return a-1-l.nodeSize;a-=o.nodeSize}}else{if(t.index()0;n--)if(r.node(n).type.spec.tableRole=="table")return s&&s(t.tr.delete(r.before(n),r.after(n)).scrollIntoView()),!0;return!1}function Pz(t,s){const r=t.selection;if(!(r instanceof cc))return!1;if(s){const n=t.tr,a=em(t.schema).cell.createAndFill().content;r.forEachCell((o,l)=>{o.content.eq(a)||n.replace(n.mapping.map(l+1),n.mapping.map(l+o.nodeSize-1),new Nn(a,0,0))}),n.docChanged&&s(n)}return!0}function uBt(t){if(t.size===0)return null;let{content:s,openStart:r,openEnd:n}=t;for(;s.childCount==1&&(r>0&&n>0||s.child(0).type.spec.tableRole=="table");)r--,n--,s=s.child(0).content;const a=s.child(0),o=a.type.spec.tableRole,l=a.type.schema,i=[];if(o=="row")for(let c=0;c=0;l--){const{rowspan:i,colspan:c}=o.child(l).attrs;for(let u=a;u=s.length&&s.push(Or.empty),r[a]n&&(g=g.type.createChecked(n3(g.attrs,g.attrs.colspan,p+g.attrs.colspan-n),g.content)),u.push(g),p+=g.attrs.colspan;for(let v=1;va&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Or.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function pBt(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=em(i);let u,p;if(a>s.width)for(let f=0,g=0;fs.height){const f=[];for(let _=0,w=(s.height-1)*s.width;_=s.width?!1:r.nodeAt(s.map[w+_]).type==c.header_cell;f.push(j?p||(p=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const g=c.row.create(null,Or.from(f)),v=[];for(let _=s.height;_{if(!a)return!1;const o=r.selection;if(o instanceof cc)return Bie(r,n,xi.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=aet(a,t,s);if(l==null)return!1;if(t=="horiz")return Bie(r,n,xi.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=XJe(i,t,s);let u;return c?u=xi.near(c,1):s<0?u=xi.near(r.doc.resolve(i.before(-1)),-1):u=xi.near(r.doc.resolve(i.after(-1)),1),Bie(r,n,u)}}}function Lz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof cc)l=o;else{const c=aet(a,t,s);if(c==null)return!1;l=new cc(r.doc.resolve(c))}const i=XJe(l.$headCell,t,s);return i?Bie(r,n,new cc(l.$anchorCell,i)):!1}}function xBt(t,s){const r=t.state.doc,n=fE(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new cc(n))),!0):!1}function gBt(t,s,r){if(!py(t.state))return!1;let n=uBt(r);const a=t.state.selection;if(a instanceof cc){n||(n={width:1,height:1,rows:[Or.from(ube(em(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=vd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=mBt(n,i.right-i.left,i.bottom-i.top),h8e(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Que(t.state),l=o.start(-1);return h8e(t.state,t.dispatch,l,vd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function yBt(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=m8e(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof cc)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=fE(t.state.selection.$anchor))!=null&&((r=Rge(t,s))===null||r===void 0?void 0:r.pos)!=a.pos)o(a,s),s.preventDefault();else if(!n)return;function o(c,u){let p=Rge(t,u);const f=p_.getState(t.state)==null;if(!p||!Pke(c,p))if(f)p=c;else return;const g=new cc(c,p);if(f||!t.state.selection.eq(g)){const v=t.state.tr.setSelection(g);f&&v.setMeta(p_,c.pos),t.dispatch(v)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),p_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(p_,-1))}function i(c){const u=c,p=p_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(m8e(t,u.target)!=n&&(f=Rge(t,s),!f))return l();f&&o(f,u)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",i)}function aet(t,s,r){if(!(t.state.selection instanceof si))return null;const{$head:n}=t.state.selection;for(let a=n.depth-1;a>=0;a--){const o=n.node(a);if((r<0?n.index(a):n.indexAfter(a))!=(r<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(a),i=s=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(i)?l:null}}return null}function m8e(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function Rge(t,s){const r=t.posAtCoords({left:s.clientX,top:s.clientY});if(!r)return null;const n=r.inside>=0?r.inside:r.pos;return fE(t.state.doc.resolve(n))}var vBt=class{constructor(s,r){this.node=s,this.defaultCellMinWidth=r,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${r}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),hbe(s,this.colgroup,this.table,r),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(s){return s.type!=this.node.type?!1:(this.node=s,hbe(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function hbe(t,s,r,n,a,o){let l=0,i=!0,c=s.firstChild;const u=t.firstChild;if(u){for(let f=0,g=0;fnew n(f,r,g)),new _Bt(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=df.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{wBt(l,i,t,a)},mouseleave:l=>{jBt(l)},mousedown:(l,i)=>{NBt(l,i,s,r)}},decorations:l=>{const i=df.getState(l);if(i&&i.activeHandle>-1)return TBt(l,i.activeHandle)},nodeViews:{}}});return o}var _Bt=class $ie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(df);if(n&&n.setHandle!=null)return new $ie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new $ie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return dbe(s.doc.resolve(a))||(a=-1),new $ie(a,r.dragging)}return r}};function wBt(t,s,r,n){if(!t.editable)return;const a=df.getState(t.state);if(a&&!a.dragging){const o=SBt(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=p8e(t,s,"left",r):c-s.clientX<=r&&(l=p8e(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=vd.get(c),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}iet(t,l)}}}function jBt(t){if(!t.editable)return;const s=df.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&iet(t,-1)}function NBt(t,s,r,n){var a;if(!t.editable)return!1;const o=(a=t.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,l=df.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=kBt(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(df,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const g=df.getState(t.state);g!=null&&g.dragging&&(CBt(t,g.activeHandle,f8e(g.dragging,f,r)),t.dispatch(t.state.tr.setMeta(df,{setDragging:null})))}function p(f){if(!f.which)return u(f);const g=df.getState(t.state);if(g&&g.dragging){const v=f8e(g.dragging,f,r);x8e(t,g.activeHandle,v,n)}}return x8e(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function kBt(t,s,{colspan:r,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=t.domAtPos(s);let l=o.node.childNodes[o.offset].offsetWidth,i=r;if(n)for(let c=0;c{const n=t.nodes[r];n.spec.tableRole&&(s[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=s,s}function LBt(t,s,r,n,a){const o=IBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!DBt(s))return!1;let r=0;const n=IJe(s.ranges[0].$from,o=>o.type.name==="table");return n==null||n.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(r+=1)}),r===s.ranges.length?(t.commands.deleteTable(),!0):!1},OBt=rm.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:EBt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:s}){const{colgroup:r,tableWidth:n,tableMinWidth:a}=PBt(t,this.options.cellMinWidth),o=["table",Gc(this.options.HTMLAttributes,s,{style:n?`width: ${n}`:`min-width: ${a}`}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:t=3,cols:s=3,withHeaderRow:r=!0}={})=>({tr:n,dispatch:a,editor:o})=>{const l=LBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(si.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>Z9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>Y9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>X9t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>eBt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>tBt(t,s),deleteRow:()=>({state:t,dispatch:s})=>rBt(t,s),deleteTable:()=>({state:t,dispatch:s})=>dBt(t,s),mergeCells:()=>({state:t,dispatch:s})=>i8e(t,s),splitCell:()=>({state:t,dispatch:s})=>o8e(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>ED("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>ED("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>lBt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>i8e(t,s)?!0:o8e(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>iBt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>c8e(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>c8e(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&set(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=cc.create(s.doc,t.anchorCell,t.headCell);s.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Dz,"Mod-Backspace":Dz,Delete:Dz,"Mod-Delete":Dz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[bBt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ABt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:to(ca(t,"tableRole",s))}}}),RBt=rm.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Gc(this.options.HTMLAttributes,t),0]}}),FBt=rm.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Gc(this.options.HTMLAttributes,t),0]}}),zBt=rm.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const s=t.getAttribute("colwidth");return s?s.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Gc(this.options.HTMLAttributes,t),0]}});function fy({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState(!0),f=gke({extensions:[vke,Tke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Ake.configure({types:["heading","paragraph"]}),Eke,I9t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),OBt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),RBt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),FBt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),zBt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,j)=>{var S;const k=(S=j.clipboardData)==null?void 0:S.items;if(!k)return!1;for(const M of Array.from(k))if(M.type.startsWith("image/")){j.preventDefault();const L=M.getAsFile();if(!L)continue;const P=new FileReader;return P.onload=O=>{var U;const $=(U=O.target)==null?void 0:U.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},P.readAsDataURL(L),!0}return!1}}});N.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const g=()=>{if(!f)return;const w=f.getAttributes("link").href||"",j=f.getAttributes("link").target;c(w),p(j==="_blank"),l(!0)},v=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),c(""))},_=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(zM,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:2}).run(),className:f.isActive("heading",{level:2})?"bg-muted":"",title:"Heading 2",children:e.jsx(BM,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBold().run(),className:f.isActive("bold")?"bg-muted":"",title:"Bold",children:e.jsx(tS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleItalic().run(),className:f.isActive("italic")?"bg-muted":"",title:"Italic",children:e.jsx(oS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleBulletList().run(),className:f.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:e.jsx(rh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleOrderedList().run(),className:f.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:e.jsx(x0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("left").run(),className:f.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:e.jsx(X4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("center").run(),className:f.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:e.jsx(Q4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().setTextAlign("right").run(),className:f.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:e.jsx(J4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:g,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:_,title:"Remove Link",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo",children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo",children:e.jsx(vS,{className:"h-4 w-4"})})]}),e.jsx(fke,{editor:f,className:"prose prose-sm max-w-none p-3 focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror_img]:max-w-none [&_.ProseMirror_table]:border-none [&_.ProseMirror_table]:border-collapse [&_.ProseMirror_td]:border-none [&_.ProseMirror_td]:p-0 [&_.ProseMirror_td]:align-top [&_.ProseMirror_th]:border-none [&_.ProseMirror_th]:p-0 [&_.ProseMirror_tr]:border-none",style:{minHeight:n}})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"link-url",children:"URL"}),e.jsx(ze,{id:"link-url",value:i,onChange:w=>c(w.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(be,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:v,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var BBt=Object.defineProperty,$Bt=(t,s,r)=>s in t?BBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Lc=(t,s,r)=>$Bt(t,typeof s!="symbol"?s+"":s,r);const Wle={x:0,y:0,width:0,height:0,unit:"px"},L5=(t,s,r)=>Math.min(Math.max(t,s),r),qBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),v8e=(t,s)=>t===s||t.width===s.width&&t.height===s.height&&t.x===s.x&&t.y===s.y&&t.unit===s.unit;function UBt(t,s,r,n){const a=Xy(t,r,n);return t.width&&(a.height=a.width/s),t.height&&(a.width=a.height*s),a.y+a.height>n&&(a.height=n-a.y,a.width=a.height*s),a.x+a.width>r&&(a.width=r-a.x,a.height=a.width/s),t.unit==="%"?n_(a,r,n):a}function VBt(t,s,r){const n=Xy(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?n_(n,s,r):n}function n_(t,s,r){return t.unit==="%"?{...Wle,...t,unit:"%"}:{unit:"%",x:t.x?t.x/s*100:0,y:t.y?t.y/r*100:0,width:t.width?t.width/s*100:0,height:t.height?t.height/r*100:0}}function Xy(t,s,r){return t.unit?t.unit==="px"?{...Wle,...t,unit:"px"}:{unit:"px",x:t.x?t.x*s/100:0,y:t.y?t.y*r/100:0,width:t.width?t.width*s/100:0,height:t.height?t.height*r/100:0}:{...Wle,...t,unit:"px"}}function b8e(t,s,r,n,a,o=0,l=0,i=n,c=a){const u={...t};let p=Math.min(o,n),f=Math.min(l,a),g=Math.min(i,n),v=Math.min(c,a);s&&(s>1?(p=l?l*s:p,f=p/s,g=i*s):(f=o?o/s:f,p=f*s,v=c/s)),u.y<0&&(u.height=Math.max(u.height+u.y,f),u.y=0),u.x<0&&(u.width=Math.max(u.width+u.x,p),u.x=0);const _=n-(u.x+u.width);_<0&&(u.x=Math.min(u.x,n-p),u.width+=_);const w=a-(u.y+u.height);if(w<0&&(u.y=Math.min(u.y,a-f),u.height+=w),u.widthg&&((r==="sw"||r=="nw")&&(u.x-=g-u.width),u.width=g),u.height>v&&((r==="nw"||r=="ne")&&(u.y-=v-u.height),u.height=v),s){const j=u.width/u.height;if(js){const k=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=k-u.width),u.width=k}}return u}function HBt(t,s,r,n){const a={...t};return s==="ArrowLeft"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="w"?(a.x-=r,a.width+=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="e"?a.width-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowRight"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="w"?(a.x+=r,a.width-=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="e"?a.width+=r:n==="se"&&(a.width+=r,a.height+=r)),s==="ArrowUp"?n==="nw"?(a.x-=r,a.y-=r,a.width+=r,a.height+=r):n==="n"?(a.y-=r,a.height+=r):n==="ne"?(a.y-=r,a.width+=r,a.height+=r):n==="sw"?(a.x+=r,a.width-=r,a.height-=r):n==="s"?a.height-=r:n==="se"&&(a.width-=r,a.height-=r):s==="ArrowDown"&&(n==="nw"?(a.x+=r,a.y+=r,a.width-=r,a.height-=r):n==="n"?(a.y+=r,a.height-=r):n==="ne"?(a.y+=r,a.width-=r,a.height-=r):n==="sw"?(a.x-=r,a.width+=r,a.height+=r):n==="s"?a.height+=r:n==="se"&&(a.width+=r,a.height+=r)),a}const D5={capture:!0,passive:!1};let GBt=0;const Yb=class Eg extends N.PureComponent{constructor(){super(...arguments),Lc(this,"docMoveBound",!1),Lc(this,"mouseDownOnCrop",!1),Lc(this,"dragStarted",!1),Lc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Lc(this,"componentRef",N.createRef()),Lc(this,"mediaRef",N.createRef()),Lc(this,"resizeObserver"),Lc(this,"initChangeCalled",!1),Lc(this,"instanceId",`rc-${GBt++}`),Lc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Lc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Xy(r,a.width,a.height);if(n)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=s.target.dataset.ord,i=!!l;let c=s.clientX,u=s.clientY,p=o.x,f=o.y;if(l){const g=s.clientX-a.x,v=s.clientY-a.y;let _=0,w=0;l==="ne"||l=="e"?(_=g-(o.x+o.width),w=v-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(_=g-(o.x+o.width),w=v-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(_=g-o.x,w=v-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(_=g-o.x,w=v-o.y,p=o.x+o.width,f=o.y+o.height),c=p+a.x+_,u=f+a.y+w}this.evData={startClientX:c,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),Lc(this,"onComponentPointerDown",s=>{const{crop:r,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&r)return;s.cancelable&&s.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const c=s.clientX-i.x,u=s.clientY-i.y,p={unit:"px",x:c,y:u,width:0,height:0};this.evData={startClientX:s.clientX,startClientY:s.clientY,startCropX:c,startCropY:u,clientX:s.clientX,clientY:s.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Xy(p,i.width,i.height),n_(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Lc(this,"onDocPointerMove",s=>{const{crop:r,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!r||!this.mouseDownOnCrop)return;s.cancelable&&s.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(s));const{evData:i}=this;i.clientX=s.clientX,i.clientY=s.clientY;let c;i.isResize?c=this.resizeCrop():c=this.dragCrop(),v8e(r,c)||a(Xy(c,l.width,l.height),n_(c,l.width,l.height))}),Lc(this,"onComponentKeyDown",s=>{const{crop:r,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=s.key;let i=!1;if(!r)return;const c=this.getBox(),u=this.makePixelCrop(c),p=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Eg.nudgeStepLarge:s.shiftKey?Eg.nudgeStepMedium:Eg.nudgeStep;if(l==="ArrowLeft"?(u.x-=p,i=!0):l==="ArrowRight"?(u.x+=p,i=!0):l==="ArrowUp"?(u.y-=p,i=!0):l==="ArrowDown"&&(u.y+=p,i=!0),i){s.cancelable&&s.preventDefault(),u.x=L5(u.x,0,c.width-u.width),u.y=L5(u.y,0,c.height-u.height);const f=Xy(u,c.width,c.height),g=n_(u,c.width,c.height);a(f,g),o&&o(f,g)}}),Lc(this,"onHandlerKeyDown",(s,r)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:c,maxHeight:u,onChange:p,onComplete:f}=this.props,g=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const v=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Eg.nudgeStepLarge:s.shiftKey?Eg.nudgeStepMedium:Eg.nudgeStep,_=Xy(a,g.width,g.height),w=HBt(_,s.key,v,r),j=b8e(w,n,r,g.width,g.height,l,i,c,u);if(!v8e(a,j)){const k=n_(j,g.width,g.height);p(j,k),f&&f(j,k)}}),Lc(this,"onDocPointerDone",s=>{const{crop:r,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!r)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(s),a&&a(Xy(r,l.width,l.height),n_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Lc(this,"onDragFocus",()=>{var s;(s=this.componentRef.current)==null||s.scrollTo(0,0)})}get document(){return document}getBox(){const s=this.mediaRef.current;if(!s)return{x:0,y:0,width:0,height:0};const{x:r,y:n,width:a,height:o}=s.getBoundingClientRect();return{x:r,y:n,width:a,height:o}}componentDidUpdate(s){const{crop:r,onComplete:n}=this.props;if(n&&!s.crop&&r){const{width:a,height:o}=this.getBox();a&&o&&n(Xy(r,a,o),n_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,D5),this.document.addEventListener("pointerup",this.onDocPointerDone,D5),this.document.addEventListener("pointercancel",this.onDocPointerDone,D5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,D5),this.document.removeEventListener("pointerup",this.onDocPointerDone,D5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,D5),this.docMoveBound=!1)}getCropStyle(){const{crop:s}=this.props;if(s)return{top:`${s.y}${s.unit}`,left:`${s.x}${s.unit}`,width:`${s.width}${s.unit}`,height:`${s.height}${s.unit}`}}dragCrop(){const{evData:s}=this,r=this.getBox(),n=this.makePixelCrop(r),a=s.clientX-s.startClientX,o=s.clientY-s.startClientY;return n.x=L5(s.startCropX+a,0,r.width-n.width),n.y=L5(s.startCropY+o,0,r.height-n.height),n}getPointRegion(s,r,n,a){const{evData:o}=this,l=o.clientX-s.x,i=o.clientY-s.y;let c;a&&r?c=r==="nw"||r==="n"||r==="ne":c=i1?o?[o,o/r]:[l*r,l]:l?[l*r,l]:[o,o/r]}resizeCrop(){const{evData:s}=this,{aspect:r=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,r,this.props.minWidth,this.props.minHeight);let c=this.makePixelCrop(o);const u=this.getPointRegion(o,s.ord,l,i),p=s.ord||u;let f=s.clientX-s.startClientX,g=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(g=Math.min(g,-i));const v={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(v.x=s.startCropX,v.width=f,r?(v.height=v.width/r,v.y=s.startCropY-v.height):(v.height=Math.abs(g),v.y=s.startCropY-v.height)):u==="se"?(v.x=s.startCropX,v.y=s.startCropY,v.width=f,r?v.height=v.width/r:v.height=g):u==="sw"?(v.x=s.startCropX+f,v.y=s.startCropY,v.width=Math.abs(f),r?v.height=v.width/r:v.height=g):u==="nw"&&(v.x=s.startCropX+f,v.width=Math.abs(f),r?(v.height=v.width/r,v.y=s.startCropY-v.height):(v.height=Math.abs(g),v.y=s.startCropY+g));const _=b8e(v,r,u,o.width,o.height,l,i,n,a);return r||Eg.xyOrds.indexOf(p)>-1?c=_:Eg.xOrds.indexOf(p)>-1?(c.x=_.x,c.width=_.width):Eg.yOrds.indexOf(p)>-1&&(c.y=_.y,c.height=_.height),c.x=L5(c.x,0,o.width-c.width),c.y=L5(c.y,0,o.height-c.height),c}renderCropSelection(){const{ariaLabels:s=Eg.defaultProps.ariaLabels,disabled:r,locked:n,renderSelectionAddon:a,ruleOfThirds:o,crop:l}=this.props,i=this.getCropStyle();if(l)return ht.createElement("div",{style:i,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":s.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!r&&!n&&ht.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},ht.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),ht.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":s.nwDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"nw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":s.nDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"n"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":s.neDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"ne"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":s.eDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"e"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":s.seDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"se"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":s.sDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"s"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":s.swDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"sw"),role:"button"}),ht.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":s.wDragHandle,onKeyDown:c=>this.onHandlerKeyDown(c,"w"),role:"button"})),a&&ht.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:c=>c.stopPropagation()},a(this.state)),o&&ht.createElement(ht.Fragment,null,ht.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),ht.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(s){const r={...Wle,...this.props.crop||{}};return Xy(r,s.width,s.height)}render(){const{aspect:s,children:r,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:c,ruleOfThirds:u}=this.props,{cropIsActive:p,newCropIsBeingDrawn:f}=this.state,g=o?this.renderCropSelection():null,v=qBt("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",f&&"ReactCrop--new-crop",o&&s&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&u&&"ReactCrop--rule-of-thirds",!this.dragStarted&&o&&!o.width&&!o.height&&"ReactCrop--invisible-crop",n&&"ReactCrop--no-animate");return ht.createElement("div",{ref:this.componentRef,className:v,style:c},ht.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},r),o?ht.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},ht.createElement("defs",null,ht.createElement("mask",{id:`hole-${this.instanceId}`},ht.createElement("rect",{width:"100%",height:"100%",fill:"white"}),n?ht.createElement("ellipse",{cx:`${o.x+o.width/2}${o.unit}`,cy:`${o.y+o.height/2}${o.unit}`,rx:`${o.width/2}${o.unit}`,ry:`${o.height/2}${o.unit}`,fill:"black"}):ht.createElement("rect",{x:`${o.x}${o.unit}`,y:`${o.y}${o.unit}`,width:`${o.width}${o.unit}`,height:`${o.height}${o.unit}`,fill:"black"}))),ht.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,g)}};Lc(Yb,"xOrds",["e","w"]),Lc(Yb,"yOrds",["n","s"]),Lc(Yb,"xyOrds",["nw","ne","se","sw"]),Lc(Yb,"nudgeStep",1),Lc(Yb,"nudgeStepMedium",10),Lc(Yb,"nudgeStepLarge",100),Lc(Yb,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let WBt=Yb;var oet=["PageUp","PageDown"],cet=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],det={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},xE="Slider",[pbe,KBt,ZBt]=TO(xE),[uet]=od(xE,[ZBt]),[YBt,Xue]=uet(xE),het=N.forwardRef((t,s)=>{const{name:r,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:p,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:v=!1,form:_,...w}=t,j=N.useRef(new Set),k=N.useRef(0),M=l==="horizontal"?QBt:XBt,[L=[],P]=oh({prop:p,defaultProp:u,onChange:X=>{var ee;(ee=[...j.current][k.current])==null||ee.focus(),f(X)}}),O=N.useRef(L);function $(X){const Y=r$t(L,X);V(X,Y)}function U(X){V(X,k.current)}function B(){const X=O.current[k.current];L[k.current]!==X&&g(L)}function V(X,Y,{commit:ee}={commit:!1}){const Q=o$t(o),ce=l$t(Math.round((X-n)/o)*o+n,Q),ne=uD(ce,[n,a]);P((re=[])=>{const oe=t$t(re,ne,Y);if(i$t(oe,c*o)){k.current=oe.indexOf(ne);const fe=String(oe)!==String(re);return fe&&ee&&g(oe),fe?oe:re}else return re})}return e.jsx(YBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:k,thumbs:j.current,values:L,orientation:l,form:_,children:e.jsx(pbe.Provider,{scope:t.__scopeSlider,children:e.jsx(pbe.Slot,{scope:t.__scopeSlider,children:e.jsx(M,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:Lr(w.onPointerDown,()=>{i||(O.current=L)}),min:n,max:a,inverted:v,onSlideStart:i?void 0:$,onSlideMove:i?void 0:U,onSlideEnd:i?void 0:B,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,L.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:Y})=>{if(!i){const ce=oet.includes(X.key)||X.shiftKey&&cet.includes(X.key)?10:1,ne=k.current,re=L[ne],oe=o*ce*Y;V(re+oe,ne,{commit:!0})}}})})})})});het.displayName=xE;var[met,pet]=uet(xE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),QBt=N.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...p}=t,[f,g]=N.useState(null),v=Va(s,M=>g(M)),_=N.useRef(void 0),w=Lw(a),j=w==="ltr",k=j&&!o||!j&&o;function S(M){const L=_.current||f.getBoundingClientRect(),P=[0,L.width],$=Ike(P,k?[r,n]:[n,r]);return _.current=L,$(M-L.left)}return e.jsx(met,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:e.jsx(fet,{dir:w,"data-orientation":"horizontal",...p,ref:v,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const L=S(M.clientX);l==null||l(L)},onSlideMove:M=>{const L=S(M.clientX);i==null||i(L)},onSlideEnd:()=>{_.current=void 0,c==null||c()},onStepKeyDown:M=>{const P=det[k?"from-left":"from-right"].includes(M.key);u==null||u({event:M,direction:P?-1:1})}})})}),XBt=N.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,p=N.useRef(null),f=Va(s,p),g=N.useRef(void 0),v=!a;function _(w){const j=g.current||p.current.getBoundingClientRect(),k=[0,j.height],M=Ike(k,v?[n,r]:[r,n]);return g.current=j,M(w-j.top)}return e.jsx(met,{scope:t.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:e.jsx(fet,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=_(w.clientY);o==null||o(j)},onSlideMove:w=>{const j=_(w.clientY);l==null||l(j)},onSlideEnd:()=>{g.current=void 0,i==null||i()},onStepKeyDown:w=>{const k=det[v?"from-bottom":"from-top"].includes(w.key);c==null||c({event:w,direction:k?-1:1})}})})}),fet=N.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,p=Xue(xE,r);return e.jsx(an.span,{...u,ref:s,onKeyDown:Lr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):oet.concat(cet).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Lr(t.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(g)?g.focus():n(f)}),onPointerMove:Lr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Lr(t.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),o(f))})})}),xet="SliderTrack",get=N.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Xue(xet,r);return e.jsx(an.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});get.displayName=xet;var fbe="SliderRange",yet=N.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Xue(fbe,r),o=pet(fbe,r),l=N.useRef(null),i=Va(s,l),c=a.values.length,u=a.values.map(g=>_et(g,a.min,a.max)),p=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(an.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});yet.displayName=fbe;var xbe="SliderThumb",vet=N.forwardRef((t,s)=>{const r=KBt(t.__scopeSlider),[n,a]=N.useState(null),o=Va(s,i=>a(i)),l=N.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(JBt,{...t,ref:o,index:l})}),JBt=N.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Xue(xbe,r),i=pet(xbe,r),[c,u]=N.useState(null),p=Va(s,S=>u(S)),f=c?l.form||!!c.closest("form"):!0,g=PO(c),v=l.values[n],_=v===void 0?0:_et(v,l.min,l.max),w=s$t(n,l.values.length),j=g==null?void 0:g[i.size],k=j?n$t(j,_,i.direction):0;return N.useEffect(()=>{if(c)return l.thumbs.add(c),()=>{l.thumbs.delete(c)}},[c,l.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${_}% + ${k}px)`},children:[e.jsx(pbe.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(an.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":v,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:v===void 0?{display:"none"}:t.style,onFocus:Lr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(bet,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:v},n)]})});vet.displayName=xbe;var e$t="RadioBubbleInput",bet=N.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=N.useRef(null),o=Va(a,n),l=HO(s);return N.useEffect(()=>{const i=a.current;if(!i)return;const c=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==s&&p){const f=new Event("input",{bubbles:!0});p.call(i,s),i.dispatchEvent(f)}},[l,s]),e.jsx(an.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});bet.displayName=e$t;function t$t(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function _et(t,s,r){const o=100/(r-s)*(t-s);return uD(o,[0,100])}function s$t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function r$t(t,s){if(t.length===1)return 0;const r=t.map(a=>Math.abs(a-s)),n=Math.min(...r);return r.indexOf(n)}function n$t(t,s,r){const n=t/2,o=Ike([0,50],[0,n]);return(n-o(s)*r)*r}function a$t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function i$t(t,s){if(s>0){const r=a$t(t);return Math.min(...r)>=s}return!0}function Ike(t,s){return r=>{if(t[0]===t[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(t[1]-t[0]);return s[0]+n*(r-t[0])}}function o$t(t){return(String(t).split(".")[1]||"").length}function l$t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var wet=het,c$t=get,d$t=yet,u$t=vet;const Yg=N.forwardRef(({className:t,...s},r)=>e.jsxs(wet,{ref:r,className:It("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(c$t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(d$t,{className:"absolute h-full bg-primary"})}),e.jsx(u$t,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Yg.displayName=wet.displayName;function h$t(t,s,r){return VBt(UBt({unit:"%",width:90},r,t,s),t,s)}const Lke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=N.useRef(null),[l,i]=N.useState(),[c,u]=N.useState(),[p,f]=N.useState(1),[g,v]=N.useState(0),_=N.useCallback(k=>{const{width:S,height:M}=k.currentTarget;i(h$t(S,M,a))},[a]),w=N.useCallback(async()=>{const k=o.current;if(!k||!c)return;const S=document.createElement("canvas"),M=S.getContext("2d");if(!M)return;const L=k.naturalWidth/k.width,P=k.naturalHeight/k.height,O=400;S.width=O,S.height=O,M.imageSmoothingQuality="high";const $=c.x*L,U=c.y*P,B=c.width*L,V=c.height*P,X=g*Math.PI/180,Y=S.width/2,ee=S.height/2;return M.save(),M.translate(Y,ee),M.rotate(X),M.scale(p,p),M.translate(-Y,-ee),M.drawImage(k,$,U,B,V,0,0,O,O),M.restore(),new Promise((Q,ce)=>{S.toBlob(ne=>{ne?Q(ne):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,p,g]),j=async()=>{try{const k=await w();k&&(n(k),s())}catch(k){console.error("Error cropping image:",k)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsx(_s,{children:"Crop Your Photo"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:e.jsx(WBt,{crop:l,onChange:(k,S)=>i(S),onComplete:k=>u(k),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${g}deg)`,maxHeight:"400px",width:"auto"},onLoad:_})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(JM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Yg,{value:[p],min:.5,max:3,step:.1,onValueChange:([k])=>f(k),className:"flex-1"}),e.jsx(J_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(RL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Yg,{value:[g],min:-180,max:180,step:1,onValueChange:([k])=>v(k),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[g,"°"]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:j,children:"Save Photo"})]})]})})},m$t=()=>{const{user:t}=Os(),{toast:s}=Ha(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(null);N.useEffect(()=>{t&&c()},[t]);const c=async()=>{n(!0);try{const{data:f}=await H.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await H.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:g,error:v}=await H.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(v)throw v;g!=null&&g.url&&window.open(g.url,"_blank")}catch(f){console.error("Error opening customer portal:",f),s({title:"Error",description:f.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return e.jsx(st,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(st,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(st,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(st,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(st,{variant:"secondary",children:"Canceled"});default:return e.jsx(st,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(gr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(en,{className:"mr-2 h-4 w-4"}),"Manage Billing"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription."})]})]})},p$t=()=>{const{user:t}=Os(),s=nr(),{toast:r}=Ha(),[n]=uc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:p}=eQe(),[f,g]=N.useState(!1),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState(""),[P,O]=N.useState({name:"",email:"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,U]=N.useState(!1),[B,V]=N.useState(!1),[X,Y]=N.useState({newPassword:"",confirmPassword:""});N.useEffect(()=>{t&&ee()},[t]),N.useEffect(()=>{o&&t&&setTimeout(()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const ee=async()=>{var oe,fe,ge;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ue,error:xe}=await H.from("profiles").select("name, email, phone, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(xe)throw console.error("Profile query error:",xe),xe;ue?(console.log("Profile loaded successfully:",ue),O({name:ue.name||"",email:ue.email||"",phone:ue.phone||"",title:ue.title||"",bio:ue.bio||"",areas_served:ue.areas_served||"",years_experience:((oe=ue.years_experience)==null?void 0:oe.toString())||"",instagram_url:ue.instagram_url||"",facebook_url:ue.facebook_url||"",linkedin_url:ue.linkedin_url||"",email_signature:ue.email_signature||"",use_email_signature:ue.use_email_signature||!1}),U(ue.digest_opt_out||!1)):(console.warn("No profile found for user"),O({name:((fe=t.user_metadata)==null?void 0:fe.name)||((ge=t.email)==null?void 0:ge.split("@")[0])||"",email:t.email||"",phone:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:_e}=await H.storage.from("avatars").list(`${t.id}`);if(_e&&_e.length>0){const{data:$e}=H.storage.from("avatars").getPublicUrl(`${t.id}/${_e[0].name}`);_($e.publicUrl)}}catch(ue){console.error("Error loading profile:",ue),r({title:"Error",description:ue.message||"Failed to load profile",variant:"destructive"})}},Q=oe=>{var ue;const fe=(ue=oe.target.files)==null?void 0:ue[0];if(!fe)return;const ge=new FileReader;ge.onloadend=()=>{L(ge.result),S(!0)},ge.readAsDataURL(fe),oe.target.value=""},ce=async oe=>{if(t){j(!0);try{const{data:fe}=await H.storage.from("avatars").list(`${t.id}`);fe&&fe.length>0&&await H.storage.from("avatars").remove(fe.map(Me=>`${t.id}/${Me.name}`));const ue=`${t.id}/avatar.jpg`,{error:xe}=await H.storage.from("avatars").upload(ue,oe,{upsert:!0,contentType:"image/jpeg"});if(xe)throw xe;const{data:_e}=H.storage.from("avatars").getPublicUrl(ue),$e=_e.publicUrl;_(`${$e}?t=${Date.now()}`),await H.from("profiles").update({avatar_url:$e}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(fe){console.error("Error uploading avatar:",fe),r({title:"Error",description:fe.message||"Failed to upload photo",variant:"destructive"})}finally{j(!1)}}},ne=async()=>{if(!P.name.trim()||!P.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}g(!0);try{const{error:oe}=await H.from("profiles").update({name:P.name.trim(),email:P.email.trim(),phone:P.phone.trim()||null,title:P.title.trim()||null,bio:P.bio.trim()||null,areas_served:P.areas_served.trim()||null,years_experience:P.years_experience?parseInt(P.years_experience):null,instagram_url:P.instagram_url.trim()||null,facebook_url:P.facebook_url.trim()||null,linkedin_url:P.linkedin_url.trim()||null,email_signature:P.email_signature||"",use_email_signature:P.use_email_signature}).eq("id",t==null?void 0:t.id);if(oe)throw oe;r({title:"Success",description:"Profile updated successfully"})}catch(oe){console.error("Error updating profile:",oe),r({title:"Error",description:oe.message||"Failed to update profile",variant:"destructive"})}finally{g(!1)}},re=async()=>{if(!X.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(X.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(X.newPassword!==X.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}g(!0);try{const{error:oe}=await H.auth.updateUser({password:X.newPassword});if(oe)throw oe;r({title:"Success",description:"Password updated successfully"}),Y({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(oe){console.error("Error updating password:",oe),r({title:"Error",description:oe.message||"Failed to update password",variant:"destructive"})}finally{g(!1)}};return e.jsx(Ts,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var oe;(oe=document.getElementById("change-password-section"))==null||oe.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(lS,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Profile Photo"}),e.jsx(gr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(kn,{className:"h-24 w-24",children:[e.jsx(Ua,{src:v}),e.jsx(Sn,{className:"text-2xl",children:P.name.split(" ").map(oe=>oe[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Q,disabled:w}),e.jsxs(K,{variant:"outline",onClick:()=>{var oe;return(oe=document.getElementById("avatar-upload"))==null?void 0:oe.click()},disabled:w,children:[e.jsx(di,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Personal Information"}),e.jsx(gr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:P.name,onChange:oe=>O({...P,name:oe.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:P.email,onChange:oe=>O({...P,email:oe.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone Number"}),e.jsx(ze,{id:"phone",type:"tel",value:P.phone,onChange:oe=>O({...P,phone:oe.target.value}),placeholder:"e.g., +14155551234",maxLength:20}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used for SMS lead notifications from your website — if you have a local authority site"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Job Title"}),e.jsx(ze,{id:"title",value:P.title,onChange:oe=>O({...P,title:oe.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"bio",children:"Bio"}),e.jsx(Pr,{id:"bio",value:P.bio,onChange:oe=>O({...P,bio:oe.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(ze,{id:"areas_served",value:P.areas_served,onChange:oe=>O({...P,areas_served:oe.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(ze,{id:"years_experience",type:"number",min:"0",value:P.years_experience,onChange:oe=>O({...P,years_experience:oe.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(ze,{value:P.linkedin_url,onChange:oe=>O({...P,linkedin_url:oe.target.value}),placeholder:"LinkedIn URL"}),e.jsx(ze,{value:P.instagram_url,onChange:oe=>O({...P,instagram_url:oe.target.value}),placeholder:"Instagram URL"}),e.jsx(ze,{value:P.facebook_url,onChange:oe=>O({...P,facebook_url:oe.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ne,disabled:f,children:[e.jsx(Uc,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Uv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(gr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:P.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(qr,{checked:P.use_email_signature,onCheckedChange:oe=>O({...P,use_email_signature:oe})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Signature"}),e.jsx(fy,{content:P.email_signature,onChange:oe=>O({...P,email_signature:oe}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:ne,disabled:f,children:[e.jsx(Uc,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:a?"Set Your Password":"Change Password"}),e.jsx(gr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"newPassword",children:"New Password"}),e.jsx(ze,{id:"newPassword",type:"password",value:X.newPassword,onChange:oe=>Y({...X,newPassword:oe.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(ze,{id:"confirmPassword",type:"password",value:X.confirmPassword,onChange:oe=>Y({...X,confirmPassword:oe.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(Uc,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&e.jsx(K,{variant:"outline",onClick:()=>s("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[i?e.jsx(Lm,{className:"h-5 w-5"}):e.jsx(i1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(gr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(qr,{checked:i,onCheckedChange:oe=>{oe?u():p()},disabled:c})]}):e.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Push notifications are not available in this browser."}),e.jsxs("p",{className:"text-xs space-y-1",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"Android:"})," Use Chrome or Firefox.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"})," Push notifications on iOS ",e.jsx("em",{children:"only"})," work when this site is installed as an app from ",e.jsx("strong",{children:"Safari"}),". Open this site in Safari → tap the ",e.jsx("strong",{children:"Share"})," button → ",e.jsx("strong",{children:"Add to Home Screen"}),". Other browsers (Chrome, Firefox, etc.) on iOS do not support push notifications due to Apple restrictions."]})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[$?e.jsx(kL,{className:"h-5 w-5"}):e.jsx(lr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(gr,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(qr,{checked:!$,onCheckedChange:async oe=>{V(!0);try{const{error:fe}=await H.from("profiles").update({digest_opt_out:!oe}).eq("id",t==null?void 0:t.id);if(fe)throw fe;U(!oe),r({title:oe?"Subscribed":"Unsubscribed",description:oe?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(fe){r({title:"Error",description:fe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:B})]})})]}),e.jsx(H8t,{}),e.jsx(m$t,{})]}),e.jsx(Lke,{open:k,onClose:()=>S(!1),imageSrc:M,onCropComplete:ce,aspectRatio:1})]})})};var f$t="AspectRatio",jet=N.forwardRef((t,s)=>{const{ratio:r=1/1,style:n,...a}=t;return e.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/r}%`},"data-radix-aspect-ratio-wrapper":"",children:e.jsx(an.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});jet.displayName=f$t;var x$t=jet;const g$t=x$t;function y$t(){const{user:t}=Os(),s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),{data:l,isLoading:i}=mt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:_,error:w}=await H.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return _},enabled:!!t&&a}),c=Lt({mutationFn:async()=>{const _=new Uint8Array(12);crypto.getRandomValues(_);const w=btoa(String.fromCharCode(..._)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:j}=await H.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(j)throw j;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),me.success("Calendar subscription URL generated!")},onError:_=>{me.error("Failed to generate calendar URL: "+_.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),me.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},g=()=>{if(u){const _=u.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(_)}`;window.open(w,"_blank")}},v=()=>{if(u){const _=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(_,"_blank")}};return e.jsxs(xs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Wr,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),e.jsx("div",{className:"space-y-4 py-4",children:i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Your Calendar URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(ba,{className:"h-4 w-4 text-green-500"}):e.jsx(yi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:f,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"Add to Apple Calendar",e.jsx(en,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:g,children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-15A2.5 2.5 0 0 1 4.5 2H9v2H4.5a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5V15h2v4.5a2.5 2.5 0 0 1-2.5 2.5z"}),e.jsx("path",{d:"M12 2v8.5a1.5 1.5 0 0 0 1.5 1.5H22V2h-10z",fill:"#4285F4"}),e.jsx("path",{d:"M12 12V2H4.5A2.5 2.5 0 0 0 2 4.5V12h10z",fill:"#34A853"}),e.jsx("path",{d:"M2 12v7.5A2.5 2.5 0 0 0 4.5 22H12v-10H2z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 22h7.5a2.5 2.5 0 0 0 2.5-2.5V12h-10v10z",fill:"#EA4335"})]}),"Add to Google Calendar",e.jsx(en,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:v,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(en,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center pt-2",children:"Events sync automatically. If your membership expires, the calendar will show as empty."})]}):e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),e.jsx(K,{onClick:()=>c.mutate(),disabled:c.isPending,className:"w-full",children:c.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var Jue="Tabs",[v$t]=od(Jue,[Dw]),Net=Dw(),[b$t,Dke]=v$t(Jue),ket=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,p=Lw(i),[f,g]=oh({prop:n,onChange:a,defaultProp:o??"",caller:Jue});return e.jsx(b$t,{scope:r,baseId:Eu(),value:f,onValueChange:g,orientation:l,dir:p,activationMode:c,children:e.jsx(an.div,{dir:p,"data-orientation":l,...u,ref:s})})});ket.displayName=Jue;var Cet="TabsList",Met=N.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=Dke(Cet,r),l=Net(r);return e.jsx(Gde,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(an.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});Met.displayName=Cet;var Tet="TabsTrigger",Aet=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=Dke(Tet,r),i=Net(r),c=Iet(l.baseId,n),u=Let(l.baseId,n),p=n===l.value;return e.jsx(Wde,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(an.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...o,ref:s,onMouseDown:Lr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Lr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Lr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});Aet.displayName=Tet;var Eet="TabsContent",Pet=N.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=Dke(Eet,r),c=Iet(i.baseId,n),u=Let(i.baseId,n),p=n===i.value,f=N.useRef(p);return N.useEffect(()=>{const g=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(zd,{present:a||p,children:({present:g})=>e.jsx(an.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:g&&o})})});Pet.displayName=Eet;function Iet(t,s){return`${t}-trigger-${s}`}function Let(t,s){return`${t}-content-${s}`}var _$t=ket,Det=Met,Oet=Aet,Ret=Pet;const _a=_$t,fa=N.forwardRef(({className:t,...s},r)=>e.jsx(Det,{ref:r,className:It("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));fa.displayName=Det.displayName;const ns=N.forwardRef(({className:t,...s},r)=>e.jsx(Oet,{ref:r,className:It("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...s}));ns.displayName=Oet.displayName;const ws=N.forwardRef(({className:t,...s},r)=>e.jsx(Ret,{ref:r,className:It("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));ws.displayName=Ret.displayName;const w$t={first_timer:Jn,regular:h1,dedicated:tc,veteran:vo,streak_master:sh,century:vo},j$t={first_timer:"bg-green-500/10 text-green-500 border-green-500/20",regular:"bg-blue-500/10 text-blue-500 border-blue-500/20",dedicated:"bg-purple-500/10 text-purple-500 border-purple-500/20",veteran:"bg-amber-500/10 text-amber-500 border-amber-500/20",streak_master:"bg-orange-500/10 text-orange-500 border-orange-500/20",century:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20"};function _8e(t){return t===1?e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(h1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(tc,{className:"h-5 w-5 text-amber-600"}):e.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:t})}function Fet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Os(),{data:o,isLoading:l}=jQe(s?5:10,r),{data:i}=NQe(a==null?void 0:a.id),{data:c}=SQe(a==null?void 0:a.id),{data:u}=kQe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(vs,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),c&&e.jsxs(st,{variant:"secondary",className:"text-xs",children:["Rank #",c]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(sh,{className:"h-4 w-4 text-orange-500"}),e.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),u&&u.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[u.slice(0,4).map(p=>{const f=w$t[p.badge_type]||Jn;return e.jsxs(st,{variant:"outline",className:`text-xs ${j$t[p.badge_type]||""}`,title:p.badge_description||"",children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),u.length>4&&e.jsxs(st,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(_a,{defaultValue:"points",className:"w-full",children:[e.jsxs(fa,{className:"w-full mb-3",children:[e.jsx(ns,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(ns,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(ws,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var g,v,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:_8e(f+1)}),e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{className:"text-xs",children:((v=(g=p.profile)==null?void 0:g.name)==null?void 0:v.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx(ws,{value:"events",className:"mt-0",children:e.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,f)=>f.total_events_attended-p.total_events_attended).map((p,f)=>{var g,v,_;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${f===0?"bg-yellow-500/5":""}`,children:[e.jsx("div",{className:"w-6 flex justify-center",children:_8e(f+1)}),e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{className:"text-xs",children:((v=(g=p.profile)==null?void 0:g.name)==null?void 0:v.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((_=p.profile)==null?void 0:_.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function N$t(){const t=nr(),{user:s,isAdmin:r}=Os(),n=Xt(),{data:a,isLoading:o}=mt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:j}=await H.from("events").select("*").order("event_date",{ascending:!0});if(j)throw j;return w}}),{data:l}=mt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:j}=await H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(j)throw j;return w},enabled:!!s}),{data:i}=mt({queryKey:["event-registration-counts"],queryFn:async()=>{let w=[],j=0;const k=1e3;for(;;){const{data:M,error:L}=await H.from("event_registrations").select("event_id").range(j,j+k-1);if(L)throw L;if(!M||M.length===0||(w=w.concat(M),M.length{S[M.event_id]=(S[M.event_id]||0)+1}),S}}),c=Lt({mutationFn:async w=>{await H.auth.refreshSession();const{data:j,error:k}=await H.functions.invoke("zoom-register",{body:{event_id:w}});if(k)throw k;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:w=>{me.error("Failed to register: "+w.message)}}),u=Lt({mutationFn:async w=>{const{data:j,error:k}=await H.functions.invoke("zoom-unregister",{body:{event_id:w}});if(k)throw k;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:w=>{me.error("Failed to cancel: "+w.message)}}),p=w=>l==null?void 0:l.some(j=>j.event_id===w),f=w=>{const j=l==null?void 0:l.find(k=>k.event_id===w);return j==null?void 0:j.zoom_join_url},g=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,v=(a==null?void 0:a.filter(w=>oT(w.event_date)!=="ended"))||[],_=(a==null?void 0:a.filter(w=>oT(w.event_date)==="ended"))||[];return e.jsx(Ts,{title:"Events",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Events"}),e.jsx("p",{className:"text-muted-foreground",children:"Browse and register for upcoming events"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y$t,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):v.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:v.map(w=>{const j=oT(w.event_date),k=ENe(w.event_date),S=j==="live",M=j==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":M?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${w.id}`),children:[k&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(x1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(g$t,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Pt,{children:[e.jsx(Rt,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(gr,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-4 w-4"}),yD(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(t8,{className:"flex gap-2",onClick:L=>L.stopPropagation(),children:p(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(w.id),disabled:u.isPending,children:[e.jsx(Mr,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(w.id)||w.zoom_link,"_blank"),children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>c.mutate(w.id),disabled:c.isPending||g(w),children:g(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ba,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),_.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:_.map(w=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-base line-clamp-1",children:w.title}),e.jsx(gr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Fet,{showUserStats:!0})})]})]})})}const Fge=[{value:"all",label:"All Roles",icon:hr},{value:"newest",label:"Newest Members",icon:un},{value:"brokerage_manager",label:"Brokerage Managers",icon:KL},{value:"admin",label:"Admins",icon:Au}];function k$t({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var Le,Qe;const{user:o,isAdmin:l,isBrokerageManager:i}=Os(),[c,u]=N.useState([]),[p,f]=N.useState([]),[g,v]=N.useState([]),[_,w]=N.useState([]),[j,k]=N.useState(""),[S,M]=N.useState(""),[L,P]=N.useState(""),[O,$]=N.useState(!1),[U,B]=N.useState(!1),[V,X]=N.useState("agents"),[Y,ee]=N.useState("all"),[Q,ce]=N.useState({}),ne=l||i;N.useEffect(()=>{t&&o&&(l?re():oe())},[t,o,l]),N.useEffect(()=>{t||(v([]),w([]),k(""),M(""),P(""),X("agents"),ee("all"))},[t]);const re=async()=>{if(o){$(!0);try{const{data:Te,error:pt}=await H.from("brokerages").select("id, name").order("name");if(pt)throw pt;const ye=1e3,qe={};let at=0,tt=!0;for(;tt;){const{data:He,error:ct}=await H.from("profiles").select("brokerage_id").range(at*ye,(at+1)*ye-1);if(ct)throw ct;He==null||He.forEach(Ue=>{Ue.brokerage_id&&(qe[Ue.brokerage_id]=(qe[Ue.brokerage_id]||0)+1)}),tt=(He==null?void 0:He.length)===ye,at++}f((Te==null?void 0:Te.map(He=>({...He,agent_count:qe[He.id]||0})))||[]);const Ae=[];for(at=0,tt=!0;tt;){const{data:He,error:ct}=await H.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(at*ye,(at+1)*ye-1);if(ct)throw ct;He&&Ae.push(...He),tt=(He==null?void 0:He.length)===ye,at++}const rt={};for(at=0,tt=!0;tt;){const{data:He,error:ct}=await H.from("user_roles").select("user_id, role").range(at*ye,(at+1)*ye-1);if(ct)throw ct;He==null||He.forEach(Ue=>{rt[Ue.user_id]||(rt[Ue.user_id]=[]),rt[Ue.user_id].push(Ue.role)}),tt=(He==null?void 0:He.length)===ye,at++}ce(rt),u(Ae.map(He=>{var ct;return{id:He.id,name:He.name,email:He.email,brokerage_name:((ct=He.brokerages)==null?void 0:ct.name)||"No Brokerage",roles:rt[He.id]||[],created_at:He.created_at}}))}catch(Te){console.error("Error loading data:",Te),me.error("Failed to load agents and brokerages")}finally{$(!1)}}},oe=async()=>{if(o){$(!0);try{const{data:Te}=await H.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Te!=null&&Te.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:pt,error:ye}=await H.from("profiles").select("id, name, email").eq("brokerage_id",Te.brokerage_id).neq("id",o.id).order("name");if(ye)throw ye;u(pt||[])}catch(Te){console.error("Error loading agents:",Te),me.error("Failed to load agents")}finally{$(!1)}}},fe=c.filter(Te=>{var ye;const pt=Te.name.toLowerCase().includes(j.toLowerCase())||Te.email.toLowerCase().includes(j.toLowerCase())||((ye=Te.brokerage_name)==null?void 0:ye.toLowerCase().includes(j.toLowerCase()));if(l&&Y!=="all"&&Y!=="newest"){const qe=Q[Te.id]||[];return pt&&qe.includes(Y)}return pt}).sort((Te,pt)=>Y==="newest"?(pt.created_at||"").localeCompare(Te.created_at||""):0),ge=p.filter(Te=>Te.name.toLowerCase().includes(S.toLowerCase())),ue=()=>{g.length===fe.length?v([]):v(fe.map(Te=>Te.id))},xe=()=>{_.length===ge.length?w([]):w(ge.map(Te=>Te.id))},_e=Te=>{if(!ne){v([Te]);return}v(pt=>pt.includes(Te)?pt.filter(ye=>ye!==Te):[...pt,Te])},$e=Te=>{w(pt=>pt.includes(Te)?pt.filter(ye=>ye!==Te):[...pt,Te])},Me=async()=>{if(!(g.length>0||_.length>0)){me.error("Please select at least one agent or brokerage to share with");return}B(!0);try{const{data:pt,error:ye}=await H.functions.invoke("send-share-notification",{body:{recipientIds:g,brokerageIds:_,resourceType:r,resourceId:n,resourceTitle:a,message:L.trim()||void 0}});if(ye)throw ye;const qe=(pt==null?void 0:pt.sharesCreated)||g.length;me.success(`Shared with ${qe} agent${qe!==1?"s":""}`),s(!1)}catch(pt){console.error("Error sharing resource:",pt),me.error("Failed to share resource")}finally{B(!1)}},Ie=Te=>Te.split(" ").map(pt=>pt[0]).join("").toUpperCase().slice(0,2),ke=Te=>{const pt=Q[Te]||[];return pt.includes("admin")?e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):pt.includes("brokerage_manager")?e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},pe=g.length+_.length,we=Y!=="all"&&Y!=="newest"?fe.length:null;return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{className:"flex-shrink-0",children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Wr,{className:"line-clamp-2",children:['Share "',a,'" with ',l?"agents or brokerages":"agents in your brokerage"]})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[l?e.jsxs(_a,{value:V,onValueChange:X,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(ns,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),g.length>0&&e.jsx(st,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:g.length})]}),e.jsxs(ns,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),_.length>0&&e.jsx(st,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:_.length})]})]}),e.jsxs(ws,{value:"agents",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:j,onChange:Te=>k(Te.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:Y,onValueChange:ee,children:[e.jsxs(Gs,{className:"w-[180px]",children:[e.jsx(ey,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Filter by role"})]}),e.jsx(Ws,{children:Fge.map(Te=>e.jsx(Mt,{value:Te.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te.icon,{className:"h-4 w-4"}),e.jsx("span",{children:Te.label})]})},Te.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:fe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===fe.length&&fe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[we!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[we," ",(Le=Fge.find(Te=>Te.value===Y))==null?void 0:Le.label]}),e.jsxs("span",{className:"font-medium",children:[g.length," selected"]})]})]}),e.jsx(Ki,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):fe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:Y!=="all"?`No ${(Qe=Fge.find(Te=>Te.value===Y))==null?void 0:Qe.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:fe.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Te.id)?"bg-accent":""}`,onClick:()=>_e(Te.id),children:[e.jsx(Oo,{checked:g.includes(Te.id),onCheckedChange:()=>_e(Te.id),className:"flex-shrink-0"}),e.jsx(kn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(Sn,{className:"text-xs bg-primary/10 text-primary",children:Ie(Te.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),ke(Te.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Te.email,Te.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Te.brokerage_name]})]})]})]},Te.id))})})]}),e.jsxs(ws,{value:"brokerages",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:S,onChange:Te=>M(Te.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:xe,className:"text-xs h-8",disabled:ge.length===0,children:[e.jsx(Ca,{className:"h-3.5 w-3.5 mr-1.5"}),_.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[_.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Ki,{className:"h-[250px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(Ca,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:ge.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${_.includes(Te.id)?"bg-accent":""}`,onClick:()=>$e(Te.id),children:[e.jsx(Oo,{checked:_.includes(Te.id),onCheckedChange:()=>$e(Te.id),className:"flex-shrink-0"}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Ca,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Te.agent_count," agent",Te.agent_count!==1?"s":""]})]})]},Te.id))})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:j,onChange:Te=>k(Te.target.value),className:"pl-9"})]}),ne&&e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ue,className:"text-xs h-8",disabled:fe.length===0,children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===fe.length&&fe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[g.length," selected"]})]}),e.jsx(Ki,{className:"h-[300px] border rounded-lg",children:O?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):fe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:fe.map(Te=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${g.includes(Te.id)?"bg-accent":""}`,onClick:()=>_e(Te.id),children:[e.jsx(Oo,{checked:g.includes(Te.id),onCheckedChange:()=>_e(Te.id),className:"flex-shrink-0"}),e.jsx(kn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(Sn,{className:"text-xs bg-primary/10 text-primary",children:Ie(Te.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Te.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Te.email})]})]},Te.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(be,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Pr,{id:"message",placeholder:"I thought you might find this useful...",value:L,onChange:Te=>P(Te.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Me,disabled:pe===0||U,children:U?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function gE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=N.useState(!1),{user:c}=Os();return c?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(k$t,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function S$t(){const{eventId:t}=lo(),s=nr(),{user:r}=Os(),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(0),[u,p]=N.useState(!0),[f,g]=N.useState(!1);N.useEffect(()=>{t&&v()},[t,r]);const v=async()=>{try{const{data:M,error:L}=await H.from("events").select("*").eq("id",t).single();if(L)throw L;a(M);const{count:P}=await H.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(P||0),r){const{data:O}=await H.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(O)}}catch(M){console.error("Error loading event:",M),me.error("Failed to load event"),s("/events")}finally{p(!1)}},_=async()=>{if(!(!r||!n)){g(!0);try{const{error:M}=await H.auth.refreshSession();if(M){console.error("Session refresh failed:",M),me.error("Your session has expired. Please log in again.");return}if(o){const{error:L}=await H.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully cancelled registration"),l(null),c(P=>P-1)}else{const{data:L,error:P}=await H.functions.invoke("zoom-register",{body:{event_id:n.id}});if(P)throw P;me.success("Successfully registered for event!"),l({id:L.registration_id,zoom_join_url:L.zoom_join_url}),c(O=>O+1)}}catch(M){console.error("Registration error:",M),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{g(!1)}}},w=M=>{var L,P,O;if(M.includes("iframe.mediadelivery.net")||M.includes("video.bunnycdn.com")){const $=M.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(M.includes("youtube.com")||M.includes("youtu.be")){const $=M.includes("youtu.be")?(L=M.split("youtu.be/")[1])==null?void 0:L.split("?")[0]:(P=M.split("v=")[1])==null?void 0:P.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(M.includes("vimeo.com")){const $=(O=M.split("vimeo.com/")[1])==null?void 0:O.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return M};if(u)return e.jsx(Ts,{title:"Event",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading event..."})]})})});if(!n)return e.jsx(Ts,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const j=k0(new Date(n.event_date)),k=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Ts,{title:n.title,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(K,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>s("/events"),children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),j&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(st,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),e.jsx(gE,{resourceType:"event",resourceId:n.id,resourceTitle:n.title})]}),n.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground dark:prose-invert",dangerouslySetInnerHTML:{__html:n.description}})]}),n.video_url&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(pp,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hn,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:yD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(gi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!j&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(en,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:_,disabled:f,children:[f?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:_,disabled:f||(k??!1),children:f?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):k?"Event Full":"Register Now"})}),j&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(en,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const C$t=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(Cn,{className:"h-6 w-6"}),path:"/mission-control/video/record",category:"Marketing",color:"bg-rose-500/15 text-rose-600"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(Mx,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing",color:"bg-sky-500/15 text-sky-600"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(ty,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing",color:"bg-amber-500/15 text-amber-600"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(wn,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing",color:"bg-emerald-500/15 text-emerald-600"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(Th,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House",color:"bg-orange-500/15 text-orange-600"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(fn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing",color:"bg-pink-500/15 text-pink-600"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(lr,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0,color:"bg-indigo-500/15 text-indigo-600"},{id:"reelflow",name:"ReelFlow",description:"Turn property photos into cinematic video clips and reels — powered by AI",icon:e.jsx(yu,{className:"h-6 w-6"}),path:"/admin/beta/homereel",category:"Marketing",beta:!0,isNew:!0,color:"bg-violet-500/15 text-violet-600"},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx($n,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],M$t=()=>{const{user:t,isAdmin:s}=Os(),r=nr(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(""),[u,p]=N.useState("all"),[f,g]=N.useState(new Set),[v,_]=N.useState(new Set);N.useEffect(()=>{w()},[t]);const w=async()=>{try{const{data:B}=await H.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),V=(B==null?void 0:B.map(fe=>fe.tag))||[],{data:X,error:Y}=await H.from("app_tiles").select("*").order("name");if(Y)throw Y;const[{data:ee},{data:Q}]=await Promise.all([H.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),H.from("user_tool_favorites").select("tool_id").eq("user_id",t==null?void 0:t.id)]),ce=new Set((ee==null?void 0:ee.map(fe=>fe.app_id))||[]);g(ce);const ne=new Set((Q||[]).map(fe=>fe.tool_id));_(ne);const oe=((X==null?void 0:X.filter(fe=>!fe.required_tags||fe.required_tags.length===0?!0:fe.required_tags.some(ge=>V.includes(ge))))||[]).sort((fe,ge)=>fe.name==="LevelUp Members Portal"?-1:ge.name==="LevelUp Members Portal"?1:0);a(oe)}catch(B){console.error("Error loading apps:",B),me.error("Failed to load apps")}finally{l(!1)}},j=async B=>{var X;const V=window.open("about:blank","_blank");try{const{data:Y,error:ee}=await H.auth.getSession();if(ee||!Y.session){V==null||V.close(),me.error("Session expired. Please refresh the page and try again.");return}const Q=Y.session.access_token;await H.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:B.app_id,app_name:B.name,user_agent:navigator.userAgent});const{data:ce,error:ne}=await H.functions.invoke("sso-launch",{body:{app_id:B.app_id},headers:{Authorization:`Bearer ${Q}`}});if(ne)throw ne;ce!=null&&ce.redirect_url?V&&!V.closed?(V.location.href=ce.redirect_url,(X=V.focus)==null||X.call(V)):window.location.assign(ce.redirect_url):(V==null||V.close(),me.error("Launch link unavailable"))}catch(Y){V==null||V.close(),console.error("Error launching app:",Y),me.error("Failed to launch app. Please try again.")}},k=async(B,V)=>{B.stopPropagation();const X=f.has(V);try{if(X){const{error:Y}=await H.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(Y)throw Y;g(ee=>{const Q=new Set(ee);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:Y}=await H.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(Y)throw Y;g(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling favorite:",Y),me.error("Failed to update favorites")}},S=async(B,V)=>{B.stopPropagation();const X=v.has(V);try{if(X){const{error:Y}=await H.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(Y)throw Y;_(ee=>{const Q=new Set(ee);return Q.delete(V),Q}),me.success("Removed from favorites")}else{const{error:Y}=await H.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(Y)throw Y;_(ee=>new Set(ee).add(V)),me.success("Added to favorites")}}catch(Y){console.error("Error toggling tool favorite:",Y),me.error("Failed to update favorites")}},M=n.filter(B=>{var X;const V=B.name.toLowerCase().includes(i.toLowerCase())||((X=B.description)==null?void 0:X.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has(B.id):V}),L=C$t.filter(B=>{if(B.adminOnly&&!s)return!1;const V=B.name.toLowerCase().includes(i.toLowerCase())||B.description.toLowerCase().includes(i.toLowerCase());return u==="favorites"?V&&v.has(B.id):V}),P=L.reduce((B,V)=>(B[V.category]||(B[V.category]=[]),B[V.category].push(V),B),{}),O=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Ts,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const $=u==="all"||u==="tools"||u==="favorites",U=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Ts,{title:"Apps & Tools",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps & Tools"}),e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:B=>c(B.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:O.map(B=>e.jsxs("button",{onClick:()=>p(B.id),className:It("pb-3 text-sm font-medium transition-colors relative",u===B.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[B.label,u===B.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},B.id))}),$&&Object.keys(P).length>0&&e.jsxs("div",{className:"mb-10",children:[u==="all"&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(sy,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(P).map(([B,V])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:B})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:V.map(X=>{const Y=v.has(X.id);return e.jsxs("div",{onClick:()=>r(X.path),className:It("group flex items-start gap-4 p-5 bg-card rounded-xl border transition-all duration-200 hover:shadow-lg cursor-pointer relative overflow-hidden",X.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[X.isNew&&e.jsx("div",{className:"absolute top-0 right-0 bg-gradient-to-r from-violet-500 to-indigo-500 text-white text-[10px] font-bold uppercase px-3 py-0.5 rounded-bl-lg tracking-wider shadow-sm",children:"✨ New"}),e.jsx("div",{className:It("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",X.color||"bg-primary/10 text-primary"),children:X.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate flex items-center gap-2",children:[X.name,X.beta&&e.jsx("span",{className:"text-[10px] font-semibold bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded-full border border-amber-200",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:X.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",Y?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:ee=>S(ee,X.id),children:e.jsx(Sx,{className:It("h-5 w-5",Y&&"fill-current")})})]},X.id)})})]},B))]}),U&&e.jsxs("div",{children:[u==="all"&&M.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(en,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),M.length===0&&u!=="all"&&!(u==="favorites"&&L.length>0)?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(Sx,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app or tool to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Eh,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:s?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),s&&e.jsx(K,{className:"mt-4",onClick:()=>r("/admin/apps"),children:"Add Apps"})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:M.map(B=>{const V=f.has(B.id),X=B.name.toLowerCase().includes("agent review")||B.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>j(B),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:B.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:B.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:B.description})]}),e.jsx("button",{className:It("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:Y=>k(Y,B.id),children:e.jsx(Sx,{className:It("h-5 w-5",V&&"fill-current")})})]}),X&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:Y=>Y.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},B.id)})})]}),$&&U&&M.length===0&&L.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(sn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No results found"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Try a different search term"})]})]})},T$t=()=>{const t=nr(),[s,r]=N.useState(""),[n,a]=N.useState("all"),[o,l]=N.useState("all"),[i,c]=N.useState("grid"),{data:u=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:k,error:S}=await H.from("template_categories").select("*").order("name");if(S)throw S;return k}}),{data:p=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:k,error:S}=await H.from("template_types").select("*").order("name");if(S)throw S;return k}}),{data:f=[],isLoading:g}=mt({queryKey:["canva-templates"],queryFn:async()=>{const{data:k,error:S}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(S)throw S;const{data:M,error:L}=await H.from("template_links").select("*").order("sort_order");if(L)throw L;const{data:P}=await H.from("template_likes").select("template_id"),{data:O}=await H.from("template_comments").select("template_id"),$=new Map;P==null||P.forEach(V=>{$.set(V.template_id,($.get(V.template_id)||0)+1)});const U=new Map;return O==null||O.forEach(V=>{U.set(V.template_id,(U.get(V.template_id)||0)+1)}),(k||[]).map(V=>({...V,links:(M||[]).filter(X=>X.template_id===V.id)||[],likesCount:$.get(V.id)||0,commentsCount:U.get(V.id)||0}))}}),v=f.filter(k=>{var P;const S=k.name.toLowerCase().includes(s.toLowerCase())||((P=k.description)==null?void 0:P.toLowerCase().includes(s.toLowerCase())),M=n==="all"||k.category_id===n,L=o==="all"||k.type_id===o;return S&&M&&L}),_=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",j=k=>{t(`/templates/${k}`)};return e.jsx(Ts,{title:"Canva Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:s,onChange:k=>r(k.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:n,onValueChange:a,children:[e.jsx(Gs,{className:"w-full sm:w-48",children:e.jsx(Ys,{placeholder:"All Categories"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),u.map(k=>e.jsx(Mt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs(Ks,{value:o,onValueChange:l,children:[e.jsx(Gs,{className:"w-full sm:w-48",children:e.jsx(Ys,{placeholder:"All Types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),p.map(k=>e.jsx(Mt,{value:k.id,children:k.name},k.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(K,{variant:"outline",size:"sm",onClick:_,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>c("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>c("list"),className:"rounded-full",children:e.jsx(rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[v.length," template",v.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((k,S)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(vs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(vs,{className:"h-5 w-3/4 mb-2"}),e.jsx(vs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(vs,{className:"h-5 w-16"}),e.jsx(vs,{className:"h-5 w-20"})]})]})},S))}),!g&&v.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(K,{variant:"outline",onClick:_,children:"Clear Filters"})]}),!g&&v.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:v.map(k=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>j(k.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[k.preview_image_url?e.jsx("img",{src:k.preview_image_url,alt:k.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),k.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Bo,{className:"h-3 w-3"}),k.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:k.name}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Lde(k.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[k.category&&e.jsx(st,{variant:"secondary",className:"text-xs",children:k.category.name}),k.type&&e.jsx(st,{variant:"outline",className:"text-xs",children:k.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3.5 w-3.5"}),k.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3.5 w-3.5"}),k.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),j(k.id)},children:[e.jsx(en,{className:"h-4 w-4"}),"View Template"]})]})]},k.id))})]})})};var A$t="Separator",w8e="horizontal",E$t=["horizontal","vertical"],zet=N.forwardRef((t,s)=>{const{decorative:r,orientation:n=w8e,...a}=t,o=P$t(n)?n:w8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(an.div,{"data-orientation":o,...i,...a,ref:s})});zet.displayName=A$t;function P$t(t){return E$t.includes(t)}var Bet=zet;const al=N.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(Bet,{ref:a,decorative:r,orientation:s,className:It("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));al.displayName=Bet.displayName;const I$t=()=>{const{templateId:t}=lo(),s=nr(),{user:r,isAdmin:n}=Os(),{toast:a}=Ha(),o=Xt(),{trackEngagement:l}=hE(),[i,c]=N.useState(""),{data:u,isLoading:p}=mt({queryKey:["template-detail",t],queryFn:async()=>{const{data:L,error:P}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(P)throw P;const{data:O}=await H.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:$}=await H.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...L,links:O||[],guides:$||[]}},enabled:!!t}),{data:f=[]}=mt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:L,error:P}=await H.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(P)throw P;return(L||[]).map(O=>O.resource_kits).filter(Boolean)},enabled:!!t});N.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:g=[]}=mt({queryKey:["template-likes",t],queryFn:async()=>{const{data:L,error:P}=await H.from("template_likes").select("*").eq("template_id",t);if(P)throw P;return L},enabled:!!t}),{data:v=[]}=mt({queryKey:["template-comments",t],queryFn:async()=>{const{data:L,error:P}=await H.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(P)throw P;const O=[...new Set(L.map(B=>B.user_id))],{data:$}=await H.from("profiles").select("id, name").in("id",O),U=new Map(($==null?void 0:$.map(B=>[B.id,B.name]))||[]);return L.map(B=>({...B,user_name:U.get(B.user_id)||"Unknown User"}))},enabled:!!t}),_=Lt({mutationFn:async L=>{const{error:P}=await H.from("template_comments").insert({template_id:t,user_id:r.id,content:L});if(P)throw P},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:L=>{a({title:"Error adding comment",description:L.message,variant:"destructive"})}}),w=Lt({mutationFn:async L=>{const{error:P}=await H.from("template_comments").delete().eq("id",L);if(P)throw P},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),j=Lt({mutationFn:async()=>{const L=g.find(P=>P.user_id===(r==null?void 0:r.id));if(L){const{error:P}=await H.from("template_likes").delete().eq("id",L.id);if(P)throw P}else{const{error:P}=await H.from("template_likes").insert({template_id:t,user_id:r.id});if(P)throw P}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),k=g.some(L=>L.user_id===(r==null?void 0:r.id)),S=L=>L.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),M=L=>{L.preventDefault(),!(!i.trim()||!r)&&_.mutate(i.trim())};return p?e.jsx(Ts,{title:"Templates",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):u?e.jsx(Ts,{title:u.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/templates",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:u.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.category&&e.jsx(st,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(st,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(pa,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(gE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:k?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!r||j.isPending,children:[e.jsx(nh,{className:`h-4 w-4 ${k?"fill-current":""}`}),g.length," ",g.length===1?"Like":"Likes"]})]})]}),u.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&>p]:mb-4 [&>p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:u.description}})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(L.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(en,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(L.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:L.name}),L.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(L.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Al,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(L=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${L.id}`),children:[L.featured_image_url?e.jsx("img",{src:L.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Al,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:L.name})]},L.id))})]})}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(qc,{className:"h-5 w-5"}),"Comments (",v.length,")"]}),r?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Add a comment...",value:i,onChange:L=>c(L.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||_.isPending,children:e.jsx($n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:v.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):v.map(L=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(kn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Sn,{className:"text-sm",children:S(L.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:L.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vc(new Date(L.created_at),{addSuffix:!0})}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>w.mutate(L.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:L.content})]})]})})},L.id))})]})]})}):e.jsx(Ts,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/templates",children:"Back to Templates"})})]})})},L$t=()=>{const{user:t}=Os(),[s,r]=N.useState(""),[n,a]=N.useState("all"),{data:o=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:g,error:v}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(v)throw v;return g}}),{data:l=[],isLoading:i}=mt({queryKey:["academy-videos"],queryFn:async()=>{const{data:g,error:v}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(v)throw v;const{data:_,error:w}=await H.from("academy_resources").select("*").order("sort_order");if(w)throw w;return g.map(k=>({...k,resources:(_==null?void 0:_.filter(S=>S.video_id===k.id))||[]}))}}),{data:c=[]}=mt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:g,error:v}=await H.from("academy_video_likes").select("video_id, user_id");if(v)throw v;return g}}),u=l.filter(g=>{var w;const v=s===""||g.title.toLowerCase().includes(s.toLowerCase())||((w=g.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),_=n==="all"||g.category_id===n;return v&&_}),p=g=>c.filter(v=>v.video_id===g).length,f=g=>c.some(v=>v.video_id===g&&v.user_id===(t==null?void 0:t.id));return e.jsx(Ts,{title:"Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:s,onChange:g=>r(g.target.value),className:"pl-10"})]})}),e.jsx(_a,{value:n,onValueChange:a,children:e.jsxs(fa,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(ns,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(g=>e.jsx(ns,{value:g.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:g.name},g.id))]})}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s?"Try adjusting your search terms":"Check back soon for new content"})]})}):e.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:u.map(g=>e.jsx(pa,{to:`/academy/${g.id}`,children:e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[g.thumbnail_url?e.jsx("img",{src:g.thumbnail_url,alt:g.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/90 flex items-center justify-center",children:e.jsx(il,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),g.duration&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),g.duration]})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Rt,{className:"text-lg line-clamp-2",children:g.title})}),g.category&&e.jsx(st,{variant:"secondary",className:"w-fit",children:g.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[g.description&&e.jsx(gr,{className:"line-clamp-2",children:g.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:`h-4 w-4 ${f(g.id)?"fill-primary text-primary":""}`}),p(g.id)]}),g.resources&&g.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),g.resources.length]})]})]})]})},g.id))})]})})};function $et({resourceType:t,resourceId:s}){const{data:r=[]}=mt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await H.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await H.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(Bl,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(pa,{to:`/templates/${n.id}`,children:e.jsxs(st,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(Bl,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const D$t=(t,s)=>{if(s==="bunny_stream"){let r=t.replace("iframe.mediadelivery.net","player.mediadelivery.net");return r.includes("?")||(r+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),r}if(s==="youtube"){const r=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=t.match(r);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(s==="vimeo"){const r=/vimeo\.com\/(?:video\/)?(\d+)/,n=t.match(r);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(s==="loom"){const r=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=t.match(r);if(n)return`https://www.loom.com/embed/${n[1]}`}return t},O$t=()=>{const{videoId:t}=lo();nr();const{user:s,isAdmin:r}=Os(),{toast:n}=Ha(),a=Xt(),{trackEngagement:o}=hE(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["academy-video",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:P}=await H.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...M,resources:P||[]}},enabled:!!t});N.useEffect(()=>{c&&o("academy_video",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_likes").select("*").eq("video_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(L)throw L;const P=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",P),$=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:$.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),v=Lt({mutationFn:async M=>{const{error:L}=await H.from("academy_video_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("academy_video_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=p.some(M=>M.user_id===(s==null?void 0:s.id)),j=M=>{switch(M==null?void 0:M.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},k=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(Ts,{title:"Academy",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):c?e.jsx(Ts,{title:c.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/academy",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Academy"]})}),e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-black",style:{paddingTop:"56.25%"},children:["youtube","vimeo","loom","bunny_stream"].includes(c.video_type)?e.jsx("iframe",{src:D$t(c.video_url,c.video_type),loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,height:"100%",width:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[e.jsx(Cn,{className:"h-16 w-16 opacity-50"}),e.jsx(K,{variant:"secondary",asChild:!0,children:e.jsxs("a",{href:c.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[e.jsx(en,{className:"h-4 w-4"}),"Open Video"]})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.title}),c.category&&e.jsx(st,{variant:"secondary",children:c.category.name})]}),e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(pa,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(gE,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(nh,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.resources&&c.resources.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:c.resources.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:j(M.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:M.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:M.file_type})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx($et,{resourceType:"academy_video",resourceId:c.id}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(qc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx($n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(kn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Sn,{className:"text-sm",children:k(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ts,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/academy",children:"Back to Academy"})})]})})};function R$t(){const t=nr(),[s,r]=N.useState(""),{data:n,isLoading:a}=mt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:v,error:_}=await H.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;return v}}),{data:o}=mt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:v,error:_}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l}=mt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:v,error:_}=await H.from("resource_kit_likes").select("kit_id");if(_)throw _;return v}}),{data:i}=mt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:v,error:_}=await H.from("resource_kit_comments").select("kit_id");if(_)throw _;return v}}),c=n==null?void 0:n.filter(v=>{var _;return v.name.toLowerCase().includes(s.toLowerCase())||((_=v.description)==null?void 0:_.toLowerCase().includes(s.toLowerCase()))}),u=v=>(o==null?void 0:o.filter(_=>_.kit_id===v))||[],p=v=>(l==null?void 0:l.filter(_=>_.kit_id===v).length)||0,f=v=>(i==null?void 0:i.filter(_=>_.kit_id===v).length)||0,g=v=>{t(`/toolbox/${v}`)};return e.jsx(Ts,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resource kits...",value:s,onChange:v=>r(v.target.value),className:"pl-10"})]}),!a&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(c==null?void 0:c.length)||0," resource kit",(c==null?void 0:c.length)!==1?"s":""," available"]}),a?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((v,_)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(vs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(vs,{className:"h-5 w-3/4 mb-2"}),e.jsx(vs,{className:"h-4 w-full mb-4"}),e.jsx(vs,{className:"h-4 w-2/3"})]})},_))}):(c==null?void 0:c.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(Al,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),e.jsx("p",{className:"text-muted-foreground",children:s?"Try adjusting your search terms":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:c==null?void 0:c.map(v=>{const _=u(v.id).length,w=p(v.id),j=f(v.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>g(v.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:v.featured_image_url?e.jsx("img",{src:v.featured_image_url,alt:v.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Al,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:v.name}),v.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:Lde(v.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),_," file",_!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3.5 w-3.5"}),j]})]})]})]})]},v.id)})})]})})}const F$t=()=>{const{kitId:t}=lo(),{user:s,isAdmin:r}=Os(),{toast:n}=Ha(),a=Xt(),{trackEngagement:o}=hE(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(L)throw L;const{data:P}=await H.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:O}=await H.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...M,files:P||[],links:O||[]}},enabled:!!t});N.useEffect(()=>{c&&o("toolbox",c.id,c.name,"view")},[c==null?void 0:c.id]);const{data:p=[]}=mt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_likes").select("*").eq("kit_id",t);if(L)throw L;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:M,error:L}=await H.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(L)throw L;const P=[...new Set(M.map(U=>U.user_id))],{data:O}=await H.from("profiles").select("id, name").in("id",P),$=new Map((O==null?void 0:O.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:$.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:M});if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:M=>{n({title:"Error adding comment",description:M.message,variant:"destructive"})}}),v=Lt({mutationFn:async M=>{const{error:L}=await H.from("resource_kit_comments").delete().eq("id",M);if(L)throw L},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(L=>L.user_id===(s==null?void 0:s.id));if(M){const{error:L}=await H.from("resource_kit_likes").delete().eq("id",M.id);if(L)throw L}else{const{error:L}=await H.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(L)throw L}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=p.some(M=>M.user_id===(s==null?void 0:s.id)),j=M=>M.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),k=M=>M?M<1024?M+" B":M<1024*1024?(M/1024).toFixed(1)+" KB":(M/(1024*1024)).toFixed(1)+" MB":"",S=M=>{M.preventDefault(),!(!l.trim()||!s)&&g.mutate(l.trim())};return u?e.jsx(Ts,{title:"Toolbox",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):c?e.jsx(Ts,{title:c.name,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/toolbox",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Toolbox"]})}),c.featured_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.featured_image_url,alt:c.name,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:c.name})}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(pa,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(gE,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(nh,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.files&&c.files.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"Included Resources (",c.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.files.map(M=>e.jsxs("a",{href:M.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_pdf"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(wn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:M.name}),M.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:k(M.file_size)})]})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},M.id))})]})}),c.links&&c.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(en,{className:"h-4 w-4"}),"Canva Templates (",c.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.links.map(M=>e.jsxs("a",{href:M.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("toolbox",c.id,c.name,"click_canva"),className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:e.jsx(en,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:M.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},M.id))})]})}),e.jsx($et,{resourceType:"resource_kit",resourceId:c.id}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(qc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Add a comment...",value:l,onChange:M=>i(M.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||g.isPending,children:e.jsx($n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(M=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(kn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Sn,{className:"text-sm",children:j(M.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:M.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vc(new Date(M.created_at),{addSuffix:!0})}),M.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:M.content})]})]})})},M.id))})]})]})}):e.jsx(Ts,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Al,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/toolbox",children:"Back to Toolbox"})})]})})},z$t=()=>{const t=nr(),[s,r]=N.useState(""),[n,a]=N.useState("grid"),{data:o=[],isLoading:l}=mt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await H.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:g}=await H.from("social_swag_links").select("*").order("sort_order");if(g)throw g;const{data:v}=await H.from("social_swag_likes").select("swag_id"),{data:_}=await H.from("social_swag_comments").select("swag_id"),w=new Map;v==null||v.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const j=new Map;return _==null||_.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(M=>M.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:j.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),c=u=>{t(`/social-swag/${u}`)};return e.jsx(Ts,{title:"Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search social swag...",value:s,onChange:u=>r(u.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(vs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(vs,{className:"h-5 w-3/4 mb-2"}),e.jsx(vs,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No items match your search":"No social swag available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(u=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>c(u.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[u.preview_image_url?e.jsx("img",{src:u.preview_image_url,alt:u.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),u.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Bo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3.5 w-3.5"}),u.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),c(u.id)},children:[e.jsx(en,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ki=function(){return ki=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(c||!u),f=s>1&&(u||!c),g=function(){n&&o(n)},v=function(){a&&o(a)};return e.jsx(yqt,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:v})}function vqt(t){var s,r=hc(),n=r.classNames,a=r.disableNavigation,o=r.styles,l=r.captionLayout,i=r.components,c=(s=i==null?void 0:i.CaptionLabel)!==null&&s!==void 0?s:Vet,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(j8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(j8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(N8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id})]}):u=e.jsxs(e.Fragment,{children:[e.jsx(c,{id:t.id,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(N8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function bqt(t){var s=hc(),r=s.footer,n=s.styles,a=s.classNames.tfoot;return r?e.jsx("tfoot",{className:a,style:n.tfoot,children:e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:r})})}):e.jsx(e.Fragment,{})}function _qt(t,s,r){for(var n=r?D1(new Date):Xh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=Il(n,o);a.push(l)}return a}function wqt(){var t=hc(),s=t.classNames,r=t.styles,n=t.showWeekNumber,a=t.locale,o=t.weekStartsOn,l=t.ISOWeek,i=t.formatters.formatWeekdayName,c=t.labels.labelWeekday,u=_qt(a,o,l);return e.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&e.jsx("td",{style:r.head_cell,className:s.head_cell}),u.map(function(p,f){return e.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(p,{locale:a}),children:i(p,{locale:a})},f)})]})}function jqt(){var t,s=hc(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:wqt;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function Nqt(t){var s=hc(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var Oke=N.createContext(void 0);function kqt(t){if(!nR(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(Oke.Provider,{value:s,children:t.children})}return e.jsx(Sqt,{initialProps:t.initialProps,children:t.children})}function Sqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var g,v;(g=s.onDayClick)===null||g===void 0||g.call(s,u,p,f);var _=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!_){var w=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var j=n?qet([],n):[];if(p.selected){var k=j.findIndex(function(S){return Tl(u,S)});j.splice(k,1)}else j.push(u);(v=s.onSelect)===null||v===void 0||v.call(s,j,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(g){return Tl(g,u)});return!!(p&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(Oke.Provider,{value:c,children:r})}function Rke(){var t=N.useContext(Oke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function Cqt(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?Tl(a,t)&&Tl(n,t)?void 0:Tl(a,t)?{from:a,to:void 0}:Tl(n,t)?void 0:ZS(n,t)?{from:t,to:a}:{from:n,to:t}:a?ZS(t,a)?{from:a,to:t}:{from:t,to:a}:n?YS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var Fke=N.createContext(void 0);function Mqt(t){if(!aR(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(Fke.Provider,{value:s,children:t.children})}return e.jsx(Tqt,{initialProps:t.initialProps,children:t.children})}function Tqt(t){var s=t.initialProps,r=t.children,n=s.selected,a=n||{},o=a.from,l=a.to,i=s.min,c=s.max,u=function(v,_,w){var j,k;(j=s.onDayClick)===null||j===void 0||j.call(s,v,_,w);var S=Cqt(v,n);(k=s.onSelect)===null||k===void 0||k.call(s,S,v,_,w)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],Tl(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:Nie(o,i-1),before:Il(o,i-1)}),o&&l&&p.disabled.push({after:o,before:Il(o,i-1)}),!o&&l&&p.disabled.push({after:Nie(l,i-1),before:Il(l,i-1)})),c){if(o&&!l&&(p.disabled.push({before:Il(o,-c+1)}),p.disabled.push({after:Il(o,c-1)})),o&&l){var f=mf(l,o)+1,g=c-f;p.disabled.push({before:Nie(o,g)}),p.disabled.push({after:Il(l,g)})}!o&&l&&(p.disabled.push({before:Il(l,-c+1)}),p.disabled.push({after:Il(l,c-1)}))}return e.jsx(Fke.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function zke(){var t=N.useContext(Fke);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function qie(t){return Array.isArray(t)?qet([],t):t!==void 0?[t]:[]}function Aqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=qie(a)}),s}var uy;(function(t){t.Outside="outside",t.Disabled="disabled",t.Selected="selected",t.Hidden="hidden",t.Today="today",t.RangeStart="range_start",t.RangeEnd="range_end",t.RangeMiddle="range_middle"})(uy||(uy={}));var Eqt=uy.Selected,Tv=uy.Disabled,Pqt=uy.Hidden,Iqt=uy.Today,zge=uy.RangeEnd,Bge=uy.RangeMiddle,$ge=uy.RangeStart,Lqt=uy.Outside;function Dqt(t,s,r){var n,a=(n={},n[Eqt]=qie(t.selected),n[Tv]=qie(t.disabled),n[Pqt]=qie(t.hidden),n[Iqt]=[t.today],n[zge]=[],n[Bge]=[],n[$ge]=[],n[Lqt]=[],n);return t.fromDate&&a[Tv].push({before:t.fromDate}),t.toDate&&a[Tv].push({after:t.toDate}),nR(t)?a[Tv]=a[Tv].concat(s.modifiers[Tv]):aR(t)&&(a[Tv]=a[Tv].concat(r.modifiers[Tv]),a[$ge]=r.modifiers[$ge],a[Bge]=r.modifiers[Bge],a[zge]=r.modifiers[zge]),a}var Wet=N.createContext(void 0);function Oqt(t){var s=hc(),r=Rke(),n=zke(),a=Dqt(s,r,n),o=Aqt(s.modifiers),l=ki(ki({},a),o);return e.jsx(Wet.Provider,{value:l,children:t.children})}function Ket(){var t=N.useContext(Wet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function Rqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function Fqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function zqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function Bqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function $qt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function qqt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=mf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=mf(t,n)>=0&&mf(a,t)>=0;return l}return a?Tl(a,t):n?Tl(n,t):!1}function Uqt(t){return Sje(t)}function Vqt(t){return Array.isArray(t)&&t.every(Sje)}function Hqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(Uqt(r))return Tl(t,r);if(Vqt(r))return r.includes(t);if(Fqt(r))return qqt(t,r);if($qt(r))return r.dayOfWeek.includes(t.getDay());if(Rqt(r)){var n=mf(r.before,t),a=mf(r.after,t),o=n>0,l=a<0,i=ZS(r.before,r.after);return i?l&&o:o||l}return zqt(r)?mf(t,r.after)>0:Bqt(r)?mf(r.before,t)>0:typeof r=="function"?r(t):!1})}function Bke(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return Hqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!mue(t,r)&&(a.outside=!0),a}function Gqt(t,s){for(var r=zc(t[0]),n=dx(t[t.length-1]),a,o,l=r;l<=n;){var i=Bke(l,s),c=!i.disabled&&!i.hidden;if(!c){l=Il(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=Il(l,1)}return o||a}var Wqt=365;function Zet(t,s){var r=s.moveBy,n=s.direction,a=s.context,o=s.modifiers,l=s.retry,i=l===void 0?{count:0,lastFocused:t}:l,c=a.weekStartsOn,u=a.fromDate,p=a.toDate,f=a.locale,g={day:Il,week:j4,month:Bm,year:E4t,startOfWeek:function(j){return a.ISOWeek?D1(j):Xh(j,{locale:f,weekStartsOn:c})},endOfWeek:function(j){return a.ISOWeek?zWe(j):uue(j,{locale:f,weekStartsOn:c})}},v=g[r](t,n==="after"?1:-1);n==="before"&&u?v=P4t([u,v]):n==="after"&&p&&(v=I4t([p,v]));var _=!0;if(o){var w=Bke(v,o);_=!w.disabled&&!w.hidden}return _?v:i.count>Wqt?i.lastFocused:Zet(v,{moveBy:r,direction:n,context:a,modifiers:o,retry:ki(ki({},i),{count:i.count+1})})}var Yet=N.createContext(void 0);function Kqt(t){var s=iR(),r=Ket(),n=N.useState(),a=n[0],o=n[1],l=N.useState(),i=l[0],c=l[1],u=Gqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},g=function(j){o(j)},v=hc(),_=function(j,k){if(a){var S=Zet(a,{moveBy:j,direction:k,context:v,modifiers:r});Tl(a,S)||(s.goToDate(S,a),g(S))}},w={focusedDay:a,focusTarget:p,blur:f,focus:g,focusDayAfter:function(){return _("day","after")},focusDayBefore:function(){return _("day","before")},focusWeekAfter:function(){return _("week","after")},focusWeekBefore:function(){return _("week","before")},focusMonthBefore:function(){return _("month","before")},focusMonthAfter:function(){return _("month","after")},focusYearBefore:function(){return _("year","before")},focusYearAfter:function(){return _("year","after")},focusStartOfWeek:function(){return _("startOfWeek","before")},focusEndOfWeek:function(){return _("endOfWeek","after")}};return e.jsx(Yet.Provider,{value:w,children:t.children})}function $ke(){var t=N.useContext(Yet);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function Zqt(t,s){var r=Ket(),n=Bke(t,r,s);return n}var qke=N.createContext(void 0);function Yqt(t){if(!ehe(t.initialProps)){var s={selected:void 0};return e.jsx(qke.Provider,{value:s,children:t.children})}return e.jsx(Qqt,{initialProps:t.initialProps,children:t.children})}function Qqt(t){var s=t.initialProps,r=t.children,n=function(o,l,i){var c,u,p;if((c=s.onDayClick)===null||c===void 0||c.call(s,o,l,i),l.selected&&!s.required){(u=s.onSelect)===null||u===void 0||u.call(s,void 0,o,l,i);return}(p=s.onSelect)===null||p===void 0||p.call(s,o,o,l,i)},a={selected:s.selected,onDayClick:n};return e.jsx(qke.Provider,{value:a,children:r})}function Qet(){var t=N.useContext(qke);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Xqt(t,s){var r=hc(),n=Qet(),a=Rke(),o=zke(),l=$ke(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,g=l.focus,v=l.focusMonthBefore,_=l.focusMonthAfter,w=l.focusYearBefore,j=l.focusYearAfter,k=l.focusStartOfWeek,S=l.focusEndOfWeek,M=function(re){var oe,fe,ge,ue;ehe(r)?(oe=n.onDayClick)===null||oe===void 0||oe.call(n,t,s,re):nR(r)?(fe=a.onDayClick)===null||fe===void 0||fe.call(a,t,s,re):aR(r)?(ge=o.onDayClick)===null||ge===void 0||ge.call(o,t,s,re):(ue=r.onDayClick)===null||ue===void 0||ue.call(r,t,s,re)},L=function(re){var oe;g(t),(oe=r.onDayFocus)===null||oe===void 0||oe.call(r,t,s,re)},P=function(re){var oe;f(),(oe=r.onDayBlur)===null||oe===void 0||oe.call(r,t,s,re)},O=function(re){var oe;(oe=r.onDayMouseEnter)===null||oe===void 0||oe.call(r,t,s,re)},$=function(re){var oe;(oe=r.onDayMouseLeave)===null||oe===void 0||oe.call(r,t,s,re)},U=function(re){var oe;(oe=r.onDayPointerEnter)===null||oe===void 0||oe.call(r,t,s,re)},B=function(re){var oe;(oe=r.onDayPointerLeave)===null||oe===void 0||oe.call(r,t,s,re)},V=function(re){var oe;(oe=r.onDayTouchCancel)===null||oe===void 0||oe.call(r,t,s,re)},X=function(re){var oe;(oe=r.onDayTouchEnd)===null||oe===void 0||oe.call(r,t,s,re)},Y=function(re){var oe;(oe=r.onDayTouchMove)===null||oe===void 0||oe.call(r,t,s,re)},ee=function(re){var oe;(oe=r.onDayTouchStart)===null||oe===void 0||oe.call(r,t,s,re)},Q=function(re){var oe;(oe=r.onDayKeyUp)===null||oe===void 0||oe.call(r,t,s,re)},ce=function(re){var oe;switch(re.key){case"ArrowLeft":re.preventDefault(),re.stopPropagation(),r.dir==="rtl"?i():c();break;case"ArrowRight":re.preventDefault(),re.stopPropagation(),r.dir==="rtl"?c():i();break;case"ArrowDown":re.preventDefault(),re.stopPropagation(),u();break;case"ArrowUp":re.preventDefault(),re.stopPropagation(),p();break;case"PageUp":re.preventDefault(),re.stopPropagation(),re.shiftKey?w():v();break;case"PageDown":re.preventDefault(),re.stopPropagation(),re.shiftKey?j():_();break;case"Home":re.preventDefault(),re.stopPropagation(),k();break;case"End":re.preventDefault(),re.stopPropagation(),S();break}(oe=r.onDayKeyDown)===null||oe===void 0||oe.call(r,t,s,re)},ne={onClick:M,onFocus:L,onBlur:P,onKeyDown:ce,onKeyUp:Q,onMouseEnter:O,onMouseLeave:$,onPointerEnter:U,onPointerLeave:B,onTouchCancel:V,onTouchEnd:X,onTouchMove:Y,onTouchStart:ee};return ne}function Jqt(){var t=hc(),s=Qet(),r=Rke(),n=zke(),a=ehe(t)?s.selected:nR(t)?r.selected:aR(t)?n.selected:void 0;return a}function eUt(t){return Object.values(uy).includes(t)}function tUt(t,s){var r=[t.classNames.day];return Object.keys(s).forEach(function(n){var a=t.modifiersClassNames[n];if(a)r.push(a);else if(eUt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function sUt(t,s){var r=ki({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ki(ki({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function rUt(t,s,r){var n,a,o,l=hc(),i=$ke(),c=Zqt(t,s),u=Xqt(t,c),p=Jqt(),f=!!(l.onDayClick||l.mode!=="default");N.useEffect(function(){var O;c.outside||i.focusedDay&&f&&Tl(i.focusedDay,t)&&((O=r.current)===null||O===void 0||O.focus())},[i.focusedDay,t,r,f,c.outside]);var g=tUt(l,c).join(" "),v=sUt(l,c),_=!!(c.outside&&!l.showOutsideDays||c.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:Nqt,j=e.jsx(w,{date:t,displayMonth:s,activeModifiers:c}),k={style:v,className:g,children:j,role:"gridcell"},S=i.focusTarget&&Tl(i.focusTarget,t)&&!c.outside,M=i.focusedDay&&Tl(i.focusedDay,t),L=ki(ki(ki({},k),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||S?0:-1,n)),u),P={isButton:f,isHidden:_,activeModifiers:c,selectedDays:p,buttonProps:L,divProps:k};return P}function nUt(t){var s=N.useRef(null),r=rUt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Kle,ki({name:"day",ref:s},r.buttonProps)):e.jsx("div",ki({},r.divProps))}function aUt(t){var s=t.number,r=t.dates,n=hc(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,c=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,p=u(Number(s),{locale:i});if(!a)return e.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var f=c(Number(s),{locale:i}),g=function(v){a(s,r,v)};return e.jsx(Kle,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:g,children:p})}function iUt(t){var s,r,n=hc(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,c=(s=i==null?void 0:i.Day)!==null&&s!==void 0?s:nUt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:aUt,p;return l&&(p=e.jsx("td",{className:o.cell,style:a.cell,children:e.jsx(u,{number:t.weekNumber,dates:t.dates})})),e.jsxs("tr",{className:o.row,style:a.row,children:[p,t.dates.map(function(f){return e.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:e.jsx(c,{displayMonth:t.displayMonth,date:f})},OSt(f))})]})}function k8e(t,s,r){for(var n=r!=null&&r.ISOWeek?zWe(s):uue(s,r),a=r!=null&&r.ISOWeek?D1(t):Xh(t,r),o=mf(n,a),l=[],i=0;i<=o;i++)l.push(Il(a,i));var c=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?Cje(p):Tje(p,r),g=u.find(function(v){return v.weekNumber===f});return g?(g.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return c}function oUt(t,s){var r=k8e(zc(t),dx(t),s);if(s!=null&&s.useFixedWeeks){var n=FSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=j4(o,6-n),i=k8e(j4(o,1),l,s);r.push.apply(r,i)}}return r}function lUt(t){var s,r,n,a=hc(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,g=a.firstWeekContainsDate,v=a.ISOWeek,_=oUt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:v,locale:o,weekStartsOn:f,firstWeekContainsDate:g}),w=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:jqt,j=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:iUt,k=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:bqt;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&e.jsx(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:_.map(function(S){return e.jsx(j,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(k,{displayMonth:t.displayMonth})]})}function cUt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var dUt=cUt()?N.useLayoutEffect:N.useEffect,qge=!1,uUt=0;function S8e(){return"react-day-picker-".concat(++uUt)}function hUt(t){var s,r=t??(qge?S8e():null),n=N.useState(r),a=n[0],o=n[1];return dUt(function(){a===null&&o(S8e())},[]),N.useEffect(function(){qge===!1&&(qge=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function mUt(t){var s,r,n=hc(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=iR().displayMonths,u=hUt(n.id?"".concat(n.id,"-").concat(t.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(t.displayIndex):void 0,f=[o.month],g=l.month,v=t.displayIndex===0,_=t.displayIndex===c.length-1,w=!v&&!_;a==="rtl"&&(s=[v,_],_=s[0],v=s[1]),v&&(f.push(o.caption_start),g=ki(ki({},g),l.caption_start)),_&&(f.push(o.caption_end),g=ki(ki({},g),l.caption_end)),w&&(f.push(o.caption_between),g=ki(ki({},g),l.caption_between));var j=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:vqt;return e.jsxs("div",{className:f.join(" "),style:g,children:[e.jsx(j,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(lUt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function pUt(t){var s=hc(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function fUt(t){var s,r,n=t.initialProps,a=hc(),o=$ke(),l=iR(),i=N.useState(!1),c=i[0],u=i[1];N.useEffect(function(){a.initialFocus&&o.focusTarget&&(c||(o.focus(o.focusTarget),u(!0)))},[a.initialFocus,c,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var f=ki(ki({},a.styles.root),a.style),g=Object.keys(n).filter(function(_){return _.startsWith("data-")}).reduce(function(_,w){var j;return ki(ki({},_),(j={},j[w]=n[w],j))},{}),v=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:pUt;return e.jsx("div",ki({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:e.jsx(v,{children:l.displayMonths.map(function(_,w){return e.jsx(mUt,{displayIndex:w,displayMonth:_},w)})})}))}function xUt(t){var s=t.children,r=B$t(t,["children"]);return e.jsx(aqt,{initialProps:r,children:e.jsx(fqt,{children:e.jsx(Yqt,{initialProps:r,children:e.jsx(kqt,{initialProps:r,children:e.jsx(Mqt,{initialProps:r,children:e.jsx(Oqt,{children:e.jsx(Kqt,{children:s})})})})})})})}function gUt(t){return e.jsx(xUt,ki({},t,{children:e.jsx(fUt,{initialProps:t})}))}function jf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(gUt,{showOutsideDays:r,className:It("p-3",t),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:It(lD({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:It(lD({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({...a})=>e.jsx(Xo,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(oa,{className:"h-4 w-4"})},...n})}jf.displayName="Calendar";var the="Popover",[Xet]=od(the,[$0]),oR=$0(),[yUt,Uw]=Xet(the),Jet=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=oR(s),c=N.useRef(null),[u,p]=N.useState(!1),[f,g]=oh({prop:n,defaultProp:a??!1,onChange:o,caller:the});return e.jsx(IO,{...i,children:e.jsx(yUt,{scope:s,contentId:Eu(),triggerRef:c,open:f,onOpenChange:g,onOpenToggle:N.useCallback(()=>g(v=>!v),[g]),hasCustomAnchor:u,onCustomAnchorAdd:N.useCallback(()=>p(!0),[]),onCustomAnchorRemove:N.useCallback(()=>p(!1),[]),modal:l,children:r})})};Jet.displayName=the;var ett="PopoverAnchor",vUt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Uw(ett,r),o=oR(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return N.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(YA,{...o,...n,ref:s})});vUt.displayName=ett;var ttt="PopoverTrigger",stt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Uw(ttt,r),o=oR(r),l=Va(s,a.triggerRef),i=e.jsx(an.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":ott(a.open),...n,ref:l,onClick:Lr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(YA,{asChild:!0,...o,children:i})});stt.displayName=ttt;var Uke="PopoverPortal",[bUt,_Ut]=Xet(Uke,{forceMount:void 0}),rtt=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Uw(Uke,s);return e.jsx(bUt,{scope:s,forceMount:r,children:e.jsx(zd,{present:r||o.open,children:e.jsx(GA,{asChild:!0,container:a,children:n})})})};rtt.displayName=Uke;var nA="PopoverContent",ntt=N.forwardRef((t,s)=>{const r=_Ut(nA,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Uw(nA,t.__scopePopover);return e.jsx(zd,{present:n||o.open,children:o.modal?e.jsx(jUt,{...a,ref:s}):e.jsx(NUt,{...a,ref:s})})});ntt.displayName=nA;var wUt=mw("PopoverContent.RemoveScroll"),jUt=N.forwardRef((t,s)=>{const r=Uw(nA,t.__scopePopover),n=N.useRef(null),a=Va(s,n),o=N.useRef(!1);return N.useEffect(()=>{const l=n.current;if(l)return Kde(l)},[]),e.jsx(zO,{as:wUt,allowPinchZoom:!0,children:e.jsx(att,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Lr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Lr(t.onPointerDownOutside,l=>{const i=l.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0,u=i.button===2||c;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Lr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),NUt=N.forwardRef((t,s)=>{const r=Uw(nA,t.__scopePopover),n=N.useRef(!1),a=N.useRef(!1);return e.jsx(att,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=t.onCloseAutoFocus)==null||l.call(t,o),o.defaultPrevented||(n.current||(i=r.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((u=r.triggerRef.current)==null?void 0:u.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),att=N.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,...f}=t,g=Uw(nA,r),v=oR(r);return Hde(),e.jsx(RO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(Aw,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(LO,{"data-state":ott(g.open),role:"dialog",id:g.contentId,...v,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),itt="PopoverClose",kUt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Uw(itt,r);return e.jsx(an.button,{type:"button",...n,ref:s,onClick:Lr(t.onClick,()=>a.onOpenChange(!1))})});kUt.displayName=itt;var SUt="PopoverArrow",CUt=N.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=oR(r);return e.jsx(DO,{...a,...n,ref:s})});CUt.displayName=SUt;function ott(t){return t?"open":"closed"}var MUt=Jet,TUt=stt,AUt=rtt,ltt=ntt;const $o=MUt,qo=TUt,Ro=N.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(AUt,{children:e.jsx(ltt,{ref:a,align:s,sideOffset:r,className:It("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));Ro.displayName=ltt.displayName;const EUt=b3("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Vke=N.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:It(EUt({variant:s}),t),...r}));Vke.displayName="Alert";const PUt=N.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:It("mb-1 font-medium leading-none tracking-tight",t),...s}));PUt.displayName="AlertTitle";const Hke=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:It("text-sm [&_p]:leading-relaxed",t),...s}));Hke.displayName="AlertDescription";function IUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Xt(),[c,u]=N.useState(a),[p,f]=N.useState([]),[g,v]=N.useState(null),[_,w]=N.useState("now"),[j,k]=N.useState(w6e(M6e(new Date),1)),[S,M]=N.useState("12"),[L,P]=N.useState("00"),[O,$]=N.useState("PM");N.useEffect(()=>{if(t){u(a),w("now"),f([]);const _e=w6e(M6e(new Date),1);k(_e);const $e=_e.getHours();M(String($e>12?$e-12:$e===0?12:$e)),P("00"),$($e>=12?"PM":"AM")}},[t,a]);const U=()=>{if(!j)return null;let _e=parseInt(S);const $e=parseInt(L);return O==="PM"&&_e!==12&&(_e+=12),O==="AM"&&_e===12&&(_e=0),r8(s8(j,_e),$e)},{data:B,isLoading:V}=mt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:_e}}=await H.auth.getUser();if(!_e)return[];const{data:$e,error:Me}=await H.from("social_accounts").select("*").eq("user_id",_e.id).eq("is_active",!0).order("platform",{ascending:!0});if(Me)throw Me;return console.log("Fetched social accounts for posting:",$e),$e},enabled:t,staleTime:0}),X=Lt({mutationFn:async({accountId:_e,platform:$e})=>{v(_e);const{data:Me,error:Ie}=await H.functions.invoke("social-post",{body:{platform:$e,accountId:_e,imageUrl:r,caption:c}});if(Ie)throw Ie;if(Me!=null&&Me.error)throw new Error(Me.error);return Me},onSuccess:_e=>{const $e=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":_e.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${$e}!`)},onError:_e=>{me.error(`Failed to post: ${_e.message}`)},onSettled:()=>{v(null)}}),Y=Lt({mutationFn:async({accountId:_e,platform:$e,scheduledFor:Me})=>{const{data:{user:Ie}}=await H.auth.getUser();if(!Ie)throw new Error("Not authenticated");const{error:ke}=await H.from("scheduled_posts").insert({user_id:Ie.id,social_account_id:_e,platform:$e,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:Me.toISOString(),status:"scheduled"});if(ke)throw ke;return{platform:$e}},onSuccess:_e=>{const $e=_e.platform==="facebook"?"Facebook":_e.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${$e}!`)},onError:_e=>{me.error(`Failed to schedule: ${_e.message}`)}}),ee=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(_==="schedule"){const _e=U();if(!_e||_e<=new Date){me.error("Please select a future date and time");return}for(const $e of p){const Me=B==null?void 0:B.find(Ie=>Ie.id===$e);Me&&await Y.mutateAsync({accountId:$e,platform:Me.platform,scheduledFor:_e})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${ms(_e,"PPp")}`)}else for(const _e of p){const $e=B==null?void 0:B.find(Me=>Me.id===_e);$e&&await X.mutateAsync({accountId:_e,platform:$e.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Q=_e=>{f($e=>$e.includes(_e)?$e.filter(Me=>Me!==_e):[...$e,_e])},ce=(B==null?void 0:B.filter(_e=>_e.platform==="facebook"))||[],ne=(B==null?void 0:B.filter(_e=>_e.platform==="instagram"))||[],re=(B==null?void 0:B.filter(_e=>_e.platform==="linkedin"))||[],oe=(B==null?void 0:B.filter(_e=>_e.platform==="google_business"))||[],fe=((B==null?void 0:B.length)||0)>0,ge=X.isPending||Y.isPending,ue=Array.from({length:12},(_e,$e)=>String($e+1)),xe=["00","15","30","45"];return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create Social Post"}),e.jsx(Wr,{children:"Share this image to your connected social accounts"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-full max-w-[200px] mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:r,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"caption",children:"Caption"}),e.jsx(Pr,{id:"caption",placeholder:"Write a caption for your post...",value:c,onChange:_e=>u(_e.target.value),rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/2200 characters"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:It("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",_==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),_==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(un,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!j&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),j?ms(j,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:j,onSelect:k,disabled:_e=>_ee.jsx(Mt,{value:_e,children:_e},_e))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ks,{value:L,onValueChange:P,children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:xe.map(_e=>e.jsx(Mt,{value:_e,children:_e},_e))})]}),e.jsxs(Ks,{value:O,onValueChange:_e=>$(_e),children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ms(U()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-6 w-6 animate-spin"})}),!V&&!fe&&e.jsxs(Vke,{children:[e.jsx(Cl,{className:"h-4 w-4"}),e.jsxs(Hke,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(pa,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Qo,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),ce.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Cu,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:_e.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Cu,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.page_name||_e.platform_username}),g===_e.id&&e.jsx(bs,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),ne.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Tu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ne.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:_e.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Tu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",_e.platform_username]}),g===_e.id&&e.jsx(bs,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),re.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Mp,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),re.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:_e.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.platform_username}),g===_e.id&&e.jsx(bs,{className:"h-4 w-4 animate-spin"})]},_e.id))]}),oe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(ia,{className:"h-4 w-4 text-red-600"})," Google Business"]}),oe.map(_e=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Oo,{checked:p.includes(_e.id),onCheckedChange:()=>Q(_e.id),disabled:g===_e.id}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:_e.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(ia,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:_e.page_name||_e.platform_username}),g===_e.id&&e.jsx(bs,{className:"h-4 w-4 animate-spin"})]},_e.id))]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:ee,disabled:p.length===0||ge,className:"gap-2",children:[ge?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):_==="schedule"?e.jsx(hn,{className:"h-4 w-4"}):e.jsx($n,{className:"h-4 w-4"}),_==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function LUt(){const t=Xt(),[s,r]=N.useState(void 0),[n,a]=N.useState("all"),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(void 0),[f,g]=N.useState("12"),[v,_]=N.useState("00"),[w,j]=N.useState("PM"),{data:k=[],isLoading:S}=mt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:oe,error:fe}=await H.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(fe)throw fe;return oe}}),M=k.filter(oe=>{if(n!=="all"&&oe.status!==n)return!1;if(s&&oe.scheduled_for){const fe=new Date(oe.scheduled_for);if(!Tl(fe,s))return!1}return!0}),L=k.filter(oe=>oe.scheduled_for).map(oe=>$m(new Date(oe.scheduled_for))),P=Lt({mutationFn:async oe=>{const{error:fe}=await H.from("scheduled_posts").update({caption:oe.caption,scheduled_for:oe.scheduled_for}).eq("id",oe.id);if(fe)throw fe},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:oe=>{me.error(`Failed to update: ${oe.message}`)}}),O=Lt({mutationFn:async oe=>{const{error:fe}=await H.from("scheduled_posts").update({status:"cancelled"}).eq("id",oe);if(fe)throw fe},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to cancel: ${oe.message}`)}}),$=Lt({mutationFn:async oe=>{const{error:fe}=await H.from("scheduled_posts").delete().eq("id",oe);if(fe)throw fe},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to delete: ${oe.message}`)}}),U=Lt({mutationFn:async oe=>{const{data:fe,error:ge}=await H.functions.invoke("social-post",{body:{platform:oe.platform,accountId:oe.social_account_id,imageUrl:oe.image_url,caption:oe.caption}});if(ge)throw ge;if(fe!=null&&fe.error)throw new Error(fe.error);return await H.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:fe.postId}).eq("id",oe.id),fe},onSuccess:oe=>{const fe=oe.platform==="facebook"?"Facebook":oe.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${fe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:oe=>{me.error(`Failed to post: ${oe.message}`)}}),B=oe=>{if(l(oe),c(oe.caption||""),oe.scheduled_for){const fe=new Date(oe.scheduled_for);p(fe);const ge=fe.getHours();g(String(ge>12?ge-12:ge===0?12:ge)),_(String(fe.getMinutes()).padStart(2,"0")),j(ge>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let oe=parseInt(f);const fe=parseInt(v);w==="PM"&&oe!==12&&(oe+=12),w==="AM"&&oe===12&&(oe=0);const ge=r8(s8(u,oe),fe);P.mutate({id:o.id,caption:i,scheduled_for:ge.toISOString()})},X=oe=>{switch(oe){case"facebook":return e.jsx(Cu,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Tu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(Mp,{className:"h-4 w-4 text-blue-700"});default:return null}},Y=oe=>{switch(oe){case"scheduled":return e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(st,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(gi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(st,{variant:"destructive",className:"gap-1",children:[e.jsx(jc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(st,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Cl,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(st,{variant:"outline",children:oe})}},ee=Array.from({length:12},(oe,fe)=>String(fe+1)),Q=["00","15","30","45"],ce=k.filter(oe=>oe.status==="scheduled").length,ne=k.filter(oe=>oe.status==="posted").length,re=k.filter(oe=>oe.status==="scheduled"&&oe.scheduled_for&&zSt(new Date(oe.scheduled_for))).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ce}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:re}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ne}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:k.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Od,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(jf,{mode:"single",selected:s,onSelect:r,className:It("pointer-events-auto"),modifiers:{hasPost:L},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ey,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(oe=>e.jsx(K,{variant:n===oe?"default":"outline",size:"sm",onClick:()=>a(oe),className:"capitalize",children:oe},oe))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&M.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ms(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:M.map(oe=>{var fe,ge;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:oe.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[X(oe.platform),e.jsx("span",{className:"font-medium",children:((fe=oe.social_accounts)==null?void 0:fe.page_name)||((ge=oe.social_accounts)==null?void 0:ge.platform_username)||"Unknown"}),Y(oe.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[oe.status==="scheduled"&&e.jsxs(G1,{children:[e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>B(oe),children:e.jsx(za,{className:"h-4 w-4"})})}),e.jsx(ec,{children:"Edit post"})]}),e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U.mutate(oe),disabled:U.isPending,children:U.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"})})}),e.jsx(ec,{children:"Post now"})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Cancel this scheduled post?"}),e.jsx(ic,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Keep"}),e.jsx(Fl,{onClick:()=>O.mutate(oe.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Fl,{onClick:()=>$.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(oe.status==="posted"||oe.status==="cancelled"||oe.status==="failed")&&e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete this post?"}),e.jsx(ic,{children:"This will permanently remove this post from your history."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>$.mutate(oe.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),oe.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:oe.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),oe.status==="posted"&&oe.posted_at?`Posted ${ms(new Date(oe.posted_at),"PPp")}`:oe.scheduled_for?`Scheduled for ${ms(new Date(oe.scheduled_for),"PPp")}`:"Not scheduled"]}),oe.status==="failed"&&oe.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",oe.error_message]})]})]})},oe.id)})})]})]}),e.jsx(xs,{open:!!o,onOpenChange:oe=>!oe&&l(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Scheduled Post"}),e.jsx(Wr,{children:"Update the caption or reschedule this post"})]}),o&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-32 mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:o.image_url,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Pr,{value:i,onChange:oe=>c(oe.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(be,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),u?ms(u,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:u,onSelect:p,disabled:oe=>oee.jsx(Mt,{value:oe,children:oe},oe))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ks,{value:v,onValueChange:_,children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Q.map(oe=>e.jsx(Mt,{value:oe,children:oe},oe))})]}),e.jsxs(Ks,{value:w,onValueChange:oe=>j(oe),children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:P.isPending,children:[P.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function Oz(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ctt={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(t,s){(function(r){t.exports=r()})(function(){return function r(n,a,o){function l(u,p){if(!a[u]){if(!n[u]){var f=typeof Oz=="function"&&Oz;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var v=a[u]={exports:{}};n[u][0].call(v.exports,function(_){var w=n[u][1][_];return l(w||_)},v,v.exports,r,n,a,o)}return a[u].exports}for(var i=typeof Oz=="function"&&Oz,c=0;c>2,v=(3&u)<<4|p>>4,_=1>6:64,w=2>4,p=(15&g)<<4|(v=i.indexOf(c.charAt(w++)))>>2,f=(3&v)<<6|(_=i.indexOf(c.charAt(w++))),S[j++]=u,v!==64&&(S[j++]=p),_!==64&&(S[j++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(p,f,g,v,_){this.compressedSize=p,this.uncompressedSize=f,this.crc32=g,this.compression=v,this.compressedContent=_}u.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return p.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(p,f,g){return p.pipe(new i).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,a){var o=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,a){var o=r("./utils"),l=function(){for(var i,c=[],u=0;u<256;u++){i=u;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;c[u]=i}return c}();n.exports=function(i,c){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(u,p,f,g){var v=l,_=g+f;u^=-1;for(var w=g;w<_;w++)u=u>>>8^v[255&(u^p[w])];return-1^u}(0|c,i,i.length,0):function(u,p,f,g){var v=l,_=g+f;u^=-1;for(var w=g;w<_;w++)u=u>>>8^v[255&(u^p.charCodeAt(w))];return-1^u}(0|c,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),c=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}a.magic="\b\0",i.inherits(p,c),p.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(u,f.data),!1)},p.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},a.compressWorker=function(f){return new p("Deflate",f)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,a){function o(v,_){var w,j="";for(w=0;w<_;w++)j+=String.fromCharCode(255&v),v>>>=8;return j}function l(v,_,w,j,k,S){var M,L,P=v.file,O=v.compression,$=S!==u.utf8encode,U=i.transformTo("string",S(P.name)),B=i.transformTo("string",u.utf8encode(P.name)),V=P.comment,X=i.transformTo("string",S(V)),Y=i.transformTo("string",u.utf8encode(V)),ee=B.length!==P.name.length,Q=Y.length!==V.length,ce="",ne="",re="",oe=P.dir,fe=P.date,ge={crc32:0,compressedSize:0,uncompressedSize:0};_&&!w||(ge.crc32=v.crc32,ge.compressedSize=v.compressedSize,ge.uncompressedSize=v.uncompressedSize);var ue=0;_&&(ue|=8),$||!ee&&!Q||(ue|=2048);var xe=0,_e=0;oe&&(xe|=16),k==="UNIX"?(_e=798,xe|=function(Me,Ie){var ke=Me;return Me||(ke=Ie?16893:33204),(65535&ke)<<16}(P.unixPermissions,oe)):(_e=20,xe|=function(Me){return 63&(Me||0)}(P.dosPermissions)),M=fe.getUTCHours(),M<<=6,M|=fe.getUTCMinutes(),M<<=5,M|=fe.getUTCSeconds()/2,L=fe.getUTCFullYear()-1980,L<<=4,L|=fe.getUTCMonth()+1,L<<=5,L|=fe.getUTCDate(),ee&&(ne=o(1,1)+o(p(U),4)+B,ce+="up"+o(ne.length,2)+ne),Q&&(re=o(1,1)+o(p(X),4)+Y,ce+="uc"+o(re.length,2)+re);var $e="";return $e+=` \0`,$e+=o(ue,2),$e+=O.magic,$e+=o(M,2),$e+=o(L,2),$e+=o(ge.crc32,4),$e+=o(ge.compressedSize,4),$e+=o(ge.uncompressedSize,4),$e+=o(U.length,2),$e+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+$e+U+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(_e,2)+$e+o(X.length,2)+"\0\0\0\0"+o(xe,4)+o(j,4)+U+ce+X}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function g(v,_,w,j){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=w,this.encodeFileName=j,this.streamFiles=v,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(g,c),g.prototype.push=function(v){var _=v.meta.percent||0,w=this.entriesCount,j=this._sources.length;this.accumulate?this.contentBuffer.push(v):(this.bytesWritten+=v.data.length,c.prototype.push.call(this,{data:v.data,meta:{currentFile:this.currentFile,percent:w?(_+100*(w-j-1))/w:100}}))},g.prototype.openedSource=function(v){this.currentSourceOffset=this.bytesWritten,this.currentFile=v.file.name;var _=this.streamFiles&&!v.file.dir;if(_){var w=l(v,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(v){this.accumulate=!1;var _=this.streamFiles&&!v.file.dir,w=l(v,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),_)this.push({data:function(j){return f.DATA_DESCRIPTOR+o(j.crc32,4)+o(j.compressedSize,4)+o(j.uncompressedSize,4)}(v),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var v=this.bytesWritten,_=0;_=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=i,u},readString:function(i){return o.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},n.exports=l},{"../utils":32}],19:[function(r,n,a){var o=r("./Uint8ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,a){var o=r("./DataReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},l.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},l.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},l.prototype.readData=function(i){this.checkOffset(i);var c=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./DataReader":18}],21:[function(r,n,a){var o=r("./ArrayReader");function l(i){o.call(this,i)}r("../utils").inherits(l,o),l.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,c},n.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,a){var o=r("../utils"),l=r("../support"),i=r("./ArrayReader"),c=r("./StringReader"),u=r("./NodeBufferReader"),p=r("./Uint8ArrayReader");n.exports=function(f){var g=o.getTypeOf(f);return o.checkSupport(g),g!=="string"||l.uint8array?g==="nodebuffer"?new u(f):l.uint8array?new p(o.transformTo("uint8array",f)):new i(o.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,a){var o=r("./GenericWorker"),l=r("../utils");function i(c){o.call(this,"ConvertWorker to "+c),this.destType=c}l.inherits(i,o),i.prototype.processChunk=function(c){this.push({data:l.transformTo(this.destType,c.data),meta:c.meta})},n.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,a){var o=r("./GenericWorker"),l=r("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,o),i.prototype.processChunk=function(c){this.streamInfo.crc32=l(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}o.inherits(i,l),i.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}l.prototype.processChunk.call(this,c)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,a){var o=r("../utils"),l=r("./GenericWorker");function i(c){l.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(p){u.dataIsReady=!0,u.data=p,u.max=p&&p.length||0,u.type=o.getTypeOf(p),u.isPaused||u._tickAndRepeat()},function(p){u.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,a){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,i){return this._listeners[l].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,i){if(this._listeners[l])for(var c=0;c "+l:l}},n.exports=o},{}],29:[function(r,n,a){var o=r("../utils"),l=r("./ConvertWorker"),i=r("./GenericWorker"),c=r("../base64"),u=r("../support"),p=r("../external"),f=null;if(u.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(_,w){return new p.Promise(function(j,k){var S=[],M=_._internalType,L=_._outputType,P=_._mimeType;_.on("data",function(O,$){S.push(O),w&&w($)}).on("error",function(O){S=[],k(O)}).on("end",function(){try{var O=function($,U,B){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",U),B);case"base64":return c.encode(U);default:return o.transformTo($,U)}}(L,function($,U){var B,V=0,X=null,Y=0;for(B=0;B"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),c=r("./stream/GenericWorker"),u=new Array(256),p=0;p<256;p++)u[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}a.utf8encode=function(v){return l.nodebuffer?i.newBufferFrom(v,"utf-8"):function(_){var w,j,k,S,M,L=_.length,P=0;for(S=0;S>>6:(j<65536?w[M++]=224|j>>>12:(w[M++]=240|j>>>18,w[M++]=128|j>>>12&63),w[M++]=128|j>>>6&63),w[M++]=128|63&j);return w}(v)},a.utf8decode=function(v){return l.nodebuffer?o.transformTo("nodebuffer",v).toString("utf-8"):function(_){var w,j,k,S,M=_.length,L=new Array(2*M);for(w=j=0;w>10&1023,L[j++]=56320|1023&k)}return L.length!==j&&(L.subarray?L=L.subarray(0,j):L.length=j),o.applyFromCharCode(L)}(v=o.transformTo(l.uint8array?"uint8array":"array",v))},o.inherits(f,c),f.prototype.processChunk=function(v){var _=o.transformTo(l.uint8array?"uint8array":"array",v.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=_;(_=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),_.set(w,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var j=function(S,M){var L;for((M=M||S.length)>S.length&&(M=S.length),L=M-1;0<=L&&(192&S[L])==128;)L--;return L<0||L===0?M:L+u[S[L]]>M?L:M}(_),k=_;j!==_.length&&(l.uint8array?(k=_.subarray(0,j),this.leftOver=_.subarray(j,_.length)):(k=_.slice(0,j),this.leftOver=_.slice(j,_.length))),this.push({data:a.utf8decode(k),meta:v.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=f,o.inherits(g,c),g.prototype.processChunk=function(v){this.push({data:a.utf8encode(v.data),meta:v.meta})},a.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),c=r("./external");function u(w){return w}function p(w,j){for(var k=0;k>8;this.dir=!!(16&this.externalFileAttributes),v==0&&(this.dosPermissions=63&this.externalFileAttributes),v==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var v=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=v.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=v.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=v.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=v.readInt(4))}},readExtraFields:function(v){var _,w,j,k=v.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});v.index+4>>6:(v<65536?g[j++]=224|v>>>12:(g[j++]=240|v>>>18,g[j++]=128|v>>>12&63),g[j++]=128|v>>>6&63),g[j++]=128|63&v);return g},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var g=new o.Buf8(f.length),v=0,_=g.length;v<_;v++)g[v]=f.charCodeAt(v);return g},a.buf2string=function(f,g){var v,_,w,j,k=g||f.length,S=new Array(2*k);for(v=_=0;v>10&1023,S[_++]=56320|1023&w)}return p(S,_)},a.utf8border=function(f,g){var v;for((g=g||f.length)>f.length&&(g=f.length),v=g-1;0<=v&&(192&f[v])==128;)v--;return v<0||v===0?g:v+c[f[v]]>g?v:g}},{"./common":41}],43:[function(r,n,a){n.exports=function(o,l,i,c){for(var u=65535&o|0,p=o>>>16&65535|0,f=0;i!==0;){for(i-=f=2e3>>1:l>>>1;i[c]=l}return i}();n.exports=function(l,i,c,u){var p=o,f=u+c;l^=-1;for(var g=u;g>>8^p[255&(l^i[g])];return-1^l}},{}],46:[function(r,n,a){var o,l=r("../utils/common"),i=r("./trees"),c=r("./adler32"),u=r("./crc32"),p=r("./messages"),f=0,g=4,v=0,_=-2,w=-1,j=4,k=2,S=8,M=9,L=286,P=30,O=19,$=2*L+1,U=15,B=3,V=258,X=V+B+1,Y=42,ee=113,Q=1,ce=2,ne=3,re=4;function oe(ye,qe){return ye.msg=p[qe],qe}function fe(ye){return(ye<<1)-(4ye.avail_out&&(at=ye.avail_out),at!==0&&(l.arraySet(ye.output,qe.pending_buf,qe.pending_out,at,ye.next_out),ye.next_out+=at,qe.pending_out+=at,ye.total_out+=at,ye.avail_out-=at,qe.pending-=at,qe.pending===0&&(qe.pending_out=0))}function xe(ye,qe){i._tr_flush_block(ye,0<=ye.block_start?ye.block_start:-1,ye.strstart-ye.block_start,qe),ye.block_start=ye.strstart,ue(ye.strm)}function _e(ye,qe){ye.pending_buf[ye.pending++]=qe}function $e(ye,qe){ye.pending_buf[ye.pending++]=qe>>>8&255,ye.pending_buf[ye.pending++]=255&qe}function Me(ye,qe){var at,tt,Ae=ye.max_chain_length,rt=ye.strstart,He=ye.prev_length,ct=ye.nice_match,Ue=ye.strstart>ye.w_size-X?ye.strstart-(ye.w_size-X):0,Ze=ye.window,Je=ye.w_mask,Ge=ye.prev,et=ye.strstart+V,it=Ze[rt+He-1],Dt=Ze[rt+He];ye.prev_length>=ye.good_match&&(Ae>>=2),ct>ye.lookahead&&(ct=ye.lookahead);do if(Ze[(at=qe)+He]===Dt&&Ze[at+He-1]===it&&Ze[at]===Ze[rt]&&Ze[++at]===Ze[rt+1]){rt+=2,at++;do;while(Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&Ze[++rt]===Ze[++at]&&rtUe&&--Ae!=0);return He<=ye.lookahead?He:ye.lookahead}function Ie(ye){var qe,at,tt,Ae,rt,He,ct,Ue,Ze,Je,Ge=ye.w_size;do{if(Ae=ye.window_size-ye.lookahead-ye.strstart,ye.strstart>=Ge+(Ge-X)){for(l.arraySet(ye.window,ye.window,Ge,Ge,0),ye.match_start-=Ge,ye.strstart-=Ge,ye.block_start-=Ge,qe=at=ye.hash_size;tt=ye.head[--qe],ye.head[qe]=Ge<=tt?tt-Ge:0,--at;);for(qe=at=Ge;tt=ye.prev[--qe],ye.prev[qe]=Ge<=tt?tt-Ge:0,--at;);Ae+=Ge}if(ye.strm.avail_in===0)break;if(He=ye.strm,ct=ye.window,Ue=ye.strstart+ye.lookahead,Ze=Ae,Je=void 0,Je=He.avail_in,Ze=B)for(rt=ye.strstart-ye.insert,ye.ins_h=ye.window[rt],ye.ins_h=(ye.ins_h<=B&&(ye.ins_h=(ye.ins_h<=B)if(tt=i._tr_tally(ye,ye.strstart-ye.match_start,ye.match_length-B),ye.lookahead-=ye.match_length,ye.match_length<=ye.max_lazy_match&&ye.lookahead>=B){for(ye.match_length--;ye.strstart++,ye.ins_h=(ye.ins_h<=B&&(ye.ins_h=(ye.ins_h<=B&&ye.match_length<=ye.prev_length){for(Ae=ye.strstart+ye.lookahead-B,tt=i._tr_tally(ye,ye.strstart-1-ye.prev_match,ye.prev_length-B),ye.lookahead-=ye.prev_length-1,ye.prev_length-=2;++ye.strstart<=Ae&&(ye.ins_h=(ye.ins_h<ye.pending_buf_size-5&&(at=ye.pending_buf_size-5);;){if(ye.lookahead<=1){if(Ie(ye),ye.lookahead===0&&qe===f)return Q;if(ye.lookahead===0)break}ye.strstart+=ye.lookahead,ye.lookahead=0;var tt=ye.block_start+at;if((ye.strstart===0||ye.strstart>=tt)&&(ye.lookahead=ye.strstart-tt,ye.strstart=tt,xe(ye,!1),ye.strm.avail_out===0)||ye.strstart-ye.block_start>=ye.w_size-X&&(xe(ye,!1),ye.strm.avail_out===0))return Q}return ye.insert=0,qe===g?(xe(ye,!0),ye.strm.avail_out===0?ne:re):(ye.strstart>ye.block_start&&(xe(ye,!1),ye.strm.avail_out),Q)}),new we(4,4,8,4,ke),new we(4,5,16,8,ke),new we(4,6,32,32,ke),new we(4,4,16,16,pe),new we(8,16,32,32,pe),new we(8,16,128,128,pe),new we(8,32,128,256,pe),new we(32,128,258,1024,pe),new we(32,258,258,4096,pe)],a.deflateInit=function(ye,qe){return pt(ye,qe,S,15,8,0)},a.deflateInit2=pt,a.deflateReset=Te,a.deflateResetKeep=Qe,a.deflateSetHeader=function(ye,qe){return ye&&ye.state?ye.state.wrap!==2?_:(ye.state.gzhead=qe,v):_},a.deflate=function(ye,qe){var at,tt,Ae,rt;if(!ye||!ye.state||5>8&255),_e(tt,tt.gzhead.time>>16&255),_e(tt,tt.gzhead.time>>24&255),_e(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),_e(tt,255&tt.gzhead.os),tt.gzhead.extra&&tt.gzhead.extra.length&&(_e(tt,255&tt.gzhead.extra.length),_e(tt,tt.gzhead.extra.length>>8&255)),tt.gzhead.hcrc&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending,0)),tt.gzindex=0,tt.status=69):(_e(tt,0),_e(tt,0),_e(tt,0),_e(tt,0),_e(tt,0),_e(tt,tt.level===9?2:2<=tt.strategy||tt.level<2?4:0),_e(tt,3),tt.status=ee);else{var He=S+(tt.w_bits-8<<4)<<8;He|=(2<=tt.strategy||tt.level<2?0:tt.level<6?1:tt.level===6?2:3)<<6,tt.strstart!==0&&(He|=32),He+=31-He%31,tt.status=ee,$e(tt,He),tt.strstart!==0&&($e(tt,ye.adler>>>16),$e(tt,65535&ye.adler)),ye.adler=1}if(tt.status===69)if(tt.gzhead.extra){for(Ae=tt.pending;tt.gzindex<(65535&tt.gzhead.extra.length)&&(tt.pending!==tt.pending_buf_size||(tt.gzhead.hcrc&&tt.pending>Ae&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),ue(ye),Ae=tt.pending,tt.pending!==tt.pending_buf_size));)_e(tt,255&tt.gzhead.extra[tt.gzindex]),tt.gzindex++;tt.gzhead.hcrc&&tt.pending>Ae&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),tt.gzindex===tt.gzhead.extra.length&&(tt.gzindex=0,tt.status=73)}else tt.status=73;if(tt.status===73)if(tt.gzhead.name){Ae=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>Ae&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),ue(ye),Ae=tt.pending,tt.pending===tt.pending_buf_size)){rt=1;break}rt=tt.gzindexAe&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),rt===0&&(tt.gzindex=0,tt.status=91)}else tt.status=91;if(tt.status===91)if(tt.gzhead.comment){Ae=tt.pending;do{if(tt.pending===tt.pending_buf_size&&(tt.gzhead.hcrc&&tt.pending>Ae&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),ue(ye),Ae=tt.pending,tt.pending===tt.pending_buf_size)){rt=1;break}rt=tt.gzindexAe&&(ye.adler=u(ye.adler,tt.pending_buf,tt.pending-Ae,Ae)),rt===0&&(tt.status=103)}else tt.status=103;if(tt.status===103&&(tt.gzhead.hcrc?(tt.pending+2>tt.pending_buf_size&&ue(ye),tt.pending+2<=tt.pending_buf_size&&(_e(tt,255&ye.adler),_e(tt,ye.adler>>8&255),ye.adler=0,tt.status=ee)):tt.status=ee),tt.pending!==0){if(ue(ye),ye.avail_out===0)return tt.last_flush=-1,v}else if(ye.avail_in===0&&fe(qe)<=fe(at)&&qe!==g)return oe(ye,-5);if(tt.status===666&&ye.avail_in!==0)return oe(ye,-5);if(ye.avail_in!==0||tt.lookahead!==0||qe!==f&&tt.status!==666){var ct=tt.strategy===2?function(Ue,Ze){for(var Je;;){if(Ue.lookahead===0&&(Ie(Ue),Ue.lookahead===0)){if(Ze===f)return Q;break}if(Ue.match_length=0,Je=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++,Je&&(xe(Ue,!1),Ue.strm.avail_out===0))return Q}return Ue.insert=0,Ze===g?(xe(Ue,!0),Ue.strm.avail_out===0?ne:re):Ue.last_lit&&(xe(Ue,!1),Ue.strm.avail_out===0)?Q:ce}(tt,qe):tt.strategy===3?function(Ue,Ze){for(var Je,Ge,et,it,Dt=Ue.window;;){if(Ue.lookahead<=V){if(Ie(Ue),Ue.lookahead<=V&&Ze===f)return Q;if(Ue.lookahead===0)break}if(Ue.match_length=0,Ue.lookahead>=B&&0Ue.lookahead&&(Ue.match_length=Ue.lookahead)}if(Ue.match_length>=B?(Je=i._tr_tally(Ue,1,Ue.match_length-B),Ue.lookahead-=Ue.match_length,Ue.strstart+=Ue.match_length,Ue.match_length=0):(Je=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++),Je&&(xe(Ue,!1),Ue.strm.avail_out===0))return Q}return Ue.insert=0,Ze===g?(xe(Ue,!0),Ue.strm.avail_out===0?ne:re):Ue.last_lit&&(xe(Ue,!1),Ue.strm.avail_out===0)?Q:ce}(tt,qe):o[tt.level].func(tt,qe);if(ct!==ne&&ct!==re||(tt.status=666),ct===Q||ct===ne)return ye.avail_out===0&&(tt.last_flush=-1),v;if(ct===ce&&(qe===1?i._tr_align(tt):qe!==5&&(i._tr_stored_block(tt,0,0,!1),qe===3&&(ge(tt.head),tt.lookahead===0&&(tt.strstart=0,tt.block_start=0,tt.insert=0))),ue(ye),ye.avail_out===0))return tt.last_flush=-1,v}return qe!==g?v:tt.wrap<=0?1:(tt.wrap===2?(_e(tt,255&ye.adler),_e(tt,ye.adler>>8&255),_e(tt,ye.adler>>16&255),_e(tt,ye.adler>>24&255),_e(tt,255&ye.total_in),_e(tt,ye.total_in>>8&255),_e(tt,ye.total_in>>16&255),_e(tt,ye.total_in>>24&255)):($e(tt,ye.adler>>>16),$e(tt,65535&ye.adler)),ue(ye),0=at.w_size&&(rt===0&&(ge(at.head),at.strstart=0,at.block_start=0,at.insert=0),Ze=new l.Buf8(at.w_size),l.arraySet(Ze,qe,Je-at.w_size,at.w_size,0),qe=Ze,Je=at.w_size),He=ye.avail_in,ct=ye.next_in,Ue=ye.input,ye.avail_in=Je,ye.next_in=0,ye.input=qe,Ie(at);at.lookahead>=B;){for(tt=at.strstart,Ae=at.lookahead-(B-1);at.ins_h=(at.ins_h<>>=B=U>>>24,M-=B,(B=U>>>16&255)===0)ce[p++]=65535&U;else{if(!(16&B)){if(!(64&B)){U=L[(65535&U)+(S&(1<>>=B,M-=B),M<15&&(S+=Q[c++]<>>=B=U>>>24,M-=B,!(16&(B=U>>>16&255))){if(!(64&B)){U=P[(65535&U)+(S&(1<>>=B,M-=B,(B=p-f)>3,S&=(1<<(M-=V<<3))-1,o.next_in=c,o.next_out=p,o.avail_in=c>>24&255)+(Y>>>8&65280)+((65280&Y)<<8)+((255&Y)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(Y){var ee;return Y&&Y.state?(ee=Y.state,Y.total_in=Y.total_out=ee.total=0,Y.msg="",ee.wrap&&(Y.adler=1&ee.wrap),ee.mode=_,ee.last=0,ee.havedict=0,ee.dmax=32768,ee.head=null,ee.hold=0,ee.bits=0,ee.lencode=ee.lendyn=new o.Buf32(w),ee.distcode=ee.distdyn=new o.Buf32(j),ee.sane=1,ee.back=-1,g):v}function L(Y){var ee;return Y&&Y.state?((ee=Y.state).wsize=0,ee.whave=0,ee.wnext=0,M(Y)):v}function P(Y,ee){var Q,ce;return Y&&Y.state?(ce=Y.state,ee<0?(Q=0,ee=-ee):(Q=1+(ee>>4),ee<48&&(ee&=15)),ee&&(ee<8||15=re.wsize?(o.arraySet(re.window,ee,Q-re.wsize,re.wsize,0),re.wnext=0,re.whave=re.wsize):(ce<(ne=re.wsize-re.wnext)&&(ne=ce),o.arraySet(re.window,ee,Q-ce,ne,re.wnext),(ce-=ne)?(o.arraySet(re.window,ee,Q-ce,ce,0),re.wnext=ce,re.whave=re.wsize):(re.wnext+=ne,re.wnext===re.wsize&&(re.wnext=0),re.whave>>8&255,Q.check=i(Q.check,rt,2,0),xe=ue=0,Q.mode=2;break}if(Q.flags=0,Q.head&&(Q.head.done=!1),!(1&Q.wrap)||(((255&ue)<<8)+(ue>>8))%31){Y.msg="incorrect header check",Q.mode=30;break}if((15&ue)!=8){Y.msg="unknown compression method",Q.mode=30;break}if(xe-=4,ye=8+(15&(ue>>>=4)),Q.wbits===0)Q.wbits=ye;else if(ye>Q.wbits){Y.msg="invalid window size",Q.mode=30;break}Q.dmax=1<>8&1),512&Q.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,Q.check=i(Q.check,rt,2,0)),xe=ue=0,Q.mode=3;case 3:for(;xe<32;){if(fe===0)break e;fe--,ue+=ce[re++]<>>8&255,rt[2]=ue>>>16&255,rt[3]=ue>>>24&255,Q.check=i(Q.check,rt,4,0)),xe=ue=0,Q.mode=4;case 4:for(;xe<16;){if(fe===0)break e;fe--,ue+=ce[re++]<>8),512&Q.flags&&(rt[0]=255&ue,rt[1]=ue>>>8&255,Q.check=i(Q.check,rt,2,0)),xe=ue=0,Q.mode=5;case 5:if(1024&Q.flags){for(;xe<16;){if(fe===0)break e;fe--,ue+=ce[re++]<>>8&255,Q.check=i(Q.check,rt,2,0)),xe=ue=0}else Q.head&&(Q.head.extra=null);Q.mode=6;case 6:if(1024&Q.flags&&(fe<(Me=Q.length)&&(Me=fe),Me&&(Q.head&&(ye=Q.head.extra_len-Q.length,Q.head.extra||(Q.head.extra=new Array(Q.head.extra_len)),o.arraySet(Q.head.extra,ce,re,Me,ye)),512&Q.flags&&(Q.check=i(Q.check,ce,Me,re)),fe-=Me,re+=Me,Q.length-=Me),Q.length))break e;Q.length=0,Q.mode=7;case 7:if(2048&Q.flags){if(fe===0)break e;for(Me=0;ye=ce[re+Me++],Q.head&&ye&&Q.length<65536&&(Q.head.name+=String.fromCharCode(ye)),ye&&Me>9&1,Q.head.done=!0),Y.adler=Q.check=0,Q.mode=12;break;case 10:for(;xe<32;){if(fe===0)break e;fe--,ue+=ce[re++]<>>=7&xe,xe-=7&xe,Q.mode=27;break}for(;xe<3;){if(fe===0)break e;fe--,ue+=ce[re++]<>>=1)){case 0:Q.mode=14;break;case 1:if(V(Q),Q.mode=20,ee!==6)break;ue>>>=2,xe-=2;break e;case 2:Q.mode=17;break;case 3:Y.msg="invalid block type",Q.mode=30}ue>>>=2,xe-=2;break;case 14:for(ue>>>=7&xe,xe-=7&xe;xe<32;){if(fe===0)break e;fe--,ue+=ce[re++]<>>16^65535)){Y.msg="invalid stored block lengths",Q.mode=30;break}if(Q.length=65535&ue,xe=ue=0,Q.mode=15,ee===6)break e;case 15:Q.mode=16;case 16:if(Me=Q.length){if(fe>>=5,xe-=5,Q.ndist=1+(31&ue),ue>>>=5,xe-=5,Q.ncode=4+(15&ue),ue>>>=4,xe-=4,286>>=3,xe-=3}for(;Q.have<19;)Q.lens[He[Q.have++]]=0;if(Q.lencode=Q.lendyn,Q.lenbits=7,at={bits:Q.lenbits},qe=u(0,Q.lens,0,19,Q.lencode,0,Q.work,at),Q.lenbits=at.bits,qe){Y.msg="invalid code lengths set",Q.mode=30;break}Q.have=0,Q.mode=19;case 19:for(;Q.have>>16&255,Le=65535&Ae,!((pe=Ae>>>24)<=xe);){if(fe===0)break e;fe--,ue+=ce[re++]<>>=pe,xe-=pe,Q.lens[Q.have++]=Le;else{if(Le===16){for(tt=pe+2;xe>>=pe,xe-=pe,Q.have===0){Y.msg="invalid bit length repeat",Q.mode=30;break}ye=Q.lens[Q.have-1],Me=3+(3&ue),ue>>>=2,xe-=2}else if(Le===17){for(tt=pe+3;xe>>=pe)),ue>>>=3,xe-=3}else{for(tt=pe+7;xe>>=pe)),ue>>>=7,xe-=7}if(Q.have+Me>Q.nlen+Q.ndist){Y.msg="invalid bit length repeat",Q.mode=30;break}for(;Me--;)Q.lens[Q.have++]=ye}}if(Q.mode===30)break;if(Q.lens[256]===0){Y.msg="invalid code -- missing end-of-block",Q.mode=30;break}if(Q.lenbits=9,at={bits:Q.lenbits},qe=u(p,Q.lens,0,Q.nlen,Q.lencode,0,Q.work,at),Q.lenbits=at.bits,qe){Y.msg="invalid literal/lengths set",Q.mode=30;break}if(Q.distbits=6,Q.distcode=Q.distdyn,at={bits:Q.distbits},qe=u(f,Q.lens,Q.nlen,Q.ndist,Q.distcode,0,Q.work,at),Q.distbits=at.bits,qe){Y.msg="invalid distances set",Q.mode=30;break}if(Q.mode=20,ee===6)break e;case 20:Q.mode=21;case 21:if(6<=fe&&258<=ge){Y.next_out=oe,Y.avail_out=ge,Y.next_in=re,Y.avail_in=fe,Q.hold=ue,Q.bits=xe,c(Y,$e),oe=Y.next_out,ne=Y.output,ge=Y.avail_out,re=Y.next_in,ce=Y.input,fe=Y.avail_in,ue=Q.hold,xe=Q.bits,Q.mode===12&&(Q.back=-1);break}for(Q.back=0;we=(Ae=Q.lencode[ue&(1<>>16&255,Le=65535&Ae,!((pe=Ae>>>24)<=xe);){if(fe===0)break e;fe--,ue+=ce[re++]<>Qe)])>>>16&255,Le=65535&Ae,!(Qe+(pe=Ae>>>24)<=xe);){if(fe===0)break e;fe--,ue+=ce[re++]<>>=Qe,xe-=Qe,Q.back+=Qe}if(ue>>>=pe,xe-=pe,Q.back+=pe,Q.length=Le,we===0){Q.mode=26;break}if(32&we){Q.back=-1,Q.mode=12;break}if(64&we){Y.msg="invalid literal/length code",Q.mode=30;break}Q.extra=15&we,Q.mode=22;case 22:if(Q.extra){for(tt=Q.extra;xe>>=Q.extra,xe-=Q.extra,Q.back+=Q.extra}Q.was=Q.length,Q.mode=23;case 23:for(;we=(Ae=Q.distcode[ue&(1<>>16&255,Le=65535&Ae,!((pe=Ae>>>24)<=xe);){if(fe===0)break e;fe--,ue+=ce[re++]<>Qe)])>>>16&255,Le=65535&Ae,!(Qe+(pe=Ae>>>24)<=xe);){if(fe===0)break e;fe--,ue+=ce[re++]<>>=Qe,xe-=Qe,Q.back+=Qe}if(ue>>>=pe,xe-=pe,Q.back+=pe,64&we){Y.msg="invalid distance code",Q.mode=30;break}Q.offset=Le,Q.extra=15&we,Q.mode=24;case 24:if(Q.extra){for(tt=Q.extra;xe>>=Q.extra,xe-=Q.extra,Q.back+=Q.extra}if(Q.offset>Q.dmax){Y.msg="invalid distance too far back",Q.mode=30;break}Q.mode=25;case 25:if(ge===0)break e;if(Me=$e-ge,Q.offset>Me){if((Me=Q.offset-Me)>Q.whave&&Q.sane){Y.msg="invalid distance too far back",Q.mode=30;break}Ie=Me>Q.wnext?(Me-=Q.wnext,Q.wsize-Me):Q.wnext-Me,Me>Q.length&&(Me=Q.length),ke=Q.window}else ke=ne,Ie=oe-Q.offset,Me=Q.length;for(ge$?(B=Ie[ke+j[ee]],xe[_e+j[ee]]):(B=96,0),S=1<>oe)+(M-=S)]=U<<24|B<<16|V|0,M!==0;);for(S=1<>=1;if(S!==0?(ue&=S-1,ue+=S):ue=0,ee++,--$e[Y]==0){if(Y===ce)break;Y=f[g+j[ee]]}if(ne>>7)]}function _e(Ae,rt){Ae.pending_buf[Ae.pending++]=255&rt,Ae.pending_buf[Ae.pending++]=rt>>>8&255}function $e(Ae,rt,He){Ae.bi_valid>k-He?(Ae.bi_buf|=rt<>k-Ae.bi_valid,Ae.bi_valid+=He-k):(Ae.bi_buf|=rt<>>=1,He<<=1,0<--rt;);return He>>>1}function ke(Ae,rt,He){var ct,Ue,Ze=new Array(j+1),Je=0;for(ct=1;ct<=j;ct++)Ze[ct]=Je=Je+He[ct-1]<<1;for(Ue=0;Ue<=rt;Ue++){var Ge=Ae[2*Ue+1];Ge!==0&&(Ae[2*Ue]=Ie(Ze[Ge]++,Ge))}}function pe(Ae){var rt;for(rt=0;rt>1;1<=He;He--)Qe(Ae,Ze,He);for(Ue=et;He=Ae.heap[1],Ae.heap[1]=Ae.heap[Ae.heap_len--],Qe(Ae,Ze,1),ct=Ae.heap[1],Ae.heap[--Ae.heap_max]=He,Ae.heap[--Ae.heap_max]=ct,Ze[2*Ue]=Ze[2*He]+Ze[2*ct],Ae.depth[Ue]=(Ae.depth[He]>=Ae.depth[ct]?Ae.depth[He]:Ae.depth[ct])+1,Ze[2*He+1]=Ze[2*ct+1]=Ue,Ae.heap[1]=Ue++,Qe(Ae,Ze,1),2<=Ae.heap_len;);Ae.heap[--Ae.heap_max]=Ae.heap[1],function(Dt,Vt){var hs,As,Ms,cs,er,xt,Ps=Vt.dyn_tree,mr=Vt.max_code,Tr=Vt.stat_desc.static_tree,Dr=Vt.stat_desc.has_stree,xn=Vt.stat_desc.extra_bits,Si=Vt.stat_desc.extra_base,Ia=Vt.stat_desc.max_length,ur=0;for(cs=0;cs<=j;cs++)Dt.bl_count[cs]=0;for(Ps[2*Dt.heap[Dt.heap_max]+1]=0,hs=Dt.heap_max+1;hs>=7;Ue>>=1)if(1&it&&Ge.dyn_ltree[2*et]!==0)return l;if(Ge.dyn_ltree[18]!==0||Ge.dyn_ltree[20]!==0||Ge.dyn_ltree[26]!==0)return i;for(et=32;et>>3,(Ze=Ae.static_len+3+7>>>3)<=Ue&&(Ue=Ze)):Ue=Ze=He+5,He+4<=Ue&&rt!==-1?tt(Ae,rt,He,ct):Ae.strategy===4||Ze===Ue?($e(Ae,2+(ct?1:0),3),Te(Ae,X,Y)):($e(Ae,4+(ct?1:0),3),function(Ge,et,it,Dt){var Vt;for($e(Ge,et-257,5),$e(Ge,it-1,5),$e(Ge,Dt-4,4),Vt=0;Vt>>8&255,Ae.pending_buf[Ae.d_buf+2*Ae.last_lit+1]=255&rt,Ae.pending_buf[Ae.l_buf+Ae.last_lit]=255&He,Ae.last_lit++,rt===0?Ae.dyn_ltree[2*He]++:(Ae.matches++,rt--,Ae.dyn_ltree[2*(Q[He]+f+1)]++,Ae.dyn_dtree[2*xe(rt)]++),Ae.last_lit===Ae.lit_bufsize-1},a._tr_align=function(Ae){$e(Ae,2,3),Me(Ae,M,X),function(rt){rt.bi_valid===16?(_e(rt,rt.bi_buf),rt.bi_buf=0,rt.bi_valid=0):8<=rt.bi_valid&&(rt.pending_buf[rt.pending++]=255&rt.bi_buf,rt.bi_buf>>=8,rt.bi_valid-=8)}(Ae)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var c,u,p,f,g=1,v={},_=!1,w=l.document,j=Object.getPrototypeOf&&Object.getPrototypeOf(l);j=j&&j.setTimeout?j:l,c={}.toString.call(l.process)==="[object process]"?function(L){process.nextTick(function(){S(L)})}:function(){if(l.postMessage&&!l.importScripts){var L=!0,P=l.onmessage;return l.onmessage=function(){L=!1},l.postMessage("","*"),l.onmessage=P,L}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",M,!1):l.attachEvent("onmessage",M),function(L){l.postMessage(f+L,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(L){S(L.data)},function(L){p.port2.postMessage(L)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(L){var P=w.createElement("script");P.onreadystatechange=function(){S(L),P.onreadystatechange=null,u.removeChild(P),P=null},u.appendChild(P)}):function(L){setTimeout(S,0,L)},j.setImmediate=function(L){typeof L!="function"&&(L=new Function(""+L));for(var P=new Array(arguments.length-1),O=0;O"u"?o===void 0?this:o:self)}).call(this,typeof Yv<"u"?Yv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ctt);var DUt=ctt.exports;const OUt=Po(DUt);function Uge(t,s=400,r=75){return t&&`${t.replace("/storage/v1/object/public/","/storage/v1/render/image/public/")}?width=${s}&quality=${r}&resize=contain`}const RUt=()=>{const{isAdmin:t}=Os(),[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState("all"),[i,c]=N.useState(new Set),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState("images"),[w,j]=N.useState(null),{data:k=[],isLoading:S}=mt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:fe,error:ge}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ge)throw ge;return fe}}),{data:M=[]}=mt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:fe,error:ge}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ge)throw ge;return fe}}),{data:L=[]}=mt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:fe,error:ge}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ge)throw ge;return fe}}),{data:P=[]}=mt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:fe,error:ge}=await H.from("social_accounts").select("id, platform").eq("is_active",!0);if(ge)throw ge;return fe||[]}}),O=P.length>0,$=N.useMemo(()=>o==="all"?null:L.find(fe=>fe.month===o)||null,[o,L]),U=N.useMemo(()=>[...new Set(k.map(ge=>ge.month))].sort((ge,ue)=>ue.localeCompare(ge)),[k]);N.useEffect(()=>{U.length>0&&o==="all"&&l(U[0])},[U,o]);const B=fe=>{try{const ge=Pje(fe,"yyyy-MM",new Date);return ms(ge,"MMMM yyyy")}catch{return fe}},V=N.useMemo(()=>o==="all"?k:k.filter(fe=>fe.month===o),[o,k]),X=N.useMemo(()=>{var fe;return o==="all"?null:((fe=M.find(ge=>ge.month===o))==null?void 0:fe.canva_link)||null},[o,M]),Y=async fe=>{try{await navigator.clipboard.writeText(fe),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},ee=async(fe,ge)=>{try{const xe=await(await fetch(fe)).blob(),_e=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),$e=navigator.canShare&&navigator.canShare({files:[new File([xe],"test.jpg",{type:"image/jpeg"})]});if(_e&&$e){const Me=new File([xe],`social-swag-${ge}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Me],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const Me=window.URL.createObjectURL(xe),Ie=document.createElement("a");Ie.href=Me,Ie.download=`social-swag-${ge}.jpg`,document.body.appendChild(Ie),Ie.click(),document.body.removeChild(Ie),window.URL.revokeObjectURL(Me),me.success("Image downloaded!")}}catch(ue){ue.name!=="AbortError"&&me.error("Failed to download image")}},Q=fe=>{c(ge=>{const ue=new Set(ge);return ue.has(fe)?ue.delete(fe):ue.add(fe),ue})},ce=()=>{c(new Set(V.map(fe=>fe.id)))},ne=()=>{c(new Set),p(!1)},re=async()=>{const fe=V.filter(ge=>i.has(ge.id));if(fe.length===0){me.error("No images selected");return}g(!0),me.info(`Preparing ${fe.length} images for download...`);try{const ge=new OUt,ue=[...fe].sort((Ie,ke)=>Ie.sort_order-ke.sort_order);for(let Ie=0;Ie{u?Q(fe.id):r(fe)};return e.jsx(Ts,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(fn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(vl,{className:"h-3 w-3 mr-1"}),k.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(_a,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(fa,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(ns,{value:"gallery",className:"gap-2",children:[e.jsx(vl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(ns,{value:"scheduled",className:"gap-2",children:[e.jsx(Od,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(ws,{value:"gallery",className:"space-y-6",children:[t?O?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(pa,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Cu,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Tu,{className:"h-5 w-5 text-pink-600"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),e.jsx(K,{asChild:!0,className:"gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600",children:e.jsxs(pa,{to:"/social-connections",children:[e.jsx(ml,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Cu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Tu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(fe=>e.jsx("button",{onClick:()=>l(fe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===fe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(fe)},fe))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),ne()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",v==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(vl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",v==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(yu,{className:"h-4 w-4"}),"Reels"]})]}),v==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ne,className:"gap-2",children:[e.jsx(Mr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:re,disabled:f,className:"gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Please ensure your browser allows downloads from the LevelUp Dashboard."})]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ba,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&v==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(fe=>{const ge=i.has(fe.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ge&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(fe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Uge(fe.image_url,400,75),alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110",loading:"lazy",decoding:"async"}),fe.post_date&&!u&&e.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:e.jsx("div",{className:"absolute flex items-center justify-center text-white font-bold text-[10px] tracking-wider uppercase",style:{top:"20px",left:"-34px",width:"136px",transform:"rotate(-45deg)",backgroundColor:"#2d5052",padding:"5px 0",boxShadow:"0 2px 4px rgba(0,0,0,0.25)"},children:ms(new Date(fe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ge?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ge&&e.jsx(ba,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},fe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(vl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&v==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Uge($.image_url,400,75),alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(st,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(yu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(yu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(xs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(fs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:Uge(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Post on ",ms(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{j({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx($n,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(xs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(fs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(yu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(en,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(IUt,{open:!!w,onOpenChange:fe=>!fe&&j(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx(ws,{value:"scheduled",children:e.jsx(LUt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(un,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(Cu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Tu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:U.map(fe=>e.jsx("button",{onClick:()=>l(fe),className:It("px-4 py-2 rounded-full text-sm font-medium transition-all",o===fe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(fe)},fe))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",B(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{_("images"),ne()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",v==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(vl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:It("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",v==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(yu,{className:"h-4 w-4"}),"Reels"]})]}),v==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ne,className:"gap-2",children:[e.jsx(Mr,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:re,disabled:f,className:"gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),f?"Downloading...":`Download ${i.size} Selected`]})]}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[e.jsx(ba,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&v==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(fe=>{const ge=i.has(fe.id);return e.jsx(Ee,{className:It("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&ge&&"ring-2 ring-primary ring-offset-2"),onClick:()=>oe(fe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:fe.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),u&&e.jsx("div",{className:It("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",ge?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:ge&&e.jsx(ba,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},fe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(vl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&v==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(st,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(yu,{className:"h-3 w-3 mr-1"}),"Reel"]})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(yu,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),e.jsx(xs,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(fs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>Y(s.caption),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>ee(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(vi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(xs,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(fs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:e.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:e.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(yu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>Y(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&e.jsxs(K,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[e.jsx(en,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},FUt=()=>{const{swagId:t}=lo(),{user:s}=Os(),{toast:r}=Ha(),n=Xt(),{trackEngagement:a}=hE(),[o,l]=N.useState(""),{data:i,isLoading:c}=mt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:M}=await H.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...k,links:M||[]}},enabled:!!t});N.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=mt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return k},enabled:!!t}),{data:p=[]}=mt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:k,error:S}=await H.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const M=[...new Set(k.map(O=>O.user_id))],{data:L}=await H.from("profiles").select("id, name").in("id",M),P=new Map((L==null?void 0:L.map(O=>[O.id,O.name]))||[]);return k.map(O=>({...O,user_name:P.get(O.user_id)||"Unknown User"}))},enabled:!!t}),f=Lt({mutationFn:async k=>{const{error:S}=await H.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:k});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:k=>{r({title:"Error adding comment",description:k.message,variant:"destructive"})}}),g=Lt({mutationFn:async k=>{const{error:S}=await H.from("social_swag_comments").delete().eq("id",k);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),v=Lt({mutationFn:async()=>{const k=u.find(S=>S.user_id===(s==null?void 0:s.id));if(k){const{error:S}=await H.from("social_swag_likes").delete().eq("id",k.id);if(S)throw S}else{const{error:S}=await H.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),_=u.some(k=>k.user_id===(s==null?void 0:s.id)),w=k=>k.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=k=>{k.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return c?e.jsx(Ts,{title:"Social Swag",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):i?e.jsx(Ts,{title:i.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/social-swag",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Social Swag"]})}),i.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:i.preview_image_url,alt:i.title,className:"w-full max-h-[500px] object-contain"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:i.title})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:_?"default":"outline",className:"gap-2 w-fit",onClick:()=>v.mutate(),disabled:!s||v.isPending,children:[e.jsx(nh,{className:`h-4 w-4 ${_?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Bo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(k=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(k.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:k.title}),e.jsx(en,{className:"h-4 w-4 text-muted-foreground"})]},k.id))})]})}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(qc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Add a comment...",value:o,onChange:k=>l(k.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx($n,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(k=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(kn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(Sn,{className:"text-sm",children:w(k.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:k.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Vc(new Date(k.created_at),{addSuffix:!0})}),k.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>g.mutate(k.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:k.content})]})]})})},k.id))})]})]})}):e.jsx(Ts,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Bo,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/social-swag",children:"Back to Social Swag"})})]})})},zUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=N.useState(!0),[i,c]=N.useState(!0),[u,p]=N.useState(!0),f=g=>g.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(K_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(vf,{open:o,onOpenChange:l,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?e.jsx(oo,{className:"h-4 w-4"}):e.jsx(oa,{className:"h-4 w-4"})]})}),e.jsx(_f,{className:"space-y-1 pl-2",children:t.map(g=>e.jsxs(K,{variant:r===g.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(g.id),children:[e.jsx("span",{className:"mr-2",children:g.icon||"📂"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),s.length>0&&e.jsxs(vf,{open:i,onOpenChange:c,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(Eh,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(oo,{className:"h-4 w-4"}):e.jsx(oa,{className:"h-4 w-4"})]})}),e.jsx(_f,{className:"space-y-1 pl-2",children:s.map(g=>e.jsxs(K,{variant:r===`group:${g.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${g.id}`),children:[e.jsx("span",{className:"mr-2",children:g.icon||"🔒"}),e.jsx("span",{className:"truncate",children:g.name})]},g.id))})]}),e.jsxs(vf,{open:u,onOpenChange:p,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),"Online Now",a.length>0&&e.jsx("span",{className:"ml-1 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 min-w-[20px] text-center",children:a.length})]}),u?e.jsx(oo,{className:"h-4 w-4"}):e.jsx(oa,{className:"h-4 w-4"})]})}),e.jsx(_f,{className:"pl-2 space-y-1",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2 px-2",children:"No one else online right now"}):a.map(g=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(kn,{className:"h-7 w-7",children:[e.jsx(Ua,{src:g.avatarUrl}),e.jsx(Sn,{className:"text-xs",children:f(g.name)})]}),e.jsx(wd,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"text-sm truncate",children:g.name})]},g.id))})]})]})})})},BUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=N.useState(!1),i=u=>u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),c=()=>{if(r==="all")return"All Posts";if(r.startsWith("group:")){const p=r.replace("group:",""),f=s.find(g=>g.id===p);return f?`🔒 ${f.name}`:"Private Group"}const u=t.find(p=>p.id===r);return u?`${u.icon||"📂"} ${u.name}`:"Category"};return e.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(oo,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Bd,{className:"w-56 bg-background border",children:[e.jsxs(Aa,{onClick:()=>n("all"),children:[e.jsx(K_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(xw,{}),e.jsx(Rve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Aa,{onClick:()=>n(u.id),children:[e.jsx("span",{className:"mr-2",children:u.icon||"📂"}),u.name]},u.id)),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(xw,{}),e.jsxs(Rve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Eh,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Aa,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(lE,{open:o,onOpenChange:l,children:[e.jsx(fNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(hr,{className:"h-4 w-4"}),a.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-green-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:a.length})]})}),e.jsxs(S3,{children:[e.jsx(cE,{children:e.jsxs(dE,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Ki,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):e.jsx("div",{className:"space-y-2",children:a.map(u=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:u.avatarUrl}),e.jsx(Sn,{children:i(u.name)})]}),e.jsx(wd,{className:"h-3 w-3 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),e.jsx("span",{className:"font-medium",children:u.name})]},u.id))})})]})]})]})};var Vge,she="HoverCard",[dtt]=od(she,[$0]),rhe=$0(),[$Ut,Gke]=dtt(she),utt=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=rhe(s),u=N.useRef(0),p=N.useRef(0),f=N.useRef(!1),g=N.useRef(!1),[v,_]=oh({prop:n,defaultProp:a??!1,onChange:o,caller:she}),w=N.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>_(!0),l)},[l,_]),j=N.useCallback(()=>{clearTimeout(u.current),!f.current&&!g.current&&(p.current=window.setTimeout(()=>_(!1),i))},[i,_]),k=N.useCallback(()=>_(!1),[_]);return N.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx($Ut,{scope:s,open:v,onOpenChange:_,onOpen:w,onClose:j,onDismiss:k,hasSelectionRef:f,isPointerDownOnContentRef:g,children:e.jsx(IO,{...c,children:r})})};utt.displayName=she;var htt="HoverCardTrigger",mtt=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Gke(htt,r),o=rhe(r);return e.jsx(YA,{asChild:!0,...o,children:e.jsx(an.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Lr(t.onPointerEnter,Yle(a.onOpen)),onPointerLeave:Lr(t.onPointerLeave,Yle(a.onClose)),onFocus:Lr(t.onFocus,a.onOpen),onBlur:Lr(t.onBlur,a.onClose),onTouchStart:Lr(t.onTouchStart,l=>l.preventDefault())})})});mtt.displayName=htt;var qUt="HoverCardPortal",[XTs,UUt]=dtt(qUt,{forceMount:void 0}),Zle="HoverCardContent",ptt=N.forwardRef((t,s)=>{const r=UUt(Zle,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=Gke(Zle,t.__scopeHoverCard);return e.jsx(zd,{present:n||o.open,children:e.jsx(VUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Lr(t.onPointerEnter,Yle(o.onOpen)),onPointerLeave:Lr(t.onPointerLeave,Yle(o.onClose)),ref:s})})});ptt.displayName=Zle;var VUt=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=Gke(Zle,r),u=rhe(r),p=N.useRef(null),f=Va(s,p),[g,v]=N.useState(!1);return N.useEffect(()=>{if(g){const _=document.body;return Vge=_.style.userSelect||_.style.webkitUserSelect,_.style.userSelect="none",_.style.webkitUserSelect="none",()=>{_.style.userSelect=Vge,_.style.webkitUserSelect=Vge}}},[g]),N.useEffect(()=>{if(p.current){const _=()=>{v(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var j;((j=document.getSelection())==null?void 0:j.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",_),()=>{document.removeEventListener("pointerup",_),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),N.useEffect(()=>{p.current&&WUt(p.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(Aw,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Lr(o,_=>{_.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(LO,{...u,...i,onPointerDown:Lr(i.onPointerDown,_=>{_.currentTarget.contains(_.target)&&v(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:g?"text":void 0,WebkitUserSelect:g?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),HUt="HoverCardArrow",GUt=N.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=rhe(r);return e.jsx(DO,{...a,...n,ref:s})});GUt.displayName=HUt;function Yle(t){return s=>s.pointerType==="touch"?void 0:t()}function WUt(t){const s=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;r.nextNode();)s.push(r.currentNode);return s}var KUt=utt,ZUt=mtt,ftt=ptt;const YUt=KUt,QUt=ZUt,xtt=N.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(ftt,{ref:a,align:s,sideOffset:r,className:It("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));xtt.displayName=ftt.displayName;const XUt=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"},{type:"laugh",emoji:"😂",label:"Haha"},{type:"wow",emoji:"😮",label:"Wow"},{type:"sad",emoji:"😢",label:"Sad"},{type:"angry",emoji:"😠",label:"Angry"}],JUt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),gtt=({reactions:t,children:s})=>{if(t.length===0)return e.jsx(e.Fragment,{children:s});const r={};return t.forEach(n=>{r[n.reaction_type]||(r[n.reaction_type]=[]),r[n.reaction_type].push(n)}),e.jsxs(YUt,{openDelay:200,closeDelay:100,children:[e.jsx(QUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(xtt,{className:"w-64 p-3 bg-popover border shadow-lg z-50",side:"top",align:"start",children:e.jsx("div",{className:"space-y-3",children:Object.entries(r).map(([n,a])=>{const o=XUt.find(l=>l.type===n);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-lg",children:o==null?void 0:o.emoji}),e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o==null?void 0:o.label," (",a.length,")"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[a.slice(0,10).map(l=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:l.user_avatar||void 0}),e.jsx(Sn,{className:"text-[10px]",children:JUt(l.user_name||"U")})]}),e.jsx("span",{className:"text-sm text-foreground truncate",children:l.user_name||"Unknown User"})]},l.id)),a.length>10&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",a.length-10," more"]})]})]},n)})})})]})};function eVt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=N.useState(s),[l,i]=N.useState(!1);N.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const c=()=>{o(g=>g>0?g-1:t.length-1),i(!1)},u=()=>{o(g=>g{r&&(g.key==="ArrowLeft"&&c(),g.key==="ArrowRight"&&u(),g.key==="Escape"&&n(!1))},[r,t.length]);N.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(xs,{open:r,onOpenChange:n,children:e.jsxs(fs,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(Mr,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:c,children:e.jsx(Xo,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(oa,{className:"h-8 w-8"})})]}),t.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 px-3 py-1 rounded-full",children:[a+1," / ",t.length]}),(f==null?void 0:f.type)==="image"&&e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(JM,{className:"h-5 w-5"}):e.jsx(J_,{className:"h-5 w-5"})}),e.jsx("div",{className:It("flex items-center justify-center w-full h-full min-h-[50vh] p-4",l?"cursor-zoom-out overflow-auto":"cursor-zoom-in"),onClick:()=>(f==null?void 0:f.type)==="image"&&i(!l),children:(f==null?void 0:f.type)==="video"?e.jsx("video",{src:f.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:g=>g.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:It("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),t.length>1&&e.jsx("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 flex gap-2 bg-black/50 p-2 rounded-lg max-w-[90vw] overflow-x-auto",children:t.map((g,v)=>e.jsx("button",{onClick:()=>{o(v),i(!1)},className:It("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===v?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:g.type==="video"?e.jsx("video",{src:g.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:g.url,alt:"",className:"w-full h-full object-cover"})},v))})]})})}const Rz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],tVt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=Xt(),[a,o]=N.useState(!1),l=s.find(f=>f.user_id===r),i=Lt({mutationFn:async f=>{l?l.reaction_type===f?await H.from("community_comment_reactions").delete().eq("id",l.id):await H.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await H.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),c={};return s.forEach(f=>{c[f.reaction_type]=(c[f.reaction_type]||0)+1}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.length>0&&e.jsx(gtt,{reactions:s,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(c).slice(0,2).map(f=>{var g;return e.jsx("span",{className:"text-sm",children:(g=Rz.find(v=>v.type===f))==null?void 0:g.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsx("button",{className:`text-xs hover:text-primary transition-colors ${l?"text-primary font-medium":"text-muted-foreground"}`,children:l?e.jsxs("span",{children:[(u=Rz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=Rz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ya,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(Ro,{className:"w-auto p-1.5 bg-popover border shadow-lg z-50",side:"top",children:e.jsx("div",{className:"flex gap-0.5",children:Rz.map(f=>e.jsx("button",{onClick:()=>i.mutate(f.type),className:"text-xl hover:scale-125 transition-transform p-1",title:f.label,children:f.emoji},f.type))})})]})]})};function Wke({content:t,className:s}){const r=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=r.exec(t))!==null;){if(o.index>a&&n.push(t.substring(a,o.index)),o[1]){const i=o[1],c=o[2],u=o[3],p=i==="#";n.push(e.jsx(pa,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:It("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:f=>f.stopPropagation(),children:p?c:`@${c}`},`mention-${l++}`))}else if(o[4]){const i=o[4],c=i.replace(/[.,;:!?)]+$/,""),u=i.slice(c.length);let p;try{const f=new URL(c);p=f.hostname+(f.pathname!=="/"?f.pathname.slice(0,20)+(f.pathname.length>20?"...":""):"")}catch{p=c.length>40?c.slice(0,40)+"...":c}n.push(e.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:f=>f.stopPropagation(),children:p},`url-${l++}`)),u&&n.push(u)}a=o.index+o[0].length}return ae.jsx(N.Fragment,{children:i},c))})}function Qle({value:t,onChange:s,placeholder:r="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:c="encoded",enableTemplateMentions:u=!1}){const p=N.useRef(null),f=N.useRef(null),[g,v]=N.useState(!1),[_,w]=N.useState("user"),[j,k]=N.useState(""),[S,M]=N.useState(null),[L,P]=N.useState(0),[O,$]=N.useState({top:0,left:0,width:0}),U=N.useRef(new Map),B=N.useRef(new Map),V=xe=>{if(c==="plain"){const Ie=[];return U.current.forEach((pe,we)=>{xe.includes(`@${we}`)&&Ie.push(pe)}),[...new Set(Ie)]}const _e=/@\[([^\]]+)\]\(([^)]+)\)/g,$e=[];let Me;for(;(Me=_e.exec(xe))!==null;)$e.push(Me[2]);return[...new Set($e)]},X=xe=>{if(c==="plain"){const Ie=[];return B.current.forEach((pe,we)=>{xe.includes(`#${we}`)&&Ie.push(pe)}),[...new Set(Ie)]}const _e=/#\[([^\]]+)\]\(([^)]+)\)/g,$e=[];let Me;for(;(Me=_e.exec(xe))!==null;)$e.push(Me[2]);return[...new Set($e)]};N.useEffect(()=>{if(o){const xe=V(t);o(xe)}if(l){const xe=X(t);l(xe)}},[t,o,l,c]);const{data:Y=[],isLoading:ee}=mt({queryKey:["mention-users",j],queryFn:async()=>{const xe=H.from("profiles").select("id, name").limit(8),_e=j.length>=1?xe.ilike("name",`%${j}%`):xe.order("name"),{data:$e,error:Me}=await _e;if(Me)throw Me;const Ie=$e.map(pe=>pe.id),ke=await tYe(Ie);return $e.map(pe=>({id:pe.id,name:pe.name||"Unknown",avatar_url:ke.get(pe.id)}))},enabled:g&&_==="user",staleTime:3e4}),{data:Q=[],isLoading:ce}=mt({queryKey:["mention-templates",j],queryFn:async()=>{let xe=H.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);j.length>=1&&(xe=xe.ilike("name",`%${j}%`));const{data:_e,error:$e}=await xe;if($e)throw $e;return _e||[]},enabled:g&&_==="template"&&u,staleTime:3e4}),ne=_==="user"?ee:ce,re=_==="user"?Y:Q,oe=xe=>xe.split(" ").map(_e=>_e[0]).join("").toUpperCase().slice(0,2),fe=xe=>{const _e=xe.target.value,$e=xe.target.selectionStart;s(_e);const Me=_e.substring(0,$e),Ie=Me.lastIndexOf("@"),ke=u?Me.lastIndexOf("#"):-1;let pe=-1,we="user";if(Ie>ke?(pe=Ie,we="user"):ke>Ie&&u&&(pe=ke,we="template"),pe!==-1){const Le=Me.substring(pe+1),Qe=Le.includes(" "),Te=Le.includes(` `);if(!Qe&&!Te&&Le.length<=30){M(pe),k(Le),w(we),v(!0),P(0);return}}v(!1),M(null)},ge=xe=>{if(S===null)return;const _e=t.substring(0,S),$e=t.substring(S+j.length+1),Me=_==="user"?"@":"#",Ie=c==="plain"?`${Me}${xe.name} `:`${Me}[${xe.name}](${xe.id}) `;c==="plain"&&(_==="user"?U.current.set(xe.name,xe.id):B.current.set(xe.name,xe.id));const ke=_e+Ie+$e;s(ke),v(!1),M(null),k(""),setTimeout(()=>{if(p.current){const pe=_e.length+Ie.length;p.current.focus(),p.current.setSelectionRange(pe,pe)}},0)},ue=xe=>{if(!(!g||re.length===0))switch(xe.key){case"ArrowDown":xe.preventDefault(),P(_e=>(_e+1)%re.length);break;case"ArrowUp":xe.preventDefault(),P(_e=>(_e-1+re.length)%re.length);break;case"Enter":re[L]&&(xe.preventDefault(),ge(re[L]));break;case"Escape":xe.preventDefault(),v(!1);break;case"Tab":re[L]&&(xe.preventDefault(),ge(re[L]));break}};return N.useEffect(()=>{const xe=_e=>{f.current&&!f.current.contains(_e.target)&&p.current&&!p.current.contains(_e.target)&&v(!1)};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},[]),N.useEffect(()=>{if(!g)return;const xe=()=>{const _e=p.current;if(!_e)return;const $e=_e.getBoundingClientRect();$({top:$e.bottom+4,left:$e.left,width:$e.width})};return xe(),window.addEventListener("resize",xe),window.addEventListener("scroll",xe,!0),()=>{window.removeEventListener("resize",xe),window.removeEventListener("scroll",xe,!0)}},[g,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Pr,{ref:p,value:t,onChange:fe,onKeyDown:xe=>{ue(xe),xe.defaultPrevented||i==null||i(xe)},placeholder:r,className:It("resize-none",n),style:{minHeight:a}}),g&&yp.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:O.top,left:O.left,width:O.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:_==="user"?"👤 Mention a person":"📋 Link a template"}),ne?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):re.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:j.length<1?`Type to search ${_==="user"?"people":"templates"}...`:`No ${_==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:re.map((xe,_e)=>e.jsx("li",{className:It("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",_e===L?"bg-accent":"hover:bg-accent/50"),onClick:()=>ge(xe),onMouseEnter:()=>P(_e),children:_==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:xe.avatar_url}),e.jsx(Sn,{className:"text-xs",children:oe(xe.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:xe.name})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:xe.preview_image_url?e.jsx("img",{src:xe.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Bl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:xe.name})]})},xe.id))})]}),document.body)]})}function sVt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const C8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function ytt({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Xt(),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,v]=N.useState([]),_=Lt({mutationFn:async({content:S,parentCommentId:M})=>{const{data:L,error:P}=await H.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:M}).select("id").single();if(P)throw P;const O=g;if(O.length>0&&L){const $=O.filter(U=>U!==r).map(U=>({comment_id:L.id,mentioned_user_id:U,mentioned_by_user_id:r}));$.length>0&&await H.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),v([]),u(!1)}}),w=Lt({mutationFn:async S=>{const{error:M}=await H.from("community_comments").delete().eq("id",S);if(M)throw M},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),j=()=>{p.trim()&&_.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(kn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ua,{src:t.user_avatar||void 0}),e.jsx(Sn,{className:"text-xs",children:C8e(t.user_name||"U")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"bg-muted rounded-lg px-3 py-2",children:[e.jsx("div",{className:"font-medium text-sm",children:t.user_name}),e.jsx(Wke,{content:t.content,className:"text-sm break-words"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{children:Vc(new Date(t.created_at),{addSuffix:!0})}),e.jsx(tVt,{commentId:t.id,reactions:t.reactions,currentUserId:r}),r&&l<2&&e.jsxs("button",{onClick:()=>u(!c),className:"hover:text-primary flex items-center gap-1",children:[e.jsx(OL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),c&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(kn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Ua,{src:n||void 0}),e.jsx(Sn,{className:"text-xs",children:C8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Qle,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:v,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:j,disabled:!p.trim()||_.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx($n,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(S=>e.jsx(ytt,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const Fz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"},{type:"laugh",emoji:"😂",label:"Haha"},{type:"wow",emoji:"😮",label:"Wow"},{type:"sad",emoji:"😢",label:"Sad"},{type:"angry",emoji:"😠",label:"Angry"}],rVt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Os(),{avatarUrl:a}=eYe(t==null?void 0:t.id),{onlineUsers:o}=sQe(),{toast:l}=Ha(),i=Xt(),c=N.useRef(null),[u,p]=N.useState("all"),[f,g]=N.useState(""),[v,_]=N.useState(""),[w,j]=N.useState(""),[k,S]=N.useState([]),[M,L]=N.useState([]),[P,O]=N.useState(""),[$,U]=N.useState(!1),[B,V]=N.useState(null),[X,Y]=N.useState(""),[ee,Q]=N.useState(new Set),[ce,ne]=N.useState({}),[re,oe]=N.useState({}),[fe,ge]=N.useState([]),[ue,xe]=N.useState([]),[_e,$e]=N.useState({open:!1,images:[],index:0});N.useEffect(()=>{if(u.startsWith("group:")){const it=u.replace("group:","");j(it),_("")}else u!=="all"?(_(u),j("")):(_(""),j(""))},[u]);const{data:Me=[]}=mt({queryKey:["community-categories"],queryFn:async()=>{const{data:it,error:Dt}=await H.from("community_categories").select("*").order("sort_order");if(Dt)throw Dt;return it}}),{data:Ie=[]}=mt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:it,error:Dt}=await H.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Dt)throw Dt;return it}}),ke=20,{data:pe,isLoading:we,hasNextPage:Le,fetchNextPage:Qe,isFetchingNextPage:Te}=V2e({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:it})=>{var Be;const Dt=it*ke,Vt=Dt+ke;let hs=H.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Dt,Vt);if(u.startsWith("group:")){const Ye=u.replace("group:","");hs=hs.eq("private_group_id",Ye)}else u==="all"||(hs=hs.eq("category_id",u).is("private_group_id",null));const{data:As,error:Ms}=await hs;if(Ms)throw Ms;const cs=((As==null?void 0:As.length)||0)>ke,er=(As||[]).slice(0,ke);if(er.length===0)return{posts:[],hasMore:!1,nextPage:it+1};const xt=er.map(Ye=>Ye.id),Ps=[...new Set(er.filter(Ye=>Ye.category_id).map(Ye=>Ye.category_id))].filter(Boolean),[mr,Tr,Dr,xn,Si]=await Promise.all([Ps.length?H.from("community_categories").select("*").in("id",Ps):Promise.resolve({data:[]}),H.from("community_post_media").select("*").in("post_id",xt).order("sort_order"),H.from("community_reactions").select("*").in("post_id",xt),H.from("community_comments").select("*").in("post_id",xt).order("created_at",{ascending:!0}),H.from("community_post_resources").select("*").in("post_id",xt)]),Ia=mr==null?void 0:mr.data,ur=Tr==null?void 0:Tr.data,Jr=Dr==null?void 0:Dr.data,Gr=xn==null?void 0:xn.data,mn=Si==null?void 0:Si.data,Yr=(Gr||[]).map(Ye=>Ye.id),[bi,ft]=await Promise.all([Yr.length?H.from("community_comment_reactions").select("*").in("comment_id",Yr):Promise.resolve({data:[]}),(()=>{const Ye=(mn||[]).filter(bt=>bt.resource_type==="template").map(bt=>bt.resource_id);return Ye.length===0?Promise.resolve({data:[]}):H.from("canva_templates").select("id, name, preview_image_url").in("id",Ye)})()]),or=(bi==null?void 0:bi.data)||[],Vn=(ft==null?void 0:ft.data)||[],Sr=new Map(Vn.map(Ye=>[Ye.id,{name:Ye.name,preview_image_url:Ye.preview_image_url}])),jr=Array.from(new Set([...er.map(Ye=>Ye.user_id),...(Jr||[]).map(Ye=>Ye.user_id),...(Gr||[]).map(Ye=>Ye.user_id),...or.map(Ye=>Ye.user_id)])),[ea,La]=await Promise.all([jr.length?H.from("profiles").select("id, name").in("id",jr):Promise.resolve({data:[]}),tYe(jr)]),Ii=new Map(((Be=ea==null?void 0:ea.data)==null?void 0:Be.map(Ye=>[Ye.id,Ye.name]))||[]),Fo=new Map((Ia||[]).map(Ye=>[Ye.id,Ye])),$t=Ye=>{const bt=new Map,gt=[];return Ye.forEach(Ft=>{bt.set(Ft.id,{...Ft,user_name:Ii.get(Ft.user_id)||"Unknown User",user_avatar:La.get(Ft.user_id),reactions:or.filter(Zt=>Zt.comment_id===Ft.id).map(Zt=>({...Zt,user_name:Ii.get(Zt.user_id)||"Unknown User",user_avatar:La.get(Zt.user_id)})),replies:[]})}),Ye.forEach(Ft=>{const Zt=bt.get(Ft.id);if(Ft.parent_comment_id&&bt.has(Ft.parent_comment_id)){const Ut=bt.get(Ft.parent_comment_id);Ut.replies=Ut.replies||[],Ut.replies.push(Zt)}else gt.push(Zt)}),gt};return{posts:er.map(Ye=>{const bt=(mn||[]).filter(gt=>gt.post_id===Ye.id).map(gt=>{let Ft="",Zt=null;if(gt.resource_type==="template"){const Ut=Sr.get(gt.resource_id);Ft=(Ut==null?void 0:Ut.name)||"Unknown Template",Zt=(Ut==null?void 0:Ut.preview_image_url)||null}return{id:gt.id,resource_type:gt.resource_type,resource_id:gt.resource_id,resource_name:Ft,resource_preview_url:Zt}});return{...Ye,user_name:Ii.get(Ye.user_id)||"Unknown User",user_avatar:La.get(Ye.user_id),category:Ye.category_id?Fo.get(Ye.category_id):null,media:(ur||[]).filter(gt=>gt.post_id===Ye.id),reactions:((Jr||[]).filter(gt=>gt.post_id===Ye.id)||[]).map(gt=>({...gt,user_name:Ii.get(gt.user_id)||"Unknown User",user_avatar:La.get(gt.user_id)})),comments:$t((Gr||[]).filter(gt=>gt.post_id===Ye.id)),resources:bt}}),hasMore:cs,nextPage:it+1}},getNextPageParam:it=>it.hasMore?it.nextPage:void 0}),pt=N.useMemo(()=>(pe==null?void 0:pe.pages.flatMap(it=>it.posts))??[],[pe]),ye=Lt({mutationFn:async()=>{U(!0);const{data:it,error:Dt}=await H.from("community_posts").insert({user_id:t.id,category_id:w?null:v||null,private_group_id:w||null,content:f,link_url:P||null}).select().single();if(Dt)throw Dt;for(let hs=0;hs0){const hs=fe.filter(As=>As!==t.id).map(As=>({post_id:it.id,mentioned_user_id:As,mentioned_by_user_id:t.id}));hs.length>0&&await H.from("community_post_mentions").insert(hs)}const Vt=sVt(f);if(Vt.length>0){const hs=Vt.map(As=>({post_id:it.id,resource_type:"template",resource_id:As}));await H.from("community_post_resources").insert(hs)}return it},onSuccess:async it=>{var Dt;i.invalidateQueries({queryKey:["community-posts"]}),g(""),ge([]),xe([]),_(""),j(""),S([]),L([]),O(""),l({title:"Post created!"});try{const Vt=((Dt=t==null?void 0:t.user_metadata)==null?void 0:Dt.name)||"Someone",hs=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),As=hs.length>50?hs.substring(0,50)+"...":hs;await H.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Vt}: ${As}`,url:"/community"}})}catch(Vt){console.error("Failed to send push notification:",Vt)}},onError:it=>{l({title:"Error creating post",description:it.message,variant:"destructive"})},onSettled:()=>U(!1)}),qe=Lt({mutationFn:async({postId:it,content:Dt})=>{const{error:Vt}=await H.from("community_posts").update({content:Dt}).eq("id",it);if(Vt)throw Vt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),Y(""),l({title:"Post updated!"})}}),at=Lt({mutationFn:async it=>{const{error:Dt}=await H.from("community_posts").delete().eq("id",it);if(Dt)throw Dt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),tt=Lt({mutationFn:async({postId:it,isPinned:Dt})=>{const{error:Vt}=await H.from("community_posts").update({is_pinned:!Dt,pinned_at:Dt?null:new Date().toISOString(),pinned_by:Dt?null:t==null?void 0:t.id}).eq("id",it);if(Vt)throw Vt},onSuccess:(it,{isPinned:Dt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Dt?"Post unpinned":"Post pinned to top"})}}),Ae=Lt({mutationFn:async({postId:it,reactionType:Dt})=>{var hs;const Vt=(hs=pt.find(As=>As.id===it))==null?void 0:hs.reactions.find(As=>As.user_id===(t==null?void 0:t.id));Vt?Vt.reaction_type===Dt?await H.from("community_reactions").delete().eq("id",Vt.id):await H.from("community_reactions").update({reaction_type:Dt}).eq("id",Vt.id):await H.from("community_reactions").insert({post_id:it,user_id:t.id,reaction_type:Dt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),rt=Lt({mutationFn:async({postId:it,content:Dt})=>{const{data:Vt,error:hs}=await H.from("community_comments").insert({post_id:it,user_id:t.id,content:Dt}).select("id").single();if(hs)throw hs;const As=re[it]||[];if(As.length>0&&Vt){const Ms=As.filter(cs=>cs!==t.id).map(cs=>({comment_id:Vt.id,mentioned_user_id:cs,mentioned_by_user_id:t.id}));Ms.length>0&&await H.from("community_comment_mentions").insert(Ms)}},onSuccess:(it,{postId:Dt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ne(Vt=>({...Vt,[Dt]:""})),oe(Vt=>({...Vt,[Dt]:[]}))}});Lt({mutationFn:async it=>{const{error:Dt}=await H.from("community_comments").delete().eq("id",it);if(Dt)throw Dt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const He=it=>{const Dt=Array.from(it.target.files||[]);if(Dt.length+k.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(Vt=>[...Vt,...Dt]),Dt.forEach(Vt=>{const hs=new FileReader;hs.onloadend=()=>{L(As=>[...As,hs.result])},hs.readAsDataURL(Vt)})},ct=it=>{S(Dt=>Dt.filter((Vt,hs)=>hs!==it)),L(Dt=>Dt.filter((Vt,hs)=>hs!==it))},Ue=it=>it.split(" ").map(Dt=>Dt[0]).join("").toUpperCase().slice(0,2),Ze=it=>{const Dt={};return it.forEach(Vt=>{Dt[Vt.reaction_type]=(Dt[Vt.reaction_type]||0)+1}),Dt},Je=it=>{var Dt;return(Dt=it.find(Vt=>Vt.user_id===(t==null?void 0:t.id)))==null?void 0:Dt.reaction_type},Ge=it=>it.reduce((Dt,Vt)=>Dt+1+(Vt.replies?Ge(Vt.replies):0),0),et=it=>{if(n)return!0;if(!s||!it.private_group_id)return!1;const Dt=Ie.find(Vt=>Vt.id===it.private_group_id);return Dt!=null&&Dt.brokerage_id?r.some(Vt=>Vt.id===Dt.brokerage_id):!1};return e.jsx(Ts,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(zUt,{categories:Me,privateGroups:Ie,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[e.jsxs("div",{className:"px-1",children:[e.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),e.jsx(BUt,{categories:Me,privateGroups:Ie,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:a||void 0}),e.jsx(Sn,{children:t!=null&&t.email?Ue(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Qle,{placeholder:n?"What's on your mind? Use @ to mention someone, # to link a template":"What's on your mind? Use @ to mention someone",value:f,onChange:g,onMentionsChange:ge,onTemplatesChange:xe,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),M.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.map((it,Dt)=>{var Vt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Vt=k[Dt])!=null&&Vt.type.startsWith("video/")?e.jsx("video",{src:it,className:"w-full h-full object-cover"}):e.jsx("img",{src:it,alt:"",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Dt),children:e.jsx(Mr,{className:"h-3 w-3"})})]},Dt)})}),P&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:P,onChange:it=>O(it.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>O(""),children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:c,onChange:He,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(vl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var it;return(it=c.current)==null?void 0:it.click()},children:[e.jsx(Cn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>O("https://"),children:[e.jsx(Bo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Ie.length>0?e.jsxs(Ks,{value:w||v||"none",onValueChange:it=>{it==="none"?(_(""),j("")):it.startsWith("group:")?(j(it.replace("group:","")),_("")):(_(it),j(""))},children:[e.jsx(Gs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(Ys,{placeholder:"Select..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No category"}),Me.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id)),Ie.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Ie.map(it=>e.jsxs(Mt,{value:`group:${it.id}`,children:[it.icon||"🔒"," ",it.name]},it.id))]})]})]}):e.jsxs(Ks,{value:v,onValueChange:_,children:[e.jsx(Gs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(Ys,{placeholder:"Category"})}),e.jsx(Ws,{children:Me.map(it=>e.jsxs(Mt,{value:it.id,children:[it.icon," ",it.name]},it.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>ye.mutate(),disabled:!f.trim()||$,children:[e.jsx($n,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),we?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((it,Dt)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(vs,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(vs,{className:"h-4 w-32"}),e.jsx(vs,{className:"h-4 w-full"}),e.jsx(vs,{className:"h-4 w-3/4"})]})]})})},Dt))}):pt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(qc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[pt.map(it=>{var Dt,Vt,hs,As;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:it.user_avatar||void 0}),e.jsx(Sn,{children:Ue(it.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:it.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Vc(new Date(it.created_at),{addSuffix:!0})}),it.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(st,{variant:"secondary",className:"text-xs",children:[it.category.icon," ",it.category.name]})]})]})]})]}),(it.user_id===(t==null?void 0:t.id)||et(it))&&e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(xx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[et(it)&&it.private_group_id&&e.jsx(Aa,{onClick:()=>tt.mutate({postId:it.id,isPinned:it.is_pinned}),children:it.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(EL,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q_,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),it.user_id===(t==null?void 0:t.id)&&e.jsxs(Aa,{onClick:()=>{V(it),Y(it.content)},children:[e.jsx(za,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Aa,{className:"text-destructive",onClick:()=>at.mutate(it.id),children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),it.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),it.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Q_,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(Wke,{content:it.content})}),it.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${it.media.length===1?"grid-cols-1":it.media.length===2?"grid-cols-2":it.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:it.media.slice(0,4).map((Ms,cs)=>{const er=cs===3&&it.media.length>4,xt=it.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${it.media.length===1?"max-h-[500px]":it.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>$e({open:!0,images:it.media.map(Ps=>({url:Ps.media_url,type:Ps.media_type==="video"?"video":"image"})),index:cs}),children:[Ms.media_type==="video"?e.jsx("video",{src:Ms.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:Ms.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),er&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",xt]})})]},Ms.id)})}),it.link_url&&e.jsxs("a",{href:it.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[it.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:it.link_image,alt:it.link_title||"Link preview",className:"w-full h-full object-cover",onError:Ms=>{Ms.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:it.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:it.link_title}),it.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:it.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(it.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Bo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:it.link_url})]})})]}),it.reactions.length>0&&e.jsx(gtt,{reactions:it.reactions,children:e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex -space-x-1",children:Object.entries(Ze(it.reactions)).slice(0,3).map(([Ms])=>{var cs;return e.jsx("span",{className:"text-base",children:(cs=Fz.find(er=>er.type===Ms))==null?void 0:cs.emoji},Ms)})}),e.jsx("span",{children:it.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Je(it.reactions)?e.jsx("span",{className:"mr-1",children:(Dt=Fz.find(Ms=>Ms.type===Je(it.reactions)))==null?void 0:Dt.emoji}):e.jsx(nh,{className:"h-4 w-4 mr-1"}),Je(it.reactions)?(Vt=Fz.find(Ms=>Ms.type===Je(it.reactions)))==null?void 0:Vt.label:"Like"]})}),e.jsx(Ro,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:Fz.map(Ms=>e.jsx("button",{onClick:()=>Ae.mutate({postId:it.id,reactionType:Ms.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:Ms.label,children:Ms.emoji},Ms.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Q(Ms=>{const cs=new Set(Ms);return cs.has(it.id)?cs.delete(it.id):cs.add(it.id),cs}),children:[e.jsx(qc,{className:"h-4 w-4 mr-1"}),(()=>{const Ms=Ge(it.comments);return Ms>0?`Comment (${Ms})`:"Comment"})()]})]}),ee.has(it.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[it.comments.map(Ms=>e.jsx(ytt,{comment:Ms,postId:it.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:et(it)},Ms.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:a||void 0}),e.jsx(Sn,{className:"text-xs",children:Ue(((hs=t.email)==null?void 0:hs.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Qle,{placeholder:"Write a comment... (use @ to mention)",value:ce[it.id]||"",onChange:Ms=>ne(cs=>({...cs,[it.id]:Ms})),onMentionsChange:Ms=>oe(cs=>({...cs,[it.id]:Ms})),mentionFormat:"plain",onKeyDown:Ms=>{var cs;Ms.defaultPrevented||Ms.key==="Enter"&&!Ms.shiftKey&&((cs=ce[it.id])!=null&&cs.trim())&&(Ms.preventDefault(),rt.mutate({postId:it.id,content:ce[it.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var Ms;(Ms=ce[it.id])!=null&&Ms.trim()&&rt.mutate({postId:it.id,content:ce[it.id]})},disabled:!((As=ce[it.id])!=null&&As.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx($n,{className:"h-4 w-4"})})]})]})]})]})},it.id)}),Le&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>Qe(),disabled:Te,children:Te?"Loading…":"Load more posts"})})]}),e.jsx(xs,{open:!!B,onOpenChange:()=>V(null),children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Edit Post"})}),e.jsx(Pr,{value:X,onChange:it=>Y(it.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{B&&qe.mutate({postId:B.id,content:X})},disabled:!X.trim(),children:"Save Changes"})]})]})}),e.jsx(eVt,{images:_e.images,initialIndex:_e.index,open:_e.open,onOpenChange:it=>$e(Dt=>({...Dt,open:it}))})]})]})})},O5={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:qc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:gi,color:"bg-green-500"},closed:{label:"Closed",icon:jc,color:"bg-muted-foreground"}},M8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function nVt(){const{user:t}=Os(),s=Xt(),[r,n]=N.useState(null),[a,o]=N.useState(""),{data:l=[],isLoading:i}=mt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:g}=await H.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(g)throw g;return f},enabled:!!t}),{data:c=[]}=mt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:g}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(g)throw g;return f},enabled:!!r}),u=Lt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:g}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(g)throw g},onSuccess:()=>{s.invalidateQueries({queryKey:["ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=O5[r.status].icon;return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",children:M8e[r.category]}),e.jsxs(st,{className:O5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),O5[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ki,{className:"h-[300px] pr-4",children:c.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:c.map(g=>{var v;return e.jsxs("div",{className:`p-4 rounded-lg ${g.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:g.is_admin_reply?"Support Team":((v=g.profiles)==null?void 0:v.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(g.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:g.content})]},g.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(al,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Type your reply...",value:a,onChange:g=>o(g.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx($n,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(Bv,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Need Help?"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Submit a support ticket and our team will get back to you as soon as possible."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(S1e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(qs,{className:"h-5 w-5"}),"Submit a Ticket"]})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Or text us: ",e.jsx("span",{className:"font-semibold text-foreground",children:"1-866-527-8668"})]})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Your Tickets"}),e.jsx(S1e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(qc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):e.jsx("div",{className:"space-y-3",children:l.map(f=>{const g=O5[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-xs",children:M8e[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(st,{className:O5[f.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),O5[f.status].label]})]})})},f.id)})})]})})}function aVt({open:t,onOpenChange:s}){return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule Agent Onboarding"}),e.jsx(Wr,{children:"Book a one-on-one onboarding session with LevelUp"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/new-agent-onboarding",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Agent Onboarding"})]})})}function iVt({open:t,onOpenChange:s}){const{brokerageId:r}=Os(),[n,a]=N.useState(""),[o,l]=N.useState([]),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(j)throw j;return w},enabled:t&&!!r}),f=u==null?void 0:u.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),g=w=>{l(j=>j.includes(w)?j.filter(k=>k!==w):[...j,w])},v=async()=>{if(o.length===0){me.error("Please select at least one agent");return}c(!0);try{const{data:w,error:j}=await H.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(j)throw j;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),me.error(w.message||"Failed to send onboarding link")}finally{c(!1)}},_=w=>{w||(l([]),a("")),s(w)};return e.jsx(xs,{open:t,onOpenChange:_,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx($n,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Send Onboarding Link"}),e.jsx(Wr,{children:"Select agents to receive the onboarding booking link"})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Ki,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>g(w.id),children:[e.jsx(Oo,{checked:o.includes(w.id),onCheckedChange:()=>g(w.id)}),e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{className:"text-xs",children:w.name.split(" ").map(j=>j[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:v,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function oVt(){const[t,s]=N.useState(!1),[r,n]=N.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(hr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Agent Onboarding"}),e.jsx(gr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(aVt,{open:t,onOpenChange:s}),e.jsx(iVt,{open:r,onOpenChange:n})]})}function lVt({open:t,onOpenChange:s}){return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(js,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(v0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(_s,{children:"Schedule Launch Meeting"}),e.jsx(Wr,{children:"Book a private LevelUp information session for your brokerage"})]})]})}),t&&e.jsx("iframe",{src:"https://tidycal.com/jeremycollins/levelup-launch-call",className:"w-full border-0 rounded-lg",style:{height:"600px",minHeight:"500px"},title:"Schedule Launch Meeting"})]})})}function cVt(){const[t,s]=N.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(v0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Launch or ReLaunch Meeting"}),e.jsx(gr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(v0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(lVt,{open:t,onOpenChange:s})]})}function dVt(){const t=nr(),[s,r]=N.useState(""),[n,a]=N.useState(null),{data:o,isLoading:l}=mt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return w}}),{data:i}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(j)throw j;return w}}),{data:c}=mt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_pdfs").select("resource_id");if(j)throw j;return w}}),{data:u}=mt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_videos").select("resource_id");if(j)throw j;return w}}),{data:p}=mt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:j}=await H.from("brokerage_resource_links").select("resource_id");if(j)throw j;return w}}),f=o==null?void 0:o.filter(w=>{var S;const j=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),k=!n||w.category_id===n;return j&&k}),g=i==null?void 0:i.filter(w=>o==null?void 0:o.some(j=>j.category_id===w.id)),v=w=>{const j=(c==null?void 0:c.filter(M=>M.resource_id===w).length)||0,k=(u==null?void 0:u.filter(M=>M.resource_id===w).length)||0,S=(p==null?void 0:p.filter(M=>M.resource_id===w).length)||0;return{pdfCount:j,videoCount:k,linkCount:S}},_=w=>{t(`/brokerage-resources/${w}`)};return e.jsx(Ts,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(oVt,{}),e.jsx(cVt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),g&&g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(st,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),g.map(w=>e.jsx(st,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,j)=>e.jsxs(Ee,{children:[e.jsx(vs,{className:"h-40 w-full"}),e.jsx(Pt,{children:e.jsx(vs,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(vs,{className:"h-4 w-full mb-2"}),e.jsx(vs,{className:"h-4 w-2/3"})]})]},j))}):(f==null?void 0:f.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(th,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(w=>{const{pdfCount:j,videoCount:k,linkCount:S}=v(w.id),M=i==null?void 0:i.find(L=>L.id===w.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>_(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Rt,{className:"text-lg line-clamp-1",children:w.title}),M&&e.jsx(st,{variant:"secondary",className:"shrink-0 text-xs",children:M.name})]})}),e.jsxs(Oe,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[j>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),j]}),k>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-4 w-4"}),k]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const uVt=()=>{const{resourceId:t}=lo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await H.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await H.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await H.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:c}=await H.from("brokerage_resource_links").select("*").eq("resource_id",t).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:c||[]}},enabled:!!t}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return r?e.jsx(Ts,{title:"Brokerage Resources",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):s?e.jsx(Ts,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/brokerage-resources",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Resources"]})}),s.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),s.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:s.description}})]}),s.videos&&s.videos.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(wn,{className:"h-4 w-4"}),"Documents (",s.pdfs.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.pdfs.map(a=>e.jsxs("a",{href:a.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(wn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(en,{className:"h-4 w-4"}),"Canva Templates (",s.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.links.map(a=>e.jsxs("a",{href:a.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(en,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(en,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Ts,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(th,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Resource not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource may have been removed or is not available."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function hVt(){const{onlineUsers:t,totalOnline:s}=sQe();return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(st,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(wd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Ki,{className:"h-[300px] pr-4",children:e.jsx("div",{className:"space-y-3",children:t.map(r=>{var n;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsxs(kn,{className:"h-9 w-9",children:[e.jsx(Ua,{src:r.avatarUrl,alt:r.name}),e.jsx(Sn,{className:"text-xs",children:(n=r.name)==null?void 0:n.split(" ").map(a=>a[0]).join("").slice(0,2).toUpperCase()})]}),e.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full bg-green-500 ring-2 ring-background"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Online ",Vc(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const T8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:hr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:GL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Mx,path:"/admin/subscriptions",color:"bg-gradient-to-br from-green-500/20 to-green-500/10 text-green-600"},{title:"Credit Management",description:"View and manage ReelFlow, Postcard, Letter & Check credits for all agents",icon:pL,path:"/admin/credits",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"},{title:"Subscription Discounts",description:"Create and manage coupon codes",icon:Fm,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:nd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:hr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:zm,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Recruiting",description:"Manage agent recruit pipeline and outreach",icon:El,path:"/admin/recruiting",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:Bl,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Zh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:sy,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:fn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:fn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:m1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Od,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:th,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:th,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:lr,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"},{title:"Mass Email Templates",description:"Create and manage shared campaign templates",icon:Ph,path:"/admin/email-campaigns/templates",color:"bg-teal-500/10 text-teal-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:cS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:ix,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:lr,path:"/admin/email-templates",color:"bg-sky-500/10 text-sky-600"},{title:"The LevelUp Brief",description:"Create popup briefs with videos, links, and polls",icon:Ph,path:"/admin/levelup-brief",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"},{title:"Onboarding Checklist",description:"Manage getting started tasks for new users",icon:OM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:b0,path:"/admin/marketplace",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Reward Store",description:"Manage reward items agents can redeem with points",icon:So,path:"/admin/reward-store",color:"bg-purple-500/10 text-purple-600"},{title:"Agent Points",description:"View agent points, leaderboard, and award bonus points",icon:vo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:ml,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:hr,path:"/admin/agent-cards",color:"bg-gradient-to-br from-violet-500/20 to-purple-500/10 text-violet-600"},{title:"Notification Settings",description:"Test and manage push notifications",icon:Ph,path:"/admin/notification-settings",color:"bg-rose-500/10 text-rose-600"}]},community:{label:"Community & Support",sections:[{title:"Community Management",description:"Manage categories and private groups",icon:so,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:VM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:Z_,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Jn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:lr,path:"/admin/weekly-digest",color:"bg-indigo-500/10 text-indigo-600"}]},insights:{label:"Insights",sections:[{title:"Analytics",description:"View activity logs and platform statistics",icon:yo,path:"/admin/analytics",color:"bg-emerald-500/10 text-emerald-600"},{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for agents",icon:Th,path:"/admin/brokerage-content-activity",color:"bg-sky-500/10 text-sky-600"}]},lms:{label:"LevelUp U",sections:[{title:"Manage Courses",description:"Create and manage LMS training courses, modules, and access",icon:Zh,path:"/admin/lms",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"}]},"agent-os":{label:"Agent OS",sections:[{title:"Agent OS Control Center",description:"Manage InnerCircle feature: relationship types, action types, scripts, plans & feature flags",icon:Ya,path:"/admin/agent-os",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Listing Exchange",description:"Approve, feature, and moderate community listings",icon:dn,path:"/admin/listing-exchange",color:"bg-gradient-to-br from-blue-500/20 to-sky-500/10 text-blue-600"},{title:"Presentation Analytics",description:"Track agent presentation usage, views, and leads",icon:ty,path:"/admin/presentation-analytics",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"},{title:"Guest Book Analytics",description:"Track open house sign-in usage, visitors, and lead generation",icon:Th,path:"/admin/guest-book-analytics",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"}]},beta:{label:"🧪 Beta Lab",sections:[{title:"Social Post Generator",description:"Auto-generate branded social media posts from MLS listing data",icon:vl,path:"/admin/beta/social-post-generator",color:"bg-gradient-to-br from-fuchsia-500/20 to-pink-500/10 text-fuchsia-600"},{title:"Postcard Direct Mail",description:"Upload monthly postcard designs and manage agent direct mail via Postalytics",icon:lr,path:"/admin/beta/postcard-manager",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"ReelFlow",description:"Turn property photos into cinematic video reels for social media",icon:W_,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]},"lead-sites":{label:"Lead Sites",sections:[{title:"All Sites",description:"Overview of all agent websites with status and quick actions",icon:ru,path:"/admin/lead-sites",color:"bg-gradient-to-br from-sky-500/20 to-blue-500/10 text-sky-600"},{title:"MLS Feeds",description:"Manage MLS data feed connections, API keys, and coverage areas",icon:fL,path:"/admin/mls-feeds",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"},{title:"Lead Analytics",description:"Cross-site lead capture stats, conversions, and top-performing sites",icon:Jo,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"},{title:"Website Interests",description:"Track interest form submissions from TheLocalMove.com",icon:wn,path:"/admin/website-interests",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"MLS Fee Tracker",description:"Track MLS providers, setup fees, and monthly costs",icon:hl,path:"/admin/mls-fee-tracker",color:"bg-gradient-to-br from-teal-500/20 to-cyan-500/10 text-teal-600"}]}};function A8e(){const t=nr();return console.log("[AdminDashboard] render"),e.jsx(Ts,{title:"Admin Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Admin Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage all aspects of your platform"})]}),e.jsx("div",{className:"w-full lg:w-80",children:e.jsx(hVt,{})})]}),e.jsxs(_a,{defaultValue:"users",className:"w-full",children:[e.jsx(fa,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(T8e).map(([s,r])=>e.jsx(ns,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(T8e).map(([s,r])=>e.jsx(ws,{value:s,className:"mt-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.sections.map(n=>e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${n.color} mb-2 group-hover:scale-110 transition-transform`,children:e.jsx(n.icon,{className:"h-5 w-5"})}),e.jsx(Rt,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(gr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Fn=N.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:It("w-full caption-bottom text-sm",t),...s})}));Fn.displayName="Table";const zn=N.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:It("[&_tr]:border-b",t),...s}));zn.displayName="TableHeader";const Bn=N.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:It("[&_tr:last-child]:border-0",t),...s}));Bn.displayName="TableBody";const mVt=N.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:It("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));mVt.displayName="TableFooter";const Cs=N.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:It("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Cs.displayName="TableRow";const St=N.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:It("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));St.displayName="TableHead";const dt=N.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:It("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const pVt=N.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:It("mt-4 text-sm text-muted-foreground",t),...s}));pVt.displayName="TableCaption";const fVt=()=>{const{isAdmin:t}=Os(),s=nr(),[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(!1),[c,u]=N.useState(null);N.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:w,error:j}=await H.from("app_tiles").select("*").order("name");if(j)throw j;n(w||[])}catch(w){console.error("Error loading apps:",w),me.error("Failed to load apps")}finally{o(!1)}},f=async w=>{w.preventDefault();const j=new FormData(w.currentTarget),k={name:j.get("name"),description:j.get("description"),icon:j.get("icon"),app_id:j.get("app_id"),target_url:j.get("target_url"),required_tags:j.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(c){const{error:S}=await H.from("app_tiles").update(k).eq("id",c.id);if(S)throw S;me.success("App updated successfully")}else{const{error:S}=await H.from("app_tiles").insert([k]);if(S)throw S;me.success("App created successfully")}i(!1),u(null),p()}catch(S){console.error("Error saving app:",S),me.error("Failed to save app")}},g=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:j}=await H.from("app_tiles").delete().eq("id",w);if(j)throw j;me.success("App deleted successfully"),p()}catch(j){console.error("Error deleting app:",j),me.error("Failed to delete app")}},v=w=>{u(w),i(!0)},_=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Manage Apps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and configure application tiles"})]})]}),e.jsxs(xs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:_,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsx(_s,{children:c?"Edit App":"Create New App"}),e.jsx(Wr,{children:"Configure the application tile settings"})]}),e.jsxs("form",{onSubmit:f,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"App Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:c==null?void 0:c.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"app_id",children:"App ID"}),e.jsx(ze,{id:"app_id",name:"app_id",defaultValue:c==null?void 0:c.app_id,placeholder:"agent_connect",required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",name:"description",defaultValue:c==null?void 0:c.description})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:c==null?void 0:c.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"target_url",children:"Target URL"}),e.jsx(ze,{id:"target_url",name:"target_url",type:"url",defaultValue:c==null?void 0:c.target_url,required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(ze,{id:"required_tags",name:"required_tags",defaultValue:c==null?void 0:c.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{type:"submit",children:c?"Update":"Create"})]})]})]})]})]})})}),e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Application Tiles"}),e.jsx(gr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:_,children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"App ID"}),e.jsx(St,{children:"Target URL"}),e.jsx(St,{children:"Tags"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:r.map(w=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"text-2xl",children:w.icon}),e.jsx(dt,{className:"font-medium",children:w.name}),e.jsx(dt,{className:"font-mono text-sm",children:w.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(j=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:j},j))})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(w),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>g(w.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function ch({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(pa,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Admin Dashboard"]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t}),s&&e.jsx("p",{className:"text-muted-foreground",children:s})]}),r]})]})}const E8e=({expiresAt:t,className:s})=>{const r=new Date().getTime(),n=new Date(t).getTime(),a=Math.ceil((n-r)/(1e3*60*60*24));return a<=0?e.jsxs(st,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(Yu,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(st,{variant:"destructive",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(st,{className:It("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(st,{variant:"secondary",className:It("gap-1",s),children:[e.jsx(un,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},vtt=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ha(),l=N.useRef(null),[i,c]=N.useState([]),[u,p]=N.useState(""),[f,g]=N.useState(!1),[v,_]=N.useState("upload"),[w,j]=N.useState(null),k=()=>{c([]),p(""),_("upload"),j(null),l.current&&(l.current.value="")},S=()=>{k(),s(!1)},M=U=>{const B=U.split(` `).map(Q=>Q.trim()).filter(Q=>Q);if(B.length===0)return[];const V=B[0].toLowerCase(),Y=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?B.slice(1):B,ee=[];for(const Q of Y){const ne=(Q.includes(" ")?Q.split(" "):Q.split(",")).map(re=>re.trim().replace(/^["']|["']$/g,""));if(ne.length>=2){let re="",oe="",fe="",ge="",ue;if(ne.length===2){const $e=ne[0].split(" ");re=$e[0]||"",oe=$e.slice(1).join(" ")||"",fe=ne[1]}else if(ne.length===3)re=ne[0],oe=ne[1],fe=ne[2];else if(ne.length===4)re=ne[0],oe=ne[1],fe=ne[2],ge=ne[3];else if(ne.length>=5){re=ne[0],oe=ne[1],fe=ne[2],ge=ne[3];const $e=ne[4].toLowerCase();ue=$e==="true"||$e==="yes"||$e==="1"||$e==="y"}const _e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(fe);ee.push({firstName:re.trim(),lastName:oe.trim(),email:fe.trim().toLowerCase(),phone:ge.trim()||void 0,smsConsent:ue,isValid:_e&&re.trim().length>0,error:_e?re.trim()?void 0:"Missing name":"Invalid email"})}}return ee},L=U=>{var X;const B=(X=U.target.files)==null?void 0:X[0];if(!B)return;const V=new FileReader;V.onload=Y=>{var ce;const ee=(ce=Y.target)==null?void 0:ce.result,Q=M(ee);if(Q.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}c(Q),_("preview")},V.readAsText(B)},P=async()=>{const U=i.filter(V=>V.isValid);if(U.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const B=n||u||null;g(!0);try{const{data:{session:V}}=await H.auth.getSession(),X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:U.map(ee=>({firstName:ee.firstName,lastName:ee.lastName,email:ee.email,phone:ee.phone,smsConsent:ee.smsConsent})),brokerageId:B})}),Y=await X.json();if(!X.ok)throw new Error(Y.error||"Failed to import users");j(Y),_("result"),Y.created>0&&a(),o({title:"Import Complete",description:`${Y.created} user(s) created successfully.${Y.failed>0?` ${Y.failed} failed.`:""}`})}catch(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{g(!1)}},O=i.filter(U=>U.isValid).length,$=i.filter(U=>!U.isValid).length;return e.jsx(xs,{open:t,onOpenChange:S,children:e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(c1,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Wr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),v==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:L,className:"hidden"}),e.jsx(di,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var U;return(U=l.current)==null?void 0:U.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),v==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Assign to Brokerage (optional)"}),e.jsxs(Ks,{value:u||"none",onValueChange:U=>p(U==="none"?"":U),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a brokerage..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No brokerage"}),r.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[O," valid"]})]}),$>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Cl,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"SMS"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Bn,{children:i.slice(0,100).map((U,B)=>e.jsxs(Cs,{children:[e.jsx(dt,{children:U.firstName}),e.jsx(dt,{children:U.lastName}),e.jsx(dt,{children:U.email}),e.jsx(dt,{className:"text-muted-foreground",children:U.phone||"-"}),e.jsx(dt,{className:"text-muted-foreground",children:U.smsConsent===!0?"✓":U.smsConsent===!1?"✗":"-"}),e.jsx(dt,{children:U.isValid?e.jsx(st,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(st,{variant:"destructive",children:U.error||"Invalid"})})]},B))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),v==="result"&&w&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((U,B)=>e.jsxs("li",{children:["• ",U]},B)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(Un,{children:[v==="upload"&&e.jsx(K,{variant:"outline",onClick:S,children:"Cancel"}),v==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:k,children:"Back"}),e.jsx(K,{onClick:P,disabled:f||O===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${O} Agent${O!==1?"s":""}`})]}),v==="result"&&e.jsx(K,{onClick:S,children:"Done"})]})]})})};function bl({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(St,{className:It("cursor-pointer select-none",o),...l,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 font-semibold hover:text-foreground transition-colors w-full text-left",onClick:()=>n(t),children:[a,i?r==="asc"?e.jsx(Su,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Kh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(_d,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function lR(t=null,s=null){const[r,n]=N.useState(t),[a,o]=N.useState(s),l=N.useCallback(c=>{r===c?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(c),o("asc"))},[r,a]),i=N.useCallback((c,u)=>{if(!r||!a||!u[r])return c;const p=u[r];return[...c].sort((f,g)=>{const v=p(f),_=p(g);if(v==null&&_==null)return 0;if(v==null)return 1;if(_==null)return-1;let w;return typeof v=="string"&&typeof _=="string"?w=v.localeCompare(_,void 0,{sensitivity:"base"}):w=v-_,a==="asc"?w:-w})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const xVt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Jn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:vo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:nu}];function btt({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=N.useState("custom"),[l,i]=N.useState(""),[c,u]=N.useState(""),p=SNt(),f=v=>{o(v.type),i(v.title),u(v.message)},g=async v=>{if(v.preventDefault(),!l.trim()){jn({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:r,celebration_type:a,title:l.trim(),message:c.trim()||void 0}),jn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{jn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(nu,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Wr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(be,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:xVt.map((v,_)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(v),className:"text-xs",children:[e.jsx(v.icon,{className:"h-3 w-3 mr-1"}),v.title]},_))})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Ks,{value:a,onValueChange:v=>o(v),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(Mt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(Mt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(Mt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hl,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l,onChange:v=>i(v.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Pr,{id:"message",value:c,onChange:v=>u(v.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(nu,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Hge={points_earned:{label:"Points Earned",icon:vo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:dn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:hl,color:"bg-green-500"},custom:{label:"Custom",icon:fn,color:"bg-purple-500"}};function gVt(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState("all"),{data:l=[],isLoading:i}=mt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await H.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const g=[...new Set([...p.map(w=>w.user_id),...p.map(w=>w.created_by).filter(Boolean)])],{data:v}=await H.from("profiles").select("id, name, email").in("id",g),_=new Map((v==null?void 0:v.map(w=>[w.id,w]))||[]);return p.map(w=>{var j,k,S;return{...w,user_name:((j=_.get(w.user_id))==null?void 0:j.name)||"Unknown",user_email:((k=_.get(w.user_id))==null?void 0:k.email)||"",creator_name:w.created_by?((S=_.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),c=l.filter(p=>{var _,w;const f=((_=p.user_name)==null?void 0:_.toLowerCase().includes(t.toLowerCase()))||((w=p.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),g=r==="all"||p.celebration_type===r,v=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&g&&v}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Hge).reduce((p,f)=>(p[f]=l.filter(g=>g.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(nu,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(gr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),Object.entries(Hge).map(([p,f])=>e.jsx(Mt,{value:p,children:f.label},p))]})]}),e.jsxs(Ks,{value:a,onValueChange:o,children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Ys,{placeholder:"Status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"seen",children:"Seen"}),e.jsx(Mt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Points"}),e.jsx(St,{children:"Created By"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Bn,{children:c.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(p=>{const f=Hge[p.celebration_type],g=f.icon;return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(g,{className:"h-3 w-3"}),f.label]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.user_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:p.title}),p.message&&e.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),e.jsx(dt,{children:p.points_amount?e.jsxs(st,{variant:"secondary",children:["+",p.points_amount]}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(st,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(st,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),c.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",c.length," of ",l.length," celebrations"]})]})]})]})}const yVt=()=>{const{user:t}=Os(),{toast:s}=Ha(),[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(!1),[c,u]=N.useState("all"),[p,f]=N.useState("all"),[g,v]=N.useState("new"),[_,w]=N.useState(new Set),j=N.useCallback(async()=>{try{o(!0);const{data:ee,error:Q}=await H.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(Q)throw Q;const{data:ce,error:ne}=await H.from("trial_email_exports").select("user_id");if(ne)throw ne;const re=new Set((ce||[]).map(fe=>fe.user_id)),oe=(ee||[]).map(fe=>({...fe,converted_from_trial_at:fe.converted_from_trial_at??null,already_exported:re.has(fe.id)}));oe.sort((fe,ge)=>new Date(ge.created_at).getTime()-new Date(fe.created_at).getTime()),n(oe)}catch(ee){console.error("Error loading trial users:",ee),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);N.useEffect(()=>{j()},[j]);const k=ee=>ee.trial_started_at?"ghl":"stripe",S=ee=>ee.trial_expires_at?ee.trial_expires_at:ee.subscription_end_date?ee.subscription_end_date:null,M=ee=>ee.converted_from_trial_at!==null,L=ee=>{if(M(ee))return!1;const Q=S(ee);return Q?new Date(Q).getTime()<=Date.now():!1},P=r.filter(ee=>!(c!=="all"&&k(ee)!==c||p==="active"&&(L(ee)||M(ee))||p==="expired"&&!L(ee)||p==="converted"&&!M(ee)||g==="new"&&ee.already_exported||g==="exported"&&!ee.already_exported)),O=()=>{_.size===P.length?w(new Set):w(new Set(P.map(ee=>ee.id)))},$=ee=>{const Q=new Set(_);Q.has(ee)?Q.delete(ee):Q.add(ee),w(Q)},U=async()=>{if(_.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const ee=r.filter(ue=>_.has(ue.id)),Q="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=ee.map(ue=>{const xe=(ue.name||"").split(" "),_e=xe[0]||"",$e=xe.slice(1).join(" ")||"",Me=k(ue)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ie=M(ue)?"Converted":L(ue)?"Expired":"Active",ke=ue.created_at?new Date(ue.created_at).toLocaleDateString():"",pe=S(ue)?new Date(S(ue)).toLocaleDateString():"";return`"${_e}","${$e}","${ue.email}","${ue.phone||""}","${Me}","${Ie}","${ke}","${pe}"`}),ne=[Q,...ce].join(` `),re=new Blob([ne],{type:"text/csv"}),oe=URL.createObjectURL(re),fe=document.createElement("a");fe.href=oe,fe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,fe.click(),URL.revokeObjectURL(oe);const ge=ee.filter(ue=>!ue.already_exported).map(ue=>({user_id:ue.id,exported_by:t.id}));if(ge.length>0){const{error:ue}=await H.from("trial_email_exports").upsert(ge,{onConflict:"user_id"});ue&&console.error("Error marking exports:",ue)}s({title:"Export complete",description:`Downloaded ${ee.length} trial user(s). ${ge.length} newly marked as exported.`}),w(new Set),j()}catch(ee){console.error("Export error:",ee),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},B=r.filter(ee=>!ee.already_exported).length,V=r.filter(ee=>ee.already_exported).length,X=r.filter(ee=>M(ee)).length,Y=r.filter(ee=>!L(ee)&&!M(ee)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total"}),e.jsx(Rt,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"New (Not Exported)"}),e.jsx(Rt,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Active Trials"}),e.jsx(Rt,{className:"text-2xl",children:Y})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Converted 🎉"}),e.jsx(Rt,{className:"text-2xl text-primary",children:X})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Already Exported"}),e.jsx(Rt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Ks,{value:g,onValueChange:ee=>v(ee),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"new",children:"New Only"}),e.jsx(Mt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(Ks,{value:c,onValueChange:ee=>u(ee),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Trial Types"}),e.jsx(Mt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(Mt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(Ks,{value:p,onValueChange:ee=>f(ee),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"active",children:"Active Trial"}),e.jsx(Mt,{value:"expired",children:"Expired"}),e.jsx(Mt,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(K,{onClick:U,disabled:l||_.size===0,children:[l?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export Selected (",_.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:P.length>0&&_.size===P.length,onCheckedChange:O})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Trial Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Expires / Renews"}),e.jsx(St,{children:"Exported"})]})}),e.jsx(Bn,{children:P.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):P.map(ee=>{const Q=k(ee),ce=M(ee),ne=L(ee),re=S(ee);return e.jsxs(Cs,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:_.has(ee.id),onCheckedChange:()=>$(ee.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.name,ce&&e.jsx(Jo,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(dt,{className:"text-muted-foreground",children:ee.email}),e.jsx(dt,{children:Q==="stripe"?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Mx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(lr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:ce?e.jsxs(st,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Jo,{className:"h-3 w-3"}),"Converted"]}):ne?e.jsx(st,{variant:"destructive",children:"Expired"}):e.jsx(st,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:ee.created_at?new Date(ee.created_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-sm",children:ce&&re?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(re).toLocaleDateString()]}):re?new Date(re).toLocaleDateString():"—"}),e.jsx(dt,{children:ee.already_exported?e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(st,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},ee.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",P.length," of ",r.length," trial users · ",X," converted to paid"]})]})},vVt=()=>{const[t,s]=N.useState([]),[r,n]=N.useState(!0);return N.useEffect(()=>{(async()=>{const{data:o,error:l}=await H.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Nr,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:"No deletion records yet"})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"User"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Deleted By"})]})}),e.jsx(Bn,{children:t.map(a=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:ms(new Date(a.created_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"font-medium",children:a.deleted_user_name||"—"}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),e.jsx(dt,{children:a.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx(st,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),e.jsx(dt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},M3=t=>{const{user:s}=Os(),r=Xt(),n=mt({queryKey:["teams",t],queryFn:async()=>{let f=H.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:g,error:v}=await f;if(v)throw v;return g||[]},enabled:!!s}),a=f=>mt({queryKey:["team-members",f],queryFn:async()=>{const{data:g,error:v}=await H.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(v)throw v;const _=(g||[]).map(k=>k.user_id),{data:w}=await H.from("profiles").select("id, name, email, avatar_url").in("id",_),j=new Map((w||[]).map(k=>[k.id,k]));return(g||[]).map(k=>({...k,profile:j.get(k.user_id)||null}))},enabled:!!f}),o=Lt({mutationFn:async f=>{const g={name:f.name,created_by:s.id,description:f.description,contact_visibility:f.contact_visibility,lead_pond_enabled:f.lead_pond_enabled,shared_assets_enabled:f.shared_assets_enabled};f.brokerage_id&&(g.brokerage_id=f.brokerage_id);const{data:v,error:_}=await H.from("teams").insert(g).select().single();if(_)throw _;return v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team created!")},onError:f=>{me.error("Failed to create team: "+f.message)}}),l=Lt({mutationFn:async({id:f,...g})=>{const{data:v,error:_}=await H.from("teams").update(g).eq("id",f).select().single();if(_)throw _;return v},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team updated")},onError:f=>{me.error("Failed to update team: "+f.message)}}),i=Lt({mutationFn:async f=>{const{error:g}=await H.from("teams").delete().eq("id",f);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),me.success("Team deleted")},onError:f=>{me.error("Failed to delete team: "+f.message)}}),c=Lt({mutationFn:async f=>{const{data:g,error:v}=await H.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(v)throw v.message.includes("duplicate")||v.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):v;return g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member added to team")},onError:f=>{me.error(f.message)}}),u=Lt({mutationFn:async f=>{const{error:g}=await H.from("team_members").delete().eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member removed from team")},onError:f=>{me.error("Failed to remove member: "+f.message)}}),p=Lt({mutationFn:async f=>{const{error:g}=await H.from("team_members").update({role:f.role}).eq("id",f.member_id);if(g)throw g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),me.success("Member role updated")},onError:f=>{me.error("Failed to update role: "+f.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:c,removeMember:u,updateMemberRole:p,useTeamMembers:a}},bVt=()=>{const{user:t}=Os();return mt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},_tt=t=>{const{user:s}=Os(),r=Xt(),n=mt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:c}=await H.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(c)throw c;if(!i||i.length===0)return[];const u=i.map(k=>k.contact_id),p=[...new Set(i.map(k=>k.added_by))],f=i.filter(k=>k.claimed_by).map(k=>k.claimed_by),g=[...new Set([...p,...f])],[v,_]=await Promise.all([H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),H.from("profiles").select("id, name, avatar_url").in("id",g)]),w=new Map((v.data||[]).map(k=>[k.id,k])),j=new Map((_.data||[]).map(k=>[k.id,k]));return i.map(k=>({...k,status:k.claimed_by?"claimed":"available",contact:w.get(k.contact_id)||null,contributor:j.get(k.added_by)||null,claimer:k.claimed_by&&j.get(k.claimed_by)||null}))},enabled:!!t&&!!s}),a=Lt({mutationFn:async i=>{const{data:c,error:u}=await H.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Contact added to Lead Pond")},onError:i=>{me.error(i.message)}}),o=Lt({mutationFn:async i=>{const{error:c}=await H.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead claimed!")},onError:i=>{me.error(i.message)}}),l=Lt({mutationFn:async i=>{const{error:c}=await H.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(c)throw c},onSuccess:()=>{r.invalidateQueries({queryKey:["lead-pond"]}),me.success("Lead returned to pond")},onError:i=>{me.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},_Vt=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),me.success("Contact transferred successfully")},onError:s=>{me.error(s.message||"Failed to transfer contact")}})};function wtt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var P;const{user:o}=Os(),{data:l}=Ux(),{useTeamMembers:i}=M3(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=_Vt(),[p,f]=N.useState(null),[g,v]=N.useState(""),[_,w]=N.useState(!1),j=c.filter(O=>O.user_id!==(o==null?void 0:o.id)),k=async()=>{if(p){w(!0);try{for(const O of r)await u.mutateAsync({contactId:O,toUserId:p,notes:g||void 0});s(!1),f(null),v(""),a==null||a()}catch{}finally{w(!1)}}},S=j.find(O=>O.user_id===p),M=r.length>1,L=n.length>0?M?`${n.length} contacts`:n[0]:M?`${r.length} contacts`:"this contact";return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(a1,{className:"h-5 w-5"}),"Transfer ",L]}),e.jsxs(Wr,{children:["Select a team member to transfer ",M?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):j.map(O=>{var $,U,B;return e.jsxs("button",{onClick:()=>f(O.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===O.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:(($=O.profile)==null?void 0:$.avatar_url)||""}),e.jsx(Sn,{className:"text-xs",children:(((U=O.profile)==null?void 0:U.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((B=O.profile)==null?void 0:B.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:O.role.replace("_"," ")})]})]},O.user_id)})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Pr,{id:"transfer-notes",value:g,onChange:O=>v(O.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:k,disabled:!p||_,children:[_?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(a1,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(P=S.profile)==null?void 0:P.name}`:""]})]})]})})}const Kke=()=>{const t=nr(),{data:s,isLoading:r}=bVt(),{data:n}=Ux(),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState(null),[p,f]=N.useState(""),g=(n==null?void 0:n.role)==="team_leader",v=N.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(j=>{w.has(j.owner_user_id)||w.set(j.owner_user_id,{id:j.owner_user_id,name:j.owner_name||"Unknown",avatar:j.owner_avatar_url})}),Array.from(w.values())},[s]),_=N.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();w=w.filter(k=>{var S,M,L;return(k.first_name+" "+(k.last_name||"")).toLowerCase().includes(j)||((S=k.email)==null?void 0:S.toLowerCase().includes(j))||((M=k.phone)==null?void 0:M.includes(j))||((L=k.owner_name)==null?void 0:L.toLowerCase().includes(j))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{className:"h-10 w-full"}),e.jsx(vs,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team contact sharing is not enabled, or you're not on a team. Ask your manager about contact visibility settings."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Filter by agent"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Team Members"}),v.map(w=>e.jsx(Mt,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.length," contact",_.length!==1?"s":""," from ",v.length," teammate",v.length!==1?"s":""]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Fn,{className:"min-w-[800px]",children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Address"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Date Added"}),g&&e.jsx(St,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Bn,{children:_.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:g?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):_.map(w=>e.jsxs(Cs,{className:`hover:bg-accent/50 ${g?"cursor-pointer":""}`,onClick:g?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:g?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:w.owner_avatar_url||""}),e.jsx(Sn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(lr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Mn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(ia,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:w.lead_source?e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(w.created_at),"MMM d, yyyy")})}),g&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:j=>{j.stopPropagation(),u(w.id),f(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(a1,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(wtt,{open:!!c,onOpenChange:w=>{w||u(null)},contactIds:c?[c]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},Zke=({teamId:t})=>{const{user:s}=Os(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=_tt(t);if(console.log("[LeadPondView] render — teamId:",t,"itemCount:",r.length,"loading:",n),n)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(c=>e.jsx(vs,{className:"h-20 w-full"},c))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Jg,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team members can contribute contacts here for others to claim and follow up with."})]})});const l=r.filter(c=>c.status==="available"),i=r.filter(c=>c.status==="claimed");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):e.jsx("div",{className:"space-y-2",children:l.map(c=>{var u,p,f,g,v,_,w;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=c.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3"})," ",c.contact.email]}),((g=c.contact)==null?void 0:g.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(kn,{className:"h-4 w-4",children:[e.jsx(Ua,{src:((v=c.contributor)==null?void 0:v.avatar_url)||""}),e.jsx(Sn,{className:"text-[8px]",children:(((_=c.contributor)==null?void 0:_.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=c.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(vL,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},c.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>{var u,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(st,{variant:"secondary",className:"text-xs",children:["Claimed by ",((f=c.claimer)==null?void 0:f.name)||"Unknown"]})})]}),c.claimed_by===(s==null?void 0:s.id)&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>o.mutate(c.id),disabled:o.isPending,children:[e.jsx(g1,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},jtt=({teamId:t})=>{const{useTeamMembers:s}=M3(),{data:r=[]}=s(t),n=r.map(v=>v.user_id),a=new Map(r.map(v=>[v.user_id,v.profile])),{data:o=[],isLoading:l}=mt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:v,error:_}=await H.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(_)throw _;return v||[]},enabled:n.length>0}),{data:i=[],isLoading:c}=mt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:v,error:_}=await H.from("open_houses").select("id, agent_id, property_address, city, state, event_date, is_active, visitor_count, slug, created_at").in("agent_id",n).order("event_date",{ascending:!1});if(_)throw _;return v||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=mt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:v,error:_}=await H.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(_)throw _;return v||[]},enabled:n.length>0});if(l||c||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(v=>e.jsx(vs,{className:"h-20 w-full"},v))});const g=v=>{const _=a.get(v);return{name:(_==null?void 0:_.name)||"Unknown",avatar:(_==null?void 0:_.avatar_url)||"",initials:((_==null?void 0:_.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(ty,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(dn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Cn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:u.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),e.jsxs(_a,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(ns,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(ns,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(ws,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Gge,{icon:e.jsx(ty,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(v=>{const _=g(v.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(kn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ua,{src:_.avatar}),e.jsx(Sn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(v.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(st,{variant:v.status==="published"?"default":"secondary",className:"text-xs capitalize",children:v.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Dn,{className:"h-3 w-3"}),v.view_count||0]})]})]})},v.id)})}),e.jsx(ws,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Gge,{icon:e.jsx(dn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(v=>{const _=g(v.agent_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(kn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ua,{src:_.avatar}),e.jsx(Sn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(v.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[v.is_active?e.jsx(st,{className:"text-xs",children:"Active"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(hr,{className:"h-3 w-3"}),v.visitor_count||0]})]})]})},v.id)})}),e.jsx(ws,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Gge,{icon:e.jsx(Cn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(v=>{const _=g(v.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(kn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Ua,{src:_.avatar}),e.jsx(Sn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v.title||v.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ms(new Date(v.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(st,{variant:"secondary",className:"text-xs capitalize",children:v.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Dn,{className:"h-3 w-3"}),v.view_count||0]})]})]})},v.id)})})]})]})},Gge=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),Ntt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var $,U;const{useTeamMembers:p}=M3(),{data:f=[],isLoading:g}=p(t.id),[v,_]=N.useState(!1),[w,j]=N.useState(""),[k,S]=N.useState("team_member"),{data:M}=mt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:B}=await H.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(B||[]).forEach(X=>{var Y;V.set(X.user_id,((Y=X.teams)==null?void 0:Y.name)||"another team")}),V}}),L=new Set(f.map(B=>B.user_id)),P=s.filter(B=>!L.has(B.id)),O=async()=>{w&&(await a(w,k),j(""),S("team_member"),_(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(_a,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(aS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Jg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold",children:[t.name," — Members"]}),e.jsxs(xs,{open:v,onOpenChange:_,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(El,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add Team Member"}),e.jsxs(Wr,{children:["Select an agent from your brokerage to add to ",t.name,"."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Agent"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[w&&((($=P.find(B=>B.id===w))==null?void 0:$.name)||((U=P.find(B=>B.id===w))==null?void 0:U.email))||"Select an agent",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search agents..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:"No agents found."}),e.jsx($x,{children:P.map(B=>{const V=M==null?void 0:M.get(B.id);return e.jsxs(bp,{value:B.name||B.email||B.id,disabled:!!V,onSelect:()=>j(B.id),children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",w===B.id?"opacity-100":"opacity-0")}),B.name||B.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},B.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Role"}),e.jsxs(Ks,{value:k,onValueChange:S,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:O,disabled:!w||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),g?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx(vs,{className:"h-16 w-full"},B))}):f.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(B=>{var V,X,Y,ee,Q;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:((V=B.profile)==null?void 0:V.avatar_url)||""}),e.jsx(Sn,{children:(((X=B.profile)==null?void 0:X.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=B.profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(ee=B.profile)==null?void 0:ee.email})]}),B.role==="team_leader"?e.jsxs(st,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(st,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ks,{value:B.role,onValueChange:ce=>l(B.id,ce),children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(ZL,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Remove Member?"}),e.jsxs(ic,{children:["Remove ",((Q=B.profile)==null?void 0:Q.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>o(B.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},B.id)})})]}),e.jsx(ws,{value:"contacts",className:"space-y-4",children:e.jsx(Kke,{})}),t.lead_pond_enabled&&e.jsx(ws,{value:"lead-pond",className:"space-y-4",children:e.jsx(Zke,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(ws,{value:"shared-assets",className:"space-y-4",children:e.jsx(jtt,{teamId:t.id})}),e.jsxs(ws,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-lg",children:"Team Settings"}),e.jsx(gr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Team Name"}),e.jsx(ze,{defaultValue:t.name,onBlur:B=>{B.target.value!==t.name&&n({name:B.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{defaultValue:t.description||"",onBlur:B=>{B.target.value!==(t.description||"")&&n({description:B.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Contact Visibility"}),e.jsxs(Ks,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(Mt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(Mt,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Lead Pond"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),e.jsx(qr,{checked:t.lead_pond_enabled,onCheckedChange:B=>n({lead_pond_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Shared Assets"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),e.jsx(qr,{checked:t.shared_assets_enabled,onCheckedChange:B=>n({shared_assets_enabled:B})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Shared Video Library"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),e.jsx(qr,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(Nr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Team?"}),e.jsxs(ic,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},ktt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=N.useState(1),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState(""),[j,k]=N.useState(""),[S,M]=N.useState([]),L=()=>{u(1),f(""),v(""),w(""),k(""),M([])},P=B=>{B||L(),s(B)},O=async()=>{const B=_&&_!=="none"?_:i||null;await r({name:p.trim(),description:g.trim()||void 0,brokerage_id:B,leaderId:j||void 0,memberIds:S.length>0?S:void 0}),L()},$=B=>{B!==j&&M(V=>V.includes(B)?V.filter(X=>X!==B):[...V,B])},U=a.filter(B=>B.id!==j);return e.jsx(xs,{open:t,onOpenChange:P,children:e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsx(_s,{children:c===1?"Create New Team":"Assign Team Members"}),e.jsx(Wr,{children:c===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:It("h-1.5 flex-1 rounded-full transition-colors",c===2?"bg-primary":"bg-muted")})]})]}),e.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:c===1?e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(ze,{id:"team-name",value:p,onChange:B=>f(B.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"team-desc",children:"Description"}),e.jsx(Pr,{id:"team-desc",value:g,onChange:B=>v(B.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Brokerage"}),e.jsxs(Ks,{value:_,onValueChange:w,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No brokerage (independent)"}),l.map(B=>e.jsx(Mt,{value:B.id,children:B.name},B.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Dm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Ks,{value:j,onValueChange:B=>{k(B),M(V=>V.filter(X=>X!==B))},children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No leader for now"}),a.map(B=>e.jsx(Mt,{value:B.id,children:B.name||B.email||"Unknown"},B.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(El,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(st,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:U.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(hr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):U.map(B=>{const V=S.includes(B.id);return e.jsxs("button",{type:"button",className:It("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>$(B.id),children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:B.avatar_url||""}),e.jsx(Sn,{className:"text-xs",children:(B.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:B.email})]}),e.jsx("div",{className:It("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",V?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:V&&e.jsx(ba,{className:"h-3 w-3"})})]},B.id)})})]})]})}),e.jsx(Un,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Sa,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:O,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},wVt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=M3(),[c,u]=N.useState(!1),[p,f]=N.useState(null),[g,v]=N.useState(""),{data:_}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:P,error:O}=await H.from("brokerages").select("id, name").order("name");if(O)throw O;return P||[]}}),{data:w}=mt({queryKey:["admin-team-member-info",t.map(P=>P.id).join(",")],queryFn:async()=>{var B;if(t.length===0)return{};const{data:P}=await H.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!P)return{};const O=P.filter(V=>V.role==="team_leader").map(V=>V.user_id);let $={};if(O.length>0){const{data:V}=await H.from("profiles").select("id, name").in("id",O);V&&($=Object.fromEntries(V.map(X=>[X.id,{name:X.name}])))}const U={};for(const V of t){const X=P.filter(ee=>ee.team_id===V.id),Y=X.find(ee=>ee.role==="team_leader");U[V.id]={count:X.length,leaderName:Y&&((B=$[Y.user_id])==null?void 0:B.name)||null}}return U},enabled:t.length>0}),j=(p==null?void 0:p.brokerage_id)||null,{data:k}=mt({queryKey:["brokerage-agents-for-teams",j],queryFn:async()=>{let P=H.from("profiles").select("id, name, email, avatar_url").order("name");j&&(P=P.eq("brokerage_id",j));const{data:O,error:$}=await P;if($)throw $;return O||[]},enabled:!!p}),S=Object.fromEntries((_||[]).map(P=>[P.id,P.name])),M=async P=>{const O=await r.mutateAsync({name:P.name,brokerage_id:P.brokerage_id||null,description:P.description});if(P.leaderId&&P.leaderId!=="none"&&await o.mutateAsync({team_id:O.id,user_id:P.leaderId,role:"team_leader"}),P.memberIds)for(const $ of P.memberIds)await o.mutateAsync({team_id:O.id,user_id:$,role:"team_member"});u(!1)};if(p)return e.jsx(Ntt,{team:p,brokerageAgents:k||[],onBack:()=>f(null),onUpdate:P=>n.mutateAsync({id:p.id,...P}).then(O=>f(O)),onAddMember:(P,O)=>o.mutateAsync({team_id:p.id,user_id:P,role:O}),onRemoveMember:P=>l.mutateAsync({team_id:p.id,member_id:P}),onUpdateRole:(P,O)=>i.mutateAsync({team_id:p.id,member_id:P,role:O}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const L=t.filter(P=>P.name.toLowerCase().includes(g.toLowerCase())||(P.description||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search teams...",value:g,onChange:P=>v(P.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[L.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ktt,{open:c,onOpenChange:u,onCreateTeam:M,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:_,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Team Name"}),e.jsx(St,{className:"font-semibold",children:"Brokerage"}),e.jsx(St,{className:"font-semibold",children:"Leader"}),e.jsx(St,{className:"font-semibold",children:"Members"}),e.jsx(St,{className:"font-semibold",children:"Visibility"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(Bn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(P=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-32"})}),e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-24"})}),e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-28"})}),e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-12"})}),e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(dt,{children:e.jsx(vs,{className:"h-4 w-16"})})]},P))}):L.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:g?"No teams match your search":"No teams found. Create one to get started."})}):L.map(P=>{const O=w==null?void 0:w[P.id];return e.jsxs(Cs,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(P),className:"text-primary hover:underline font-medium",children:P.name}),P.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:P.description})]}),e.jsx(dt,{children:P.brokerage_id?e.jsx("span",{className:"text-sm",children:S[P.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:O!=null&&O.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),O.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(O==null?void 0:O.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Au,{className:"h-3 w-3"}),P.contact_visibility.replace("_"," ")]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(P),title:"Edit team",children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${P.name}"? This cannot be undone.`)&&a.mutate(P.id)},title:"Delete team",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})})]},P.id)})})]})})]})},jVt=()=>{const t=nr(),{user:s,isAdmin:r}=Os(),{startImpersonation:n,isLoading:a}=Vde(),{toast:o}=Ha(),[l,i]=N.useState([]),[c,u]=N.useState([]),[p,f]=N.useState([]),[g,v]=N.useState({}),[_,w]=N.useState(!0),[j,k]=N.useState({}),[S,M]=N.useState(!1),[L,P]=N.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[O,$]=N.useState(!1),[U,B]=N.useState(""),[V,X]=N.useState(1),[Y,ee]=N.useState(50),[Q,ce]=N.useState("all"),[ne,re]=N.useState("all"),[oe,fe]=N.useState("all"),[ge,ue]=N.useState("all"),[xe,_e]=N.useState(!1),[$e,Me]=N.useState(!1),[Ie,ke]=N.useState(null),[pe,we]=N.useState(null),[Le,Qe]=N.useState(!1),[Te,pt]=N.useState({name:"",email:"",brokerage_id:"",phone:""}),[ye,qe]=N.useState(null),[at,tt]=N.useState(!1),[Ae,rt]=N.useState(""),[He,ct]=N.useState(!1),[Ue,Ze]=N.useState(!1),[Je,Ge]=N.useState(null),[et,it]=N.useState(""),[Dt,Vt]=N.useState(!1),[hs,As]=N.useState(!1),[Ms,cs]=N.useState(null),[er,xt]=N.useState(!1),[Ps,mr]=N.useState(!1),[Tr,Dr]=N.useState(null),[xn,Si]=N.useState(""),[Ia,ur]=N.useState(!1),[Jr,Gr]=N.useState({email:"",name:"",password:"",phone:""}),[mn,Yr]=N.useState(!1),[bi,ft]=N.useState(!1),[or,Vn]=N.useState(""),[Sr,jr]=N.useState(!1),[ea,La]=N.useState(!1),[Ii,Fo]=N.useState(""),[$t,Se]=N.useState(new Set),[Be,Ye]=N.useState(!1),[bt,gt]=N.useState(!1),[Ft,Zt]=N.useState(null),[Ut,Qt]=N.useState(!1),[Is,ys]=N.useState(null),[vr,Hr]=N.useState([]),[xr,On]=N.useState([]),[Rn,Pn]=N.useState(!1),[wa,_o]=N.useState({});N.useEffect(()=>{!s||!r||(ni(),pl())},[s,r]);const cl=async()=>{try{const{data:wt,error:Es}=await H.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Es)throw Es;const Xs={};for(const gn of wt??[])Xs[gn.brokerage_id]||(Xs[gn.brokerage_id]=[]),Xs[gn.brokerage_id].push(gn.user_id);v(Xs)}catch(wt){console.error("Error loading brokerage manager assignments:",wt)}},ni=async()=>{try{w(!0);const{data:wt,error:Es}=await H.functions.invoke("get-user-details");if(Es)throw Es;const Xs=wt.users||[];i(Xs),f(wt.brokerages||[]),await cl();const gn=Xs.filter(yn=>yn.roles.includes("assistant"));if(gn.length>0){const yn=gn.map(Ur=>Ur.id),{data:ua}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",yn);if(ua&&ua.length>0){const Ur=[...new Set(ua.map(Op=>Op.agent_id))],{data:mo}=await H.from("profiles").select("id, name, email").in("id",Ur),tg={};for(const Op of ua){const Zr=mo==null?void 0:mo.find(rv=>rv.id===Op.agent_id);Zr&&(tg[Op.assistant_id]={agent_name:Zr.name||"",agent_email:Zr.email||""})}_o(tg)}}}catch(wt){console.error("Error loading members:",wt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},pl=async()=>{try{const{data:wt,error:Es}=await H.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Es)throw Es;u(wt||[])}catch(wt){console.error("Error loading apps:",wt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},co=async wt=>{if(!Te.name.trim()||!Te.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Te.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Xs}=await H.from("profiles").update({name:Te.name.trim(),email:Te.email.trim(),brokerage_id:Te.brokerage_id||null,phone:Te.phone.trim()||null}).eq("id",wt);if(Xs)throw Xs;o({title:"Success",description:"Member details updated successfully"}),ke(null),ni()}catch(Xs){console.error("Error updating member:",Xs),o({title:"Error",description:Xs.message||"Failed to update member",variant:"destructive"})}},Da=async wt=>{try{const{data:{session:Es}}=await H.auth.getSession(),Xs=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Es==null?void 0:Es.access_token}`},body:JSON.stringify({userId:wt})}),gn=await Xs.json();if(!Xs.ok)throw new Error(gn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Es){console.error("Error resending welcome email:",Es),o({title:"Error",description:Es.message||"Failed to resend welcome email",variant:"destructive"})}},uo=async(wt,Es)=>{try{const{error:Xs}=await H.functions.invoke("send-password-reset",{body:{email:wt,redirectTo:window.location.origin}});if(Xs)throw Xs;o({title:"Password Reset Sent",description:`Password reset email sent to ${Es}`})}catch(Xs){console.error("Error sending password reset:",Xs),o({title:"Error",description:Xs.message||"Failed to send password reset email",variant:"destructive"})}},Ai=async(wt,Es)=>{if(confirm(`Are you sure you want to delete ${Es}? This action cannot be undone.`))try{const{data:{session:Xs}}=await H.auth.getSession(),gn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xs==null?void 0:Xs.access_token}`},body:JSON.stringify({userId:wt})}),yn=await gn.json();if(!gn.ok)throw new Error(yn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),ni()}catch(Xs){console.error("Error deleting user:",Xs),o({title:"Error",description:Xs.message||"Failed to delete user",variant:"destructive"})}},ha=async()=>{if(!L.email||!L.name||!L.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(L.role==="brokerage_manager"&&!L.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}M(!0);try{const{data:{session:wt}}=await H.auth.getSession(),Es=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${wt==null?void 0:wt.access_token}`},body:JSON.stringify(L)}),Xs=await Es.json();if(!Es.ok)throw new Error(Xs.error||"Failed to create user");if(L.role&&L.role!=="user"&&Xs.userId){const gn=L.role==="brokerage_manager"?L.brokerage_id:void 0;await ho(Xs.userId,L.role,"add",gn)}o({title:"Success",description:`User ${L.email} created successfully`}),P({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),ni()}catch(wt){console.error("Error creating user:",wt),o({title:"Error",description:wt.message||"Failed to create user",variant:"destructive"})}finally{M(!1)}},ho=async(wt,Es,Xs,gn)=>{try{const{data:{session:yn}}=await H.auth.getSession(),ua={userId:wt,role:Es,action:Xs};if(Es==="brokerage_manager"){if(!gn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ua.brokerageId=gn}const Ur=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yn==null?void 0:yn.access_token}`},body:JSON.stringify(ua)}),mo=await Ur.json();if(!Ur.ok)throw new Error(mo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Xs==="add"?"added":"removed"} successfully`}),ni()}catch(yn){console.error("Error managing user role:",yn),o({title:"Error",description:yn.message||"Failed to manage user role",variant:"destructive"})}},Tc=(wt,Es)=>Es.length===0?!0:Es.some(Xs=>wt.includes(Xs)),Wc=async(wt,Es,Xs)=>{const gn=`${wt}-${Es.id}`;qe(gn);try{if(Xs){const yn=l.find(Ur=>Ur.id===wt),ua=Es.required_tags.filter(Ur=>yn==null?void 0:yn.tags.includes(Ur));for(const Ur of ua){const{error:mo}=await H.from("user_tags").delete().eq("user_id",wt).eq("tag",Ur);if(mo)throw mo}o({title:"Access Removed",description:`Removed access to ${Es.name}`})}else if(Es.required_tags.length>0){const{error:yn}=await H.from("user_tags").insert({user_id:wt,tag:Es.required_tags[0]});if(yn)throw yn;o({title:"Access Granted",description:`Granted access to ${Es.name}`})}await ni()}catch(yn){console.error("Error toggling access:",yn),o({title:"Error",description:yn.message||"Failed to update access",variant:"destructive"})}finally{qe(null)}},cu=async()=>{const wt=Ae.trim();if(!wt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(wt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Xs=>Xs.name.toLowerCase()===wt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ct(!0);try{const{error:Xs}=await H.from("brokerages").insert({name:wt});if(Xs)throw Xs;o({title:"Success",description:`Brokerage "${wt}" created successfully`}),rt(""),tt(!1),ni()}catch(Xs){console.error("Error creating brokerage:",Xs),o({title:"Error",description:Xs.message||"Failed to create brokerage",variant:"destructive"})}finally{ct(!1)}},Rf=wt=>{Ge(wt),it(wt.name),Ze(!0)},ql=()=>{Ge(null),it(""),Ze(!1)},uh=async()=>{if(!Je)return;const wt=et.trim();if(!wt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(wt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Vt(!0);try{const{error:Es}=await H.from("brokerages").update({name:wt}).eq("id",Je.id);if(Es)throw Es;o({title:"Success",description:"Brokerage updated successfully"}),ql(),ni()}catch(Es){console.error("Error updating brokerage:",Es),o({title:"Error",description:Es.message||"Failed to update brokerage",variant:"destructive"})}finally{Vt(!1)}},Sd=async(wt,Es)=>{var Xs;if(!Es||typeof Es!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const gn={userId:wt,role:"brokerage_manager",action:"add",brokerageId:Es};console.debug("[assignManagerToBrokerage] payload",gn);const{data:{session:yn}}=await H.auth.getSession(),ua=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yn==null?void 0:yn.access_token}`},body:JSON.stringify(gn)}),Ur=await ua.json();if(!ua.ok&&!((Xs=Ur.error)!=null&&Xs.includes("duplicate")))throw new Error(Ur.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await ni()}catch(gn){console.error("Error assigning manager:",gn),o({title:"Error",description:gn.message||"Failed to assign manager",variant:"destructive"})}},Km=wt=>{cs(wt),As(!0)},Ul=async()=>{if(Ms){xt(!0);try{const wt=l.filter(gn=>gn.brokerage_id===Ms.id),{data:{session:Es}}=await H.auth.getSession();for(const gn of wt){const yn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Es==null?void 0:Es.access_token}`},body:JSON.stringify({userId:gn.id})});if(!yn.ok){const ua=await yn.json();console.error(`Failed to delete user ${gn.email}:`,ua.error)}}const{error:Xs}=await H.from("brokerages").delete().eq("id",Ms.id);if(Xs)throw Xs;o({title:"Success",description:`Brokerage "${Ms.name}" and ${wt.length} member(s) deleted`}),As(!1),cs(null),ni()}catch(wt){console.error("Error deleting brokerage:",wt),o({title:"Error",description:wt.message||"Failed to delete brokerage",variant:"destructive"})}finally{xt(!1)}}},Xx=wt=>{Dr(wt),Si(""),mr(!0)},by=()=>{Dr(null),Si(""),mr(!1)},Q1=async wt=>{try{const{error:Es}=await H.from("profiles").update({brokerage_id:null}).eq("id",wt);if(Es)throw Es;o({title:"Success",description:"User removed from brokerage"}),ni()}catch(Es){console.error("Error removing user from brokerage:",Es),o({title:"Error",description:Es.message||"Failed to remove user",variant:"destructive"})}},X1=async(wt,Es)=>{try{const{error:Xs}=await H.from("profiles").update({brokerage_id:Es}).eq("id",wt);if(Xs)throw Xs;o({title:"Success",description:"User added to brokerage"}),ni()}catch(Xs){console.error("Error adding user to brokerage:",Xs),o({title:"Error",description:Xs.message||"Failed to add user",variant:"destructive"})}},J1=async()=>{if(!Tr||!Jr.email||!Jr.name||!Jr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Yr(!0);try{const{data:{session:wt}}=await H.auth.getSession(),Es=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${wt==null?void 0:wt.access_token}`},body:JSON.stringify({...Jr,brokerage_id:Tr.id,role:"user"})}),Xs=await Es.json();if(!Es.ok)throw new Error(Xs.error||"Failed to create agent");o({title:"Success",description:`Agent ${Jr.email} created successfully`}),Gr({email:"",name:"",password:"",phone:""}),ur(!1),ni()}catch(wt){console.error("Error creating agent:",wt),o({title:"Error",description:wt.message||"Failed to create agent",variant:"destructive"})}finally{Yr(!1)}},Dp=wt=>l.filter(Es=>Es.brokerage_id===wt),im=wt=>{const Es=Dp(wt);if(!xn)return Es;const Xs=xn.toLowerCase();return Es.filter(gn=>gn.name.toLowerCase().includes(Xs)||gn.email.toLowerCase().includes(Xs))},du=wt=>l.filter(Es=>Es.brokerage_id!==wt),om=l.filter(wt=>{var Xs;if(U){const gn=U.toLowerCase();if(!(wt.name.toLowerCase().includes(gn)||wt.email.toLowerCase().includes(gn)||((Xs=wt.brokerage_name)==null?void 0:Xs.toLowerCase().includes(gn))))return!1}if(Q==="claimed"&&!wt.claimed||Q==="unclaimed"&&wt.claimed||ne!=="all"&&!wt.roles.includes(ne))return!1;const Es=wt.is_trial||wt.subscription_status==="trialing";return!(oe==="trial"&&!Es||oe==="non-trial"&&Es||ge==="none"&&wt.brokerage_id||ge!=="all"&&ge!=="none"&&wt.brokerage_id!==ge)}),{sortKey:$d,sortDirection:Cd,handleSort:uu,sortData:Ff}=lR("created_at","desc"),zf=Ff(om,{name:wt=>{var Es;return((Es=wt.name)==null?void 0:Es.toLowerCase())||""},brokerage:wt=>{var Es;return((Es=wt.brokerage_name)==null?void 0:Es.toLowerCase())||""},status:wt=>wt.claimed?"active":"pending",role:wt=>wt.roles[0]||"",last_login:wt=>wt.last_sign_in_at?new Date(wt.last_sign_in_at).getTime():null,created_at:wt=>wt.created_at?new Date(wt.created_at).getTime():null}),Zm=zf.length,Ym=Y===0,Md=Ym?1:Math.ceil(Zm/Y),J0=Ym?0:(V-1)*Y,Jx=Ym?Zm:J0+Y,Pl=zf.slice(J0,Jx),eb=wt=>{B(wt),X(1)},eg=wt=>{ee(wt),X(1)},Oh=(wt,Es)=>{wt(Es),X(1)},Qw=async(wt,Es)=>{_e(!0);try{const Xs=l.find(Ur=>Ur.id===wt);if(!Xs)return;const gn=Xs.trial_expires_at?new Date(Xs.trial_expires_at):new Date,yn=new Date(gn.getTime()+Es*24*60*60*1e3),{error:ua}=await H.from("profiles").update({trial_expires_at:yn.toISOString()}).eq("id",wt);if(ua)throw ua;o({title:"Trial Extended",description:`Trial extended by ${Es} days`}),ni()}catch(Xs){console.error("Error extending trial:",Xs),o({title:"Error",description:Xs.message||"Failed to extend trial",variant:"destructive"})}finally{_e(!1)}},z3=async wt=>{Me(!0);try{const{error:Es}=await H.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",wt);if(Es)throw Es;o({title:"Account Converted",description:"User has been converted to a full account"}),ni(),_y()}catch(Es){console.error("Error converting trial:",Es),o({title:"Error",description:Es.message||"Failed to convert account",variant:"destructive"})}finally{Me(!1)}},ev=async wt=>{Pn(!0);try{const{data:Es}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",wt);if(Es&&Es.length>0){const gn=Es.map(ua=>ua.assistant_id),{data:yn}=await H.from("profiles").select("id, name, email").in("id",gn);Hr(Es.map(ua=>{const Ur=yn==null?void 0:yn.find(mo=>mo.id===ua.assistant_id);return{id:ua.id,assistant_id:ua.assistant_id,assistant_name:(Ur==null?void 0:Ur.name)||"Unknown",assistant_email:(Ur==null?void 0:Ur.email)||"",permissions:ua.permissions||{}}}))}else Hr([]);const{data:Xs}=await H.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",wt);if(Xs&&Xs.length>0){const gn=Xs.map(ua=>ua.agent_id),{data:yn}=await H.from("profiles").select("id, name, email").in("id",gn);On(Xs.map(ua=>{const Ur=yn==null?void 0:yn.find(mo=>mo.id===ua.agent_id);return{id:ua.id,agent_id:ua.agent_id,agent_name:(Ur==null?void 0:Ur.name)||"Unknown",agent_email:(Ur==null?void 0:Ur.email)||"",permissions:ua.permissions||{}}}))}else On([])}catch(Es){console.error("Error loading assistant data:",Es)}finally{Pn(!1)}},Oa=wt=>{we(wt),pt({name:wt.name,email:wt.email,brokerage_id:wt.brokerage_id||"",phone:wt.phone||""}),Qe(!0),ev(wt.id)},_y=()=>{we(null),Qe(!1),pt({name:"",email:"",brokerage_id:"",phone:""})},Xw=async()=>{pe&&(await co(pe.id),_y())},B3=wt=>{Se(Es=>{const Xs=new Set(Es);return Xs.has(wt)?Xs.delete(wt):Xs.add(wt),Xs})},$3=()=>{if($t.size===Pl.length&&Pl.every(wt=>$t.has(wt.id))){const wt=new Set($t);Pl.forEach(Es=>wt.delete(Es.id)),Se(wt)}else{const wt=new Set($t);Pl.forEach(Es=>wt.add(Es.id)),Se(wt)}},lm=()=>{Se(new Set)},tv=async()=>{if($t.size===0)return;Ye(!0);let wt=0,Es=0;try{const{data:{session:Xs}}=await H.auth.getSession();for(const gn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xs==null?void 0:Xs.access_token}`},body:JSON.stringify({userId:gn})})).ok?wt++:Es++}catch{Es++}o({title:"Bulk Email Complete",description:`Sent ${wt} emails${Es>0?`, ${Es} failed`:""}`}),lm()}catch(Xs){o({title:"Error",description:Xs.message||"Failed to send emails",variant:"destructive"})}finally{Ye(!1)}},sv=async()=>{if($t.size===0)return;Ye(!0);let wt=0,Es=0;try{const{data:{session:Xs}}=await H.auth.getSession();for(const gn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xs==null?void 0:Xs.access_token}`},body:JSON.stringify({userId:gn})})).ok?wt++:Es++}catch{Es++}o({title:"Bulk Password Reset Complete",description:`Sent ${wt} reset emails${Es>0?`, ${Es} failed`:""}`}),lm()}catch(Xs){o({title:"Error",description:Xs.message||"Failed to send password reset emails",variant:"destructive"})}finally{Ye(!1)}},Jw=async()=>{if($t.size===0)return;const wt=l.filter(yn=>$t.has(yn.id)).map(yn=>yn.name).slice(0,5).join(", "),Es=$t.size>5?` and ${$t.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${$t.size} users (${wt}${Es})? This action cannot be undone.`))return;Ye(!0);let Xs=0,gn=0;try{const{data:{session:yn}}=await H.auth.getSession();for(const ua of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${yn==null?void 0:yn.access_token}`},body:JSON.stringify({userId:ua})})).ok?Xs++:gn++}catch{gn++}o({title:"Bulk Delete Complete",description:`Deleted ${Xs} users${gn>0?`, ${gn} failed`:""}`}),lm(),ni()}catch(yn){o({title:"Error",description:yn.message||"Failed to delete users",variant:"destructive"})}finally{Ye(!1)}},tb=async()=>{gt(!0);try{const{data:{session:wt}}=await H.auth.getSession(),Es=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${wt==null?void 0:wt.access_token}`}});if(!Es.ok){const gn=await Es.json();throw new Error(gn.error||"Failed to sync phones")}const Xs=await Es.json();o({title:"Phone Sync Complete",description:`Pulled ${Xs.summary.pulledFromGHL} from GHL, pushed ${Xs.summary.pushedToGHL} to GHL, ${Xs.summary.alreadySynced} already synced`}),ni()}catch(wt){o({title:"Error",description:wt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{gt(!1)}},Qm=async(wt,Es)=>{Zt(wt);try{const{data:{session:Xs}}=await H.auth.getSession(),{data:gn}=await H.from("profiles").select("phone").eq("id",wt).single(),yn=(gn==null?void 0:gn.phone)||"",ua=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xs==null?void 0:Xs.access_token}`},body:JSON.stringify({email:Es,action:"update",phone:yn||void 0})});if(!ua.ok){const mo=await ua.json();throw new Error(mo.error||"Failed to sync with GHL")}const Ur=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Es)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:yn?`Phone ${yn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),ni()}catch(Xs){o({title:"Error",description:Xs.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},wy=async wt=>{await n(wt)},e2=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const wt=l.filter(mo=>$t.has(mo.id)),Es=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Xs=wt.map(mo=>[mo.name,mo.email,mo.phone||"",mo.brokerage_name||"",mo.roles.join("; "),mo.claimed?"Claimed":"Unclaimed",new Date(mo.created_at).toLocaleDateString()]),gn=[Es.join(","),...Xs.map(mo=>mo.map(tg=>`"${(tg||"").replace(/"/g,'""')}"`).join(","))].join(` `),yn=new Blob([gn],{type:"text/csv"}),ua=URL.createObjectURL(yn),Ur=document.createElement("a");Ur.href=ua,Ur.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Ur.click(),URL.revokeObjectURL(ua),o({title:"Export complete",description:`Exported ${wt.length} member(s)`})};return _?e.jsx(Ts,{title:"Members",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(Ts,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Member Management",description:"Manage users, roles, and permissions"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:tb,disabled:bt,children:[bt?e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:bt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:bt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>ft(!0),children:[e.jsx(c1,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Import CSV"}),e.jsx("span",{className:"sm:hidden",children:"Import"})]}),e.jsxs(xs,{open:O,onOpenChange:$,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(El,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Member"}),e.jsx("span",{className:"sm:hidden",children:"Add"})]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create New User"}),e.jsx(Wr,{children:"Add a new user to the system. They'll be able to sign in immediately."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",placeholder:"John Doe",value:L.name,onChange:wt=>P({...L,name:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:L.email,onChange:wt=>P({...L,email:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"password",children:"Password"}),e.jsx(ze,{id:"password",type:"password",placeholder:"Min 6 characters",value:L.password,onChange:wt=>P({...L,password:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"555-123-4567",value:L.phone,onChange:wt=>P({...L,phone:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"brokerage",children:["Brokerage",L.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Ks,{value:L.brokerage_id||"none",onValueChange:wt=>P({...L,brokerage_id:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"brokerage",children:e.jsx(Ys,{placeholder:L.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(wt=>e.jsx(Mt,{value:wt.id,children:wt.name},wt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"role",children:"Role"}),e.jsxs(Ks,{value:L.role,onValueChange:wt=>P({...L,role:wt}),children:[e.jsx(Gs,{id:"role",children:e.jsx(Ys,{placeholder:"Select role"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"user",children:"User"}),e.jsx(Mt,{value:"moderator",children:"Moderator"}),e.jsx(Mt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(Mt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Ks,{value:L.trial_days||"none",onValueChange:wt=>P({...L,trial_days:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"trial_days",children:e.jsx(Ys,{placeholder:"No trial (full access)"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No trial (full access)"}),e.jsx(Mt,{value:"7",children:"7-day trial"}),e.jsx(Mt,{value:"30",children:"30-day trial"}),e.jsx(Mt,{value:"60",children:"60-day trial"}),e.jsx(Mt,{value:"90",children:"90-day trial"}),e.jsx(Mt,{value:"365",children:"1-year trial"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Trial accounts don't require a credit card. Access expires after the trial period."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{onClick:ha,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(_a,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"members",children:"Members"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"trials",children:"Trial Users"}),e.jsx(ns,{value:"access",children:"Access Matrix"}),e.jsx(ns,{value:"celebrations",children:"Celebrations"}),e.jsx(ns,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(ws,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:U,onChange:wt=>eb(wt.target.value),className:"pl-10 h-9"})]}),e.jsxs(Ks,{value:Q,onValueChange:wt=>Oh(ce,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"claimed",children:"Active"}),e.jsx(Mt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(Ks,{value:ne,onValueChange:wt=>Oh(re,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Roles"}),e.jsx(Mt,{value:"admin",children:"Admin"}),e.jsx(Mt,{value:"brokerage_manager",children:"Manager"}),e.jsx(Mt,{value:"assistant",children:"Assistant"}),e.jsx(Mt,{value:"user",children:"User"})]})]}),e.jsxs(Ks,{value:oe,onValueChange:wt=>Oh(fe,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"trial",children:"Trial Only"}),e.jsx(Mt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(Ks,{value:ge,onValueChange:wt=>Oh(ue,wt),children:[e.jsx(Gs,{className:"w-[150px] h-9",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),p.map(wt=>e.jsx(Mt,{value:wt.id,children:wt.name},wt.id))]})]}),(U||Q!=="all"||ne!=="all"||oe!=="all"||ge!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{B(""),ce("all"),re("all"),fe("all"),ue("all"),X(1)},children:[e.jsx(Mr,{className:"h-4 w-4 mr-1"}),"Clear"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:Ym?`Showing all ${Zm} members`:`Showing ${J0+1}-${Math.min(Jx,Zm)} of ${Zm} members`}),e.jsxs(Ks,{value:Y.toString(),onValueChange:wt=>eg(Number(wt)),children:[e.jsx(Gs,{className:"h-9 w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"50",children:"50 / page"}),e.jsx(Mt,{value:"100",children:"100 / page"}),e.jsx(Mt,{value:"250",children:"250 / page"}),e.jsx(Mt,{value:"0",children:"All"})]})]})]})]}),$t.size>0&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vv,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[$t.size," selected"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:tv,disabled:Be,children:[Be?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(lr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:sv,disabled:Be,children:[Be?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Sp,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),e.jsx("span",{className:"sm:hidden",children:"Reset"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:e2,children:[e.jsx(vi,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Export"}),e.jsx("span",{className:"sm:hidden",children:"CSV"})]}),e.jsxs(K,{size:"sm",variant:"destructive",onClick:Jw,disabled:Be,children:[Be?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Nr,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"}),e.jsx("span",{className:"sm:hidden",children:"Del"})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:lm,disabled:Be,children:e.jsx(Mr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"w-[50px]",children:e.jsx(Oo,{checked:Pl.length>0&&Pl.every(wt=>$t.has(wt.id)),onCheckedChange:$3,"aria-label":"Select all on page"})}),e.jsx(bl,{sortKey:"name",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Name"}),e.jsx(bl,{sortKey:"brokerage",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Brokerage"}),e.jsx(bl,{sortKey:"status",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Status"}),e.jsx(bl,{sortKey:"role",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Role"}),e.jsx(bl,{sortKey:"last_login",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Last Login"}),e.jsx(bl,{sortKey:"created_at",currentSortKey:$d,currentDirection:Cd,onSort:uu,children:"Member Since"}),e.jsx(St,{className:"w-[100px]"})]})}),e.jsx(Bn,{children:Pl.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Pl.map(wt=>e.jsxs(Cs,{className:`hover:bg-muted/30 ${$t.has(wt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Oo,{checked:$t.has(wt.id),onCheckedChange:()=>B3(wt.id),"aria-label":`Select ${wt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>Oa(wt),className:"text-primary hover:underline font-medium text-left",children:wt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:wt.email})]})}),e.jsx(dt,{className:"text-muted-foreground",children:wt.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Es=wt.is_trial&&wt.trial_expires_at||!wt.is_trial&&wt.subscription_status==="trialing"&&wt.subscription_end_date,Xs=wt.trial_expires_at||wt.subscription_end_date;if(Es&&Xs){const gn=Math.ceil((new Date(Xs).getTime()-Date.now())/864e5),yn=gn<=0,ua=gn<=3;return e.jsx(st,{variant:"outline",className:It("w-fit",yn?"border-destructive text-destructive":ua?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:yn?"Trial Expired":`Trial · ${gn}d left`})}return e.jsx(st,{variant:wt.claimed?"default":"secondary",className:wt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:wt.claimed?"Active":"Pending"})})()})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col",children:[wt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:wt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),wt.roles.includes("assistant")&&wa[wt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",wa[wt.id].agent_name||wa[wt.id].agent_email]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:wt.last_sign_in_at?new Date(wt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-muted-foreground",children:wt.created_at?new Date(wt.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{ys(wt),Qt(!0)},title:"Send celebration",children:e.jsx(nu,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Oa(wt),title:"Edit member",children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qm(wt.id,wt.email),disabled:Ft===wt.id,title:"Sync phone with GHL",children:Ft===wt.id?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Da(wt.id),title:"Resend welcome email",children:e.jsx(lr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>uo(wt.email,wt.name),title:"Send password reset",children:e.jsx(lS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>wy(wt.id),disabled:a||wt.id===(s==null?void 0:s.id),title:wt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${wt.name}`,children:a?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(uS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ai(wt.id,wt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},wt.id))})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",V," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(wt=>Math.max(1,wt-1)),disabled:V===1,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Md)},(wt,Es)=>{let Xs;return Md<=5||V<=3?Xs=Es+1:V>=Md-2?Xs=Md-4+Es:Xs=V-2+Es,e.jsx(K,{variant:V===Xs?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(Xs),children:Xs},Xs)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(wt=>Math.min(Md,wt+1)),disabled:V===Md,children:e.jsx(oa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(Md),disabled:V===Md,children:"Last"})]})]})]}),e.jsx(xs,{open:Le,onOpenChange:Qe,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Member"}),e.jsx(Wr,{children:"Update member details, roles, and app access"})]}),pe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:Te.name,onChange:wt=>pt({...Te,name:wt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:Te.email,onChange:wt=>pt({...Te,email:wt.target.value}),maxLength:255})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:Te.phone,onChange:wt=>pt({...Te,phone:wt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Ks,{value:Te.brokerage_id||"none",onValueChange:wt=>pt({...Te,brokerage_id:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"edit-brokerage",children:e.jsx(Ys,{placeholder:"Select brokerage"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),p.map(wt=>e.jsx(Mt,{value:wt.id,children:wt.name},wt.id))]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[pe.roles.map(wt=>e.jsxs(st,{variant:"default",className:"gap-1",children:[e.jsx(Au,{className:"h-3 w-3"}),wt,wt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>ho(pe.id,wt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Mr,{className:"h-3 w-3"})})]},wt)),pe.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Ks,{onValueChange:wt=>ho(pe.id,wt,"add"),children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Add role..."})}),e.jsxs(Ws,{children:[!pe.roles.includes("admin")&&e.jsx(Mt,{value:"admin",children:"Admin"}),!pe.roles.includes("user")&&e.jsx(Mt,{value:"user",children:"User"})]})]}),!pe.roles.includes("brokerage_manager")&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(vr.length>0||xr.length>0||pe.roles.includes("assistant"))&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Rn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[vr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),vr.map(wt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:wt.assistant_name}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:wt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(wt.permissions).filter(([,Es])=>Es).map(([Es])=>e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:Es},Es))})]},wt.id))]}),xr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),xr.map(wt=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:wt.agent_name}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:wt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(wt.permissions).filter(([,Es])=>Es).map(([Es])=>e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:Es},Es))})]},wt.id))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),e.jsx("div",{className:"grid gap-3",children:c.map(wt=>{const Es=Tc(pe.tags,wt.required_tags),Xs=`${pe.id}-${wt.id}`,gn=ye===Xs,yn=wt.required_tags.length===0;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xl",children:wt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:wt.name}),yn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:gn?e.jsx(bs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):yn?e.jsx(st,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(qr,{checked:Es,onCheckedChange:()=>Wc(pe.id,wt,Es)})})]},wt.id)})})]}),(pe.is_trial||pe.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[pe.trial_expires_at&&e.jsx(E8e,{expiresAt:pe.trial_expires_at}),!pe.trial_expires_at&&pe.subscription_status==="trialing"&&pe.subscription_end_date&&e.jsx(E8e,{expiresAt:pe.subscription_end_date})]}),(pe.trial_expires_at||pe.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(pe.trial_expires_at||pe.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Qw(pe.id,7),disabled:xe,children:[e.jsx(V_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Qw(pe.id,14),disabled:xe,children:[e.jsx(V_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>Qw(pe.id,30),disabled:xe,children:[e.jsx(V_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>z3(pe.id),disabled:$e,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(X_,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),pe.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(pe.trial_started_at).toLocaleDateString(),pe.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(pe.trial_claimed_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Account Information"}),e.jsxs("div",{className:"text-sm space-y-1 text-muted-foreground",children:[pe.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(pe.email_confirmed_at).toLocaleString()]}),pe.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(pe.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(pe.created_at).toLocaleString()]})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:_y,children:"Cancel"}),e.jsx(K,{onClick:Xw,children:"Save Changes"})]})]})}),e.jsxs(ws,{value:"access",children:[c.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Member Access Matrix"}),e.jsx(gr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs("div",{className:"relative w-full sm:w-72",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents by name or email...",value:U,onChange:wt=>{B(wt.target.value),X(1)},className:"pl-9"})]})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),c.map(wt=>e.jsx("th",{className:"text-center p-4 font-semibold min-w-[120px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("span",{className:"text-2xl",children:wt.icon}),e.jsx("span",{className:"text-sm",children:wt.name})]})},wt.id))]})}),e.jsxs("tbody",{children:[Pl.map(wt=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsx("td",{className:"p-4 sticky left-0 bg-card z-10",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:wt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:wt.email})]})}),c.map(Es=>{const Xs=Tc(wt.tags,Es.required_tags),gn=`${wt.id}-${Es.id}`,yn=ye===gn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:yn?e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(qr,{checked:Xs,onCheckedChange:()=>Wc(wt.id,Es,Xs),disabled:Es.required_tags.length===0})})},Es.id)})]},wt.id)),Pl.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:c.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Md>1&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",J0+1,"-",Math.min(Jx,Zm)," of ",Zm," • Page ",V," of ",Md]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(wt=>Math.max(1,wt-1)),disabled:V===1,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(wt=>Math.min(Md,wt+1)),disabled:V===Md,children:e.jsx(oa,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs(ws,{value:"brokerages",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:or,onChange:wt=>Vn(wt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(wt=>wt.name.toLowerCase().includes(or.toLowerCase())).length," of ",p.length," brokerages"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const wt=[];for(const Ur of p){const mo=g[Ur.id]??[];for(const tg of mo){const Op=l.find(Zr=>Zr.id===tg);if(Op){const Zr=(Op.name||"").trim().split(/\s+/),rv=Zr[0]||"",nv=Zr.slice(1).join(" ")||"";wt.push({firstName:rv,lastName:nv,email:Op.email,brokerageName:Ur.name})}}}if(wt.length===0){o({title:"No managers found to export"});return}const Xs=[["First Name","Last Name","Email","Brokerage Name"].join(","),...wt.map(Ur=>[Ur.firstName,Ur.lastName,Ur.email,Ur.brokerageName].map(mo=>`"${(mo||"").replace(/"/g,'""')}"`).join(","))].join(` `),gn=new Blob([Xs],{type:"text/csv"}),yn=URL.createObjectURL(gn),ua=document.createElement("a");ua.href=yn,ua.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ua.click(),URL.revokeObjectURL(yn),o({title:`Exported ${wt.length} managers`})},children:[e.jsx(vi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(xs,{open:at,onOpenChange:tt,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create New Brokerage"}),e.jsx(Wr,{children:"Add a new brokerage to the system."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Ae,onChange:wt=>rt(wt.target.value),maxLength:100})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>tt(!1),children:"Cancel"}),e.jsx(K,{onClick:cu,disabled:He,children:He?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(St,{className:"font-semibold",children:"Manager(s)"}),e.jsx(St,{className:"font-semibold",children:"Agents"}),e.jsx(St,{className:"w-[150px]"})]})}),e.jsx(Bn,{children:(()=>{const wt=p.filter(Es=>Es.name.toLowerCase().includes(or.toLowerCase()));return wt.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:or?"No brokerages match your search":"No brokerages found"})}):wt.map(Es=>{const Xs=l.filter(Ur=>Ur.brokerage_id===Es.id),yn=(g[Es.id]??[]).map(Ur=>l.find(mo=>mo.id===Ur)).filter(Boolean),ua=Xs.length;return e.jsxs(Cs,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Rf(Es),className:"text-primary hover:underline font-medium",children:Es.name})}),e.jsx(dt,{children:yn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:yn.map(Ur=>e.jsx(st,{variant:"secondary",className:"text-xs",children:Ur.name},Ur.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(dt,{children:[ua," member",ua!==1?"s":""]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"h-8",onClick:()=>Xx(Es),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Rf(Es),title:"Edit brokerage",children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Km(Es),title:"Delete brokerage",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Es.id)})})()})]})}),e.jsx(xs,{open:Ue,onOpenChange:Ze,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Brokerage"}),e.jsx(Wr,{children:"Update brokerage details and manage managers"})]}),Je&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"edit-brokerage-name",value:et,onChange:wt=>it(wt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Managers"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const Es=(g[Je.id]??[]).map(Xs=>l.find(gn=>gn.id===Xs)).filter(Boolean);return Es.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Es.map(Xs=>e.jsxs(st,{variant:"default",className:"gap-1",children:[e.jsx(Au,{className:"h-3 w-3"}),Xs.name,e.jsx("button",{onClick:()=>ho(Xs.id,"brokerage_manager","remove",Je.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Mr,{className:"h-3 w-3"})})]},Xs.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs($o,{open:Sr,onOpenChange:jr,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Sr,className:"w-full justify-between",children:["Search for a member...",e.jsx(sn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search by name or email..."}),e.jsxs(zx,{className:"max-h-[200px]",children:[e.jsx(Bx,{children:"No members found."}),e.jsx($x,{children:(()=>{const wt=new Set(g[Je.id]??[]);return l.filter(Es=>!wt.has(Es.id)&&(r||Es.brokerage_id===Je.id)).map(Es=>e.jsxs(bp,{value:`${Es.name} ${Es.email}`,onSelect:()=>{Sd(Es.id,Je.id),jr(!1)},children:[Es.name," (",Es.email,")"]},Es.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(wt=>wt.brokerage_id===Je.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(wt=>wt.brokerage_id===Je.id).map(wt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:wt.name}),wt.roles.includes("brokerage_manager")&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Manager"})]},wt.id))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:ql,children:"Cancel"}),e.jsx(K,{onClick:uh,disabled:Dt,children:Dt?"Saving...":"Save Changes"})]})]})}),e.jsx(xs,{open:hs,onOpenChange:As,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Wr,{children:['Are you sure you want to delete "',Ms==null?void 0:Ms.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',Ms==null?void 0:Ms.name,'"']}),e.jsxs("li",{children:["All ",l.filter(wt=>wt.brokerage_id===(Ms==null?void 0:Ms.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>As(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ul,disabled:er,children:er?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(xs,{open:Ps,onOpenChange:mr,children:e.jsxs(fs,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5"}),"Manage ",Tr==null?void 0:Tr.name]}),e.jsx(Wr,{children:"Add, remove, or manage users in this brokerage"})]}),Tr&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search members...",value:xn,onChange:wt=>Si(wt.target.value),className:"pl-10 h-9"})]}),e.jsxs(xs,{open:Ia,onOpenChange:ur,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(El,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add New Agent"}),e.jsxs(Wr,{children:["Create a new agent for ",Tr.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-name",children:"Name"}),e.jsx(ze,{id:"agent-name",placeholder:"John Doe",value:Jr.name,onChange:wt=>Gr({...Jr,name:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-email",children:"Email"}),e.jsx(ze,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Jr.email,onChange:wt=>Gr({...Jr,email:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-password",children:"Password"}),e.jsx(ze,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Jr.password,onChange:wt=>Gr({...Jr,password:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(ze,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Jr.phone,onChange:wt=>Gr({...Jr,phone:wt.target.value})})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>ur(!1),children:"Cancel"}),e.jsx(K,{onClick:J1,disabled:mn,children:mn?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs($o,{open:ea,onOpenChange:La,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ea,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(sn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search users...",value:Ii,onValueChange:Fo}),e.jsxs(zx,{children:[e.jsx(Bx,{children:"No users found."}),e.jsx($x,{children:du(Tr.id).filter(wt=>Ii===""||wt.name.toLowerCase().includes(Ii.toLowerCase())||wt.email.toLowerCase().includes(Ii.toLowerCase())).map(wt=>e.jsxs(bp,{value:`${wt.name} ${wt.email}`,onSelect:()=>{X1(wt.id,Tr.id),La(!1),Fo("")},children:[wt.name," (",wt.email,")"]},wt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(St,{className:"font-semibold",children:"Name"}),e.jsx(St,{className:"font-semibold",children:"Email"}),e.jsx(St,{className:"font-semibold",children:"Status"}),e.jsx(St,{className:"font-semibold",children:"Role"}),e.jsx(St,{className:"w-[120px]"})]})}),e.jsx(Bn,{children:im(Tr.id).length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:xn?"No matching members found":"No members in this brokerage"})}):im(Tr.id).map(wt=>e.jsxs(Cs,{className:"hover:bg-muted/30",children:[e.jsx(dt,{className:"font-medium",children:wt.name}),e.jsx(dt,{className:"text-muted-foreground",children:wt.email}),e.jsx(dt,{children:wt.claimed?e.jsx(st,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(st,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:wt.roles.includes("brokerage_manager")?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Au,{className:"h-3 w-3"}),"Manager"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[!wt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Da(wt.id),title:"Resend welcome email",children:e.jsx(lr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Q1(wt.id),title:"Remove from brokerage",children:e.jsx(Mr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>wy(wt.id),disabled:a||wt.id===(s==null?void 0:s.id),title:wt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${wt.name}`,children:a?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(uS,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ai(wt.id,wt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},wt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Dp(Tr.id).length," total member",Dp(Tr.id).length!==1?"s":""," •",Dp(Tr.id).filter(wt=>wt.roles.includes("brokerage_manager")).length," manager",Dp(Tr.id).filter(wt=>wt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(Un,{children:e.jsx(K,{variant:"outline",onClick:by,children:"Close"})})]})})]}),e.jsx(ws,{value:"teams",children:e.jsx(wVt,{})}),e.jsx(ws,{value:"trials",children:e.jsx(yVt,{})}),e.jsx(ws,{value:"celebrations",children:e.jsx(gVt,{})}),e.jsx(ws,{value:"deletions",children:e.jsx(vVt,{})})]})]}),e.jsx(vtt,{open:bi,onOpenChange:ft,brokerages:p,onSuccess:ni}),Is&&e.jsx(btt,{open:Ut,onOpenChange:wt=>{Qt(wt),wt||ys(null)},userId:Is.id,userName:Is.name})]})},NVt=()=>{const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,v]=N.useState("");N.useEffect(()=>{_()},[]);const _=async()=>{const{data:P,error:O}=await H.from("invite_codes").select("*").order("created_at",{ascending:!1});O?(me.error("Failed to load invite codes"),console.error(O)):s(P||[]),n(!1)},w=async P=>{if(P.preventDefault(),!l.trim()){me.error("Please enter a code");return}o(!0);const{error:O}=await H.from("invite_codes").insert({code:l.trim().toUpperCase(),description:c.trim()||null,max_uses:p?parseInt(p):null,trial_days:g?parseInt(g):null});O?O.code==="23505"?me.error("This code already exists"):(me.error("Failed to create invite code"),console.error(O)):(me.success("Invite code created"),i(""),u(""),f(""),v(""),_()),o(!1)},j=async(P,O)=>{const{error:$}=await H.from("invite_codes").update({is_active:!O}).eq("id",P);$?me.error("Failed to update code"):s(t.map(U=>U.id===P?{...U,is_active:!O}:U))},k=async P=>{const{error:O}=await H.from("invite_codes").delete().eq("id",P);O?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter($=>$.id!==P)))},S="https://dashboard.relevelup.com",M=P=>{const O=`${S}/join?code=${P}`;navigator.clipboard.writeText(O),me.success("Link copied to clipboard")},L=`${S}/join`;return e.jsx(Ts,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Create New Code"}),e.jsxs(gr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:L})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"code",children:"Code"}),e.jsx(ze,{id:"code",placeholder:"WELCOME2024",value:l,onChange:P=>i(P.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(be,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"For marketing campaign",value:c,onChange:P=>u(P.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:P=>f(P.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(ze,{id:"trialDays",type:"number",placeholder:"None",value:g,onChange:P=>v(P.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Code"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Uses"}),e.jsx(St,{children:"Trial"}),e.jsx(St,{children:"Created"}),e.jsx(St,{children:"Active"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(P=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-mono font-medium",children:P.code}),e.jsx(dt,{className:"text-muted-foreground",children:P.description||"—"}),e.jsxs(dt,{children:[P.uses_count,P.max_uses&&` / ${P.max_uses}`]}),e.jsx(dt,{children:P.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[P.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(P.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx(qr,{checked:P.is_active,onCheckedChange:()=>j(P.id,P.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>M(P.code),title:"Copy invite link",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>k(P.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},P.id))})]})})]})]})})},cR=async t=>{try{const{data:s,error:r}=await H.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},yE=async t=>{try{const{data:s,error:r}=await H.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},kVt=async(t,s)=>await cR("new_templates")?yE({title:"New Template Available",body:`Check out the new template: ${t}`,url:`/templates/${s}`}):(console.log("New template notifications are disabled"),{success:!1,skipped:!0}),SVt=async(t,s)=>yE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),CVt=async(t,s)=>await cR("new_events")?yE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),MVt=async(t,s)=>await cR("new_toolbox")?yE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),gbe=async(t,s)=>await cR("new_social_swag")?yE({title:"New Social Swag",body:`New social swag available: ${t}`,url:`/social-swag/${s}`}):(console.log("New social swag notifications are disabled"),{success:!1,skipped:!0}),TVt=async(t,s)=>await cR("new_newsletters")?yE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),zz={title:"",description:"",image_url:"",video_url:"",event_date:void 0,event_time:"12:00",zoom_link:"",zoom_meeting_id:"",capacity:"",is_published:!1,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0};function AVt(){const t=nr(),s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(null),[l,i]=N.useState(zz),[c,u]=N.useState(null),[p,f]=N.useState(null),[g,v]=N.useState(!1),_=N.useRef(null),[w,j]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(!1),[P,O]=N.useState(null),[$,U]=N.useState(null),[B,V]=N.useState(!0),[X,Y]=N.useState(""),{data:ee,isLoading:Q}=mt({queryKey:["admin-events"],queryFn:async()=>{const{data:Ae,error:rt}=await H.from("events").select("*").order("event_date",{ascending:!0});if(rt)throw rt;return Ae}}),{data:ce}=mt({queryKey:["event-registrations-count"],queryFn:async()=>{let Ae=[],rt=0;const He=1e3;for(;;){const{data:Ue,error:Ze}=await H.from("event_registrations").select("event_id").range(rt,rt+He-1);if(Ze)throw Ze;if(!Ue||Ue.length===0||(Ae=Ae.concat(Ue),Ue.length{ct[Ue.event_id]=(ct[Ue.event_id]||0)+1}),ct}}),{data:ne,isLoading:re}=mt({queryKey:["event-registrations-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ae,error:rt}=await H.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",k.id).order("registered_at",{ascending:!1});if(rt)throw rt;if(!Ae||Ae.length===0)return[];const He=Ae.map(Ze=>Ze.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:Ze,error:Je}=await H.from("profiles").select("id, name, email").in("id",He);if(Je)throw Je;ct=Ze||[]}const Ue=new Map((ct==null?void 0:ct.map(Ze=>[Ze.id,Ze]))||[]);return Ae.map(Ze=>({...Ze,profiles:Ze.user_id&&Ue.get(Ze.user_id)||null}))},enabled:!!k}),{data:oe,isLoading:fe}=mt({queryKey:["event-attendees-details",k==null?void 0:k.id],queryFn:async()=>{if(!k)return[];const{data:Ae,error:rt}=await H.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",k.id).order("created_at",{ascending:!1});if(rt)throw rt;if(!Ae||Ae.length===0)return[];const He=Ae.map(Ge=>Ge.user_id).filter(Boolean);let ct=[];if(He.length>0){const{data:Ge,error:et}=await H.from("profiles").select("id, name, email").in("id",He);if(et)throw et;ct=Ge||[]}const{data:Ue}=await H.from("agent_points").select("user_id").eq("event_id",k.id),Ze=new Set((Ue==null?void 0:Ue.map(Ge=>Ge.user_id))||[]),Je=new Map((ct==null?void 0:ct.map(Ge=>[Ge.id,Ge]))||[]);return Ae.map(Ge=>({...Ge,profiles:Ge.user_id&&Je.get(Ge.user_id)||null,points_awarded:Ge.user_id?Ze.has(Ge.user_id):!1}))},enabled:!!k}),ge=Ae=>{S(Ae),j(!0)},ue=Lt({mutationFn:async Ae=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Ae})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync");return ct},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-registrations-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Ae.message)},onError:Ae=>{me.error("Failed to sync: "+Ae.message)}}),xe=Lt({mutationFn:async Ae=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const He=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${rt.access_token}`},body:JSON.stringify({event_id:Ae})}),ct=await He.json();if(!He.ok)throw new Error(ct.error||"Failed to sync attendees");return ct},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Ae!=null&&Ae.message?me.success(Ae.message):me.success(`Synced ${Ae.synced||0} attendees. ${Ae.points_awarded||0} points awarded!`)},onError:Ae=>{me.error("Failed to sync attendees: "+Ae.message)}}),_e=Lt({mutationFn:async({eventId:Ae,testMode:rt})=>{const{data:{session:He}}=await H.auth.getSession();if(!He)throw new Error("Not authenticated");const ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${He.access_token}`},body:JSON.stringify({event_id:Ae,test_mode:rt})}),Ue=await ct.json();if(!ct.ok)throw new Error(Ue.error||"Failed to send reminders");return Ue},onSuccess:Ae=>{Ae.test?me.success(Ae.message||"Test email sent!"):me.success(Ae.message||`Reminder emails sent to ${Ae.sent} registrants!`)},onError:Ae=>{me.error("Failed to send reminders: "+Ae.message)}}),{data:$e}=mt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Ae=[],rt=0;const He=1e3;for(;;){const{data:ct,error:Ue}=await H.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(rt,rt+He-1);if(Ue)throw Ue;if(!ct||ct.length===0||(Ae=[...Ae,...ct],ct.length{const{error:Ue}=await H.from("event_attendees").update({user_id:rt}).eq("id",Ae);if(Ue)throw Ue;if(ct&&He){const{error:Je}=await H.from("zoom_email_aliases").upsert({user_id:rt,zoom_email:He.toLowerCase()},{onConflict:"zoom_email"});Je&&console.error("Failed to save alias:",Je)}const Ze=k==null?void 0:k.id;if(Ze){const{data:Je}=await H.from("user_roles").select("id").eq("user_id",rt).eq("role","admin").single();if(!Je){const{data:Ge}=await H.from("agent_points").select("id").eq("user_id",rt).eq("event_id",Ze).single();Ge||(await H.rpc("award_attendance_points",{p_user_id:rt,p_event_id:Ze,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await H.rpc("check_and_award_badges",{p_user_id:rt}))}}return{userId:rt,zoomEmail:He,shouldSaveAlias:ct}},onSuccess:Ae=>{s.invalidateQueries({queryKey:["event-attendees-details",k==null?void 0:k.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let rt="Attendee linked and points awarded!";Ae.shouldSaveAlias&&Ae.zoomEmail&&(rt+=` Email "${Ae.zoomEmail}" will be auto-matched in the future.`),me.success(rt),L(!1),O(null),U(null),Y("")},onError:Ae=>{me.error("Failed to link attendee: "+Ae.message)}}),Ie=Ae=>{O(Ae),U(null),V(!0),Y(""),L(!0)},ke=()=>{!P||!$||Me.mutate({attendeeId:P.id,userId:$,zoomEmail:P.zoom_email,shouldSaveAlias:B})},pe=($e==null?void 0:$e.filter(Ae=>{var He,ct;if(!X)return!0;const rt=X.toLowerCase();return((He=Ae.name)==null?void 0:He.toLowerCase().includes(rt))||((ct=Ae.email)==null?void 0:ct.toLowerCase().includes(rt))}))||[],we=async Ae=>{const rt=Ae.name.split(".").pop(),ct=`${`${crypto.randomUUID()}.${rt}`}`,{error:Ue}=await H.storage.from("event-images").upload(ct,Ae);if(Ue)throw Ue;const{data:{publicUrl:Ze}}=H.storage.from("event-images").getPublicUrl(ct);return Ze},Le=Ae=>{var He;const rt=(He=Ae.target.files)==null?void 0:He[0];if(rt){if(rt.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(rt),f(URL.createObjectURL(rt))}},Qe=()=>{u(null),f(null),i({...l,image_url:""}),_.current&&(_.current.value="")},Te=Lt({mutationFn:async Ae=>{v(!0);let rt=Ae.image_url;c&&(rt=await we(c)||"");const He=new Date(Ae.event_date),[ct,Ue]=Ae.event_time.split(":");He.setHours(parseInt(ct),parseInt(Ue));const Ze=[new Date(He)];if(Ae.is_recurring&&Ae.recurrence_end_date){let it=new Date(He);for(;Ae.recurrence_pattern==="weekly"?it=j4(it,1):Ae.recurrence_pattern==="biweekly"?it=j4(it,2):it=Bm(it,1),!(it>Ae.recurrence_end_date);)Ze.push(new Date(it))}const Je=Ze.map(it=>({title:Ae.title,description:Ae.description||null,image_url:rt||null,video_url:Ae.video_url||null,event_date:it.toISOString(),zoom_link:Ae.zoom_link,zoom_meeting_id:Ae.zoom_meeting_id||null,capacity:Ae.capacity?parseInt(Ae.capacity):null,is_published:Ae.is_published})),{data:Ge,error:et}=await H.from("events").insert(Je).select();if(et)throw et;return Ge&&Ge.length>0&&CVt(Ae.title,Ge[0].id),Ze.length},onSuccess:Ae=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Ae>1?`${Ae} recurring events created successfully`:"Event created successfully"),n(!1),i(zz),u(null),f(null),v(!1)},onError:Ae=>{me.error("Failed to create event: "+Ae.message),v(!1)}}),pt=Lt({mutationFn:async({id:Ae,data:rt})=>{v(!0);let He=rt.image_url;c&&(He=await we(c)||"");const ct=new Date(rt.event_date),[Ue,Ze]=rt.event_time.split(":");ct.setHours(parseInt(Ue),parseInt(Ze));const{error:Je}=await H.from("events").update({title:rt.title,description:rt.description||null,image_url:He||null,video_url:rt.video_url||null,event_date:ct.toISOString(),zoom_link:rt.zoom_link,zoom_meeting_id:rt.zoom_meeting_id||null,capacity:rt.capacity?parseInt(rt.capacity):null,is_published:rt.is_published}).eq("id",Ae);if(Je)throw Je},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(zz),u(null),f(null),v(!1)},onError:Ae=>{me.error("Failed to update event: "+Ae.message),v(!1)}}),ye=Lt({mutationFn:async Ae=>{const{error:rt}=await H.from("events").delete().eq("id",Ae);if(rt)throw rt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Ae=>{me.error("Failed to delete event: "+Ae.message)}}),qe=Ae=>{var He;const rt=new Date(Ae.event_date);o(Ae),i({title:Ae.title,description:Ae.description||"",image_url:Ae.image_url||"",video_url:Ae.video_url||"",event_date:rt,event_time:ms(rt,"HH:mm"),zoom_link:Ae.zoom_link,zoom_meeting_id:Ae.zoom_meeting_id||"",capacity:((He=Ae.capacity)==null?void 0:He.toString())||"",is_published:Ae.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Ae.image_url||null),u(null),n(!0)},at=Ae=>{if(Ae.preventDefault(),!l.event_date){me.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){me.error("Please select an end date for recurring events");return}a?pt.mutate({id:a.id,data:l}):Te.mutate(l)},tt=()=>{n(!1),o(null),i(zz),u(null),f(null)};return e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/dashboard"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),e.jsxs(Ee,{className:"mb-6",children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"All Events"}),e.jsxs(xs,{open:r,onOpenChange:Ae=>!Ae&&tt(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:at,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l.title,onChange:Ae=>i({...l,title:Ae.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:l.description,onChange:Ae=>i({...l,description:Ae}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Event Image"}),e.jsx("input",{type:"file",ref:_,accept:"image/*",onChange:Le,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:Qe,children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Ae;return(Ae=_.current)==null?void 0:Ae.click()},children:[e.jsx(di,{className:"h-6 w-6"}),e.jsx("span",{className:"text-sm",children:"Click to upload image"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Date *"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.event_date?ms(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:l.event_date,onSelect:Ae=>i({...l,event_date:Ae}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"time",children:"Time *"}),e.jsx(ze,{id:"time",type:"time",value:l.event_time,onChange:Ae=>i({...l,event_time:Ae.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(ze,{id:"zoom_link",value:l.zoom_link,onChange:Ae=>i({...l,zoom_link:Ae.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(ze,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Ae=>i({...l,zoom_meeting_id:Ae.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(ze,{id:"video_url",value:l.video_url,onChange:Ae=>i({...l,video_url:Ae.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(ze,{id:"capacity",type:"number",value:l.capacity,onChange:Ae=>i({...l,capacity:Ae.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(DL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(qr,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Ae=>i({...l,is_recurring:Ae})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Frequency"}),e.jsxs(Ks,{value:l.recurrence_pattern,onValueChange:Ae=>i({...l,recurrence_pattern:Ae}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"weekly",children:"Weekly"}),e.jsx(Mt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(Mt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Repeat Until"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ms(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:l.recurrence_end_date,onSelect:Ae=>i({...l,recurrence_end_date:Ae}),disabled:Ae=>Ae<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let Ae=1,rt=new Date(l.event_date);for(;rt=l.recurrence_pattern==="weekly"?j4(rt,1):l.recurrence_pattern==="biweekly"?j4(rt,2):Bm(rt,1),!(rt>l.recurrence_end_date);)Ae++;return Ae})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{htmlFor:"is_published",children:"Published"}),e.jsx(qr,{id:"is_published",checked:l.is_published,onCheckedChange:Ae=>i({...l,is_published:Ae})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:tt,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:Te.isPending||pt.isPending||g,children:g?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:Q?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(ee==null?void 0:ee.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Date & Time"}),e.jsx(St,{children:"Registrations"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:ee==null?void 0:ee.map(Ae=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:Ae.title}),e.jsx(dt,{children:ms(new Date(Ae.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>ge(Ae),children:[e.jsx(hr,{className:"h-4 w-4"}),(ce==null?void 0:ce[Ae.id])||0,Ae.capacity&&` / ${Ae.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:It("px-2 py-1 rounded-full text-xs font-medium",Ae.is_published?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:Ae.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Ae.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(en,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Ae),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&ye.mutate(Ae.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.id))})]})})]}),e.jsx(xs,{open:w,onOpenChange:j,children:e.jsxs(fs,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),k==null?void 0:k.title]}),e.jsx(Wr,{children:"View registrations and attendees for this event"})]}),e.jsxs("div",{className:"flex items-center justify-end mb-4 gap-2 flex-wrap",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>_e.mutate({eventId:k.id,testMode:!0}),disabled:_e.isPending,children:[e.jsx(lr,{className:It("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e.mutate({eventId:k.id}),disabled:_e.isPending||!(ne!=null&&ne.length),children:[e.jsx(lr,{className:It("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),_e.isPending?"Sending...":"Send Reminder to All"]}),(k==null?void 0:k.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ue.mutate(k.id),disabled:ue.isPending,children:[e.jsx(Wo,{className:It("h-4 w-4 mr-2",ue.isPending&&"animate-spin")}),ue.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>xe.mutate(k.id),disabled:xe.isPending,children:[e.jsx(vo,{className:It("h-4 w-4 mr-2",xe.isPending&&"animate-spin")}),xe.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(_a,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"registrations",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Registrations (",(ne==null?void 0:ne.length)||0,")"]}),e.jsxs(ns,{value:"attendees",className:"gap-2",children:[e.jsx(sa,{className:"h-4 w-4"}),"Attendees (",(oe==null?void 0:oe.length)||0,")"]})]}),e.jsx(ws,{value:"registrations",className:"mt-4",children:re?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ne==null?void 0:ne.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No registrations yet for this event."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Registered"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Bn,{children:ne==null?void 0:ne.map(Ae=>{var Ue,Ze;const rt=((Ue=Ae.profiles)==null?void 0:Ue.name)||Ae.zoom_name||"Unknown",He=((Ze=Ae.profiles)==null?void 0:Ze.email)||Ae.zoom_email||null,ct=!Ae.user_id;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,ct&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(dt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(lr,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:ms(new Date(Ae.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Ae.zoom_join_url?e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"Registered"}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Ae.id)})})]})}),e.jsx(ws,{value:"attendees",className:"mt-4",children:fe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(oe==null?void 0:oe.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(k==null?void 0:k.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(oe==null?void 0:oe.filter(Ae=>!Ae.user_id).length)>0&&e.jsxs("div",{className:"mb-6 p-4 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Cl,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",oe==null?void 0:oe.filter(Ae=>!Ae.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:oe==null?void 0:oe.filter(Ae=>!Ae.user_id).map(Ae=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:Ae.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ae.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ie(Ae),className:"gap-1",children:[e.jsx(ml,{className:"h-3 w-3"}),"Link to Profile"]})]},Ae.id))})]}),e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Points"})]})}),e.jsx(Bn,{children:oe==null?void 0:oe.filter(Ae=>Ae.user_id).map(Ae=>{var ct,Ue;const rt=((ct=Ae.profiles)==null?void 0:ct.name)||Ae.zoom_name||"Unknown",He=((Ue=Ae.profiles)==null?void 0:Ue.email)||Ae.zoom_email||null;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,Ae.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(dt,{children:He?e.jsxs("a",{href:`mailto:${He}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(lr,{className:"h-3 w-3"}),He]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Ae.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(un,{className:"h-3 w-3"}),Ae.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Ae.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(vo,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Ae.id)})})]})]})})]})]})}),e.jsx(xs,{open:M,onOpenChange:L,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(ml,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Wr,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),P&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:P.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:P.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:X,onChange:Ae=>Y(Ae.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:pe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No profiles found"}):e.jsx("div",{className:"divide-y",children:pe.slice(0,20).map(Ae=>e.jsxs("button",{type:"button",onClick:()=>U(Ae.id),className:It("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===Ae.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Ae.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ae.email})]},Ae.id))})}),P.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oo,{id:"save-alias",checked:B,onCheckedChange:Ae=>V(Ae)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsx(K,{onClick:ke,disabled:!$||Me.isPending,children:Me.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function EVt({selectedKitIds:t,onChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l=[]}=mt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"Linked Toolkits"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(st,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Mr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Al,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search toolkits...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No toolkits found":"All toolkits selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.featured_image_url?e.jsx("img",{src:f.featured_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(Al,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link toolkits that agents can download alongside this template."})]})}const PVt=()=>{const{user:t}=Os(),{toast:s}=Ha(),r=Xt(),[n,a]=uc(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),[f,g]=N.useState(null),[v,_]=N.useState(0),[w,j]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(""),[P,O]=N.useState([]),[$,U]=N.useState(""),[B,V]=N.useState(""),[X,Y]=N.useState(!1),[ee,Q]=N.useState(!1),{data:ce=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:qe,error:at}=await H.from("template_categories").select("*").order("name");if(at)throw at;return qe}}),{data:ne=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:qe,error:at}=await H.from("template_types").select("*").order("name");if(at)throw at;return qe}}),{data:re=[],isLoading:oe}=mt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:qe,error:at}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(at)throw at;const{data:tt,error:Ae}=await H.from("template_links").select("*").order("sort_order");if(Ae)throw Ae;const{data:rt,error:He}=await H.from("template_guides").select("*").order("sort_order");if(He)throw He;return qe.map(Ue=>({...Ue,links:(tt==null?void 0:tt.filter(Ze=>Ze.template_id===Ue.id))||[],guides:(rt==null?void 0:rt.filter(Ze=>Ze.template_id===Ue.id))||[]}))}});N.useEffect(()=>{const qe=n.get("edit");if(qe&&re.length>0){const at=re.find(tt=>tt.id===qe);at&&($e(at),a({},{replace:!0}))}},[re,n]);const fe=Lt({mutationFn:async qe=>{const{data:at,error:tt}=await H.from("template_categories").insert({name:qe}).select().single();if(tt)throw tt;return at},onSuccess:qe=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:qe.id}),U(""),Y(!1),s({title:"Category added"})},onError:qe=>{s({title:"Error adding category",description:qe.message,variant:"destructive"})}}),ge=Lt({mutationFn:async qe=>{const{data:at,error:tt}=await H.from("template_types").insert({name:qe}).select().single();if(tt)throw tt;return at},onSuccess:qe=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:qe.id}),V(""),Q(!1),s({title:"Type added"})},onError:qe=>{s({title:"Error adding type",description:qe.message,variant:"destructive"})}}),ue=Lt({mutationFn:async qe=>{var He;let at=qe.existingImageUrl;if(qe.image){const ct=qe.image.name.split(".").pop(),Ue=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ct}`,{error:Ze}=await H.storage.from("template-previews").upload(Ue,qe.image);if(Ze)throw Ze;const{data:Je}=H.storage.from("template-previews").getPublicUrl(Ue);at=Je.publicUrl}const tt={name:qe.template.name,description:qe.template.description||null,category_id:qe.template.category_id||null,type_id:qe.template.type_id||null,preview_image_url:at,video_url:qe.videoUrl||null,publish_date:qe.template.publish_date?new Date(qe.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Ae=qe.templateId;if(Ae){const{error:ct}=await H.from("canva_templates").update(tt).eq("id",Ae);if(ct)throw ct;const{error:Ue}=await H.from("template_links").delete().eq("template_id",Ae);if(Ue)throw Ue;const Ze=((He=qe.existingGuides)==null?void 0:He.map(et=>et.id).filter(Boolean))||[],Je=qe.template.guides.map(et=>et.id).filter(Boolean),Ge=Ze.filter(et=>!Je.includes(et));Ge.length>0&&await H.from("template_guides").delete().in("id",Ge)}else{const{data:ct,error:Ue}=await H.from("canva_templates").insert(tt).select().single();if(Ue)throw Ue;Ae=ct.id,kVt(qe.template.name,ct.id)}const rt=qe.template.links.filter(ct=>ct.title.trim()&&ct.canva_share_link.trim());if(rt.length>0){const ct=rt.map((Ze,Je)=>({template_id:Ae,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:Je})),{error:Ue}=await H.from("template_links").insert(ct);if(Ue)throw Ue}for(let ct=0;ct0)){const{error:ct}=await H.from("resource_kit_templates").insert(qe.linkedKitIds.map(Ue=>({template_id:Ae,kit_id:Ue})));if(ct)throw ct}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),_e(),l(!1),s({title:i?"Template updated":"Template created"})},onError:qe=>{s({title:"Error saving template",description:qe.message,variant:"destructive"})}}),xe=Lt({mutationFn:async qe=>{const{error:at}=await H.from("canva_templates").delete().eq("id",qe);if(at)throw at},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:qe=>{s({title:"Error deleting template",description:qe.message,variant:"destructive"})}}),_e=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),L(""),c(null),Y(!1),Q(!1),U(""),V(""),g(null),_(0),j(!1),O([])},$e=async qe=>{var tt;c(qe),p({name:qe.name,description:qe.description||"",category_id:qe.category_id||"",type_id:qe.type_id||"",publish_date:qe.publish_date?new Date(qe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:qe.links&&qe.links.length>0?qe.links.map(Ae=>({id:Ae.id,title:Ae.title,canva_share_link:Ae.canva_share_link,sort_order:Ae.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((tt=qe.guides)==null?void 0:tt.map(Ae=>({id:Ae.id,name:Ae.name,file_url:Ae.file_url,file_type:Ae.file_type,file_size:Ae.file_size,sort_order:Ae.sort_order})))||[],video_url:qe.video_url||""}),L(qe.preview_image_url||""),g(null);const{data:at}=await H.from("resource_kit_templates").select("kit_id").eq("template_id",qe.id);O((at||[]).map(Ae=>Ae.kit_id)),l(!0)},Me=qe=>{var tt;const at=(tt=qe.target.files)==null?void 0:tt[0];at&&(S(at),L(URL.createObjectURL(at)))},Ie=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},ke=qe=>{if(u.links.length<=1)return;const at=u.links.filter((tt,Ae)=>Ae!==qe);p({...u,links:at})},pe=(qe,at,tt)=>{const Ae=[...u.links];Ae[qe]={...Ae[qe],[at]:tt},p({...u,links:Ae})},we=qe=>{const at=qe.target.files;if(!at)return;const tt=Array.from(at).map((Ae,rt)=>({name:Ae.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Ae.type,file_size:Ae.size,sort_order:u.guides.length+rt,file:Ae}));p({...u,guides:[...u.guides,...tt]}),qe.target.value=""},Le=qe=>{const at=u.guides.filter((tt,Ae)=>Ae!==qe);p({...u,guides:at})},Qe=(qe,at)=>{const tt=[...u.guides];tt[qe]={...tt[qe],name:at},p({...u,guides:tt})},Te=async()=>{if(!f)return null;j(!0),_(0);try{const{data:qe,error:at}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(at)throw new Error(at.message);const{videoId:tt,libraryId:Ae}=qe,{data:rt,error:He}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(He)throw new Error(He.message);const ct=new XMLHttpRequest;return await new Promise((Ze,Je)=>{ct.upload.addEventListener("progress",Ge=>{if(Ge.lengthComputable){const et=Math.round(Ge.loaded/Ge.total*100);_(et)}}),ct.addEventListener("load",()=>{ct.status>=200&&ct.status<300?Ze():Je(new Error(`Upload failed with status ${ct.status}`))}),ct.addEventListener("error",()=>Je(new Error("Upload failed"))),ct.open("PUT",rt.uploadUrl),ct.setRequestHeader("AccessKey",rt.apiKey),ct.send(f)}),`https://player.mediadelivery.net/embed/${Ae}/${tt}`}catch(qe){return console.error("Bunny upload error:",qe),s({title:"Video upload failed",description:qe instanceof Error?qe.message:"Unknown error",variant:"destructive"}),null}finally{j(!1)}},pt=qe=>{var tt;const at=(tt=qe.target.files)==null?void 0:tt[0];at&&g(at),qe.target.value=""},ye=async qe=>{if(qe.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Ae=>Ae.title.trim()&&Ae.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let tt=u.video_url;if(f){const Ae=await Te();if(!Ae)return;tt=Ae}ue.mutate({template:u,image:k,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:tt,linkedKitIds:P})};return e.jsx(Ts,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Manage Templates",description:"Create and manage Canva templates"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ne.length})})]})]}),e.jsxs(xs,{open:o,onOpenChange:qe=>{l(qe),qe||_e()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:ye,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:u.name,onChange:qe=>p({...u,name:qe.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:u.description,onChange:qe=>p({...u,description:qe}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ie,className:"gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((qe,at)=>e.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:qe.title,onChange:tt=>pe(at,"title",tt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(ze,{value:qe.canva_share_link,onChange:tt=>pe(at,"canva_share_link",tt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>ke(at),children:e.jsx(Mr,{className:"h-4 w-4"})})]},at))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Category"}),X?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:$,onChange:qe=>U(qe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&fe.mutate($.trim()),disabled:fe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Y(!1),U("")},children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.category_id,onValueChange:qe=>p({...u,category_id:qe}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:ce.map(qe=>e.jsx(Mt,{value:qe.id,children:qe.name},qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Type"}),ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:B,onChange:qe=>V(qe.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>B.trim()&&ge.mutate(B.trim()),disabled:ge.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),V("")},children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.type_id,onValueChange:qe=>p({...u,type_id:qe}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsx(Ws,{children:ne.map(qe=>e.jsx(Mt,{value:qe.id,children:qe.name},qe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:qe=>p({...u,publish_date:qe.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[M?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:M,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx(K,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{S(null),L("")},children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsx("div",{className:"w-32 h-24 rounded-lg border-2 border-dashed border-muted-foreground/25 flex items-center justify-center",children:e.jsx(vl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:Me,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Video (Optional)"}),u.video_url&&!f?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Cn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",v,"%"]})]}),e.jsx(Bi,{value:v,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Cn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:f.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(f.size/1024/1024).toFixed(1)," MB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>g(null),children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:"video/*",onChange:pt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(Cn,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Click to upload a video"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a video to embed on the template page (Bunny.net)"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:we,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((qe,at)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(wn,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(ze,{value:qe.name,onChange:tt=>Qe(at,tt.target.value),placeholder:"Guide name",className:"flex-1"}),qe.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(qe.file_size/1024).toFixed(0)," KB"]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Le(at),children:e.jsx(Mr,{className:"h-4 w-4"})})]},qe.id||at))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),e.jsx(EVt,{selectedKitIds:P,onChange:O}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),_e()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ue.isPending,children:ue.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:oe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):re.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:re.map(qe=>{var at,tt,Ae,rt,He;return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:qe.preview_image_url?e.jsx("img",{src:qe.preview_image_url,alt:qe.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(vl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:qe.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(st,{variant:"secondary",children:[((at=qe.links)==null?void 0:at.length)||0," link",(((tt=qe.links)==null?void 0:tt.length)||0)!==1?"s":""]}),(((Ae=qe.guides)==null?void 0:Ae.length)||0)>0&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(wn,{className:"h-3 w-3"}),(rt=qe.guides)==null?void 0:rt.length," guide",(((He=qe.guides)==null?void 0:He.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:qe.category?e.jsx(st,{variant:"secondary",children:qe.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:qe.type?e.jsx(st,{variant:"outline",children:qe.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(qe.publish_date).toLocaleDateString()}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"icon",variant:"ghost",onClick:()=>$e(qe),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&xe.mutate(qe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},qe.id)})})]})})})]})})};function Stt({selectedTemplateIds:t,onChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l=[]}=mt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:g}=await H.from("canva_templates").select("id, name, preview_image_url").order("name");if(g)throw g;return f}}),i=l.filter(f=>t.includes(f.id)),c=l.filter(f=>!t.includes(f.id)&&f.name.toLowerCase().includes(r.toLowerCase())),u=f=>{s([...t,f])},p=f=>{s(t.filter(g=>g!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(dS,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(f=>e.jsxs(st,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Mr,{className:"h-3 w-3"})})]},f.id))}),e.jsxs($o,{open:a,onOpenChange:o,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(dS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(Ro,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search templates...",value:r,onChange:f=>n(f.target.value),className:"pl-7 h-8 text-sm"})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:c.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:r?"No templates found":"All templates selected"}):c.map(f=>e.jsxs("button",{type:"button",onClick:()=>{u(f.id),n("")},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[f.preview_image_url?e.jsx("img",{src:f.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(dS,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("span",{className:"truncate",children:f.name})]},f.id))})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const IVt=[{value:"bunny_stream",label:"Bunny.net Stream (Upload)"},{value:"youtube",label:"YouTube"},{value:"vimeo",label:"Vimeo"},{value:"google_drive",label:"Google Drive"},{value:"amazon_s3",label:"Amazon S3"},{value:"loom",label:"Loom"},{value:"other",label:"Other"}],LVt=()=>{const{user:t}=Os(),[s,r]=uc(),{toast:n}=Ha(),a=Xt(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,g]=N.useState(null),[v,_]=N.useState(""),[w,j]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState([]),[P,O]=N.useState([]),[$,U]=N.useState(""),[B,V]=N.useState(!1),[X,Y]=N.useState(null),[ee,Q]=N.useState(0),[ce,ne]=N.useState(!1),[re,oe]=N.useState(null),{data:fe=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:ye,error:qe}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(qe)throw qe;return ye}}),{data:ge=[],isLoading:ue}=mt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:ye,error:qe}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(qe)throw qe;const{data:at,error:tt}=await H.from("academy_resources").select("*").order("sort_order");if(tt)throw tt;return ye.map(rt=>({...rt,resources:(at==null?void 0:at.filter(He=>He.video_id===rt.id))||[]}))}});N.useEffect(()=>{const ye=s.get("edit");if(ye&&ge.length>0){const qe=ge.find(at=>at.id===ye);qe&&(ke(qe),r({},{replace:!0}))}},[ge,s]);const xe=Lt({mutationFn:async ye=>{const{data:qe,error:at}=await H.from("academy_categories").insert({name:ye,sort_order:fe.length}).select().single();if(at)throw at;return qe},onSuccess:ye=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:ye.id}),U(""),V(!1),n({title:"Category added"})},onError:ye=>{n({title:"Error adding category",description:ye.message,variant:"destructive"})}}),_e=Lt({mutationFn:async ye=>{let qe=ye.existingThumbnailUrl;if(ye.thumbnail){const Ae=ye.thumbnail.name.split(".").pop(),rt=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Ae}`,{error:He}=await H.storage.from("academy-resources").upload(rt,ye.thumbnail);if(He)throw He;const{data:ct}=H.storage.from("academy-resources").getPublicUrl(rt);qe=ct.publicUrl}const at={title:ye.video.title,description:ye.video.description||null,video_url:ye.video.video_url,video_type:ye.video.video_type,duration:ye.video.duration||null,thumbnail_url:qe,category_id:ye.video.category_id||null,publish_date:ye.video.publish_date?new Date(ye.video.publish_date).toISOString():new Date().toISOString(),is_published:ye.video.is_published,created_by:t==null?void 0:t.id};let tt=ye.videoId;if(tt){const{error:Ae}=await H.from("academy_videos").update(at).eq("id",tt);if(Ae)throw Ae}else{const{data:Ae,error:rt}=await H.from("academy_videos").insert(at).select().single();if(rt)throw rt;tt=Ae.id,SVt(ye.video.title,Ae.id)}if(ye.resourcesToDelete.length>0){const{error:Ae}=await H.from("academy_resources").delete().in("id",ye.resourcesToDelete);if(Ae)throw Ae}for(let Ae=0;Ae0){const{error:Ae}=await H.from("academy_video_templates").insert(P.map(rt=>({video_id:tt,template_id:rt})));if(Ae)throw Ae}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ie(),l(!1),n({title:i?"Video updated":"Video created"})},onError:ye=>{n({title:"Error saving video",description:ye.message,variant:"destructive"})}}),$e=Lt({mutationFn:async ye=>{const{error:qe}=await H.from("academy_videos").delete().eq("id",ye);if(qe)throw qe},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:ye=>{n({title:"Error deleting video",description:ye.message,variant:"destructive"})}}),Me=Lt({mutationFn:async({id:ye,is_published:qe})=>{const{error:at}=await H.from("academy_videos").update({is_published:qe}).eq("id",ye);if(at)throw at},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:ye=>{n({title:"Error updating video",description:ye.message,variant:"destructive"})}}),Ie=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),g(null),_(""),j([]),S([]),L([]),c(null),O([]),U(""),Y(null),Q(0),ne(!1),oe(null)},ke=async ye=>{c(ye),p({title:ye.title,description:ye.description||"",video_url:ye.video_url,video_type:ye.video_type,duration:ye.duration||"",category_id:ye.category_id||"",publish_date:ye.publish_date?new Date(ye.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:ye.is_published}),_(ye.thumbnail_url||""),S(ye.resources||[]),j([]),L([]);const{data:qe}=await H.from("academy_video_templates").select("template_id").eq("video_id",ye.id);O((qe||[]).map(at=>at.template_id)),l(!0)},pe=ye=>{var at;const qe=(at=ye.target.files)==null?void 0:at[0];qe&&(g(qe),_(URL.createObjectURL(qe)))},we=ye=>{const qe=ye.target.files;if(qe){const at=Array.from(qe).map(tt=>({file:tt,title:tt.name.replace(/\.[^/.]+$/,"")}));j([...w,...at])}ye.target.value=""},Le=ye=>{j(w.filter((qe,at)=>at!==ye))},Qe=ye=>{L([...M,ye]),S(k.filter(qe=>qe.id!==ye))},Te=async()=>{if(!X)return null;ne(!0),Q(0);try{const{data:ye,error:qe}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||X.name}});if(qe)throw new Error(qe.message);const{videoId:at,libraryId:tt}=ye;oe(at);const{data:Ae,error:rt}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(rt)throw new Error(rt.message);const He=new XMLHttpRequest;return await new Promise((Ue,Ze)=>{He.upload.addEventListener("progress",Je=>{if(Je.lengthComputable){const Ge=Math.round(Je.loaded/Je.total*100);Q(Ge)}}),He.addEventListener("load",()=>{He.status>=200&&He.status<300?Ue():Ze(new Error(`Upload failed with status ${He.status}`))}),He.addEventListener("error",()=>Ze(new Error("Upload failed"))),He.open("PUT",Ae.uploadUrl),He.setRequestHeader("AccessKey",Ae.apiKey),He.send(X)}),`https://player.mediadelivery.net/embed/${tt}/${at}`}catch(ye){return console.error("Bunny upload error:",ye),n({title:"Video upload failed",description:ye instanceof Error?ye.message:"Unknown error",variant:"destructive"}),null}finally{ne(!1)}},pt=async ye=>{if(ye.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let qe=u.video_url;if(u.video_type==="bunny_stream"&&X&&!i){const at=await Te();if(!at)return;qe=at}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!X&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}_e.mutate({video:{...u,video_url:qe},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:M})};return e.jsx(Ts,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Manage Academy",description:"Create and manage training videos and resources"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ge.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ge.filter(ye=>ye.is_published).length})})]})]}),e.jsxs(xs,{open:o,onOpenChange:ye=>{l(ye),ye||Ie()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:pt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:u.title,onChange:ye=>p({...u,title:ye.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:u.description,onChange:ye=>p({...u,description:ye}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video Type"}),e.jsxs(Ks,{value:u.video_type,onValueChange:ye=>{p({...u,video_type:ye,video_url:""}),Y(null)},disabled:ce,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:IVt.map(ye=>e.jsx(Mt,{value:ye.value,children:ye.label},ye.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(be,{children:["Upload Video File ",!i&&"*"]}),i&&u.video_url&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",e.jsx("a",{href:u.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{type:"file",accept:"video/*",onChange:ye=>{var at;const qe=(at=ye.target.files)==null?void 0:at[0];qe&&Y(qe)},disabled:ce}),X&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Cn,{className:"h-4 w-4"}),X.name," (",(X.size/(1024*1024)).toFixed(1)," MB)"]}),ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Bi,{value:ee,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[ee,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(ze,{id:"video_url",value:u.video_url,onChange:ye=>p({...u,video_url:ye.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"duration",children:"Duration"}),e.jsx(ze,{id:"duration",value:u.duration,onChange:ye=>p({...u,duration:ye.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:ye=>p({...u,publish_date:ye.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Category"}),B?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:$,onChange:ye=>U(ye.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&xe.mutate($.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),U("")},children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:u.category_id,onValueChange:ye=>p({...u,category_id:ye}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:fe.map(ye=>e.jsx(Mt,{value:ye.id,children:ye.name},ye.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[v&&e.jsx("img",{src:v,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:pe,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recommended: 16:9 aspect ratio"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Resource Files"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(di,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:we,className:"hidden"})]})})]}),(k.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[k.map(ye=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:ye.title}),e.jsx(st,{variant:"outline",className:"text-xs",children:ye.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Qe(ye.id),className:"text-destructive hover:text-destructive",children:e.jsx(Mr,{className:"h-4 w-4"})})]},ye.id)),w.map((ye,qe)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:ye.title,onChange:at=>{const tt=[...w];tt[qe].title=at.target.value,j(tt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Le(qe),className:"text-destructive hover:text-destructive",children:e.jsx(Mr,{className:"h-4 w-4"})})]},qe))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(Stt,{selectedTemplateIds:P,onChange:O}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_published",checked:u.is_published,onCheckedChange:ye=>p({...u,is_published:ye})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(Un,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_e.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):_e.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:ue?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):ge.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No videos yet"}),e.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Bn,{children:ge.map(ye=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[ye.thumbnail_url?e.jsx("img",{src:ye.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):e.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ye.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:ye.video_type.replace("_"," ")})]})]})}),e.jsx(dt,{children:ye.category?e.jsx(st,{variant:"outline",children:ye.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:ye.duration||"-"}),e.jsx(dt,{children:ye.resources&&ye.resources.length>0?e.jsxs(st,{variant:"secondary",children:[ye.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:new Date(ye.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(qr,{checked:ye.is_published,onCheckedChange:qe=>Me.mutate({id:ye.id,is_published:qe})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ke(ye),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>$e.mutate(ye.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},ye.id))})]})})})]})})};function DVt(){var _e,$e,Me;const t=Xt(),[s,r]=uc(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=N.useState(null),[f,g]=N.useState(""),[v,_]=N.useState([]),[w,j]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState(null),{data:P,isLoading:O}=mt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ie,error:ke}=await H.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(ke)throw ke;return Ie}}),{data:$}=mt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ie,error:ke}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(ke)throw ke;return Ie}}),{data:U}=mt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ie,error:ke}=await H.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(ke)throw ke;return Ie}});N.useEffect(()=>{const Ie=s.get("edit");if(Ie&&P&&P.length>0&&$&&U){const ke=P.find(pe=>pe.id===Ie);ke&&(V(ke),r({},{replace:!0}))}},[P,$,U,s]);const B=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),_([]),j([]),S([]),l(null)},V=async Ie=>{l(Ie),c({name:Ie.name,description:Ie.description||"",publish_date:Ie.publish_date.split("T")[0],is_published:Ie.is_published}),g(Ie.featured_image_url||"");const ke=($==null?void 0:$.filter(Le=>Le.kit_id===Ie.id))||[];_(ke.map(Le=>({id:Le.id,name:Le.name,file_url:Le.file_url,file_type:Le.file_type,file_size:Le.file_size,sort_order:Le.sort_order})));const pe=(U==null?void 0:U.filter(Le=>Le.kit_id===Ie.id))||[];j(pe.map(Le=>({id:Le.id,title:Le.title,canva_share_link:Le.canva_share_link,sort_order:Le.sort_order})));const{data:we}=await H.from("resource_kit_templates").select("template_id").eq("kit_id",Ie.id);S((we||[]).map(Le=>Le.template_id)),a(!0)},X=Ie=>{var pe;const ke=(pe=Ie.target.files)==null?void 0:pe[0];ke&&(p(ke),g(URL.createObjectURL(ke)))},Y=()=>{_([...v,{name:"",file_url:"",sort_order:v.length}])},ee=Ie=>{_(v.filter((ke,pe)=>pe!==Ie))},Q=(Ie,ke,pe)=>{const we=[...v];we[Ie]={...we[Ie],[ke]:pe},_(we)},ce=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},ne=Ie=>{j(w.filter((ke,pe)=>pe!==Ie))},re=(Ie,ke,pe)=>{const we=[...w];we[Ie]={...we[Ie],[ke]:pe},j(we)},oe=(Ie,ke)=>{var we;const pe=(we=ke.target.files)==null?void 0:we[0];if(pe){const Le=[...v],Qe=pe.name.replace(/\.[^/.]+$/,"");Le[Ie]={...Le[Ie],file:pe,file_type:pe.type,file_size:pe.size,name:Le[Ie].name||Qe},_(Le)}},fe=Lt({mutationFn:async()=>{let Ie=(o==null?void 0:o.featured_image_url)||null;if(u){const Qe=u.name.split(".").pop(),Te=`${Date.now()}.${Qe}`,{error:pt}=await H.storage.from("resource-kits").upload(`featured/${Te}`,u);if(pt)throw pt;const{data:ye}=H.storage.from("resource-kits").getPublicUrl(`featured/${Te}`);Ie=ye.publicUrl}const ke={name:i.name,description:i.description||null,featured_image_url:Ie,publish_date:i.publish_date,is_published:i.is_published};let pe;const we=!o,Le=(o==null?void 0:o.is_published)||!1;if(o){const{error:Qe}=await H.from("resource_kits").update(ke).eq("id",o.id);if(Qe)throw Qe;pe=o.id;const Te=($==null?void 0:$.filter(Ae=>Ae.kit_id===o.id).map(Ae=>Ae.id))||[],pt=v.filter(Ae=>Ae.id).map(Ae=>Ae.id),ye=Te.filter(Ae=>!pt.includes(Ae));ye.length>0&&await H.from("resource_kit_files").delete().in("id",ye);const qe=(U==null?void 0:U.filter(Ae=>Ae.kit_id===o.id).map(Ae=>Ae.id))||[],at=w.filter(Ae=>Ae.id).map(Ae=>Ae.id),tt=qe.filter(Ae=>!at.includes(Ae));tt.length>0&&await H.from("resource_kit_links").delete().in("id",tt)}else{const{data:Qe,error:Te}=await H.from("resource_kits").insert(ke).select().single();if(Te)throw Te;pe=Qe.id}for(let Qe=0;Qe0){const{error:Qe}=await H.from("resource_kit_templates").insert(k.map(Te=>({kit_id:pe,template_id:Te})));if(Qe)throw Qe}return{kitId:pe,kitName:i.name,isNewKit:we,wasPublished:Le,isPublished:i.is_published}},onSuccess:Ie=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),me.success(o?"Resource kit updated":"Resource kit created"),Ie.isPublished&&(Ie.isNewKit||!Ie.wasPublished)&&MVt(Ie.kitName,Ie.kitId),a(!1),B()},onError:Ie=>{me.error("Failed to save resource kit: "+Ie.message)}}),ge=Lt({mutationFn:async Ie=>{const{error:ke}=await H.from("resource_kits").delete().eq("id",Ie);if(ke)throw ke},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Ie=>{me.error("Failed to delete: "+Ie.message)}}),ue=Ie=>{if(Ie.preventDefault(),!i.name){me.error("Please enter a name");return}fe.mutate()},xe=Ie=>($==null?void 0:$.filter(ke=>ke.kit_id===Ie).length)||0;return e.jsx(Ts,{title:"Toolbox Management",description:"Create and manage resource kits for agents",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(P==null?void 0:P.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(P==null?void 0:P.filter(Ie=>Ie.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{B(),a(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Files"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:O?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(P==null?void 0:P.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):P==null?void 0:P.map(Ie=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ie.featured_image_url?e.jsx("img",{src:Ie.featured_image_url,alt:Ie.name,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Al,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ie.name}),Ie.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ie.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),xe(Ie.id)]})}),e.jsx(dt,{children:ms(new Date(Ie.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Ie.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Ie.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const ke=($==null?void 0:$.filter(we=>we.kit_id===Ie.id))||[],pe=(U==null?void 0:U.filter(we=>we.kit_id===Ie.id))||[];L({...Ie,files:ke,links:pe})},children:e.jsx(Dn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Ie),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&ge.mutate(Ie.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ie.id))})]})})}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Featured Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[f?e.jsx("img",{src:f,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(Al,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:X})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:Ie=>c({...i,name:Ie.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:i.description,onChange:Ie=>c({...i,description:Ie}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ie=>c({...i,publish_date:Ie.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:i.is_published,onCheckedChange:Ie=>c({...i,is_published:Ie})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Y,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),v.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:v.map((Ie,ke)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["File ",ke+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(ke),children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"File name (e.g., Getting Started Guide)",value:Ie.name,onChange:pe=>Q(ke,"name",pe.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",onChange:pe=>oe(ke,pe),className:"flex-1"}),Ie.file_url&&!Ie.file&&e.jsx("a",{href:Ie.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ie.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},ke))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ce,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Ie,ke)=>e.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Canva Link ",ke+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ne(ke),children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ie.title,onChange:pe=>re(ke,"title",pe.target.value)}),e.jsx(ze,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ie.canva_share_link,onChange:pe=>re(ke,"canva_share_link",pe.target.value)})]},ke))})]}),e.jsx(Stt,{selectedTemplateIds:k,onChange:S}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:fe.isPending,children:fe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(xs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsx(_s,{children:M==null?void 0:M.name})}),e.jsxs("div",{className:"space-y-4",children:[(M==null?void 0:M.featured_image_url)&&e.jsx("img",{src:M.featured_image_url,alt:M.name,className:"w-full h-48 object-cover rounded-lg"}),(M==null?void 0:M.description)&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((_e=M==null?void 0:M.files)==null?void 0:_e.length)||0,")"]}),(($e=M==null?void 0:M.files)==null?void 0:$e.length)===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No files in this kit"}):e.jsx("div",{className:"space-y-2",children:(Me=M==null?void 0:M.files)==null?void 0:Me.map(Ie=>e.jsxs("a",{href:Ie.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(wn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ie.name})]},Ie.id))})]}),(M==null?void 0:M.links)&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.links.map(Ie=>e.jsxs("a",{href:Ie.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(Bo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ie.title})]},Ie.id))})]})]})]})})]})})}const OVt=()=>{const{user:t}=Os(),{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=N.useState(null),[f,g]=N.useState(""),{data:v=[],isLoading:_}=mt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:U,error:B}=await H.from("social_swag").select("*").order("publish_date",{ascending:!1});if(B)throw B;const{data:V,error:X}=await H.from("social_swag_links").select("*").order("sort_order");if(X)throw X;return U.map(ee=>({...ee,links:(V==null?void 0:V.filter(Q=>Q.swag_id===ee.id))||[]}))}}),w=Lt({mutationFn:async U=>{let B=U.existingImageUrl;if(U.image){const ce=U.image.name.split(".").pop(),ne=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ce}`,{error:re}=await H.storage.from("template-previews").upload(ne,U.image);if(re)throw re;const{data:oe}=H.storage.from("template-previews").getPublicUrl(ne);B=oe.publicUrl}const V={title:U.item.title,description:U.item.description||null,preview_image_url:B,publish_date:U.item.publish_date?new Date(U.item.publish_date).toISOString():new Date().toISOString(),is_published:U.item.is_published,created_by:t==null?void 0:t.id};let X=U.itemId;const Y=!X,ee=(o==null?void 0:o.is_published)||!1;if(X){const{error:ce}=await H.from("social_swag").update(V).eq("id",X);if(ce)throw ce;await H.from("social_swag_links").delete().eq("swag_id",X)}else{const{data:ce,error:ne}=await H.from("social_swag").insert(V).select().single();if(ne)throw ne;X=ce.id}const Q=U.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(Q.length>0){const ce=Q.map((re,oe)=>({swag_id:X,title:re.title.trim(),canva_share_link:re.canva_share_link.trim(),sort_order:oe})),{error:ne}=await H.from("social_swag_links").insert(ce);if(ne)throw ne}return{itemId:X,itemTitle:U.item.title,isNewItem:Y,wasPublished:ee,isPublished:U.item.is_published}},onSuccess:U=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),U.isPublished&&(U.isNewItem||!U.wasPublished)&&gbe(U.itemTitle,U.itemId),a(!1),k()},onError:U=>{s({title:"Error saving item",description:U.message,variant:"destructive"})}}),j=Lt({mutationFn:async U=>{const{error:B}=await H.from("social_swag").delete().eq("id",U);if(B)throw B},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:U=>{s({title:"Error deleting item",description:U.message,variant:"destructive"})}}),k=()=>{c({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),g(""),l(null)},S=U=>{l(U),c({title:U.title,description:U.description||"",publish_date:U.publish_date?new Date(U.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:U.is_published,links:U.links&&U.links.length>0?U.links.map(B=>({id:B.id,title:B.title,canva_share_link:B.canva_share_link,sort_order:B.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),g(U.preview_image_url||""),a(!0)},M=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];B&&(p(B),g(URL.createObjectURL(B)))},L=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},P=U=>{if(i.links.length<=1)return;const B=i.links.filter((V,X)=>X!==U);c({...i,links:B})},O=(U,B,V)=>{const X=[...i.links];X[U]={...X[U],[B]:V},c({...i,links:X})},$=U=>{if(U.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ts,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Manage Social Swag",description:"Create and manage social media content"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:v.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:v.filter(U=>U.is_published).length})})]})]}),e.jsxs(xs,{open:n,onOpenChange:U=>{a(U),U||k()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:i.title,onChange:U=>c({...i,title:U.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:i.description,onChange:U=>c({...i,description:U}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:U=>c({...i,publish_date:U.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:U=>c({...i,is_published:U})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),g("")},children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(vl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:L,children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((U,B)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",B+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>P(B),children:e.jsx(Mr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Instagram Post)",value:U.title,onChange:V=>O(B,"title",V.target.value)}),e.jsx(ze,{placeholder:"Canva share link",value:U.canva_share_link,onChange:V=>O(B,"canva_share_link",V.target.value)})]})},B))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):v.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Links"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:v.map(U=>{var B;return e.jsxs(Cs,{children:[e.jsx(dt,{children:U.preview_image_url?e.jsx("img",{src:U.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(vl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:U.title}),e.jsxs(dt,{children:[((B=U.links)==null?void 0:B.length)||0," links"]}),e.jsx(dt,{children:new Date(U.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(st,{variant:U.is_published?"default":"secondary",children:U.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${U.id}`,"_blank"),children:e.jsx(Dn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(U),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&j.mutate(U.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},U.id)})})]})})})]})})};function RVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const nhe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function vE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Yke(t){return"nodeType"in t}function Pp(t){var s,r;return t?vE(t)?t:Yke(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Qke(t){const{Document:s}=Pp(t);return t instanceof s}function dR(t){return vE(t)?!1:t instanceof Pp(t).HTMLElement}function Ctt(t){return t instanceof Pp(t).SVGElement}function bE(t){return t?vE(t)?t.document:Yke(t)?Qke(t)?t:dR(t)||Ctt(t)?t.ownerDocument:document:document:document}const O0=nhe?N.useLayoutEffect:N.useEffect;function Xke(t){const s=N.useRef(t);return O0(()=>{s.current=t}),N.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=N.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function PD(t,s){s===void 0&&(s=[t]);const r=N.useRef(t);return O0(()=>{r.current!==t&&(r.current=t)},s),r}function uR(t,s){const r=N.useRef();return N.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Xle(t){const s=Xke(t),r=N.useRef(null),n=N.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function ybe(t){const s=N.useRef();return N.useEffect(()=>{s.current=t},[t]),s.current}let Wge={};function hR(t,s){return N.useMemo(()=>{if(s)return s;const r=Wge[t]==null?0:Wge[t]+1;return Wge[t]=r,t+"-"+r},[t,s])}function Mtt(t){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a{const i=Object.entries(l);for(const[c,u]of i){const p=o[c];p!=null&&(o[c]=p+t*u)}return o},{...s})}}const uT=Mtt(1),ID=Mtt(-1);function zVt(t){return"clientX"in t&&"clientY"in t}function Jke(t){if(!t)return!1;const{KeyboardEvent:s}=Pp(t.target);return s&&t instanceof s}function BVt(t){if(!t)return!1;const{TouchEvent:s}=Pp(t.target);return s&&t instanceof s}function vbe(t){if(BVt(t)){if(t.touches&&t.touches.length){const{clientX:s,clientY:r}=t.touches[0];return{x:s,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:s,clientY:r}=t.changedTouches[0];return{x:s,y:r}}}return zVt(t)?{x:t.clientX,y:t.clientY}:null}const a3=Object.freeze({Translate:{toString(t){if(!t)return;const{x:s,y:r}=t;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:s,scaleY:r}=t;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[a3.Translate.toString(t),a3.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),P8e="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function $Vt(t){return t.matches(P8e)?t:t.querySelector(P8e)}const qVt={display:"none"};function UVt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:qVt},r)}function VVt(t){let{id:s,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ht.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function HVt(){const[t,s]=N.useState("");return{announce:N.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const Ttt=N.createContext(null);function GVt(t){const s=N.useContext(Ttt);N.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function WVt(){const[t]=N.useState(()=>new Set),s=N.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[N.useCallback(n=>{let{type:a,event:o}=n;t.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[t]),s]}const KVt={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. `},ZVt={onDragStart(t){let{active:s}=t;return"Picked up draggable item "+s.id+"."},onDragOver(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(t){let{active:s,over:r}=t;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(t){let{active:s}=t;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function YVt(t){let{announcements:s=ZVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=KVt}=t;const{announce:o,announcement:l}=HVt(),i=hR("DndLiveRegion"),[c,u]=N.useState(!1);if(N.useEffect(()=>{u(!0)},[]),GVt(N.useMemo(()=>({onDragStart(f){let{active:g}=f;o(s.onDragStart({active:g}))},onDragMove(f){let{active:g,over:v}=f;s.onDragMove&&o(s.onDragMove({active:g,over:v}))},onDragOver(f){let{active:g,over:v}=f;o(s.onDragOver({active:g,over:v}))},onDragEnd(f){let{active:g,over:v}=f;o(s.onDragEnd({active:g,over:v}))},onDragCancel(f){let{active:g,over:v}=f;o(s.onDragCancel({active:g,over:v}))}}),[o,s])),!c)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(UVt,{id:n,value:a.draggable}),ht.createElement(VVt,{id:i,announcement:l}));return r?yp.createPortal(p,r):p}var vu;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(vu||(vu={}));function Jle(){}function ece(t,s){return N.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function e4e(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const hy=Object.freeze({x:0,y:0});function Att(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function Ett(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function QVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function I8e(t){let{left:s,top:r,height:n,width:a}=t;return[{x:s,y:r},{x:s+a,y:r},{x:s,y:r+n},{x:s+a,y:r+n}]}function Ptt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function L8e(t,s,r){return s===void 0&&(s=t.left),r===void 0&&(r=t.top),{x:s+t.width*.5,y:r+t.height*.5}}const t4e=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=L8e(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=Att(L8e(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(Ett)},XVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=I8e(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=I8e(c),p=a.reduce((g,v,_)=>g+Att(u[_],v),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(Ett)};function JVt(t,s){const r=Math.max(s.top,t.top),n=Math.max(s.left,t.left),a=Math.min(s.left+s.width,t.left+t.width),o=Math.min(s.top+s.height,t.top+t.height),l=a-n,i=o-r;if(n{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=[];for(const o of n){const{id:l}=o,i=r.get(l);if(i){const c=JVt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(QVt)};function tHt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Itt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:hy}function sHt(t){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o({...l,top:l.top+t*i.y,bottom:l.bottom+t*i.y,left:l.left+t*i.x,right:l.right+t*i.x}),{...r})}}const rHt=sHt(1);function nHt(t){if(t.startsWith("matrix3d(")){const s=t.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(t.startsWith("matrix(")){const s=t.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function aHt(t,s,r){const n=nHt(s);if(!n)return t;const{scaleX:a,scaleY:o,x:l,y:i}=n,c=t.left-l-(1-a)*parseFloat(r),u=t.top-i-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),p=a?t.width/a:t.width,f=o?t.height/o:t.height;return{width:p,height:f,top:u,right:c+p,bottom:u+f,left:c}}const iHt={ignoreTransform:!1};function _E(t,s){s===void 0&&(s=iHt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Pp(t).getComputedStyle(t);u&&(r=aHt(r,u,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:c}=r;return{top:n,left:a,width:o,height:l,bottom:i,right:c}}function D8e(t){return _E(t,{ignoreTransform:!0})}function oHt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function lHt(t,s){return s===void 0&&(s=Pp(t).getComputedStyle(t)),s.position==="fixed"}function cHt(t,s){s===void 0&&(s=Pp(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=s[a];return typeof o=="string"?r.test(o):!1})}function ahe(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(Qke(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!dR(a)||Ctt(a)||r.includes(a))return r;const o=Pp(t).getComputedStyle(a);return a!==t&&cHt(a,o)&&r.push(a),lHt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Ltt(t){const[s]=ahe(t,1);return s??null}function Kge(t){return!nhe||!t?null:vE(t)?t:Yke(t)?Qke(t)||t===bE(t).scrollingElement?window:dR(t)?t:null:null}function Dtt(t){return vE(t)?t.scrollX:t.scrollLeft}function Ott(t){return vE(t)?t.scrollY:t.scrollTop}function bbe(t){return{x:Dtt(t),y:Ott(t)}}var Ku;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ku||(Ku={}));function Rtt(t){return!nhe||!t?!1:t===document.scrollingElement}function Ftt(t){const s={x:0,y:0},r=Rtt(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},a=t.scrollTop<=s.y,o=t.scrollLeft<=s.x,l=t.scrollTop>=n.y,i=t.scrollLeft>=n.x;return{isTop:a,isLeft:o,isBottom:l,isRight:i,maxScroll:n,minScroll:s}}const dHt={x:.2,y:.2};function uHt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=dHt);const{isTop:u,isBottom:p,isLeft:f,isRight:g}=Ftt(t),v={x:0,y:0},_={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+w.height?(v.y=Ku.Backward,_.y=n*Math.abs((s.top+w.height-o)/w.height)):!p&&c>=s.bottom-w.height&&(v.y=Ku.Forward,_.y=n*Math.abs((s.bottom-w.height-c)/w.height)),!g&&i>=s.right-w.width?(v.x=Ku.Forward,_.x=n*Math.abs((s.right-w.width-i)/w.width)):!f&&l<=s.left+w.width&&(v.x=Ku.Backward,_.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:v,speed:_}}function hHt(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:s,left:r,right:n,bottom:a}=t.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:t.clientWidth,height:t.clientHeight}}function ztt(t){return t.reduce((s,r)=>uT(s,bbe(r)),hy)}function mHt(t){return t.reduce((s,r)=>s+Dtt(r),0)}function pHt(t){return t.reduce((s,r)=>s+Ott(r),0)}function fHt(t,s){if(s===void 0&&(s=_E),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);Ltt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const xHt=[["x",["left","right"],mHt],["y",["top","bottom"],pHt]];class s4e{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=ahe(r),a=ztt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of xHt)for(const c of l)Object.defineProperty(this,c,{get:()=>{const u=i(n),p=a[o]-u;return this.rect[c]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class w8{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var a;(a=this.target)==null||a.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function gHt(t){const{EventTarget:s}=Pp(t);return t instanceof s?t:bE(t)}function Zge(t,s){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var hx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(hx||(hx={}));function O8e(t){t.preventDefault()}function yHt(t){t.stopPropagation()}var Ao;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Ao||(Ao={}));const Btt={start:[Ao.Space,Ao.Enter],cancel:[Ao.Esc],end:[Ao.Space,Ao.Enter,Ao.Tab]},vHt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case Ao.Right:return{...r,x:r.x+25};case Ao.Left:return{...r,x:r.x-25};case Ao.Down:return{...r,y:r.y+25};case Ao.Up:return{...r,y:r.y-25}}};class r4e{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new w8(bE(r)),this.windowListeners=new w8(Pp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(hx.Resize,this.handleCancel),this.windowListeners.add(hx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(hx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&fHt(n),r(hy)}handleKeyDown(s){if(Jke(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Btt,coordinateGetter:l=vHt,scrollBehavior:i="smooth"}=a,{code:c}=s;if(o.end.includes(c)){this.handleEnd(s);return}if(o.cancel.includes(c)){this.handleCancel(s);return}const{collisionRect:u}=n.current,p=u?{x:u.left,y:u.top}:hy;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const g=ID(f,p),v={x:0,y:0},{scrollableAncestors:_}=n.current;for(const w of _){const j=s.code,{isTop:k,isRight:S,isLeft:M,isBottom:L,maxScroll:P,minScroll:O}=Ftt(w),$=hHt(w),U={x:Math.min(j===Ao.Right?$.right-$.width/2:$.right,Math.max(j===Ao.Right?$.left:$.left+$.width/2,f.x)),y:Math.min(j===Ao.Down?$.bottom-$.height/2:$.bottom,Math.max(j===Ao.Down?$.top:$.top+$.height/2,f.y))},B=j===Ao.Right&&!S||j===Ao.Left&&!M,V=j===Ao.Down&&!L||j===Ao.Up&&!k;if(B&&U.x!==f.x){const X=w.scrollLeft+g.x,Y=j===Ao.Right&&X<=P.x||j===Ao.Left&&X>=O.x;if(Y&&!g.y){w.scrollTo({left:X,behavior:i});return}Y?v.x=w.scrollLeft-X:v.x=j===Ao.Right?w.scrollLeft-P.x:w.scrollLeft-O.x,v.x&&w.scrollBy({left:-v.x,behavior:i});break}else if(V&&U.y!==f.y){const X=w.scrollTop+g.y,Y=j===Ao.Down&&X<=P.y||j===Ao.Up&&X>=O.y;if(Y&&!g.x){w.scrollTo({top:X,behavior:i});return}Y?v.y=w.scrollTop-X:v.y=j===Ao.Down?w.scrollTop-P.y:w.scrollTop-O.y,v.y&&w.scrollBy({top:-v.y,behavior:i});break}}this.handleMove(s,uT(ID(f,this.referenceCoordinates),v))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}r4e.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Btt,onActivation:a}=s,{active:o}=r;const{code:l}=t.nativeEvent;if(n.start.includes(l)){const i=o.activatorNode.current;return i&&t.target!==i?!1:(t.preventDefault(),a==null||a({event:t.nativeEvent}),!0)}return!1}}];function R8e(t){return!!(t&&"distance"in t)}function F8e(t){return!!(t&&"delay"in t)}class n4e{constructor(s,r,n){var a;n===void 0&&(n=gHt(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:o}=s,{target:l}=o;this.props=s,this.events=r,this.document=bE(l),this.documentListeners=new w8(this.document),this.listeners=new w8(n),this.windowListeners=new w8(Pp(l)),this.initialCoordinates=(a=vbe(o))!=null?a:hy,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(hx.Resize,this.handleCancel),this.windowListeners.add(hx.DragStart,O8e),this.windowListeners.add(hx.VisibilityChange,this.handleCancel),this.windowListeners.add(hx.ContextMenu,O8e),this.documentListeners.add(hx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(F8e(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(R8e(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(hx.Click,yHt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(hx.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const c=(r=vbe(s))!=null?r:hy,u=ID(a,c);if(!n&&i){if(R8e(i)){if(i.tolerance!=null&&Zge(u,i.tolerance))return this.handleCancel();if(Zge(u,i.distance))return this.handleStart()}if(F8e(i)&&Zge(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}s.cancelable&&s.preventDefault(),l(c)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ao.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const bHt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class mR extends n4e{constructor(s){const{event:r}=s,n=bE(r.target);super(s,bHt,n)}}mR.activators=[{eventName:"onPointerDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const _Ht={move:{name:"mousemove"},end:{name:"mouseup"}};var _be;(function(t){t[t.RightClick=2]="RightClick"})(_be||(_be={}));class wHt extends n4e{constructor(s){super(s,_Ht,bE(s.event.target))}}wHt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===_be.RightClick?!1:(n==null||n({event:r}),!0)}}];const Yge={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class jHt extends n4e{constructor(s){super(s,Yge)}static setup(){return window.addEventListener(Yge.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Yge.move.name,s)};function s(){}}}jHt.activators=[{eventName:"onTouchStart",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;const{touches:a}=r;return a.length>1?!1:(n==null||n({event:r}),!0)}}];var j8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(j8||(j8={}));var tce;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(tce||(tce={}));function NHt(t){let{acceleration:s,activator:r=j8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=tce.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:g}=t;const v=SHt({delta:f,disabled:!o}),[_,w]=FVt(),j=N.useRef({x:0,y:0}),k=N.useRef({x:0,y:0}),S=N.useMemo(()=>{switch(r){case j8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case j8.DraggableRect:return a}},[r,a,c]),M=N.useRef(null),L=N.useCallback(()=>{const O=M.current;if(!O)return;const $=j.current.x*k.current.x,U=j.current.y*k.current.y;O.scrollBy($,U)},[]),P=N.useMemo(()=>i===tce.TreeOrder?[...u].reverse():u,[i,u]);N.useEffect(()=>{if(!o||!u.length||!S){w();return}for(const O of P){if((n==null?void 0:n(O))===!1)continue;const $=u.indexOf(O),U=p[$];if(!U)continue;const{direction:B,speed:V}=uHt(O,U,S,s,g);for(const X of["x","y"])v[X][B[X]]||(V[X]=0,B[X]=0);if(V.x>0||V.y>0){w(),M.current=O,_(L,l),j.current=V,k.current=B;return}}j.current={x:0,y:0},k.current={x:0,y:0},w()},[s,L,n,w,o,l,JSON.stringify(S),JSON.stringify(v),_,u,P,p,JSON.stringify(g)])}const kHt={x:{[Ku.Backward]:!1,[Ku.Forward]:!1},y:{[Ku.Backward]:!1,[Ku.Forward]:!1}};function SHt(t){let{delta:s,disabled:r}=t;const n=ybe(s);return uR(a=>{if(r||!n||!a)return kHt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Ku.Backward]:a.x[Ku.Backward]||o.x===-1,[Ku.Forward]:a.x[Ku.Forward]||o.x===1},y:{[Ku.Backward]:a.y[Ku.Backward]||o.y===-1,[Ku.Forward]:a.y[Ku.Forward]||o.y===1}}},[r,s,n])}function CHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return uR(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function MHt(t,s){return N.useMemo(()=>t.reduce((r,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:s(l.handler,n)}));return[...r,...o]},[]),[t,s])}var LD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(LD||(LD={}));var wbe;(function(t){t.Optimized="optimized"})(wbe||(wbe={}));const z8e=new Map;function THt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=N.useState(null),{frequency:i,measure:c,strategy:u}=a,p=N.useRef(t),f=j(),g=PD(f),v=N.useCallback(function(k){k===void 0&&(k=[]),!g.current&&l(S=>S===null?k:S.concat(k.filter(M=>!S.includes(M))))},[g]),_=N.useRef(null),w=uR(k=>{if(f&&!r)return z8e;if(!k||k===z8e||p.current!==t||o!=null){const S=new Map;for(let M of t){if(!M)continue;if(o&&o.length>0&&!o.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const L=M.node.current,P=L?new s4e(c(L),L):null;M.rect.current=P,P&&S.set(M.id,P)}return S}return k},[t,o,r,f,c]);return N.useEffect(()=>{p.current=t},[t]),N.useEffect(()=>{f||v()},[r,f]),N.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),N.useEffect(()=>{f||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{v(),_.current=null},i))},[i,f,v,...n]),{droppableRects:w,measureDroppableContainers:v,measuringScheduled:o!=null};function j(){switch(u){case LD.Always:return!1;case LD.BeforeDragging:return r;default:return!r}}}function $tt(t,s){return uR(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function AHt(t,s){return $tt(t,s)}function EHt(t){let{callback:s,disabled:r}=t;const n=Xke(s),a=N.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return N.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function ihe(t){let{callback:s,disabled:r}=t;const n=Xke(s),a=N.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return N.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function PHt(t){return new s4e(_E(t),t)}function B8e(t,s,r){s===void 0&&(s=PHt);const[n,a]=N.useState(null);function o(){a(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??r)!=null?u:null}const p=s(t);return JSON.stringify(c)===JSON.stringify(p)?c:p})}const l=EHt({callback(c){if(t)for(const u of c){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),i=ihe({callback:o});return O0(()=>{o(),t?(i==null||i.observe(t),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),l==null||l.disconnect())},[t]),n}function IHt(t){const s=$tt(t);return Itt(t,s)}const $8e=[];function LHt(t){const s=N.useRef(t),r=uR(n=>t?n&&n!==$8e&&t&&s.current&&t.parentNode===s.current.parentNode?n:ahe(t):$8e,[t]);return N.useEffect(()=>{s.current=t},[t]),r}function DHt(t){const[s,r]=N.useState(null),n=N.useRef(t),a=N.useCallback(o=>{const l=Kge(o.target);l&&r(i=>i?(i.set(l,bbe(l)),new Map(i)):null)},[]);return N.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=Kge(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,bbe(u)]):null}).filter(c=>c!=null);r(i.length?new Map(i):null),n.current=t}return()=>{l(t),l(o)};function l(i){i.forEach(c=>{const u=Kge(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),N.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>uT(o,l),hy):ztt(t):hy,[t,s])}function q8e(t,s){s===void 0&&(s=[]);const r=N.useRef(null);return N.useEffect(()=>{r.current=null},s),N.useEffect(()=>{const n=t!==hy;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?ID(t,r.current):hy}function OHt(t){N.useEffect(()=>{if(!nhe)return;const s=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r==null||r()}},t.map(s=>{let{sensor:r}=s;return r}))}function RHt(t,s){return N.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function qtt(t){return N.useMemo(()=>t?oHt(t):null,[t])}const U8e=[];function FHt(t,s){s===void 0&&(s=_E);const[r]=t,n=qtt(r?Pp(r):null),[a,o]=N.useState(U8e);function l(){o(()=>t.length?t.map(c=>Rtt(c)?n:new s4e(s(c),c)):U8e)}const i=ihe({callback:l});return O0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function zHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return dR(s)?s:t}function BHt(t){let{measure:s}=t;const[r,n]=N.useState(null),a=N.useCallback(u=>{for(const{target:p}of u)if(dR(p)){n(f=>{const g=s(p);return f?{...f,width:g.width,height:g.height}:g});break}},[s]),o=ihe({callback:a}),l=N.useCallback(u=>{const p=zHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,c]=Xle(l);return N.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const $Ht=[{sensor:mR,options:{}},{sensor:r4e,options:{}}],qHt={current:{}},Uie={draggable:{measure:D8e},droppable:{measure:D8e,strategy:LD.WhileDragging,frequency:wbe.Optimized},dragOverlay:{measure:_E}};class N8 extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const UHt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new N8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jle},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Uie,measureDroppableContainers:Jle,windowRect:null,measuringScheduled:!1},VHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jle,draggableNodes:new Map,over:null,measureDroppableContainers:Jle},ohe=N.createContext(VHt),Utt=N.createContext(UHt);function HHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new N8}}}function GHt(t,s){switch(s.type){case vu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case vu.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:s.coordinates.x-t.draggable.initialCoordinates.x,y:s.coordinates.y-t.draggable.initialCoordinates.y}}};case vu.DragEnd:case vu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case vu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new N8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case vu.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=s,o=t.droppable.containers.get(r);if(!o||n!==o.key)return t;const l=new N8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case vu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new N8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function WHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=N.useContext(ohe),o=ybe(n),l=ybe(r==null?void 0:r.id);return N.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!Jke(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:c,node:u}=i;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[c.current,u.current]){if(!p)continue;const f=$Vt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function KHt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function ZHt(t){return N.useMemo(()=>({draggable:{...Uie.draggable,...t==null?void 0:t.draggable},droppable:{...Uie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Uie.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function YHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=N.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;O0(()=>{if(!l&&!i||!s){o.current=!1;return}if(o.current||!n)return;const u=s==null?void 0:s.node.current;if(!u||u.isConnected===!1)return;const p=r(u),f=Itt(p,n);if(l||(f.x=0),i||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Ltt(u);g&&g.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const Vtt=N.createContext({...hy,scaleX:1,scaleY:1});var a_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(a_||(a_={}));const a4e=N.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:p=$Ht,collisionDetection:f=eHt,measuring:g,modifiers:v,..._}=s;const w=N.useReducer(GHt,void 0,HHt),[j,k]=w,[S,M]=WVt(),[L,P]=N.useState(a_.Uninitialized),O=L===a_.Initialized,{draggable:{active:$,nodes:U,translate:B},droppable:{containers:V}}=j,X=$!=null?U.get($):null,Y=N.useRef({initial:null,translated:null}),ee=N.useMemo(()=>{var Ia;return $!=null?{id:$,data:(Ia=X==null?void 0:X.data)!=null?Ia:qHt,rect:Y}:null},[$,X]),Q=N.useRef(null),[ce,ne]=N.useState(null),[re,oe]=N.useState(null),fe=PD(_,Object.values(_)),ge=hR("DndDescribedBy",l),ue=N.useMemo(()=>V.getEnabled(),[V]),xe=ZHt(g),{droppableRects:_e,measureDroppableContainers:$e,measuringScheduled:Me}=THt(ue,{dragging:O,dependencies:[B.x,B.y],config:xe.droppable}),Ie=CHt(U,$),ke=N.useMemo(()=>re?vbe(re):null,[re]),pe=Si(),we=AHt(Ie,xe.draggable.measure);YHt({activeNode:$!=null?U.get($):null,config:pe.layoutShiftCompensation,initialRect:we,measure:xe.draggable.measure});const Le=B8e(Ie,xe.draggable.measure,we),Qe=B8e(Ie?Ie.parentElement:null),Te=N.useRef({activatorEvent:null,active:null,activeNode:Ie,collisionRect:null,collisions:null,droppableRects:_e,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pt=V.getNodeFor((r=Te.current.over)==null?void 0:r.id),ye=BHt({measure:xe.dragOverlay.measure}),qe=(n=ye.nodeRef.current)!=null?n:Ie,at=O?(a=ye.rect)!=null?a:Le:null,tt=!!(ye.nodeRef.current&&ye.rect),Ae=IHt(tt?null:Le),rt=qtt(qe?Pp(qe):null),He=LHt(O?pt??Ie:null),ct=FHt(He),Ue=KHt(v,{transform:{x:B.x-Ae.x,y:B.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:re,active:ee,activeNodeRect:Le,containerNodeRect:Qe,draggingNodeRect:at,over:Te.current.over,overlayNodeRect:ye.rect,scrollableAncestors:He,scrollableAncestorRects:ct,windowRect:rt}),Ze=ke?uT(ke,B):null,Je=DHt(He),Ge=q8e(Je),et=q8e(Je,[Le]),it=uT(Ue,Ge),Dt=at?rHt(at,Ue):null,Vt=ee&&Dt?f({active:ee,collisionRect:Dt,droppableRects:_e,droppableContainers:ue,pointerCoordinates:Ze}):null,hs=Ptt(Vt,"id"),[As,Ms]=N.useState(null),cs=tt?Ue:uT(Ue,et),er=tHt(cs,(o=As==null?void 0:As.rect)!=null?o:null,Le),xt=N.useRef(null),Ps=N.useCallback((Ia,ur)=>{let{sensor:Jr,options:Gr}=ur;if(Q.current==null)return;const mn=U.get(Q.current);if(!mn)return;const Yr=Ia.nativeEvent,bi=new Jr({active:Q.current,activeNode:mn,event:Yr,options:Gr,context:Te,onAbort(or){if(!U.get(or))return;const{onDragAbort:Sr}=fe.current,jr={id:or};Sr==null||Sr(jr),S({type:"onDragAbort",event:jr})},onPending(or,Vn,Sr,jr){if(!U.get(or))return;const{onDragPending:La}=fe.current,Ii={id:or,constraint:Vn,initialCoordinates:Sr,offset:jr};La==null||La(Ii),S({type:"onDragPending",event:Ii})},onStart(or){const Vn=Q.current;if(Vn==null)return;const Sr=U.get(Vn);if(!Sr)return;const{onDragStart:jr}=fe.current,ea={activatorEvent:Yr,active:{id:Vn,data:Sr.data,rect:Y}};yp.unstable_batchedUpdates(()=>{jr==null||jr(ea),P(a_.Initializing),k({type:vu.DragStart,initialCoordinates:or,active:Vn}),S({type:"onDragStart",event:ea}),ne(xt.current),oe(Yr)})},onMove(or){k({type:vu.DragMove,coordinates:or})},onEnd:ft(vu.DragEnd),onCancel:ft(vu.DragCancel)});xt.current=bi;function ft(or){return async function(){const{active:Sr,collisions:jr,over:ea,scrollAdjustedTranslate:La}=Te.current;let Ii=null;if(Sr&&La){const{cancelDrop:Fo}=fe.current;Ii={activatorEvent:Yr,active:Sr,collisions:jr,delta:La,over:ea},or===vu.DragEnd&&typeof Fo=="function"&&await Promise.resolve(Fo(Ii))&&(or=vu.DragCancel)}Q.current=null,yp.unstable_batchedUpdates(()=>{k({type:or}),P(a_.Uninitialized),Ms(null),ne(null),oe(null),xt.current=null;const Fo=or===vu.DragEnd?"onDragEnd":"onDragCancel";if(Ii){const $t=fe.current[Fo];$t==null||$t(Ii),S({type:Fo,event:Ii})}})}}},[U]),mr=N.useCallback((Ia,ur)=>(Jr,Gr)=>{const mn=Jr.nativeEvent,Yr=U.get(Gr);if(Q.current!==null||!Yr||mn.dndKit||mn.defaultPrevented)return;const bi={active:Yr};Ia(Jr,ur.options,bi)===!0&&(mn.dndKit={capturedBy:ur.sensor},Q.current=Gr,Ps(Jr,ur))},[U,Ps]),Tr=MHt(p,mr);OHt(p),O0(()=>{Le&&L===a_.Initializing&&P(a_.Initialized)},[Le,L]),N.useEffect(()=>{const{onDragMove:Ia}=fe.current,{active:ur,activatorEvent:Jr,collisions:Gr,over:mn}=Te.current;if(!ur||!Jr)return;const Yr={active:ur,activatorEvent:Jr,collisions:Gr,delta:{x:it.x,y:it.y},over:mn};yp.unstable_batchedUpdates(()=>{Ia==null||Ia(Yr),S({type:"onDragMove",event:Yr})})},[it.x,it.y]),N.useEffect(()=>{const{active:Ia,activatorEvent:ur,collisions:Jr,droppableContainers:Gr,scrollAdjustedTranslate:mn}=Te.current;if(!Ia||Q.current==null||!ur||!mn)return;const{onDragOver:Yr}=fe.current,bi=Gr.get(hs),ft=bi&&bi.rect.current?{id:bi.id,rect:bi.rect.current,data:bi.data,disabled:bi.disabled}:null,or={active:Ia,activatorEvent:ur,collisions:Jr,delta:{x:mn.x,y:mn.y},over:ft};yp.unstable_batchedUpdates(()=>{Ms(ft),Yr==null||Yr(or),S({type:"onDragOver",event:or})})},[hs]),O0(()=>{Te.current={activatorEvent:re,active:ee,activeNode:Ie,collisionRect:Dt,collisions:Vt,droppableRects:_e,draggableNodes:U,draggingNode:qe,draggingNodeRect:at,droppableContainers:V,over:As,scrollableAncestors:He,scrollAdjustedTranslate:it},Y.current={initial:at,translated:Dt}},[ee,Ie,Vt,Dt,U,qe,at,_e,V,As,He,it]),NHt({...pe,delta:B,draggingRect:Dt,pointerCoordinates:Ze,scrollableAncestors:He,scrollableAncestorRects:ct});const Dr=N.useMemo(()=>({active:ee,activeNode:Ie,activeNodeRect:Le,activatorEvent:re,collisions:Vt,containerNodeRect:Qe,dragOverlay:ye,draggableNodes:U,droppableContainers:V,droppableRects:_e,over:As,measureDroppableContainers:$e,scrollableAncestors:He,scrollableAncestorRects:ct,measuringConfiguration:xe,measuringScheduled:Me,windowRect:rt}),[ee,Ie,Le,re,Vt,Qe,ye,U,V,_e,As,$e,He,ct,xe,Me,rt]),xn=N.useMemo(()=>({activatorEvent:re,activators:Tr,active:ee,activeNodeRect:Le,ariaDescribedById:{draggable:ge},dispatch:k,draggableNodes:U,over:As,measureDroppableContainers:$e}),[re,Tr,ee,Le,k,ge,U,As,$e]);return ht.createElement(Ttt.Provider,{value:M},ht.createElement(ohe.Provider,{value:xn},ht.createElement(Utt.Provider,{value:Dr},ht.createElement(Vtt.Provider,{value:er},u)),ht.createElement(WHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(YVt,{...i,hiddenTextDescribedById:ge}));function Si(){const Ia=(ce==null?void 0:ce.autoScrollEnabled)===!1,ur=typeof c=="object"?c.enabled===!1:c===!1,Jr=O&&!Ia&&!ur;return typeof c=="object"?{...c,enabled:Jr}:{enabled:Jr}}}),QHt=N.createContext(null),V8e="button",XHt="Draggable";function JHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=hR(XHt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:g}=N.useContext(ohe),{role:v=V8e,roleDescription:_="draggable",tabIndex:w=0}=a??{},j=(c==null?void 0:c.id)===s,k=N.useContext(j?Vtt:QHt),[S,M]=Xle(),[L,P]=Xle(),O=RHt(l,s),$=PD(r);O0(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:L,data:$}),()=>{const B=f.get(s);B&&B.key===o&&f.delete(s)}),[f,s]);const U=N.useMemo(()=>({role:v,tabIndex:w,"aria-disabled":n,"aria-pressed":j&&v===V8e?!0:void 0,"aria-roledescription":_,"aria-describedby":p.draggable}),[n,v,w,j,_,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:U,isDragging:j,listeners:n?void 0:O,node:S,over:g,setNodeRef:M,setActivatorNodeRef:P,transform:k}}function eGt(){return N.useContext(Utt)}const tGt="Droppable",sGt={timeout:25};function rGt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=hR(tGt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=N.useContext(ohe),p=N.useRef({disabled:r}),f=N.useRef(!1),g=N.useRef(null),v=N.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:j}={...sGt,...a},k=PD(w??n),S=N.useCallback(()=>{if(!f.current){f.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{u(Array.isArray(k.current)?k.current:[k.current]),v.current=null},j)},[j]),M=ihe({callback:S,disabled:_||!l}),L=N.useCallback((U,B)=>{M&&(B&&(M.unobserve(B),f.current=!1),U&&M.observe(U))},[M]),[P,O]=Xle(L),$=PD(s);return N.useEffect(()=>{!M||!P.current||(M.disconnect(),f.current=!1,M.observe(P.current))},[P,M]),N.useEffect(()=>(i({type:vu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:P,rect:g,data:$}}),()=>i({type:vu.UnregisterDroppable,key:o,id:n})),[n]),N.useEffect(()=>{r!==p.current.disabled&&(i({type:vu.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:g,isOver:(c==null?void 0:c.id)===n,node:P,over:c,setNodeRef:O}}function i4e(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function nGt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Bz(t){return t!==null&&t>=0}function aGt(t,s){if(t===s)return!0;if(t.length!==s.length)return!1;for(let r=0;r{var s;let{rects:r,activeNodeRect:n,activeIndex:a,overIndex:o,index:l}=t;const i=(s=r[a])!=null?s:n;if(!i)return null;const c=oGt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...$z}:l=o?{x:i.width+c,y:0,...$z}:{x:0,y:0,...$z}};function oGt(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return!n||!a&&!o?0:r{let{rects:s,activeIndex:r,overIndex:n,index:a}=t;const o=i4e(s,n,r),l=s[a],i=o[a];return!i||!l?null:{x:i.left-l.left,y:i.top-l.top,scaleX:i.width/l.width,scaleY:i.height/l.height}},qz={scaleX:1,scaleY:1},eAs=t=>{var s;let{activeIndex:r,activeNodeRect:n,index:a,rects:o,overIndex:l}=t;const i=(s=o[r])!=null?s:n;if(!i)return null;if(a===r){const u=o[l];return u?{x:0,y:rr&&a<=l?{x:0,y:-i.height-c,...qz}:a=l?{x:0,y:i.height+c,...qz}:{x:0,y:0,...qz}};function lGt(t,s,r){const n=t[s],a=t[s-1],o=t[s+1];return n?rn.map(O=>typeof O=="object"&&"id"in O?O.id:O),[n]),_=l!=null,w=l?v.indexOf(l.id):-1,j=u?v.indexOf(u.id):-1,k=N.useRef(v),S=!aGt(v,k.current),M=j!==-1&&w===-1||S,L=iGt(o);O0(()=>{S&&_&&p(v)},[S,v,_,p]),N.useEffect(()=>{k.current=v},[v]);const P=N.useMemo(()=>({activeIndex:w,containerId:f,disabled:L,disableTransforms:M,items:v,overIndex:j,useDragOverlay:g,sortedRects:nGt(v,c),strategy:a}),[w,f,L.draggable,L.droppable,M,v,j,c,g,a]);return ht.createElement(Gtt.Provider,{value:P},s)}const cGt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return i4e(r,n,a).indexOf(s)},dGt=t=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:c,transition:u}=t;return!u||!n||i!==o&&a===l?!1:r?!0:l!==a&&s===c},uGt={duration:200,easing:"ease"},Wtt="transform",hGt=a3.Transition.toString({property:Wtt,duration:0,easing:"linear"}),mGt={roleDescription:"sortable"};function pGt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=N.useState(null),i=N.useRef(r);return O0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=_E(n.current,{ignoreTransform:!0}),p={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(p.x||p.y)&&l(p)}}r!==i.current&&(i.current=r)},[s,r,n,a]),N.useEffect(()=>{o&&l(null)},[o]),o}function l4e(t){let{animateLayoutChanges:s=dGt,attributes:r,disabled:n,data:a,getNewIndex:o=cGt,id:l,strategy:i,resizeObserverConfig:c,transition:u=uGt}=t;const{items:p,containerId:f,activeIndex:g,disabled:v,disableTransforms:_,sortedRects:w,overIndex:j,useDragOverlay:k,strategy:S}=N.useContext(Gtt),M=fGt(n,v),L=p.indexOf(l),P=N.useMemo(()=>({sortable:{containerId:f,index:L,items:p},...a}),[f,a,L,p]),O=N.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:U,isOver:B,setNodeRef:V}=rGt({id:l,data:P,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...c}}),{active:X,activatorEvent:Y,activeNodeRect:ee,attributes:Q,setNodeRef:ce,listeners:ne,isDragging:re,over:oe,setActivatorNodeRef:fe,transform:ge}=JHt({id:l,data:P,attributes:{...mGt,...r},disabled:M.draggable}),ue=RVt(V,ce),xe=!!X,_e=xe&&!_&&Bz(g)&&Bz(j),$e=!k&&re,Me=$e&&_e?ge:null,ke=_e?Me??(i??S)({rects:w,activeNodeRect:ee,activeIndex:g,overIndex:j,index:L}):null,pe=Bz(g)&&Bz(j)?o({id:l,items:p,activeIndex:g,overIndex:j}):L,we=X==null?void 0:X.id,Le=N.useRef({activeId:we,items:p,newIndex:pe,containerId:f}),Qe=p!==Le.current.items,Te=s({active:X,containerId:f,isDragging:re,isSorting:xe,id:l,index:L,items:p,newIndex:Le.current.newIndex,previousItems:Le.current.items,previousContainerId:Le.current.containerId,transition:u,wasDragging:Le.current.activeId!=null}),pt=pGt({disabled:!Te,index:L,node:U,rect:$});return N.useEffect(()=>{xe&&Le.current.newIndex!==pe&&(Le.current.newIndex=pe),f!==Le.current.containerId&&(Le.current.containerId=f),p!==Le.current.items&&(Le.current.items=p)},[xe,pe,f,p]),N.useEffect(()=>{if(we===Le.current.activeId)return;if(we!=null&&Le.current.activeId==null){Le.current.activeId=we;return}const qe=setTimeout(()=>{Le.current.activeId=we},50);return()=>clearTimeout(qe)},[we]),{active:X,activeIndex:g,attributes:Q,data:P,rect:$,index:L,newIndex:pe,items:p,isOver:B,isSorting:xe,isDragging:re,listeners:ne,node:U,overIndex:j,over:oe,setNodeRef:ue,setActivatorNodeRef:fe,setDroppableNodeRef:V,setDraggableNodeRef:ce,transform:pt??ke,transition:ye()};function ye(){if(pt||Qe&&Le.current.newIndex===L)return hGt;if(!($e&&!Jke(Y)||!u)&&(xe||Te))return a3.Transition.toString({...u,property:Wtt})}}function fGt(t,s){var r,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(r=t==null?void 0:t.draggable)!=null?r:s.draggable,droppable:(n=t==null?void 0:t.droppable)!=null?n:s.droppable}}function sce(t){if(!t)return!1;const s=t.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const xGt=[Ao.Down,Ao.Right,Ao.Up,Ao.Left],gGt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(xGt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const c=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=a.get(f.id);if(g)switch(t.code){case Ao.Down:n.topg.top&&c.push(f);break;case Ao.Left:n.left>g.left&&c.push(f);break;case Ao.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),g=o.get(p),v=g?a.get(g.id):null,_=g==null?void 0:g.node.current;if(_&&v&&f&&g){const j=ahe(_).some((O,$)=>i[$]!==O),k=Ktt(f,g),S=yGt(f,g),M=j||!k?{x:0,y:0}:{x:S?n.width-v.width:0,y:S?n.height-v.height:0},L={x:v.left,y:v.top};return M.x&&M.y?L:ID(L,M)}}}};function Ktt(t,s){return!sce(t)||!sce(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function yGt(t,s){return!sce(t)||!sce(s)||!Ktt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>r(t),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(st,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(hn,{className:"h-2.5 w-2.5"}),ms(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:It("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-3 w-3"}),t.post_date?ms(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(Ro,{className:"w-auto p-0",align:"start",children:[e.jsx(jf,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ms(f,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),t.post_date&&e.jsx("div",{className:"p-2 border-t",children:e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(t.id,null),children:"Clear date"})})]})]})]})]})})}const bGt=()=>{const t=Xt(),[s,r]=N.useState("all"),[n,a]=N.useState(!1),[o,l]=N.useState(ms(new Date,"yyyy-MM")),[i,c]=N.useState([]),[u,p]=N.useState(!1),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(""),[k,S]=N.useState(null),[M,L]=N.useState(!1),[P,O]=N.useState(!1),[$,U]=N.useState(ms(new Date,"yyyy-MM")),[B,V]=N.useState(null),[X,Y]=N.useState(""),[ee,Q]=N.useState(""),[ce,ne]=N.useState(""),[re,oe]=N.useState(!1),fe=e4e(ece(mR,{activationConstraint:{distance:5}}),ece(r4e,{coordinateGetter:gGt})),{data:ge=[],isLoading:ue}=mt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ze,error:Je}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Je)throw Je;return Ze}}),{data:xe=[]}=mt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ze,error:Je}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Je)throw Je;return Ze}}),{data:_e=[]}=mt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ze,error:Je}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Je)throw Je;return Ze}}),$e=[...new Set(ge.map(Ze=>Ze.month))].sort((Ze,Je)=>Je.localeCompare(Ze)),Me=s==="all"?ge:ge.filter(Ze=>Ze.month===s),Ie=Ze=>{const Je=Pje(Ze,"yyyy-MM",new Date);return ms(Je,"MMMM yyyy")},ke=Ze=>{_(Ze),j(Ze.caption),S(Ze.post_date)},pe=async()=>{if(v){L(!0);try{const{error:Ze}=await H.from("social_swag_2").update({caption:w,post_date:k}).eq("id",v.id);if(Ze)throw Ze;me.success("Image updated"),_(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{me.error("Failed to update image")}finally{L(!1)}}},we=async Ze=>{const{active:Je,over:Ge}=Ze;if(!Ge||Je.id===Ge.id)return;const et=Me,it=et.findIndex(hs=>hs.id===Je.id),Dt=et.findIndex(hs=>hs.id===Ge.id);if(it===-1||Dt===-1)return;const Vt=i4e(et,it,Dt);t.setQueryData(["admin-social-swag-2"],hs=>{if(!hs)return hs;const As={};return Vt.forEach((Ms,cs)=>{As[Ms.id]=cs}),hs.map(Ms=>As[Ms.id]!==void 0?{...Ms,sort_order:As[Ms.id]}:Ms).sort((Ms,cs)=>Ms.month!==cs.month?cs.month.localeCompare(Ms.month):Ms.sort_order-cs.sort_order)});try{await Promise.all(Vt.map((hs,As)=>H.from("social_swag_2").update({sort_order:As}).eq("id",hs.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},Le=Ze=>{const Ge=Array.from(Ze.target.files||[]).sort((et,it)=>et.name.localeCompare(it.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(et=>({file:et,preview:URL.createObjectURL(et),caption:""}));c(et=>[...et,...Ge].slice(0,16))},Qe=Ze=>{c(Je=>{const Ge=[...Je];return URL.revokeObjectURL(Ge[Ze].preview),Ge.splice(Ze,1),Ge})},Te=(Ze,Je)=>{c(Ge=>{const et=[...Ge];return et[Ze]={...et[Ze],caption:Je},et})},pt=async()=>{var Je;if(i.length===0){me.error("Please add at least one image");return}if(i.filter(Ge=>!Ge.caption.trim()).length>0){me.error("Please add captions to all images");return}p(!0);try{const{data:Ge}=await H.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),et=(((Je=Ge==null?void 0:Ge[0])==null?void 0:Je.sort_order)??-1)+1;for(let it=0;it{const Je=Ze.image_url.split("/social-swag-2/");Je[1]&&await H.storage.from("social-swag-2").remove([Je[1]]);const{error:Ge}=await H.from("social_swag_2").delete().eq("id",Ze.id);if(Ge)throw Ge},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),qe=Lt({mutationFn:async({id:Ze,postDate:Je})=>{const{error:Ge}=await H.from("social_swag_2").update({post_date:Je}).eq("id",Ze);if(Ge)throw Ge},onSuccess:()=>{me.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>me.error("Failed to update post date")}),at=Lt({mutationFn:async({month:Ze,link:Je})=>{const{error:Ge}=await H.from("social_swag_2_months").upsert({month:Ze,canva_link:Je||null},{onConflict:"month"});if(Ge)throw Ge},onSuccess:()=>{me.success("Canva link updated"),g(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),tt=Ze=>{var Je;return((Je=xe.find(Ge=>Ge.month===Ze))==null?void 0:Je.canva_link)||""},Ae=Ze=>_e.find(Je=>Je.month===Ze)||null,rt=Ze=>{var Ge;const Je=(Ge=Ze.target.files)==null?void 0:Ge[0];Je&&(V(Je),Y(URL.createObjectURL(Je)))},He=()=>{X&&URL.revokeObjectURL(X),V(null),Y(""),Q(""),ne("")},ct=async()=>{if(!B){me.error("Please select an image");return}oe(!0);try{const Ze=B.name.split(".").pop(),Je=`reels/${$}-${Date.now()}.${Ze}`,{error:Ge}=await H.storage.from("social-swag-2").upload(Je,B);if(Ge)throw Ge;const{data:{publicUrl:et}}=H.storage.from("social-swag-2").getPublicUrl(Je),{error:it}=await H.from("social_swag_2_reels").upsert({month:$,image_url:et,canva_link:ce||null,caption:ee||null},{onConflict:"month"});if(it)throw it;me.success("Reel uploaded successfully!"),gbe(`${Ie($)} Reel`,"social-swag-2"),He(),O(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),me.error("Failed to upload reel")}finally{oe(!1)}},Ue=Lt({mutationFn:async Ze=>{const Je=Ze.image_url.split("/social-swag-2/");Je[1]&&await H.storage.from("social-swag-2").remove([Je[1]]);const{error:Ge}=await H.from("social_swag_2_reels").delete().eq("id",Ze.id);if(Ge)throw Ge},onSuccess:()=>{me.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>me.error("Failed to delete reel")});return e.jsxs(Ts,{title:"Admin - Social Swag 2.0",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(xs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(fs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Month"}),e.jsx(ze,{type:"month",value:o,onChange:Ze=>l(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:Le,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(di,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((Ze,Je)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Ze.preview,alt:`Upload ${Je+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>Qe(Je),children:e.jsx(Mr,{className:"h-3 w-3"})})]}),e.jsx(Pr,{placeholder:"Caption...",value:Ze.caption,onChange:Ge=>Te(Je,Ge.target.value),className:"text-xs h-20"})]},Je))}),e.jsx(K,{onClick:pt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(xs,{open:P,onOpenChange:Ze=>{O(Ze),Ze||He()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(yu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(fs,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Month"}),e.jsx(ze,{type:"month",value:$,onChange:Ze=>U(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Reel Preview Image"}),X?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:X,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(X),V(null),Y("")},children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:rt,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(yu,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select reel preview image"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Canva Download Link"}),e.jsx(ze,{value:ce,onChange:Ze=>ne(Ze.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Pr,{value:ee,onChange:Ze=>Q(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ct,disabled:re||!B,className:"w-full gap-2",children:re?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ge.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:$e.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(_a,{value:s,onValueChange:r,children:e.jsxs(fa,{children:[e.jsx(ns,{value:"all",children:"All"}),$e.map(Ze=>e.jsx(ns,{value:Ze,children:Ie(Ze)},Ze))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(be,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ie(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(ze,{value:f.link,onChange:Ze=>g({...f,link:Ze.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>at.mutate(f),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:tt(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g({month:s,link:tt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(yu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(be,{className:"text-sm text-muted-foreground",children:["Reel for ",Ie(s)]}),(()=>{const Ze=Ae(s);return Ze?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ze.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"line-clamp-2",children:Ze.caption||"No caption"}),Ze.canva_link&&e.jsx("a",{href:Ze.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ue.mutate(Ze),children:e.jsx(Nr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ue?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Me.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(vl,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images yet. Upload some!"})]}):e.jsx(a4e,{sensors:fe,collisionDetection:t4e,onDragEnd:we,children:e.jsx(o4e,{items:Me.map(Ze=>Ze.id),strategy:pR,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Me.map(Ze=>e.jsx(vGt,{item:Ze,onEdit:ke,onDelete:Je=>ye.mutate(Je),onDateChange:(Je,Ge)=>qe.mutate({id:Je,postDate:Ge})},Ze.id))})})})]}),e.jsx(xs,{open:!!v,onOpenChange:Ze=>{Ze||_(null)},children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Edit Image"})}),v&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:v.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Caption"}),e.jsx(Pr,{value:w,onChange:Ze=>j(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("flex-1 justify-start gap-2 font-normal",!k&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4"}),k?ms(new Date(k+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:k?new Date(k+"T00:00:00"):void 0,onSelect:Ze=>S(Ze?ms(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),k&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Mr,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(null),children:"Cancel"}),e.jsx(K,{onClick:pe,disabled:M,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},_Gt=()=>{const{toast:t}=Ha(),s=Xt(),[r,n]=N.useState("categories"),[a,o]=N.useState(!1),[l,i]=N.useState(null),[c,u]=N.useState({name:"",description:"",icon:""}),[p,f]=N.useState(!1),[g,v]=N.useState(null),[_,w]=N.useState({name:"",description:"",icon:""}),[j,k]=N.useState(!1),[S,M]=N.useState(null),[L,P]=N.useState(""),{data:O=[],isLoading:$}=mt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:we,error:Le}=await H.from("community_categories").select("*").order("sort_order");if(Le)throw Le;return we}}),{data:U=[],isLoading:B}=mt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:we,error:Le}=await H.from("community_private_groups").select("*").order("sort_order");if(Le)throw Le;return we}}),{data:V=[]}=mt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:we,error:Le}=await H.from("community_private_group_members").select("*").eq("group_id",S.id);if(Le)throw Le;return we},enabled:!!S}),{data:X=[]}=mt({queryKey:["admin-all-profiles"],queryFn:async()=>{let Le=[],Qe=0,Te=!0;for(;Te;){const{data:pt,error:ye}=await H.from("profiles").select("id, name, email, brokerage_id").order("name").range(Qe,Qe+1e3-1);if(ye)throw ye;pt&&pt.length>0?(Le=[...Le,...pt],Qe+=1e3,Te=pt.length===1e3):Te=!1}return Le}}),{data:Y=[]}=mt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:we,error:Le}=await H.from("brokerages").select("*").order("name");if(Le)throw Le;return we}}),ee=Lt({mutationFn:async we=>{if(we.id){const{error:Le}=await H.from("community_categories").update({name:we.name,description:we.description||null,icon:we.icon||null}).eq("id",we.id);if(Le)throw Le}else{const Le=Math.max(...O.map(Te=>Te.sort_order),0),{error:Qe}=await H.from("community_categories").insert({name:we.name,description:we.description||null,icon:we.icon||null,sort_order:Le+1});if(Qe)throw Qe}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:we=>{t({title:"Error",description:we.message,variant:"destructive"})}}),Q=Lt({mutationFn:async we=>{const{error:Le}=await H.from("community_categories").delete().eq("id",we);if(Le)throw Le},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Lt({mutationFn:async({id:we,direction:Le})=>{const Qe=O.findIndex(Te=>Te.id===we);if(Le==="up"&&Qe>0){const Te=O[Qe-1],pt=O[Qe];await H.from("community_categories").update({sort_order:pt.sort_order}).eq("id",Te.id),await H.from("community_categories").update({sort_order:Te.sort_order}).eq("id",pt.id)}else if(Le==="down"&&Qes.invalidateQueries({queryKey:["admin-community-categories"]})}),ne=Lt({mutationFn:async we=>{if(we.id){const{error:Le}=await H.from("community_private_groups").update({name:we.name,description:we.description||null,icon:we.icon||null}).eq("id",we.id);if(Le)throw Le}else{const Le=Math.max(...U.map(Te=>Te.sort_order),0),{error:Qe}=await H.from("community_private_groups").insert({name:we.name,description:we.description||null,icon:we.icon||null,sort_order:Le+1});if(Qe)throw Qe}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),v(null),w({name:"",description:"",icon:""}),t({title:g?"Private group updated!":"Private group created!"})},onError:we=>{t({title:"Error",description:we.message,variant:"destructive"})}}),re=Lt({mutationFn:async we=>{const{error:Le}=await H.from("community_private_groups").delete().eq("id",we);if(Le)throw Le},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),oe=Lt({mutationFn:async({id:we,direction:Le})=>{const Qe=U.findIndex(Te=>Te.id===we);if(Le==="up"&&Qe>0){const Te=U[Qe-1],pt=U[Qe];await H.from("community_private_groups").update({sort_order:pt.sort_order}).eq("id",Te.id),await H.from("community_private_groups").update({sort_order:Te.sort_order}).eq("id",pt.id)}else if(Le==="down"&&Qes.invalidateQueries({queryKey:["admin-private-groups"]})}),fe=Lt({mutationFn:async({groupId:we,userId:Le,isMember:Qe})=>{if(Qe){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",we).eq("user_id",Le);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:we,user_id:Le});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ge=Lt({mutationFn:async({groupId:we,brokerageId:Le,isMember:Qe})=>{if(Qe){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",we).eq("brokerage_id",Le);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:we,brokerage_id:Le});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ue=we=>{i(we),u({name:we.name,description:we.description||"",icon:we.icon||""}),o(!0)},xe=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},_e=we=>{v(we),w({name:we.name,description:we.description||"",icon:we.icon||""}),f(!0)},$e=()=>{v(null),w({name:"",description:"",icon:""}),f(!0)},Me=we=>{M(we),P(""),k(!0)},Ie=we=>V.some(Le=>Le.user_id===we),ke=we=>V.some(Le=>Le.brokerage_id===we),pe=X.filter(we=>we.name.toLowerCase().includes(L.toLowerCase())||we.email.toLowerCase().includes(L.toLowerCase()));return e.jsx(Ts,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(_a,{value:r,onValueChange:n,children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"categories",children:"Public Categories"}),e.jsxs(ns,{value:"private-groups",children:[e.jsx(Eh,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(ws,{value:"categories",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),e.jsxs(K,{onClick:xe,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bn,{children:$?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):O.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):O.map((we,Le)=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===0,onClick:()=>ce.mutate({id:we.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===O.length-1,onClick:()=>ce.mutate({id:we.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:we.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:we.name}),e.jsx(dt,{className:"text-muted-foreground",children:we.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ue(we),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&Q.mutate(we.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},we.id))})]})})})]}),e.jsxs(ws,{value:"private-groups",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Private groups visible only to assigned members or brokerages"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Ca,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:$e,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[50px]",children:"Order"}),e.jsx(St,{className:"w-[80px]",children:"Icon"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"w-[120px]",children:"Members"}),e.jsx(St,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Bn,{children:B?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):U.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):U.map((we,Le)=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===0,onClick:()=>oe.mutate({id:we.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:Le===U.length-1,onClick:()=>oe.mutate({id:we.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:we.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[we.name,we.brokerage_id?e.jsxs(st,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(Eh,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:we.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(we),children:[e.jsx(hr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!we.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_e(we),children:e.jsx(za,{className:"h-4 w-4"})}),!we.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&re.mutate(we.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),we.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},we.id))})]})})})]})]}),e.jsx(xs,{open:a,onOpenChange:o,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:c.icon,onChange:we=>u(Le=>({...Le,icon:we.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:c.name,onChange:we=>u(Le=>({...Le,name:we.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Pr,{value:c.description,onChange:we=>u(Le=>({...Le,description:we.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ee.mutate({...c,id:l==null?void 0:l.id}),disabled:!c.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),e.jsx(xs,{open:p,onOpenChange:f,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:g?"Edit Private Group":"Create Private Group"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(ze,{value:_.icon,onChange:we=>w(Le=>({...Le,icon:we.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(ze,{value:_.name,onChange:we=>w(Le=>({...Le,name:we.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Pr,{value:_.description,onChange:we=>w(Le=>({...Le,description:we.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ne.mutate({..._,id:g==null?void 0:g.id}),disabled:!_.name.trim(),children:g?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(xs,{open:j,onOpenChange:k,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_a,{defaultValue:"brokerages",children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ns,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(ns,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(ws,{value:"brokerages",className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select brokerages to grant all their agents access to this private group."}),e.jsx(Ki,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Y.map(we=>e.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:ke(we.id),onCheckedChange:()=>{S&&ge.mutate({groupId:S.id,brokerageId:we.id,isMember:ke(we.id)})}}),e.jsx("span",{className:"font-medium",children:we.name})]}),e.jsxs(st,{variant:"secondary",children:[X.filter(Le=>Le.brokerage_id===we.id).length," agents"]})]},we.id)),Y.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(ws,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search users...",value:L,onChange:we=>P(we.target.value),className:"pl-9"})]}),e.jsx(Ki,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[pe.map(we=>e.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{checked:Ie(we.id),onCheckedChange:()=>{S&&fe.mutate({groupId:S.id,userId:we.id,isMember:Ie(we.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:we.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:we.email})]})]})},we.id)),pe.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>k(!1),children:"Done"})})]})]})})]})})},H8e=t=>{switch(t){case"academy_video":return e.jsx(il,{className:"h-3 w-3"});case"template":return e.jsx(wn,{className:"h-3 w-3"});case"toolbox":return e.jsx(Al,{className:"h-3 w-3"});case"newsletter":return e.jsx(m1,{className:"h-3 w-3"});case"social_swag":return e.jsx(fn,{className:"h-3 w-3"});default:return e.jsx(en,{className:"h-3 w-3"})}},wGt=t=>{switch(t){case"academy_video":return"Academy";case"template":return"Template";case"toolbox":return"Toolbox";case"newsletter":return"Newsletter";case"social_swag":return"Social Swag";default:return t}},jGt=t=>{switch(t){case"view":return"Viewed";case"click_canva":return"Clicked Canva";case"click_pdf":return"Downloaded PDF";case"click_video":return"Watched Video";case"click_link":return"Clicked Link";case"click_drive":return"Clicked Drive";default:return t}},NGt=()=>{const{toast:t}=Ha(),[s,r]=N.useState([]),[n,a]=N.useState([]),[o,l]=N.useState([]),[i,c]=N.useState(!0),[u,p]=N.useState(""),[f,g]=N.useState(null),[v,_]=N.useState([]),[w,j]=N.useState([]);N.useEffect(()=>{k()},[]);const k=async()=>{try{c(!0);const{data:V,error:X}=await H.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(X)throw X;const{data:Y,error:ee}=await H.from("content_engagement_logs").select(` id, user_id, resource_type, resource_id, resource_title, action_type, created_at `).order("created_at",{ascending:!1}).limit(5e3);if(ee)throw ee;const Q=[...new Set((Y==null?void 0:Y.map(ue=>ue.user_id))||[])],{data:ce}=await H.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Q),ne=new Map((ce==null?void 0:ce.map(ue=>[ue.id,ue]))||[]),re=(V==null?void 0:V.map(ue=>{var xe,_e,$e,Me;return{id:ue.id,user_id:ue.user_id,app_name:ue.app_name,launched_at:ue.launched_at,user_name:((xe=ue.profiles)==null?void 0:xe.name)||"Unknown",user_email:((_e=ue.profiles)==null?void 0:_e.email)||"Unknown",brokerage_name:((Me=($e=ue.profiles)==null?void 0:$e.brokerages)==null?void 0:Me.name)||null}}))||[],oe=(Y==null?void 0:Y.map(ue=>{var _e;const xe=ne.get(ue.user_id);return{id:ue.id,user_id:ue.user_id,resource_type:ue.resource_type,resource_id:ue.resource_id,resource_title:ue.resource_title,action_type:ue.action_type,created_at:ue.created_at,user_name:(xe==null?void 0:xe.name)||"Unknown",user_email:(xe==null?void 0:xe.email)||"Unknown",brokerage_name:((_e=xe==null?void 0:xe.brokerages)==null?void 0:_e.name)||null}}))||[];r(re),a(oe);const fe=new Map;re.forEach(ue=>{if(!fe.has(ue.user_id))fe.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:"app",last_activity_name:ue.app_name,last_activity_at:ue.launched_at,total_app_launches:1,total_content_views:0});else{const xe=fe.get(ue.user_id);xe.total_app_launches++,new Date(ue.launched_at)>new Date(xe.last_activity_at)&&(xe.last_activity_type="app",xe.last_activity_name=ue.app_name,xe.last_activity_at=ue.launched_at)}}),oe.forEach(ue=>{if(!fe.has(ue.user_id))fe.set(ue.user_id,{user_id:ue.user_id,user_name:ue.user_name,user_email:ue.user_email,brokerage_name:ue.brokerage_name,last_activity_type:ue.resource_type,last_activity_name:ue.resource_title,last_activity_at:ue.created_at,total_app_launches:0,total_content_views:1});else{const xe=fe.get(ue.user_id);xe.total_content_views++,new Date(ue.created_at)>new Date(xe.last_activity_at)&&(xe.last_activity_type=ue.resource_type,xe.last_activity_name=ue.resource_title,xe.last_activity_at=ue.created_at)}});const ge=Array.from(fe.values()).sort((ue,xe)=>new Date(xe.last_activity_at).getTime()-new Date(ue.last_activity_at).getTime());l(ge)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{c(!1)}},S=V=>{g({id:V.user_id,name:V.user_name,email:V.user_email});const X=s.filter(ee=>ee.user_id===V.user_id),Y=n.filter(ee=>ee.user_id===V.user_id);_(X),j(Y)},M=()=>{g(null),_([]),j([])},{sortKey:L,sortDirection:P,handleSort:O,sortData:$}=lR("last_activity_at","desc"),U=o.filter(V=>{var Y;if(!u)return!0;const X=u.toLowerCase();return V.user_name.toLowerCase().includes(X)||V.user_email.toLowerCase().includes(X)||((Y=V.brokerage_name)==null?void 0:Y.toLowerCase().includes(X))}),B=$(U,{user:V=>{var X;return((X=V.user_name)==null?void 0:X.toLowerCase())||""},brokerage:V=>{var X;return((X=V.brokerage_name)==null?void 0:X.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.total_content_views});return i?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"User Activity"}),e.jsx(gr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(bl,{sortKey:"user",currentSortKey:L,currentDirection:P,onSort:O,children:"User"}),e.jsx(bl,{sortKey:"brokerage",currentSortKey:L,currentDirection:P,onSort:O,children:"Brokerage"}),e.jsx(St,{children:"Last Activity"}),e.jsx(bl,{sortKey:"last_activity_at",currentSortKey:L,currentDirection:P,onSort:O,children:"Last Active"}),e.jsx(bl,{sortKey:"apps",currentSortKey:L,currentDirection:P,onSort:O,className:"text-right",children:"Apps"}),e.jsx(bl,{sortKey:"content",currentSortKey:L,currentDirection:P,onSort:O,className:"text-right",children:"Content"})]})}),e.jsx(Bn,{children:B.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(V=>e.jsxs(Cs,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>S(V),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:V.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:V.user_email})]})}),e.jsx(dt,{children:V.brokerage_name?e.jsx(st,{variant:"outline",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-2",children:V.last_activity_type==="app"?e.jsxs(st,{variant:"secondary",children:[e.jsx(en,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(st,{variant:"outline",className:"flex items-center gap-1",children:[H8e(V.last_activity_type),e.jsx("span",{className:"max-w-32 truncate",children:V.last_activity_name})]})})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Vc(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(st,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(st,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(xs,{open:!!f,onOpenChange:V=>!V&&M(),children:e.jsxs(fs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Wr,{children:f==null?void 0:f.email})]}),e.jsxs(_a,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(ns,{value:"apps",children:["App Launches (",v.length,")"]})]}),e.jsx(ws,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Bn,{children:w.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(V=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[H8e(V.resource_type),wGt(V.resource_type)]})}),e.jsx(dt,{className:"max-w-48",children:e.jsx("span",{className:"truncate block",children:V.resource_title})}),e.jsx(dt,{children:e.jsx(st,{variant:"secondary",children:jGt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Vc(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(ws,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Bn,{children:v.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):v.map(V=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx(st,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Vc(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},kGt=()=>{const{toast:t}=Ha(),[s,r]=N.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=N.useState(!0);N.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await H.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await H.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),c=(l||0)-(i||0),{count:u}=await H.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await H.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:g}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),v=new Date;v.setMonth(v.getMonth()-1);const{count:_}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",v.toISOString()),{data:w}=await H.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),j=new Set(w==null?void 0:w.map(k=>k.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:g||0,launchesThisMonth:_||0,uniqueActiveThisWeek:j})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},G8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},W8e={event:"bg-blue-100 text-blue-800",template:"bg-purple-100 text-purple-800",academy_video:"bg-green-100 text-green-800",resource_kit:"bg-orange-100 text-orange-800",newsletter:"bg-pink-100 text-pink-800",social_swag:"bg-yellow-100 text-yellow-800"};function Ztt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=N.useState([]),[a,o]=N.useState(!0),[l,i]=N.useState(""),[c,u]=N.useState("all");N.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let O=[];if(t&&s){const{data:Q}=await H.from("profiles").select("id").eq("brokerage_id",s);if(O=(Q==null?void 0:Q.map(ce=>ce.id))||[],O.length===0){n([]),o(!1);return}}let $=H.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&O.length>0&&($=$.or(`sender_id.in.(${O.join(",")}),recipient_id.in.(${O.join(",")})`));const{data:U,error:B}=await $;if(B)throw B;const V=new Set;U==null||U.forEach(Q=>{V.add(Q.sender_id),V.add(Q.recipient_id)});const{data:X}=await H.from("profiles").select("id, name, email").in("id",Array.from(V)),Y=new Map((X==null?void 0:X.map(Q=>[Q.id,Q]))||[]),ee=(U==null?void 0:U.map(Q=>({...Q,sender:Y.get(Q.sender_id),recipient:Y.get(Q.recipient_id)})))||[];n(ee)}catch(O){console.error("Error loading shares:",O)}finally{o(!1)}},{sortKey:f,sortDirection:g,handleSort:v,sortData:_}=lR("created_at","desc"),w=r.filter(O=>{var B,V;const $=l===""||O.resource_title.toLowerCase().includes(l.toLowerCase())||((B=O.sender)==null?void 0:B.name.toLowerCase().includes(l.toLowerCase()))||((V=O.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),U=c==="all"||O.resource_type===c;return $&&U}),j=_(w,{resource:O=>{var $;return(($=O.resource_title)==null?void 0:$.toLowerCase())||""},type:O=>O.resource_type,sender:O=>{var $,U;return((U=($=O.sender)==null?void 0:$.name)==null?void 0:U.toLowerCase())||""},recipient:O=>{var $,U;return((U=($=O.recipient)==null?void 0:$.name)==null?void 0:U.toLowerCase())||""},status:O=>O.is_read?1:0,created_at:O=>new Date(O.created_at).getTime()}),k=r.length,S=new Set(r.map(O=>O.sender_id)).size,M=new Set(r.map(O=>O.recipient_id)).size,L=r.length>0?Math.round(r.filter(O=>O.is_read).length/r.length*100):0,P=r.reduce((O,$)=>(O[$.resource_type]=(O[$.resource_type]||0)+1,O),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((O,$)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(vs,{className:"h-8 w-16"})})]},$))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(vs,{className:"h-[300px]"})})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(nd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:k})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:M})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[L,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(P).map(([O,$])=>e.jsxs(st,{variant:"secondary",className:W8e[O],children:[G8e[O],": ",$]},O)),Object.keys(P).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Share History"}),e.jsxs(gr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:O=>i(O.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Resource type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"event",children:"Events"}),e.jsx(Mt,{value:"template",children:"Templates"}),e.jsx(Mt,{value:"academy_video",children:"Academy Videos"}),e.jsx(Mt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(Mt,{value:"newsletter",children:"Newsletters"}),e.jsx(Mt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Ki,{className:"h-[400px]",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(bl,{sortKey:"resource",currentSortKey:f,currentDirection:g,onSort:v,children:"Resource"}),e.jsx(bl,{sortKey:"type",currentSortKey:f,currentDirection:g,onSort:v,children:"Type"}),e.jsx(bl,{sortKey:"sender",currentSortKey:f,currentDirection:g,onSort:v,children:"Sender"}),e.jsx(bl,{sortKey:"recipient",currentSortKey:f,currentDirection:g,onSort:v,children:"Recipient"}),e.jsx(bl,{sortKey:"status",currentSortKey:f,currentDirection:g,onSort:v,children:"Status"}),e.jsx(bl,{sortKey:"created_at",currentSortKey:f,currentDirection:g,onSort:v,children:"Date"})]})}),e.jsx(Bn,{children:j.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):j.map(O=>{var $,U;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:O.resource_title}),e.jsx(dt,{children:e.jsx(st,{variant:"secondary",className:W8e[O.resource_type],children:G8e[O.resource_type]})}),e.jsx(dt,{children:(($=O.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(dt,{children:((U=O.recipient)==null?void 0:U.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(st,{variant:O.is_read?"default":"outline",children:O.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(O.created_at),"MMM d, yyyy")})]},O.id)})})]})})]})]})]})}const Qge={academy_video:{label:"Academy Videos",icon:Cn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:Dn},template:{label:"Templates",icon:qv,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:Nh},toolbox:{label:"Toolkit",icon:sy,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:vi},newsletter:{label:"Newsletters",icon:lr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:Nh},social_swag:{label:"Social Swag",icon:Bl,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:Nh},event:{label:"Events",icon:hn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:Nh}};function K8e(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function SGt(t,s){return t==="toolbox"?s.downloads:s.clicks}function CGt(){var O;const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(null),l=N.useRef(null),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=lR("total_views","desc");N.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:$,error:U}=await H.rpc("get_admin_content_engagement");if(U)throw U;s($||[])}catch($){console.error("Error loading content engagement:",$)}finally{n(!1)}},g=$=>{o(U=>{const B=U===$?null:$;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),B})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map(($,U)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(vs,{className:"h-8 w-16"})})]},U))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(vs,{className:"h-64 w-full"})})})]});const v=t.reduce(($,U)=>$+U.total_views,0),_=t.reduce(($,U)=>$+U.total_clicks,0),w=t.reduce(($,U)=>$+U.total_downloads,0),j=t.length,k=t.reduce(($,U)=>($[U.resource_type]||($[U.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),$[U.resource_type].views+=U.total_views,$[U.resource_type].clicks+=U.total_clicks,$[U.resource_type].downloads+=U.total_downloads,$[U.resource_type].assets+=1,$[U.resource_type].uniqueUsers+=U.unique_users,$),{}),S=a?t.filter($=>$.resource_type===a):t,M=p(S,{asset:$=>{var U;return((U=$.resource_title)==null?void 0:U.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>K8e($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),L=a?Qge[a]||{label:a,icon:Dn,actionLabel:"Actions"}:null,P=L==null?void 0:L.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(Dn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:v.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(Nh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(Nh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[v>0?Math.round((_+w)/v*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(gr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(k).map(([$,U])=>{const B=Qge[$]||{label:$,icon:Dn,color:"bg-muted text-muted-foreground",actionIcon:Nh},V=B.icon,X=a===$;return e.jsxs("button",{type:"button",onClick:()=>g($),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${X?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${B.color}`,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:B.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",U.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B.actionIcon,{className:"h-3 w-3"})," ",SGt($,U)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",U.uniqueUsers]})]})]}),e.jsxs(st,{variant:"secondary",className:"text-[10px]",children:[U.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm font-medium flex items-center gap-2",children:L&&P?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"h-4 w-4"}),L.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(gr,{children:a?`${S.length} ${((O=L==null?void 0:L.label)==null?void 0:O.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Ki,{className:"h-[400px]",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[40px]",children:"#"}),e.jsx(bl,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(bl,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(bl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(bl,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:L?L.actionLabel:"Actions"}),e.jsx(bl,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(bl,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(Bn,{children:M.map(($,U)=>{const B=Qge[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(Cs,{children:[e.jsx(dt,{className:"text-muted-foreground text-xs",children:U+1}),e.jsx(dt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:$.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(st,{className:`text-[10px] ${B.color}`,children:B.label})}),e.jsx(dt,{className:"text-right font-medium",children:$.total_views}),e.jsx(dt,{className:"text-right font-medium",children:K8e($)}),e.jsx(dt,{className:"text-right",children:$.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?Vc(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}var MGt=Array.isArray,Ip=MGt,TGt=typeof Yv=="object"&&Yv&&Yv.Object===Object&&Yv,Ytt=TGt,AGt=Ytt,EGt=typeof self=="object"&&self&&self.Object===Object&&self,PGt=AGt||EGt||Function("return this")(),H0=PGt,IGt=H0,LGt=IGt.Symbol,fR=LGt,Z8e=fR,Qtt=Object.prototype,DGt=Qtt.hasOwnProperty,OGt=Qtt.toString,cI=Z8e?Z8e.toStringTag:void 0;function RGt(t){var s=DGt.call(t,cI),r=t[cI];try{t[cI]=void 0;var n=!0}catch{}var a=OGt.call(t);return n&&(s?t[cI]=r:delete t[cI]),a}var FGt=RGt,zGt=Object.prototype,BGt=zGt.toString;function $Gt(t){return BGt.call(t)}var qGt=$Gt,Y8e=fR,UGt=FGt,VGt=qGt,HGt="[object Null]",GGt="[object Undefined]",Q8e=Y8e?Y8e.toStringTag:void 0;function WGt(t){return t==null?t===void 0?GGt:HGt:Q8e&&Q8e in Object(t)?UGt(t):VGt(t)}var K1=WGt;function KGt(t){return t!=null&&typeof t=="object"}var Z1=KGt,ZGt=K1,YGt=Z1,QGt="[object Symbol]";function XGt(t){return typeof t=="symbol"||YGt(t)&&ZGt(t)==QGt}var wE=XGt,JGt=Ip,eWt=wE,tWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,sWt=/^\w*$/;function rWt(t,s){if(JGt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||eWt(t)?!0:sWt.test(t)||!tWt.test(t)||s!=null&&t in Object(s)}var c4e=rWt;function nWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Vw=nWt;const jE=Po(Vw);var aWt=K1,iWt=Vw,oWt="[object AsyncFunction]",lWt="[object Function]",cWt="[object GeneratorFunction]",dWt="[object Proxy]";function uWt(t){if(!iWt(t))return!1;var s=aWt(t);return s==lWt||s==cWt||s==oWt||s==dWt}var d4e=uWt;const Ti=Po(d4e);var hWt=H0,mWt=hWt["__core-js_shared__"],pWt=mWt,Xge=pWt,X8e=function(){var t=/[^.]+$/.exec(Xge&&Xge.keys&&Xge.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function fWt(t){return!!X8e&&X8e in t}var xWt=fWt,gWt=Function.prototype,yWt=gWt.toString;function vWt(t){if(t!=null){try{return yWt.call(t)}catch{}try{return t+""}catch{}}return""}var Xtt=vWt,bWt=d4e,_Wt=xWt,wWt=Vw,jWt=Xtt,NWt=/[\\^$.*+?()[\]{}|]/g,kWt=/^\[object .+?Constructor\]$/,SWt=Function.prototype,CWt=Object.prototype,MWt=SWt.toString,TWt=CWt.hasOwnProperty,AWt=RegExp("^"+MWt.call(TWt).replace(NWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function EWt(t){if(!wWt(t)||_Wt(t))return!1;var s=bWt(t)?AWt:kWt;return s.test(jWt(t))}var PWt=EWt;function IWt(t,s){return t==null?void 0:t[s]}var LWt=IWt,DWt=PWt,OWt=LWt;function RWt(t,s){var r=OWt(t,s);return DWt(r)?r:void 0}var T3=RWt,FWt=T3,zWt=FWt(Object,"create"),lhe=zWt,J8e=lhe;function BWt(){this.__data__=J8e?J8e(null):{},this.size=0}var $Wt=BWt;function qWt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var UWt=qWt,VWt=lhe,HWt="__lodash_hash_undefined__",GWt=Object.prototype,WWt=GWt.hasOwnProperty;function KWt(t){var s=this.__data__;if(VWt){var r=s[t];return r===HWt?void 0:r}return WWt.call(s,t)?s[t]:void 0}var ZWt=KWt,YWt=lhe,QWt=Object.prototype,XWt=QWt.hasOwnProperty;function JWt(t){var s=this.__data__;return YWt?s[t]!==void 0:XWt.call(s,t)}var eKt=JWt,tKt=lhe,sKt="__lodash_hash_undefined__";function rKt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=tKt&&s===void 0?sKt:s,this}var nKt=rKt,aKt=$Wt,iKt=UWt,oKt=ZWt,lKt=eKt,cKt=nKt;function NE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var SKt=kKt,CKt=che;function MKt(t,s){var r=this.__data__,n=CKt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var TKt=MKt,AKt=hKt,EKt=bKt,PKt=jKt,IKt=SKt,LKt=TKt;function kE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},P4=function(s){return i3(s)&&s.indexOf("%")===s.length-1},cn=function(s){return eYt(s)&&!xR(s)},nYt=function(s){return $i(s)},Nu=function(s){return cn(s)||i3(s)},aYt=0,CE=function(s){var r=++aYt;return"".concat(s||"").concat(r)},Em=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!cn(s)&&!i3(s))return n;var o;if(P4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return xR(o)&&(o=n),a&&o>r&&(o=r),o},f_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},iYt=function(s){if(!Array.isArray(s))return!1;for(var r=s.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function mYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Nbe(t){"@babel/helpers - typeof";return Nbe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Nbe(t)}var iDe={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},w1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},oDe=null,eye=null,b4e=function t(s){if(s===oDe&&Array.isArray(eye))return eye;var r=[];return N.Children.forEach(s,function(n){$i(n)||(ZZt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),eye=r,oDe=s,r};function kf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return w1(a)}):n=[w1(s)],b4e(t).forEach(function(a){var o=Nf(a,"type.displayName")||Nf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function sf(t,s){var r=kf(t,s);return r&&r[0]}var lDe=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!cn(n)||n<=0||!cn(a)||a<=0)},pYt=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],fYt=function(s){return s&&s.type&&i3(s.type)&&pYt.indexOf(s.type)>=0},xYt=function(s){return s&&Nbe(s)==="object"&&"clipDot"in s},gYt=function(s,r,n,a){var o,l=(o=Jge==null?void 0:Jge[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!Ti(s)&&(a&&l.includes(r)||cYt.includes(r))||n&&v4e.includes(r)},oi=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(N.isValidElement(s)&&(a=s.props),!jE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;gYt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},kbe=function t(s,r){if(s===r)return!0;var n=N.Children.count(s);if(n!==N.Children.count(r))return!1;if(n===0)return!0;if(n===1)return cDe(Array.isArray(s)?s[0]:s,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function wYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Cbe(t){var s=t.children,r=t.width,n=t.height,a=t.viewBox,o=t.className,l=t.style,i=t.title,c=t.desc,u=_Yt(t,bYt),p=a||{width:r,height:n,x:0,y:0},f=Vi("recharts-surface",o);return ht.createElement("svg",Sbe({},oi(u,!0,"svg"),{className:f,width:r,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),ht.createElement("title",null,i),ht.createElement("desc",null,c),s)}var jYt=["children","className"];function Mbe(){return Mbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function kYt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Zo=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=NYt(t,jYt),o=Vi("recharts-layer",n);return ht.createElement("g",Mbe({className:o},oi(a,!0),{ref:s}),r)}),ny=function(s,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;oa?0:a+s),r=r>a?a:r,r<0&&(r+=a),a=s>r?0:r-s>>>0,s>>>=0;for(var o=Array(a);++n=n?t:MYt(t,s,r)}var AYt=TYt,EYt="\\ud800-\\udfff",PYt="\\u0300-\\u036f",IYt="\\ufe20-\\ufe2f",LYt="\\u20d0-\\u20ff",DYt=PYt+IYt+LYt,OYt="\\ufe0e\\ufe0f",RYt="\\u200d",FYt=RegExp("["+RYt+EYt+DYt+OYt+"]");function zYt(t){return FYt.test(t)}var lst=zYt;function BYt(t){return t.split("")}var $Yt=BYt,cst="\\ud800-\\udfff",qYt="\\u0300-\\u036f",UYt="\\ufe20-\\ufe2f",VYt="\\u20d0-\\u20ff",HYt=qYt+UYt+VYt,GYt="\\ufe0e\\ufe0f",WYt="["+cst+"]",Tbe="["+HYt+"]",Abe="\\ud83c[\\udffb-\\udfff]",KYt="(?:"+Tbe+"|"+Abe+")",dst="[^"+cst+"]",ust="(?:\\ud83c[\\udde6-\\uddff]){2}",hst="[\\ud800-\\udbff][\\udc00-\\udfff]",ZYt="\\u200d",mst=KYt+"?",pst="["+GYt+"]?",YYt="(?:"+ZYt+"(?:"+[dst,ust,hst].join("|")+")"+pst+mst+")*",QYt=pst+mst+YYt,XYt="(?:"+[dst+Tbe+"?",Tbe,ust,hst,WYt].join("|")+")",JYt=RegExp(Abe+"(?="+Abe+")|"+XYt+QYt,"g");function eQt(t){return t.match(JYt)||[]}var tQt=eQt,sQt=$Yt,rQt=lst,nQt=tQt;function aQt(t){return rQt(t)?nQt(t):sQt(t)}var iQt=aQt,oQt=AYt,lQt=lst,cQt=iQt,dQt=sst;function uQt(t){return function(s){s=dQt(s);var r=lQt(s)?cQt(s):void 0,n=r?r[0]:s.charAt(0),a=r?oQt(r,1).join(""):s.slice(1);return n[t]()+a}}var hQt=uQt,mQt=hQt,pQt=mQt("toUpperCase"),fQt=pQt;const jhe=Po(fQt);function Ql(t){return function(){return t}}const fst=Math.cos,ace=Math.sin,xy=Math.sqrt,ice=Math.PI,Nhe=2*ice,Ebe=Math.PI,Pbe=2*Ebe,u4=1e-6,xQt=Pbe-u4;function xst(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return xst;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;au4)if(!(Math.abs(f*c-u*p)>u4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let v=n-l,_=a-i,w=c*c+u*u,j=v*v+_*_,k=Math.sqrt(w),S=Math.sqrt(g),M=o*Math.tan((Ebe-Math.acos((w+g-j)/(2*k*S)))/2),L=M/S,P=M/k;Math.abs(L-1)>u4&&this._append`L${s+L*p},${r+L*f}`,this._append`A${o},${o},0,0,${+(f*v>p*_)},${this._x1=s+P*c},${this._y1=r+P*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),c=n*Math.sin(a),u=s+i,p=r+c,f=1^l,g=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>u4||Math.abs(this._y1-p)>u4)&&this._append`L${u},${p}`,n&&(g<0&&(g=g%Pbe+Pbe),g>xQt?this._append`A${n},${n},0,1,${f},${s-i},${r-c}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:g>u4&&this._append`A${n},${n},0,${+(g>=Ebe)},${f},${this._x1=s+n*Math.cos(o)},${this._y1=r+n*Math.sin(o)}`)}rect(s,r,n,a){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function _4e(t){let s=3;return t.digits=function(r){if(!arguments.length)return s;if(r==null)s=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);s=n}return t},()=>new yQt(s)}function w4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function gst(t){this._context=t}gst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:this._context.lineTo(t,s);break}}};function khe(t){return new gst(t)}function yst(t){return t[0]}function vst(t){return t[1]}function bst(t,s){var r=Ql(!0),n=null,a=khe,o=null,l=_4e(i);t=typeof t=="function"?t:t===void 0?yst:Ql(t),s=typeof s=="function"?s:s===void 0?vst:Ql(s);function i(c){var u,p=(c=w4e(c)).length,f,g=!1,v;for(n==null&&(o=a(v=l())),u=0;u<=p;++u)!(u=v;--_)i.point(M[_],L[_]);i.lineEnd(),i.areaEnd()}k&&(M[g]=+t(j,g,f),L[g]=+s(j,g,f),i.point(n?+n(j,g,f):M[g],r?+r(j,g,f):L[g]))}if(S)return i=null,S+""||null}function p(){return bst().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ql(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ql(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ql(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Ql(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Ql(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ql(+f),u):r},u.lineX0=u.lineY0=function(){return p().x(t).y(s)},u.lineY1=function(){return p().x(t).y(r)},u.lineX1=function(){return p().x(n).y(s)},u.defined=function(f){return arguments.length?(a=typeof f=="function"?f:Ql(!!f),u):a},u.curve=function(f){return arguments.length?(l=f,o!=null&&(i=l(o)),u):l},u.context=function(f){return arguments.length?(f==null?o=i=null:i=l(o=f),u):o},u}class _st{constructor(s,r){this._context=s,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(s,r){switch(s=+s,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(s,r):this._context.moveTo(s,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+s)/2,this._y0,this._x0,r,s,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,s,this._y0,s,r);break}}this._x0=s,this._y0=r}}function vQt(t){return new _st(t,!0)}function bQt(t){return new _st(t,!1)}const j4e={draw(t,s){const r=xy(s/ice);t.moveTo(r,0),t.arc(0,0,r,0,Nhe)}},_Qt={draw(t,s){const r=xy(s/5)/2;t.moveTo(-3*r,-r),t.lineTo(-r,-r),t.lineTo(-r,-3*r),t.lineTo(r,-3*r),t.lineTo(r,-r),t.lineTo(3*r,-r),t.lineTo(3*r,r),t.lineTo(r,r),t.lineTo(r,3*r),t.lineTo(-r,3*r),t.lineTo(-r,r),t.lineTo(-3*r,r),t.closePath()}},wst=xy(1/3),wQt=wst*2,jQt={draw(t,s){const r=xy(s/wQt),n=r*wst;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},NQt={draw(t,s){const r=xy(s),n=-r/2;t.rect(n,n,r,r)}},kQt=.8908130915292852,jst=ace(ice/10)/ace(7*ice/10),SQt=ace(Nhe/10)*jst,CQt=-fst(Nhe/10)*jst,MQt={draw(t,s){const r=xy(s*kQt),n=SQt*r,a=CQt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=Nhe*o/5,i=fst(l),c=ace(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},tye=xy(3),TQt={draw(t,s){const r=-xy(s/(tye*3));t.moveTo(0,r*2),t.lineTo(-tye*r,-r),t.lineTo(tye*r,-r),t.closePath()}},Jf=-.5,ex=xy(3)/2,Ibe=1/xy(12),AQt=(Ibe/2+1)*3,EQt={draw(t,s){const r=xy(s/AQt),n=r/2,a=r*Ibe,o=n,l=r*Ibe+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(Jf*n-ex*a,ex*n+Jf*a),t.lineTo(Jf*o-ex*l,ex*o+Jf*l),t.lineTo(Jf*i-ex*c,ex*i+Jf*c),t.lineTo(Jf*n+ex*a,Jf*a-ex*n),t.lineTo(Jf*o+ex*l,Jf*l-ex*o),t.lineTo(Jf*i+ex*c,Jf*c-ex*i),t.closePath()}};function PQt(t,s){let r=null,n=_4e(a);t=typeof t=="function"?t:Ql(t||j4e),s=typeof s=="function"?s:Ql(s===void 0?64:+s);function a(){let o;if(r||(r=o=n()),t.apply(this,arguments).draw(r,+s.apply(this,arguments)),o)return r=null,o+""||null}return a.type=function(o){return arguments.length?(t=typeof o=="function"?o:Ql(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Ql(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function oce(){}function lce(t,s,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+s)/6,(t._y0+4*t._y1+r)/6)}function Nst(t){this._context=t}Nst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:lce(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:lce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function IQt(t){return new Nst(t)}function kst(t){this._context=t}kst.prototype={areaStart:oce,areaEnd:oce,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._x2=t,this._y2=s;break;case 1:this._point=2,this._x3=t,this._y3=s;break;case 2:this._point=3,this._x4=t,this._y4=s,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+s)/6);break;default:lce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function LQt(t){return new kst(t)}function Sst(t){this._context=t}Sst.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+s)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:lce(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function DQt(t){return new Sst(t)}function Cst(t){this._context=t}Cst.prototype={areaStart:oce,areaEnd:oce,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,s){t=+t,s=+s,this._point?this._context.lineTo(t,s):(this._point=1,this._context.moveTo(t,s))}};function OQt(t){return new Cst(t)}function uDe(t){return t<0?-1:1}function hDe(t,s,r){var n=t._x1-t._x0,a=s-t._x1,o=(t._y1-t._y0)/(n||a<0&&-0),l=(r-t._y1)/(a||n<0&&-0),i=(o*a+l*n)/(n+a);return(uDe(o)+uDe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function mDe(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function sye(t,s,r){var n=t._x0,a=t._y0,o=t._x1,l=t._y1,i=(o-n)/3;t._context.bezierCurveTo(n+i,a+i*s,o-i,l-i*r,o,l)}function cce(t){this._context=t}cce.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:sye(this,this._t0,mDe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,s){var r=NaN;if(t=+t,s=+s,!(t===this._x1&&s===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;break;case 2:this._point=3,sye(this,mDe(this,r=hDe(this,t,s)),r);break;default:sye(this,this._t0,r=hDe(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function Mst(t){this._context=new Tst(t)}(Mst.prototype=Object.create(cce.prototype)).point=function(t,s){cce.prototype.point.call(this,s,t)};function Tst(t){this._context=t}Tst.prototype={moveTo:function(t,s){this._context.moveTo(s,t)},closePath:function(){this._context.closePath()},lineTo:function(t,s){this._context.lineTo(s,t)},bezierCurveTo:function(t,s,r,n,a,o){this._context.bezierCurveTo(s,t,n,r,o,a)}};function RQt(t){return new cce(t)}function FQt(t){return new Mst(t)}function Ast(t){this._context=t}Ast.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,s=this._y,r=t.length;if(r)if(this._line?this._context.lineTo(t[0],s[0]):this._context.moveTo(t[0],s[0]),r===2)this._context.lineTo(t[1],s[1]);else for(var n=pDe(t),a=pDe(s),o=0,l=1;l=0;--s)a[s]=(l[s]-a[s+1])/o[s];for(o[r-1]=(t[r]+a[r-1])/2,s=0;s=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,s),this._context.lineTo(t,s);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,s)}break}}this._x=t,this._y=s}};function BQt(t){return new She(t,.5)}function $Qt(t){return new She(t,0)}function qQt(t){return new She(t,1)}function aA(t,s){if((l=t.length)>1)for(var r=1,n,a,o=t[s[0]],l,i=o.length;r=0;)r[s]=s;return r}function UQt(t,s){return t[s]}function VQt(t){const s=[];return s.key=t,s}function HQt(){var t=Ql([]),s=Lbe,r=aA,n=UQt;function a(o){var l=Array.from(t.apply(this,arguments),VQt),i,c=l.length,u=-1,p;for(const f of o)for(i=0,++u;i0){for(var r,n,a=0,o=t[0].length,l;a0){for(var r=0,n=t[s[0]],a,o=n.length;r0)||!((o=(a=t[s[0]]).length)>0))){for(var r=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function eXt(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Est={symbolCircle:j4e,symbolCross:_Qt,symbolDiamond:jQt,symbolSquare:NQt,symbolStar:MQt,symbolTriangle:TQt,symbolWye:EQt},tXt=Math.PI/180,sXt=function(s){var r="symbol".concat(jhe(s));return Est[r]||j4e},rXt=function(s,r,n){if(r==="area")return s;switch(n){case"cross":return 5*s*s/9;case"diamond":return .5*s*s/Math.sqrt(3);case"square":return s*s;case"star":{var a=18*tXt;return 1.25*s*s*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*s*s/4;case"wye":return(21-10*Math.sqrt(3))*s*s/8;default:return Math.PI*s*s/4}},nXt=function(s,r){Est["symbol".concat(jhe(s))]=r},N4e=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,o=a===void 0?64:a,l=s.sizeType,i=l===void 0?"area":l,c=JQt(s,ZQt),u=xDe(xDe({},c),{},{type:n,size:o,sizeType:i}),p=function(){var j=sXt(n),k=PQt().type(j).size(rXt(o,i,n));return k()},f=u.className,g=u.cx,v=u.cy,_=oi(u,!0);return g===+g&&v===+v&&o===+o?ht.createElement("path",Dbe({},_,{className:Vi("recharts-symbols",f),transform:"translate(".concat(g,", ").concat(v,")"),d:p()})):null};N4e.registerSymbol=nXt;function iA(t){"@babel/helpers - typeof";return iA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},iA(t)}function Obe(){return Obe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=v.inactive?u:v.color;return ht.createElement("li",Obe({className:j,style:f,key:"legend-item-".concat(_)},o3(n.props,v,_)),ht.createElement(Cbe,{width:l,height:l,viewBox:p,style:g},n.renderIcon(v)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(k,v,_):k))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(N.PureComponent);OD(k4e,"displayName","Legend");OD(k4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var pXt=dhe;function fXt(){this.__data__=new pXt,this.size=0}var xXt=fXt;function gXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var yXt=gXt;function vXt(t){return this.__data__.get(t)}var bXt=vXt;function _Xt(t){return this.__data__.has(t)}var wXt=_Xt,jXt=dhe,NXt=h4e,kXt=m4e,SXt=200;function CXt(t,s){var r=this.__data__;if(r instanceof jXt){var n=r.__data__;if(!NXt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,g=!0,v=r&ZXt?new HXt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=JJt}var T4e=ees,tes=K1,ses=T4e,res=Z1,nes="[object Arguments]",aes="[object Array]",ies="[object Boolean]",oes="[object Date]",les="[object Error]",ces="[object Function]",des="[object Map]",ues="[object Number]",hes="[object Object]",mes="[object RegExp]",pes="[object Set]",fes="[object String]",xes="[object WeakMap]",ges="[object ArrayBuffer]",yes="[object DataView]",ves="[object Float32Array]",bes="[object Float64Array]",_es="[object Int8Array]",wes="[object Int16Array]",jes="[object Int32Array]",Nes="[object Uint8Array]",kes="[object Uint8ClampedArray]",Ses="[object Uint16Array]",Ces="[object Uint32Array]",vc={};vc[ves]=vc[bes]=vc[_es]=vc[wes]=vc[jes]=vc[Nes]=vc[kes]=vc[Ses]=vc[Ces]=!0;vc[nes]=vc[aes]=vc[ges]=vc[ies]=vc[yes]=vc[oes]=vc[les]=vc[ces]=vc[des]=vc[ues]=vc[hes]=vc[mes]=vc[pes]=vc[fes]=vc[xes]=!1;function Mes(t){return res(t)&&ses(t.length)&&!!vc[tes(t)]}var Tes=Mes;function Aes(t){return function(s){return t(s)}}var qst=Aes,mce={exports:{}};mce.exports;(function(t,s){var r=Ytt,n=s&&!s.nodeType&&s,a=n&&!0&&t&&!t.nodeType&&t,o=a&&a.exports===n,l=o&&r.process,i=function(){try{var c=a&&a.require&&a.require("util").types;return c||l&&l.binding&&l.binding("util")}catch{}}();t.exports=i})(mce,mce.exports);var Ees=mce.exports,Pes=Tes,Ies=qst,jDe=Ees,NDe=jDe&&jDe.isTypedArray,Les=NDe?Ies(NDe):Pes,Ust=Les,Des=FJt,Oes=C4e,Res=Ip,Fes=$st,zes=M4e,Bes=Ust,$es=Object.prototype,qes=$es.hasOwnProperty;function Ues(t,s){var r=Res(t),n=!r&&Oes(t),a=!r&&!n&&Fes(t),o=!r&&!n&&!a&&Bes(t),l=r||n||a||o,i=l?Des(t.length,String):[],c=i.length;for(var u in t)(s||qes.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||zes(u,c)))&&i.push(u);return i}var Ves=Ues,Hes=Object.prototype;function Ges(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||Hes;return t===r}var Wes=Ges;function Kes(t,s){return function(r){return t(s(r))}}var Vst=Kes,Zes=Vst,Yes=Zes(Object.keys,Object),Qes=Yes,Xes=Wes,Jes=Qes,ets=Object.prototype,tts=ets.hasOwnProperty;function sts(t){if(!Xes(t))return Jes(t);var s=[];for(var r in Object(t))tts.call(t,r)&&r!="constructor"&&s.push(r);return s}var rts=sts,nts=d4e,ats=T4e;function its(t){return t!=null&&ats(t.length)&&!nts(t)}var gR=its,ots=Ves,lts=rts,cts=gR;function dts(t){return cts(t)?ots(t):lts(t)}var Che=dts,uts=SJt,hts=OJt,mts=Che;function pts(t){return uts(t,mts,hts)}var fts=pts,kDe=fts,xts=1,gts=Object.prototype,yts=gts.hasOwnProperty;function vts(t,s,r,n,a,o){var l=r&xts,i=kDe(t),c=i.length,u=kDe(s),p=u.length;if(c!=p&&!l)return!1;for(var f=c;f--;){var g=i[f];if(!(l?g in s:yts.call(s,g)))return!1}var v=o.get(t),_=o.get(s);if(v&&_)return v==s&&_==t;var w=!0;o.set(t,s),o.set(s,t);for(var j=l;++f-1}var grs=xrs;function yrs(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=Irs){var u=s?null:Ers(t);if(u)return Prs(u);l=!1,a=Ars,c=new Crs}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Zrs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Yrs(t){return t.value}function Qrs(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=Krs(s,Brs);return ht.createElement(k4e,r)}var $De=1,mT=function(t){function s(){var r;$rs(this,s);for(var n=arguments.length,a=new Array(n),o=0;o$De||Math.abs(a.height-this.lastBoundingBox.height)>$De)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?Av({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,o=a.layout,l=a.align,i=a.verticalAlign,c=a.margin,u=a.chartWidth,p=a.chartHeight,f,g;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var v=this.getBBoxSnapshot();f={left:((u||0)-v.width)/2}}else f=l==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(i==="middle"){var _=this.getBBoxSnapshot();g={top:((p||0)-_.height)/2}}else g=i==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Av(Av({},f),g)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,c=a.wrapperStyle,u=a.payloadUniqBy,p=a.payload,f=Av(Av({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(v){n.wrapperNode=v}},Qrs(o,Av(Av({},this.props),{},{payload:Qst(p,u,Yrs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Av(Av({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&cn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(N.PureComponent);Mhe(mT,"displayName","Legend");Mhe(mT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var qDe=fR,Xrs=C4e,Jrs=Ip,UDe=qDe?qDe.isConcatSpreadable:void 0;function ens(t){return Jrs(t)||Xrs(t)||!!(UDe&&t&&t[UDe])}var tns=ens,sns=zst,rns=tns;function ert(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=rns),a||(a=[]);++o0&&r(i)?s>1?ert(i,s-1,r,n,a):sns(a,i):n||(a[a.length]=i)}return a}var trt=ert;function nns(t){return function(s,r,n){for(var a=-1,o=Object(s),l=n(s),i=l.length;i--;){var c=l[t?i:++a];if(r(o[c],c,o)===!1)break}return s}}var ans=nns,ins=ans,ons=ins(),lns=ons,cns=lns,dns=Che;function uns(t,s){return t&&cns(t,s,dns)}var srt=uns,hns=gR;function mns(t,s){return function(r,n){if(r==null)return r;if(!hns(r))return t(r,n);for(var a=r.length,o=s?a:-1,l=Object(r);(s?o--:++os||o&&l&&c&&!i&&!u||n&&l&&c||!r&&c||!a)return 1;if(!n&&!o&&!u&&t=i)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-s.index}var Cns=Sns,iye=f4e,Mns=x4e,Tns=G0,Ans=rrt,Ens=wns,Pns=qst,Ins=Cns,Lns=AE,Dns=Ip;function Ons(t,s,r){s.length?s=iye(s,function(o){return Dns(o)?function(l){return Mns(l,o.length===1?o[0]:o)}:o}):s=[Lns];var n=-1;s=iye(s,Pns(Tns));var a=Ans(t,function(o,l,i){var c=iye(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return Ens(a,function(o,l){return Ins(o,l,r)})}var Rns=Ons;function Fns(t,s,r){switch(r.length){case 0:return t.call(s);case 1:return t.call(s,r[0]);case 2:return t.call(s,r[0],r[1]);case 3:return t.call(s,r[0],r[1],r[2])}return t.apply(s,r)}var zns=Fns,Bns=zns,HDe=Math.max;function $ns(t,s,r){return s=HDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=HDe(n.length-s,0),l=Array(o);++a0){if(++s>=Qns)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var tas=eas,sas=Yns,ras=tas,nas=ras(sas),aas=nas,ias=AE,oas=qns,las=aas;function cas(t,s){return las(oas(t,s,ias),t+"")}var das=cas,uas=u4e,has=gR,mas=M4e,pas=Vw;function fas(t,s,r){if(!pas(r))return!1;var n=typeof s;return(n=="number"?has(r)&&mas(s,r.length):n=="string"&&s in r)?uas(r[s],t):!1}var The=fas,xas=trt,gas=Rns,yas=das,WDe=The,vas=yas(function(t,s){if(t==null)return[];var r=s.length;return r>1&&WDe(t,s[0],s[1])?s=[]:r>2&&WDe(s[0],s[1],s[2])&&(s=[s[0]]),gas(t,xas(s,1),[])}),bas=vas;const P4e=Po(bas);function RD(t){"@babel/helpers - typeof";return RD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},RD(t)}function Vbe(){return Vbe=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s.x),"".concat(dI,"-left"),cn(r)&&s&&cn(s.x)&&r=s.y),"".concat(dI,"-top"),cn(n)&&s&&cn(s.y)&&nw?Math.max(p,c[n]):Math.max(f,c[n])}function Das(t){var s=t.translateX,r=t.translateY,n=t.useTranslate3d;return{transform:n?"translate3d(".concat(s,"px, ").concat(r,"px, 0)"):"translate(".concat(s,"px, ").concat(r,"px)")}}function Oas(t){var s=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,a=t.position,o=t.reverseDirection,l=t.tooltipBox,i=t.useTranslate3d,c=t.viewBox,u,p,f;return l.height>0&&l.width>0&&r?(p=YDe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),f=YDe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),u=Das({translateX:p,translateY:f,useTranslate3d:i})):u=Ias,{cssProperties:u,cssClasses:Las({translateX:p,translateY:f,coordinate:r})}}function lA(t){"@babel/helpers - typeof";return lA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},lA(t)}function QDe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function XDe(t){for(var s=1;sJDe||Math.abs(n.height-this.state.lastBoundingBox.height)>JDe)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,o=a.active,l=a.allowEscapeViewBox,i=a.animationDuration,c=a.animationEasing,u=a.children,p=a.coordinate,f=a.hasPayload,g=a.isAnimationActive,v=a.offset,_=a.position,w=a.reverseDirection,j=a.useTranslate3d,k=a.viewBox,S=a.wrapperStyle,M=Oas({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:v,position:_,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:k}),L=M.cssClasses,P=M.cssProperties,O=XDe(XDe({transition:g&&o?"transform ".concat(i,"ms ").concat(c):void 0},P),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return ht.createElement("div",{tabIndex:-1,className:L,style:O,ref:function(U){n.wrapperNode=U}},u)}}])}(N.PureComponent),Gas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},A3={isSsr:Gas()};function cA(t){"@babel/helpers - typeof";return cA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},cA(t)}function eOe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function tOe(t){for(var s=1;s0;return ht.createElement(Has,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:g,active:o,coordinate:p,hasPayload:O,offset:v,position:j,reverseDirection:k,useTranslate3d:S,viewBox:M,wrapperStyle:L},sis(u,tOe(tOe({},this.props),{},{payload:P})))}}])}(N.PureComponent);I4e(hp,"displayName","Tooltip");I4e(hp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!A3.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var ris=H0,nis=function(){return ris.Date.now()},ais=nis,iis=/\s/;function ois(t){for(var s=t.length;s--&&iis.test(t.charAt(s)););return s}var lis=ois,cis=lis,dis=/^\s+/;function uis(t){return t&&t.slice(0,cis(t)+1).replace(dis,"")}var his=uis,mis=his,sOe=Vw,pis=wE,rOe=NaN,fis=/^[-+]0x[0-9a-f]+$/i,xis=/^0b[01]+$/i,gis=/^0o[0-7]+$/i,yis=parseInt;function vis(t){if(typeof t=="number")return t;if(pis(t))return rOe;if(sOe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=sOe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=mis(t);var r=xis.test(t);return r||gis.test(t)?yis(t.slice(2),r?2:8):fis.test(t)?rOe:+t}var crt=vis,bis=Vw,lye=ais,nOe=crt,_is="Expected a function",wis=Math.max,jis=Math.min;function Nis(t,s,r){var n,a,o,l,i,c,u=0,p=!1,f=!1,g=!0;if(typeof t!="function")throw new TypeError(_is);s=nOe(s)||0,bis(r)&&(p=!!r.leading,f="maxWait"in r,o=f?wis(nOe(r.maxWait)||0,s):o,g="trailing"in r?!!r.trailing:g);function v(O){var $=n,U=a;return n=a=void 0,u=O,l=t.apply(U,$),l}function _(O){return u=O,i=setTimeout(k,s),p?v(O):l}function w(O){var $=O-c,U=O-u,B=s-$;return f?jis(B,o-U):B}function j(O){var $=O-c,U=O-u;return c===void 0||$>=s||$<0||f&&U>=o}function k(){var O=lye();if(j(O))return S(O);i=setTimeout(k,w(O))}function S(O){return i=void 0,g&&n?v(O):(n=a=void 0,l)}function M(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function L(){return i===void 0?l:S(lye())}function P(){var O=lye(),$=j(O);if(n=arguments,a=this,c=O,$){if(i===void 0)return _(c);if(f)return clearTimeout(i),i=setTimeout(k,s),v(c)}return i===void 0&&(i=setTimeout(k,s)),l}return P.cancel=M,P.flush=L,P}var kis=Nis,Sis=kis,Cis=Vw,Mis="Expected a function";function Tis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(Mis);return Cis(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Sis(t,s,{leading:n,maxWait:s,trailing:a})}var Ais=Tis;const drt=Po(Ais);function zD(t){"@babel/helpers - typeof";return zD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},zD(t)}function aOe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Gz(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(ee=drt(ee,w,{trailing:!0,leading:!1}));var Q=new ResizeObserver(ee),ce=P.current.getBoundingClientRect(),ne=ce.width,re=ce.height;return X(ne,re),Q.observe(P.current),function(){Q.disconnect()}},[X,w]);var Y=N.useMemo(function(){var ee=B.containerWidth,Q=B.containerHeight;if(ee<0||Q<0)return null;ny(P4(l)||P4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),ny(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=P4(l)?ee:l,ne=P4(c)?Q:c;r&&r>0&&(ce?ne=ce/r:ne&&(ce=ne*r),g&&ne>g&&(ne=g)),ny(ce>0||ne>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,ce,ne,l,c,p,f,r);var re=!Array.isArray(v)&&w1(v.type).endsWith("Chart");return ht.Children.map(v,function(oe){return ht.isValidElement(oe)?N.cloneElement(oe,Gz({width:ce,height:ne},re?{style:Gz({height:"100%",width:"100%",maxHeight:ne,maxWidth:ce},oe.props.style)}:{})):oe})},[r,v,c,g,f,p,B,l]);return ht.createElement("div",{id:j?"".concat(j):void 0,className:Vi("recharts-responsive-container",k),style:Gz(Gz({},L),{},{width:l,height:c,minWidth:p,minHeight:f,maxHeight:g}),ref:P},Y)}),yR=function(s){return null};yR.displayName="Cell";function BD(t){"@babel/helpers - typeof";return BD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},BD(t)}function oOe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Kbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||A3.isSsr)return{width:0,height:0};var n=Vis(r),a=JSON.stringify({text:s,copyStyle:n});if(R5.widthCache[a])return R5.widthCache[a];try{var o=document.getElementById(lOe);o||(o=document.createElement("span"),o.setAttribute("id",lOe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Kbe(Kbe({},Uis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return R5.widthCache[a]=c,++R5.cacheCount>qis&&(R5.cacheCount=0,R5.widthCache={}),c}catch{return{width:0,height:0}}},His=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function $D(t){"@babel/helpers - typeof";return $D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},$D(t)}function gce(t,s){return Zis(t)||Kis(t,s)||Wis(t,s)||Gis()}function Gis(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wis(t,s){if(t){if(typeof t=="string")return cOe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return cOe(t,s)}}function cOe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function cos(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function fOe(t,s){return mos(t)||hos(t,s)||uos(t,s)||dos()}function dos(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uos(t,s){if(t){if(typeof t=="string")return xOe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xOe(t,s)}}function xOe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return ce.reduce(function(ne,re){var oe=re.word,fe=re.width,ge=ne[ne.length-1];if(ge&&(a==null||o||ge.width+fe+nre.width?ne:re})};if(!p)return v;for(var w="…",j=function(ce){var ne=f.slice(0,ce),re=prt({breakAll:u,style:c,children:ne+w}).wordsWithComputedWidth,oe=g(re),fe=oe.length>l||_(oe).width>Number(a);return[fe,oe]},k=0,S=f.length-1,M=0,L;k<=S&&M<=f.length-1;){var P=Math.floor((k+S)/2),O=P-1,$=j(O),U=fOe($,2),B=U[0],V=U[1],X=j(P),Y=fOe(X,1),ee=Y[0];if(!B&&!ee&&(k=P+1),B&&ee&&(S=P-1),!B&&ee){L=V;break}M++}return L||v},gOe=function(s){var r=$i(s)?[]:s.toString().split(mrt);return[{words:r}]},fos=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!A3.isSsr){var c,u,p=prt({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,g=p.spaceWidth;c=f,u=g}else return gOe(a);return pos({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return gOe(a)},yOe="#808080",l3=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.lineHeight,i=l===void 0?"1em":l,c=s.capHeight,u=c===void 0?"0.71em":c,p=s.scaleToFit,f=p===void 0?!1:p,g=s.textAnchor,v=g===void 0?"start":g,_=s.verticalAnchor,w=_===void 0?"end":_,j=s.fill,k=j===void 0?yOe:j,S=pOe(s,oos),M=N.useMemo(function(){return fos({breakAll:S.breakAll,children:S.children,maxLines:S.maxLines,scaleToFit:f,style:S.style,width:S.width})},[S.breakAll,S.children,S.maxLines,f,S.style,S.width]),L=S.dx,P=S.dy,O=S.angle,$=S.className,U=S.breakAll,B=pOe(S,los);if(!Nu(n)||!Nu(o))return null;var V=n+(cn(L)?L:0),X=o+(cn(P)?P:0),Y;switch(w){case"start":Y=cye("calc(".concat(u,")"));break;case"middle":Y=cye("calc(".concat((M.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:Y=cye("calc(".concat(M.length-1," * -").concat(i,")"));break}var ee=[];if(f){var Q=M[0].width,ce=S.width;ee.push("scale(".concat((cn(ce)?ce/Q:1)/Q,")"))}return O&&ee.push("rotate(".concat(O,", ").concat(V,", ").concat(X,")")),ee.length&&(B.transform=ee.join(" ")),ht.createElement("text",Zbe({},oi(B,!0),{x:V,y:X,className:Vi("recharts-text",$),textAnchor:v,fill:k.includes("url")?yOe:k}),M.map(function(ne,re){var oe=ne.words.join(U?"":" ");return ht.createElement("tspan",{x:V,dy:re===0?Y:i,key:"".concat(oe,"-").concat(re)},oe)}))};function lw(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function xos(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function L4e(t){let s,r,n;t.length!==2?(s=lw,r=(i,c)=>lw(t(i),c),n=(i,c)=>t(i)-c):(s=t===lw||t===xos?t:gos,r=t,n=t);function a(i,c,u=0,p=i.length){if(u>>1;r(i[f],c)<0?u=f+1:p=f}while(u>>1;r(i[f],c)<=0?u=f+1:p=f}while(uu&&n(i[f-1],c)>-n(i[f],c)?f-1:f}return{left:a,center:l,right:o}}function gos(){return 0}function frt(t){return t===null?NaN:+t}function*yos(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const vos=L4e(lw),vR=vos.right;L4e(frt).center;class vOe extends Map{constructor(s,r=wos){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),s!=null)for(const[n,a]of s)this.set(n,a)}get(s){return super.get(bOe(this,s))}has(s){return super.has(bOe(this,s))}set(s,r){return super.set(bos(this,s),r)}delete(s){return super.delete(_os(this,s))}}function bOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function bos({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function _os({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function wos(t){return t!==null&&typeof t=="object"?t.valueOf():t}function jos(t=lw){if(t===lw)return xrt;if(typeof t!="function")throw new TypeError("compare is not a function");return(s,r)=>{const n=t(s,r);return n||n===0?n:(t(r,r)===0)-(t(s,s)===0)}}function xrt(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const Nos=Math.sqrt(50),kos=Math.sqrt(10),Sos=Math.sqrt(2);function yce(t,s,r){const n=(s-t)/Math.max(0,r),a=Math.floor(Math.log10(n)),o=n/Math.pow(10,a),l=o>=Nos?10:o>=kos?5:o>=Sos?2:1;let i,c,u;return a<0?(u=Math.pow(10,-a)/l,i=Math.round(t*u),c=Math.round(s*u),i/us&&--c,u=-u):(u=Math.pow(10,a)*l,i=Math.round(t/u),c=Math.round(s/u),i*us&&--c),c0))return[];if(t===s)return[t];const n=s=a))return[];const i=o-a+1,c=new Array(i);if(n)if(l<0)for(let u=0;u=n)&&(r=n);return r}function wOe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function grt(t,s,r=0,n=1/0,a){if(s=Math.floor(s),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(t.length-1,n)),!(r<=s&&s<=n))return t;for(a=a===void 0?xrt:jos(a);n>r;){if(n-r>600){const c=n-r+1,u=s-r+1,p=Math.log(c),f=.5*Math.exp(2*p/3),g=.5*Math.sqrt(p*f*(c-f)/c)*(u-c/2<0?-1:1),v=Math.max(r,Math.floor(s-u*f/c+g)),_=Math.min(n,Math.floor(s+(c-u)*f/c+g));grt(t,s,v,_,a)}const o=t[s];let l=r,i=n;for(uI(t,r,s),a(t[n],o)>0&&uI(t,r,n);l0;)--i}a(t[r],o)===0?uI(t,r,i):(++i,uI(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function uI(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Cos(t,s,r){if(t=Float64Array.from(yos(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return wOe(t);if(s>=1)return _Oe(t);var n,a=(n-1)*s,o=Math.floor(a),l=_Oe(grt(t,o).subarray(0,o+1)),i=wOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function Mos(t,s,r=frt){if(!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return+r(t[0],0,t);if(s>=1)return+r(t[n-1],n-1,t);var n,a=(n-1)*s,o=Math.floor(a),l=+r(t[o],o,t),i=+r(t[o+1],o+1,t);return l+(i-l)*(a-o)}}function Tos(t,s,r){t=+t,s=+s,r=(a=arguments.length)<2?(s=t,t=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((s-t)/r))|0,o=new Array(a);++n>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):r===8?Kz(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Kz(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=Eos.exec(t))?new _p(s[1],s[2],s[3],1):(s=Pos.exec(t))?new _p(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Ios.exec(t))?Kz(s[1],s[2],s[3],s[4]):(s=Los.exec(t))?Kz(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Dos.exec(t))?TOe(s[1],s[2]/100,s[3]/100,1):(s=Oos.exec(t))?TOe(s[1],s[2]/100,s[3]/100,s[4]):jOe.hasOwnProperty(t)?SOe(jOe[t]):t==="transparent"?new _p(NaN,NaN,NaN,0):null}function SOe(t){return new _p(t>>16&255,t>>8&255,t&255,1)}function Kz(t,s,r,n){return n<=0&&(t=s=r=NaN),new _p(t,s,r,n)}function zos(t){return t instanceof bR||(t=HD(t)),t?(t=t.rgb(),new _p(t.r,t.g,t.b,t.opacity)):new _p}function e_e(t,s,r,n){return arguments.length===1?zos(t):new _p(t,s,r,n??1)}function _p(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}O4e(_p,e_e,vrt(bR,{brighter(t){return t=t==null?vce:Math.pow(vce,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?UD:Math.pow(UD,t),new _p(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _p(ES(this.r),ES(this.g),ES(this.b),bce(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:COe,formatHex:COe,formatHex8:Bos,formatRgb:MOe,toString:MOe}));function COe(){return`#${I4(this.r)}${I4(this.g)}${I4(this.b)}`}function Bos(){return`#${I4(this.r)}${I4(this.g)}${I4(this.b)}${I4((isNaN(this.opacity)?1:this.opacity)*255)}`}function MOe(){const t=bce(this.opacity);return`${t===1?"rgb(":"rgba("}${ES(this.r)}, ${ES(this.g)}, ${ES(this.b)}${t===1?")":`, ${t})`}`}function bce(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ES(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function I4(t){return t=ES(t),(t<16?"0":"")+t.toString(16)}function TOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Wg(t,s,r,n)}function brt(t){if(t instanceof Wg)return new Wg(t.h,t.s,t.l,t.opacity);if(t instanceof bR||(t=HD(t)),!t)return new Wg;if(t instanceof Wg)return t;t=t.rgb();var s=t.r/255,r=t.g/255,n=t.b/255,a=Math.min(s,r,n),o=Math.max(s,r,n),l=NaN,i=o-a,c=(o+a)/2;return i?(s===o?l=(r-n)/i+(r0&&c<1?0:l,new Wg(l,i,c,t.opacity)}function $os(t,s,r,n){return arguments.length===1?brt(t):new Wg(t,s,r,n??1)}function Wg(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}O4e(Wg,$os,vrt(bR,{brighter(t){return t=t==null?vce:Math.pow(vce,t),new Wg(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?UD:Math.pow(UD,t),new Wg(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*s,a=2*r-n;return new _p(dye(t>=240?t-240:t+120,a,n),dye(t,a,n),dye(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Wg(AOe(this.h),Zz(this.s),Zz(this.l),bce(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=bce(this.opacity);return`${t===1?"hsl(":"hsla("}${AOe(this.h)}, ${Zz(this.s)*100}%, ${Zz(this.l)*100}%${t===1?")":`, ${t})`}`}}));function AOe(t){return t=(t||0)%360,t<0?t+360:t}function Zz(t){return Math.max(0,Math.min(1,t||0))}function dye(t,s,r){return(t<60?s+(r-s)*t/60:t<180?r:t<240?s+(r-s)*(240-t)/60:s)*255}const R4e=t=>()=>t;function qos(t,s){return function(r){return t+r*s}}function Uos(t,s,r){return t=Math.pow(t,r),s=Math.pow(s,r)-t,r=1/r,function(n){return Math.pow(t+n*s,r)}}function Vos(t){return(t=+t)==1?_rt:function(s,r){return r-s?Uos(s,r,t):R4e(isNaN(s)?r:s)}}function _rt(t,s){var r=s-t;return r?qos(t,r):R4e(isNaN(t)?s:t)}const EOe=function t(s){var r=Vos(s);function n(a,o){var l=r((a=e_e(a)).r,(o=e_e(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=_rt(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=c(p),a.opacity=u(p),a+""}}return n.gamma=t,n}(1);function Hos(t,s){s||(s=[]);var r=t?Math.min(s.length,t.length):0,n=s.slice(),a;return function(o){for(a=0;ar&&(o=s.slice(r,o),i[l]?i[l]+=o:i[++l]=o),(n=n[0])===(a=a[0])?i[l]?i[l]+=a:i[++l]=a:(i[++l]=null,c.push({i:l,x:_ce(n,a)})),r=uye.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function sls(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?rls:sls,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?o:(c||(c=i(t.map(n),s,r)))(n(l(g)))}return f.invert=function(g){return l(a((u||(u=i(s,t.map(n),_ce)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,wce),p()):t.slice()},f.range=function(g){return arguments.length?(s=Array.from(g),p()):s.slice()},f.rangeRound=function(g){return s=Array.from(g),r=F4e,p()},f.clamp=function(g){return arguments.length?(l=g?!0:Pm,p()):l!==Pm},f.interpolate=function(g){return arguments.length?(r=g,p()):r},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,v){return n=g,a=v,p()}}function z4e(){return Ahe()(Pm,Pm)}function nls(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function jce(t,s){if((r=(t=s?t.toExponential(s-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function dA(t){return t=jce(Math.abs(t)),t?t[1]:NaN}function als(t,s){return function(r,n){for(var a=r.length,o=[],l=0,i=t[0],c=0;a>0&&i>0&&(c+i+1>n&&(i=Math.max(1,n-c)),o.push(r.substring(a-=i,a+i)),!((c+=i+1)>n));)i=t[l=(l+1)%t.length];return o.reverse().join(s)}}function ils(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var ols=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function GD(t){if(!(s=ols.exec(t)))throw new Error("invalid format: "+t);var s;return new B4e({fill:s[1],align:s[2],sign:s[3],symbol:s[4],zero:s[5],width:s[6],comma:s[7],precision:s[8]&&s[8].slice(1),trim:s[9],type:s[10]})}GD.prototype=B4e.prototype;function B4e(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}B4e.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function lls(t){e:for(var s=t.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(a+1):t}var wrt;function cls(t,s){var r=jce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(wrt=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,l=n.length;return o===l?n:o>l?n+new Array(o-l+1).join("0"):o>0?n.slice(0,o)+"."+n.slice(o):"0."+new Array(1-o).join("0")+jce(t,Math.max(0,s+o-1))[0]}function IOe(t,s){var r=jce(t,s);if(!r)return t+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const LOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:nls,e:(t,s)=>t.toExponential(s),f:(t,s)=>t.toFixed(s),g:(t,s)=>t.toPrecision(s),o:t=>Math.round(t).toString(8),p:(t,s)=>IOe(t*100,s),r:IOe,s:cls,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function DOe(t){return t}var OOe=Array.prototype.map,ROe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function dls(t){var s=t.grouping===void 0||t.thousands===void 0?DOe:als(OOe.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",a=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?DOe:ils(OOe.call(t.numerals,String)),l=t.percent===void 0?"%":t.percent+"",i=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=GD(f);var g=f.fill,v=f.align,_=f.sign,w=f.symbol,j=f.zero,k=f.width,S=f.comma,M=f.precision,L=f.trim,P=f.type;P==="n"?(S=!0,P="g"):LOe[P]||(M===void 0&&(M=12),L=!0,P="g"),(j||g==="0"&&v==="=")&&(j=!0,g="0",v="=");var O=w==="$"?r:w==="#"&&/[boxX]/.test(P)?"0"+P.toLowerCase():"",$=w==="$"?n:/[%p]/.test(P)?l:"",U=LOe[P],B=/[defgprs%]/.test(P);M=M===void 0?6:/[gprs]/.test(P)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function V(X){var Y=O,ee=$,Q,ce,ne;if(P==="c")ee=U(X)+ee,X="";else{X=+X;var re=X<0||1/X<0;if(X=isNaN(X)?c:U(Math.abs(X),M),L&&(X=lls(X)),re&&+X==0&&_!=="+"&&(re=!1),Y=(re?_==="("?_:i:_==="-"||_==="("?"":_)+Y,ee=(P==="s"?ROe[8+wrt/3]:"")+ee+(re&&_==="("?")":""),B){for(Q=-1,ce=X.length;++Qne||ne>57){ee=(ne===46?a+X.slice(Q+1):X.slice(Q))+ee,X=X.slice(0,Q);break}}}S&&!j&&(X=s(X,1/0));var oe=Y.length+X.length+ee.length,fe=oe>1)+Y+X+ee+fe.slice(oe);break;default:X=fe+Y+X+ee;break}return o(X)}return V.toString=function(){return f+""},V}function p(f,g){var v=u((f=GD(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(dA(g)/3)))*3,w=Math.pow(10,-_),j=ROe[8+_/3];return function(k){return v(w*k)+j}}return{format:u,formatPrefix:p}}var Yz,$4e,jrt;uls({thousands:",",grouping:[3],currency:["$",""]});function uls(t){return Yz=dls(t),$4e=Yz.format,jrt=Yz.formatPrefix,Yz}function hls(t){return Math.max(0,-dA(Math.abs(t)))}function mls(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(dA(s)/3)))*3-dA(Math.abs(t)))}function pls(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,dA(s)-dA(t))+1}function Nrt(t,s,r,n){var a=Xbe(t,s,r),o;switch(n=GD(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=mls(a,l))&&(n.precision=o),jrt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=pls(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=hls(a))&&(n.precision=o-(n.type==="%")*2);break}}return $4e(n)}function Hw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Ybe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return Nrt(a[0],a[a.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=s(),a=0,o=n.length-1,l=n[a],i=n[o],c,u,p=10;for(i0;){if(u=Qbe(l,i,r),u===c)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;c=u}return t},t}function Nce(){var t=z4e();return t.copy=function(){return _R(t,Nce())},Kx.apply(t,arguments),Hw(t)}function krt(t){var s;function r(n){return n==null||isNaN(n=+n)?s:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(t=Array.from(n,wce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return krt(t).unknown(s)},t=arguments.length?Array.from(t,wce):[0,1],Hw(r)}function Srt(t,s){t=t.slice();var r=0,n=t.length-1,a=t[r],o=t[n],l;return oMath.pow(t,s)}function vls(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),s=>Math.log(s)/t)}function BOe(t){return(s,r)=>-t(-s,r)}function q4e(t){const s=t(FOe,zOe),r=s.domain;let n=10,a,o;function l(){return a=vls(n),o=yls(n),r()[0]<0?(a=BOe(a),o=BOe(o),t(fls,xls)):t(FOe,zOe),s}return s.base=function(i){return arguments.length?(n=+i,l()):n},s.domain=function(i){return arguments.length?(r(i),l()):r()},s.ticks=i=>{const c=r();let u=c[0],p=c[c.length-1];const f=p0){for(;g<=v;++g)for(_=1;_p)break;k.push(w)}}else for(;g<=v;++g)for(_=n-1;_>=1;--_)if(w=g>0?_/o(-g):_*o(g),!(wp)break;k.push(w)}k.length*2{if(i==null&&(i=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=GD(c)).precision==null&&(c.trim=!0),c=$4e(c)),i===1/0)return c;const u=Math.max(1,n*i/s.ticks().length);return p=>{let f=p/o(Math.round(a(p)));return f*nr(Srt(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function Crt(){const t=q4e(Ahe()).domain([1,10]);return t.copy=()=>_R(t,Crt()).base(t.base()),Kx.apply(t,arguments),t}function $Oe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function qOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function U4e(t){var s=1,r=t($Oe(s),qOe(s));return r.constant=function(n){return arguments.length?t($Oe(s=+n),qOe(s)):s},Hw(r)}function Mrt(){var t=U4e(Ahe());return t.copy=function(){return _R(t,Mrt()).constant(t.constant())},Kx.apply(t,arguments)}function UOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function bls(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function _ls(t){return t<0?-t*t:t*t}function V4e(t){var s=t(Pm,Pm),r=1;function n(){return r===1?t(Pm,Pm):r===.5?t(bls,_ls):t(UOe(r),UOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Hw(s)}function H4e(){var t=V4e(Ahe());return t.copy=function(){return _R(t,H4e()).exponent(t.exponent())},Kx.apply(t,arguments),t}function wls(){return H4e.apply(null,arguments).exponent(.5)}function VOe(t){return Math.sign(t)*t*t}function jls(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Trt(){var t=z4e(),s=[0,1],r=!1,n;function a(o){var l=jls(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(VOe(o))},a.domain=function(o){return arguments.length?(t.domain(o),a):t.domain()},a.range=function(o){return arguments.length?(t.range((s=Array.from(o,wce)).map(VOe)),a):s.slice()},a.rangeRound=function(o){return a.range(o).round(!0)},a.round=function(o){return arguments.length?(r=!!o,a):r},a.clamp=function(o){return arguments.length?(t.clamp(o),a):t.clamp()},a.unknown=function(o){return arguments.length?(n=o,a):n},a.copy=function(){return Trt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Kx.apply(a,arguments),Hw(a)}function Art(){var t=[],s=[],r=[],n;function a(){var l=0,i=Math.max(1,s.length);for(r=new Array(i-1);++l0?r[i-1]:t[0],i=r?[n[r-1],s]:[n[u-1],n[u]]},l.unknown=function(c){return arguments.length&&(o=c),l},l.thresholds=function(){return n.slice()},l.copy=function(){return Ert().domain([t,s]).range(a).unknown(o)},Kx.apply(Hw(l),arguments)}function Prt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[vR(t,o,0,n)]:r}return a.domain=function(o){return arguments.length?(t=Array.from(o),n=Math.min(t.length,s.length-1),a):t.slice()},a.range=function(o){return arguments.length?(s=Array.from(o),n=Math.min(t.length,s.length-1),a):s.slice()},a.invertExtent=function(o){var l=s.indexOf(o);return[t[l-1],t[l]]},a.unknown=function(o){return arguments.length?(r=o,a):r},a.copy=function(){return Prt().domain(t).range(s).unknown(r)},Kx.apply(a,arguments)}const hye=new Date,mye=new Date;function Ou(t,s,r,n){function a(o){return t(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(t(o=new Date(+o)),o),a.ceil=o=>(t(o=new Date(o-1)),s(o,1),t(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(s(o=new Date(+o),l==null?1:Math.floor(l)),o),a.range=(o,l,i)=>{const c=[];if(o=a.ceil(o),i=i==null?1:Math.floor(i),!(o0))return c;let u;do c.push(u=new Date(+o)),s(o,i),t(o);while(uOu(l=>{if(l>=l)for(;t(l),!o(l);)l.setTime(l-1)},(l,i)=>{if(l>=l)if(i<0)for(;++i<=0;)for(;s(l,-1),!o(l););else for(;--i>=0;)for(;s(l,1),!o(l););}),r&&(a.count=(o,l)=>(hye.setTime(+o),mye.setTime(+l),t(hye),t(mye),Math.floor(r(hye,mye))),a.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?a.filter(n?l=>n(l)%o===0:l=>a.count(0,l)%o===0):a)),a}const kce=Ou(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);kce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ou(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):kce);kce.range;const t1=1e3,jx=t1*60,s1=jx*60,O1=s1*24,G4e=O1*7,HOe=O1*30,pye=O1*365,L4=Ou(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*t1)},(t,s)=>(s-t)/t1,t=>t.getUTCSeconds());L4.range;const W4e=Ou(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*t1)},(t,s)=>{t.setTime(+t+s*jx)},(t,s)=>(s-t)/jx,t=>t.getMinutes());W4e.range;const K4e=Ou(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*jx)},(t,s)=>(s-t)/jx,t=>t.getUTCMinutes());K4e.range;const Z4e=Ou(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*t1-t.getMinutes()*jx)},(t,s)=>{t.setTime(+t+s*s1)},(t,s)=>(s-t)/s1,t=>t.getHours());Z4e.range;const Y4e=Ou(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*s1)},(t,s)=>(s-t)/s1,t=>t.getUTCHours());Y4e.range;const wR=Ou(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*jx)/O1,t=>t.getDate()-1);wR.range;const Ehe=Ou(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/O1,t=>t.getUTCDate()-1);Ehe.range;const Irt=Ou(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/O1,t=>Math.floor(t/O1));Irt.range;function E3(t){return Ou(s=>{s.setDate(s.getDate()-(s.getDay()+7-t)%7),s.setHours(0,0,0,0)},(s,r)=>{s.setDate(s.getDate()+r*7)},(s,r)=>(r-s-(r.getTimezoneOffset()-s.getTimezoneOffset())*jx)/G4e)}const Phe=E3(0),Sce=E3(1),Nls=E3(2),kls=E3(3),uA=E3(4),Sls=E3(5),Cls=E3(6);Phe.range;Sce.range;Nls.range;kls.range;uA.range;Sls.range;Cls.range;function P3(t){return Ou(s=>{s.setUTCDate(s.getUTCDate()-(s.getUTCDay()+7-t)%7),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCDate(s.getUTCDate()+r*7)},(s,r)=>(r-s)/G4e)}const Ihe=P3(0),Cce=P3(1),Mls=P3(2),Tls=P3(3),hA=P3(4),Als=P3(5),Els=P3(6);Ihe.range;Cce.range;Mls.range;Tls.range;hA.range;Als.range;Els.range;const Q4e=Ou(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,s)=>{t.setMonth(t.getMonth()+s)},(t,s)=>s.getMonth()-t.getMonth()+(s.getFullYear()-t.getFullYear())*12,t=>t.getMonth());Q4e.range;const X4e=Ou(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCMonth(t.getUTCMonth()+s)},(t,s)=>s.getUTCMonth()-t.getUTCMonth()+(s.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());X4e.range;const R1=Ou(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,s)=>{t.setFullYear(t.getFullYear()+s)},(t,s)=>s.getFullYear()-t.getFullYear(),t=>t.getFullYear());R1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ou(s=>{s.setFullYear(Math.floor(s.getFullYear()/t)*t),s.setMonth(0,1),s.setHours(0,0,0,0)},(s,r)=>{s.setFullYear(s.getFullYear()+r*t)});R1.range;const F1=Ou(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCFullYear(t.getUTCFullYear()+s)},(t,s)=>s.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());F1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ou(s=>{s.setUTCFullYear(Math.floor(s.getUTCFullYear()/t)*t),s.setUTCMonth(0,1),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCFullYear(s.getUTCFullYear()+r*t)});F1.range;function Lrt(t,s,r,n,a,o){const l=[[L4,1,t1],[L4,5,5*t1],[L4,15,15*t1],[L4,30,30*t1],[o,1,jx],[o,5,5*jx],[o,15,15*jx],[o,30,30*jx],[a,1,s1],[a,3,3*s1],[a,6,6*s1],[a,12,12*s1],[n,1,O1],[n,2,2*O1],[r,1,G4e],[s,1,HOe],[s,3,3*HOe],[t,1,pye]];function i(u,p,f){const g=pj).right(l,g);if(v===l.length)return t.every(Xbe(u/pye,p/pye,f));if(v===0)return kce.every(Math.max(Xbe(u,p,f),1));const[_,w]=l[g/l[v-1][2]53)return null;"w"in Te||(Te.w=1),"Z"in Te?(ye=xye(hI(Te.y,0,1)),qe=ye.getUTCDay(),ye=qe>4||qe===0?Cce.ceil(ye):Cce(ye),ye=Ehe.offset(ye,(Te.V-1)*7),Te.y=ye.getUTCFullYear(),Te.m=ye.getUTCMonth(),Te.d=ye.getUTCDate()+(Te.w+6)%7):(ye=fye(hI(Te.y,0,1)),qe=ye.getDay(),ye=qe>4||qe===0?Sce.ceil(ye):Sce(ye),ye=wR.offset(ye,(Te.V-1)*7),Te.y=ye.getFullYear(),Te.m=ye.getMonth(),Te.d=ye.getDate()+(Te.w+6)%7)}else("W"in Te||"U"in Te)&&("w"in Te||(Te.w="u"in Te?Te.u%7:"W"in Te?1:0),qe="Z"in Te?xye(hI(Te.y,0,1)).getUTCDay():fye(hI(Te.y,0,1)).getDay(),Te.m=0,Te.d="W"in Te?(Te.w+6)%7+Te.W*7-(qe+5)%7:Te.w+Te.U*7-(qe+6)%7);return"Z"in Te?(Te.H+=Te.Z/100|0,Te.M+=Te.Z%100,xye(Te)):fye(Te)}}function U(we,Le,Qe,Te){for(var pt=0,ye=Le.length,qe=Qe.length,at,tt;pt=qe)return-1;if(at=Le.charCodeAt(pt++),at===37){if(at=Le.charAt(pt++),tt=P[at in GOe?Le.charAt(pt++):at],!tt||(Te=tt(we,Qe,Te))<0)return-1}else if(at!=Qe.charCodeAt(Te++))return-1}return Te}function B(we,Le,Qe){var Te=u.exec(Le.slice(Qe));return Te?(we.p=p.get(Te[0].toLowerCase()),Qe+Te[0].length):-1}function V(we,Le,Qe){var Te=v.exec(Le.slice(Qe));return Te?(we.w=_.get(Te[0].toLowerCase()),Qe+Te[0].length):-1}function X(we,Le,Qe){var Te=f.exec(Le.slice(Qe));return Te?(we.w=g.get(Te[0].toLowerCase()),Qe+Te[0].length):-1}function Y(we,Le,Qe){var Te=k.exec(Le.slice(Qe));return Te?(we.m=S.get(Te[0].toLowerCase()),Qe+Te[0].length):-1}function ee(we,Le,Qe){var Te=w.exec(Le.slice(Qe));return Te?(we.m=j.get(Te[0].toLowerCase()),Qe+Te[0].length):-1}function Q(we,Le,Qe){return U(we,s,Le,Qe)}function ce(we,Le,Qe){return U(we,r,Le,Qe)}function ne(we,Le,Qe){return U(we,n,Le,Qe)}function re(we){return l[we.getDay()]}function oe(we){return o[we.getDay()]}function fe(we){return c[we.getMonth()]}function ge(we){return i[we.getMonth()]}function ue(we){return a[+(we.getHours()>=12)]}function xe(we){return 1+~~(we.getMonth()/3)}function _e(we){return l[we.getUTCDay()]}function $e(we){return o[we.getUTCDay()]}function Me(we){return c[we.getUTCMonth()]}function Ie(we){return i[we.getUTCMonth()]}function ke(we){return a[+(we.getUTCHours()>=12)]}function pe(we){return 1+~~(we.getUTCMonth()/3)}return{format:function(we){var Le=O(we+="",M);return Le.toString=function(){return we},Le},parse:function(we){var Le=$(we+="",!1);return Le.toString=function(){return we},Le},utcFormat:function(we){var Le=O(we+="",L);return Le.toString=function(){return we},Le},utcParse:function(we){var Le=$(we+="",!0);return Le.toString=function(){return we},Le}}}var GOe={"-":"",_:" ",0:"0"},dh=/^\s*\d+/,Rls=/^%/,Fls=/[\\^$*+?|[\]().{}]/g;function el(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function Bls(t,s,r){var n=dh.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function $ls(t,s,r){var n=dh.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function qls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Uls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Vls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function WOe(t,s,r){var n=dh.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function KOe(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Hls(t,s,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(s.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function Gls(t,s,r){var n=dh.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Wls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function ZOe(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Kls(t,s,r){var n=dh.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function YOe(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Zls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Yls(t,s,r){var n=dh.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Qls(t,s,r){var n=dh.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Xls(t,s,r){var n=dh.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Jls(t,s,r){var n=Rls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function ecs(t,s,r){var n=dh.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function tcs(t,s,r){var n=dh.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function QOe(t,s){return el(t.getDate(),s,2)}function scs(t,s){return el(t.getHours(),s,2)}function rcs(t,s){return el(t.getHours()%12||12,s,2)}function ncs(t,s){return el(1+wR.count(R1(t),t),s,3)}function Drt(t,s){return el(t.getMilliseconds(),s,3)}function acs(t,s){return Drt(t,s)+"000"}function ics(t,s){return el(t.getMonth()+1,s,2)}function ocs(t,s){return el(t.getMinutes(),s,2)}function lcs(t,s){return el(t.getSeconds(),s,2)}function ccs(t){var s=t.getDay();return s===0?7:s}function dcs(t,s){return el(Phe.count(R1(t)-1,t),s,2)}function Ort(t){var s=t.getDay();return s>=4||s===0?uA(t):uA.ceil(t)}function ucs(t,s){return t=Ort(t),el(uA.count(R1(t),t)+(R1(t).getDay()===4),s,2)}function hcs(t){return t.getDay()}function mcs(t,s){return el(Sce.count(R1(t)-1,t),s,2)}function pcs(t,s){return el(t.getFullYear()%100,s,2)}function fcs(t,s){return t=Ort(t),el(t.getFullYear()%100,s,2)}function xcs(t,s){return el(t.getFullYear()%1e4,s,4)}function gcs(t,s){var r=t.getDay();return t=r>=4||r===0?uA(t):uA.ceil(t),el(t.getFullYear()%1e4,s,4)}function ycs(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+el(s/60|0,"0",2)+el(s%60,"0",2)}function XOe(t,s){return el(t.getUTCDate(),s,2)}function vcs(t,s){return el(t.getUTCHours(),s,2)}function bcs(t,s){return el(t.getUTCHours()%12||12,s,2)}function _cs(t,s){return el(1+Ehe.count(F1(t),t),s,3)}function Rrt(t,s){return el(t.getUTCMilliseconds(),s,3)}function wcs(t,s){return Rrt(t,s)+"000"}function jcs(t,s){return el(t.getUTCMonth()+1,s,2)}function Ncs(t,s){return el(t.getUTCMinutes(),s,2)}function kcs(t,s){return el(t.getUTCSeconds(),s,2)}function Scs(t){var s=t.getUTCDay();return s===0?7:s}function Ccs(t,s){return el(Ihe.count(F1(t)-1,t),s,2)}function Frt(t){var s=t.getUTCDay();return s>=4||s===0?hA(t):hA.ceil(t)}function Mcs(t,s){return t=Frt(t),el(hA.count(F1(t),t)+(F1(t).getUTCDay()===4),s,2)}function Tcs(t){return t.getUTCDay()}function Acs(t,s){return el(Cce.count(F1(t)-1,t),s,2)}function Ecs(t,s){return el(t.getUTCFullYear()%100,s,2)}function Pcs(t,s){return t=Frt(t),el(t.getUTCFullYear()%100,s,2)}function Ics(t,s){return el(t.getUTCFullYear()%1e4,s,4)}function Lcs(t,s){var r=t.getUTCDay();return t=r>=4||r===0?hA(t):hA.ceil(t),el(t.getUTCFullYear()%1e4,s,4)}function Dcs(){return"+0000"}function JOe(){return"%"}function eRe(t){return+t}function tRe(t){return Math.floor(+t/1e3)}var F5,zrt,Brt;Ocs({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Ocs(t){return F5=Ols(t),zrt=F5.format,F5.parse,Brt=F5.utcFormat,F5.utcParse,F5}function Rcs(t){return new Date(t)}function Fcs(t){return t instanceof Date?+t:+new Date(+t)}function J4e(t,s,r,n,a,o,l,i,c,u){var p=z4e(),f=p.invert,g=p.domain,v=u(".%L"),_=u(":%S"),w=u("%I:%M"),j=u("%I %p"),k=u("%a %d"),S=u("%b %d"),M=u("%B"),L=u("%Y");function P(O){return(c(O)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Cos(t,o/n))},r.copy=function(){return Vrt(s).domain(t)},Y1.apply(r,arguments)}function Dhe(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=Pm,p,f=!1,g;function v(w){return isNaN(w=+w)?g:(w=.5+((w=+p(w))-o)*(n*ws}var Krt=Hcs,Gcs=Ohe,Wcs=Krt,Kcs=AE;function Zcs(t){return t&&t.length?Gcs(t,Kcs,Wcs):void 0}var Ycs=Zcs;const Rhe=Po(Ycs);function Qcs(t,s){return tt.e^o.s<0?1:-1;for(n=o.d.length,a=t.d.length,s=0,r=nt.d[s]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};aa.decimalPlaces=aa.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*wc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};aa.dividedBy=aa.div=function(t){return j1(this,new this.constructor(t))};aa.dividedToIntegerBy=aa.idiv=function(t){var s=this,r=s.constructor;return zl(j1(s,new r(t),0,1),r.precision)};aa.equals=aa.eq=function(t){return!this.cmp(t)};aa.exponent=function(){return au(this)};aa.greaterThan=aa.gt=function(t){return this.cmp(t)>0};aa.greaterThanOrEqualTo=aa.gte=function(t){return this.cmp(t)>=0};aa.isInteger=aa.isint=function(){return this.e>this.d.length-2};aa.isNegative=aa.isneg=function(){return this.s<0};aa.isPositive=aa.ispos=function(){return this.s>0};aa.isZero=function(){return this.s===0};aa.lessThan=aa.lt=function(t){return this.cmp(t)<0};aa.lessThanOrEqualTo=aa.lte=function(t){return this.cmp(t)<1};aa.logarithm=aa.log=function(t){var s,r=this,n=r.constructor,a=n.precision,o=a+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(uf))throw Error(qx+"NaN");if(r.s<1)throw Error(qx+(r.s?"NaN":"-Infinity"));return r.eq(uf)?new n(0):($c=!1,s=j1(WD(r,o),WD(t,o),o),$c=!0,zl(s,a))};aa.minus=aa.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Jrt(s,t):Qrt(s,(t.s=-t.s,t))};aa.modulo=aa.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(qx+"NaN");return r.s?($c=!1,s=j1(r,t,0,1).times(t),$c=!0,r.minus(s)):zl(new n(r),a)};aa.naturalExponential=aa.exp=function(){return Xrt(this)};aa.naturalLogarithm=aa.ln=function(){return WD(this)};aa.negated=aa.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};aa.plus=aa.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Qrt(s,t):Jrt(s,(t.s=-t.s,t))};aa.precision=aa.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(PS+t);if(s=au(a)+1,n=a.d.length-1,r=n*wc+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return t&&s>r?s:r};aa.squareRoot=aa.sqrt=function(){var t,s,r,n,a,o,l,i=this,c=i.constructor;if(i.s<1){if(!i.s)return new c(0);throw Error(qx+"NaN")}for(t=au(i),$c=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=u0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=IE((t+1)/2)-(t<0||t%2),a==1/0?s="5e"+t:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+t),n=new c(s)):n=new c(a.toString()),r=c.precision,a=l=r+3;;)if(o=n,n=o.plus(j1(i,o,l+2)).times(.5),u0(o.d).slice(0,l)===(s=u0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(zl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return $c=!0,zl(n,r)};aa.times=aa.mul=function(t){var s,r,n,a,o,l,i,c,u,p=this,f=p.constructor,g=p.d,v=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,c=g.length,u=v.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+v[n]*g[a-n-1]+s,o[a--]=i%Gu|0,s=i/Gu|0;o[a]=(o[a]+s)%Gu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,$c?zl(t,f.precision):t};aa.toDecimalPlaces=aa.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(R0(t,0,PE),s===void 0?s=n.rounding:R0(s,0,8),zl(r,t+au(r)+1,s))};aa.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=c3(n,!0):(R0(t,0,PE),s===void 0?s=a.rounding:R0(s,0,8),n=zl(new a(n),t+1,s),r=c3(n,!0,t+1)),r};aa.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?c3(a):(R0(t,0,PE),s===void 0?s=o.rounding:R0(s,0,8),n=zl(new o(a),t+au(a)+1,s),r=c3(n.abs(),!1,t+au(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};aa.toInteger=aa.toint=function(){var t=this,s=t.constructor;return zl(new s(t),au(t)+1,s.rounding)};aa.toNumber=function(){return+this};aa.toPower=aa.pow=function(t){var s,r,n,a,o,l,i=this,c=i.constructor,u=12,p=+(t=new c(t));if(!t.s)return new c(uf);if(i=new c(i),!i.s){if(t.s<1)throw Error(qx+"Infinity");return i}if(i.eq(uf))return i;if(n=c.precision,t.eq(uf))return zl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=Yrt){for(a=new c(uf),s=Math.ceil(n/wc+4),$c=!1;r%2&&(a=a.times(i),nRe(a.d,s)),r=IE(r/2),r!==0;)i=i.times(i),nRe(i.d,s);return $c=!0,t.s<0?new c(uf).div(a):zl(a,n)}}else if(o<0)throw Error(qx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,$c=!1,a=t.times(WD(i,n+u)),$c=!0,a=Xrt(a),a.s=o,a};aa.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=au(a),n=c3(a,r<=o.toExpNeg||r>=o.toExpPos)):(R0(t,1,PE),s===void 0?s=o.rounding:R0(s,0,8),a=zl(new o(a),t,s),r=au(a),n=c3(a,t<=r||r<=o.toExpNeg,t)),n};aa.toSignificantDigits=aa.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(R0(t,1,PE),s===void 0?s=n.rounding:R0(s,0,8)),zl(new n(r),t,s)};aa.toString=aa.valueOf=aa.val=aa.toJSON=aa[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=au(t),r=t.constructor;return c3(t,s<=r.toExpNeg||s>=r.toExpPos)};function Qrt(t,s){var r,n,a,o,l,i,c,u,p=t.constructor,f=p.precision;if(!t.s||!s.s)return s.s||(s=new p(t)),$c?zl(s,f):s;if(c=t.d,u=s.d,l=t.e,a=s.e,c=c.slice(),o=l-a,o){for(o<0?(n=c,o=-o,i=u.length):(n=u,a=l,i=c.length),l=Math.ceil(f/wc),i=l>i?l+1:i+1,o>i&&(o=i,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(i=c.length,o=u.length,i-o<0&&(o=i,n=u,u=c,c=n),r=0;o;)r=(c[--o]=c[o]+u[o]+r)/Gu|0,c[o]%=Gu;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,$c?zl(s,f):s}function R0(t,s,r){if(t!==~~t||tr)throw Error(PS+t)}function u0(t){var s,r,n,a=t.length-1,o="",l=t[0];if(a>0){for(o+=l,s=1;sl?1:-1;else for(i=c=0;ia[i]?1:-1;break}return c}function r(n,a,o){for(var l=0;o--;)n[o]-=l,l=n[o]1;)n.shift()}return function(n,a,o,l){var i,c,u,p,f,g,v,_,w,j,k,S,M,L,P,O,$,U,B=n.constructor,V=n.s==a.s?1:-1,X=n.d,Y=a.d;if(!n.s)return new B(n);if(!a.s)throw Error(qx+"Division by zero");for(c=n.e-a.e,$=Y.length,P=X.length,v=new B(V),_=v.d=[],u=0;Y[u]==(X[u]||0);)++u;if(Y[u]>(X[u]||0)&&--c,o==null?S=o=B.precision:l?S=o+(au(n)-au(a))+1:S=o,S<0)return new B(0);if(S=S/wc+2|0,u=0,$==1)for(p=0,Y=Y[0],S++;(u1&&(Y=t(Y,p),X=t(X,p),$=Y.length,P=X.length),L=$,w=X.slice(0,$),j=w.length;j<$;)w[j++]=0;U=Y.slice(),U.unshift(0),O=Y[0],Y[1]>=Gu/2&&++O;do p=0,i=s(Y,w,$,j),i<0?(k=w[0],$!=j&&(k=k*Gu+(w[1]||0)),p=k/O|0,p>1?(p>=Gu&&(p=Gu-1),f=t(Y,p),g=f.length,j=w.length,i=s(f,w,g,j),i==1&&(p--,r(f,$16)throw Error(sSe+au(t));if(!t.s)return new p(uf);for($c=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(m4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(uf),p.precision=i;;){if(a=zl(a.times(t),i),r=r.times(++c),l=o.plus(j1(a,r,i)),u0(l.d).slice(0,i)===u0(o.d).slice(0,i)){for(;u--;)o=zl(o.times(o),i);return p.precision=f,s==null?($c=!0,zl(o,f)):o}o=l}}function au(t){for(var s=t.e*wc,r=t.d[0];r>=10;r/=10)s++;return s}function gye(t,s,r){if(s>t.LN10.sd())throw $c=!0,r&&(t.precision=r),Error(qx+"LN10 precision limit exceeded");return zl(new t(t.LN10),s)}function i_(t){for(var s="";t--;)s+="0";return s}function WD(t,s){var r,n,a,o,l,i,c,u,p,f=1,g=10,v=t,_=v.d,w=v.constructor,j=w.precision;if(v.s<1)throw Error(qx+(v.s?"NaN":"-Infinity"));if(v.eq(uf))return new w(0);if(s==null?($c=!1,u=j):u=s,v.eq(10))return s==null&&($c=!0),gye(w,u);if(u+=g,w.precision=u,r=u0(_),n=r.charAt(0),o=au(v),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)v=v.times(t),r=u0(v.d),n=r.charAt(0),f++;o=au(v),n>1?(v=new w("0."+r),o++):v=new w(n+"."+r.slice(1))}else return c=gye(w,u+2,j).times(o+""),v=WD(new w(n+"."+r.slice(1)),u-g).plus(c),w.precision=j,s==null?($c=!0,zl(v,j)):v;for(i=l=v=j1(v.minus(uf),v.plus(uf),u),p=zl(v.times(v),u),a=3;;){if(l=zl(l.times(p),u),c=i.plus(j1(l,new w(a),u)),u0(c.d).slice(0,u)===u0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(gye(w,u+2,j).times(o+""))),i=j1(i,new w(f),u),w.precision=j,s==null?($c=!0,zl(i,j)):i;i=c,a+=2}}function rRe(t,s){var r,n,a;for((r=s.indexOf("."))>-1&&(s=s.replace(".","")),(n=s.search(/e/i))>0?(r<0&&(r=n),r+=+s.slice(n+1),s=s.substring(0,n)):r<0&&(r=s.length),n=0;s.charCodeAt(n)===48;)++n;for(a=s.length;s.charCodeAt(a-1)===48;)--a;if(s=s.slice(n,a),s){if(a-=n,r=r-n-1,t.e=IE(r/wc),t.d=[],n=(r+1)%wc,r<0&&(n+=wc),nMce||t.e<-Mce))throw Error(sSe+r)}else t.s=0,t.e=0,t.d=[0];return t}function zl(t,s,r){var n,a,o,l,i,c,u,p,f=t.d;for(l=1,o=f[0];o>=10;o/=10)l++;if(n=s-l,n<0)n+=wc,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/wc),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=wc,a=n-wc+l}if(r!==void 0&&(o=m4(10,l-a-1),i=u/o%10|0,c=s<0||f[p+1]!==void 0||u%o,c=r<4?(i||c)&&(r==0||r==(t.s<0?3:2)):i>5||i==5&&(r==4||c||r==6&&(n>0?a>0?u/m4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=au(t),f.length=1,s=s-o-1,f[0]=m4(10,(wc-s%wc)%wc),t.e=IE(-s/wc)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(n==0?(f.length=p,o=1,p--):(f.length=p+1,o=m4(10,wc-n),f[p]=a>0?(u/m4(10,l-a)%m4(10,a)|0)*o:0),c)for(;;)if(p==0){(f[0]+=o)==Gu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Gu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if($c&&(t.e>Mce||t.e<-Mce))throw Error(sSe+au(t));return t}function Jrt(t,s){var r,n,a,o,l,i,c,u,p,f,g=t.constructor,v=g.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new g(t),$c?zl(s,v):s;if(c=t.d,f=s.d,n=s.e,u=t.e,c=c.slice(),l=u-n,l){for(p=l<0,p?(r=c,l=-l,i=f.length):(r=f,n=u,i=c.length),a=Math.max(Math.ceil(v/wc),i)+2,l>a&&(l=a,r.length=1),r.reverse(),a=l;a--;)r.push(0);r.reverse()}else{for(a=c.length,i=f.length,p=a0;--a)c[i++]=0;for(a=f.length;a>l;){if(c[--a]0?o=o.charAt(0)+"."+o.slice(1)+i_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+i_(-a-1)+o,r&&(n=r-l)>0&&(o+=i_(n))):a>=l?(o+=i_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+i_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=i_(n))),t.s<0?"-"+o:o}function nRe(t,s){if(t.length>s)return t.length=s,!0}function ent(t){var s,r,n;function a(o){var l=this;if(!(l instanceof a))return new a(o);if(l.constructor=a,o instanceof a){l.s=o.s,l.e=o.e,l.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(PS+o);if(o>0)l.s=1;else if(o<0)o=-o,l.s=-1;else{l.s=0,l.e=0,l.d=[0];return}if(o===~~o&&o<1e7){l.e=0,l.d=[o];return}return rRe(l,o.toString())}else if(typeof o!="string")throw Error(PS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,yds.test(o))rRe(l,o);else throw Error(PS+o)}if(a.prototype=aa,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=ent,a.config=a.set=vds,t===void 0&&(t={}),t)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],s=0;s=a[s+1]&&n<=a[s+2])this[r]=n;else throw Error(PS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(PS+r+": "+n);return this}var rSe=ent(gds);uf=new rSe(1);const Sl=rSe;function bds(t){return Nds(t)||jds(t)||wds(t)||_ds()}function _ds(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wds(t,s){if(t){if(typeof t=="string")return r_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return r_e(t,s)}}function jds(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function Nds(t){if(Array.isArray(t))return r_e(t)}function r_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,aRe(function(){for(var i=arguments.length,c=new Array(i),u=0;ut.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,a=!1,o=void 0;try{for(var l=t[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(r.push(i.value),!(s&&r.length===s));n=!0);}catch(c){a=!0,o=c}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return r}}function zds(t){if(Array.isArray(t))return t}function ant(t){var s=KD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function int(t,s,r){if(t.lte(0))return new Sl(0);var n=Bhe.getDigitCount(t.toNumber()),a=new Sl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new Sl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new Sl(Math.ceil(c))}function Bds(t,s,r){var n=1,a=new Sl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new Sl(10).pow(Bhe.getDigitCount(t)-1),a=new Sl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Sl(Math.floor(t)))}else t===0?a=new Sl(Math.floor((s-1)/2)):r||(a=new Sl(Math.floor(t)));var l=Math.floor((s-1)/2),i=Mds(Cds(function(c){return a.add(new Sl(c-l).mul(n)).toNumber()}),n_e);return i(0,s)}function ont(t,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-t)/(r-1)))return{step:new Sl(0),tickMin:new Sl(0),tickMax:new Sl(0)};var o=int(new Sl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new Sl(0):(l=new Sl(t).add(s).div(2),l=l.sub(new Sl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new Sl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?ont(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new Sl(i).mul(o)),tickMax:l.add(new Sl(c).mul(o))})}function $ds(t){var s=KD(t,2),r=s[0],n=s[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Math.max(a,2),i=ant([r,n]),c=KD(i,2),u=c[0],p=c[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(i_e(n_e(0,a-1).map(function(){return 1/0}))):[].concat(i_e(n_e(0,a-1).map(function(){return-1/0})),[p]);return r>n?a_e(f):f}if(u===p)return Bds(u,a,o);var g=ont(u,p,l,o),v=g.step,_=g.tickMin,w=g.tickMax,j=Bhe.rangeStep(_,w.add(new Sl(.1).mul(v)),v);return r>n?a_e(j):j}function qds(t,s){var r=KD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=ant([n,a]),i=KD(l,2),c=i[0],u=i[1];if(c===-1/0||u===1/0)return[n,a];if(c===u)return[c];var p=Math.max(s,2),f=int(new Sl(u).sub(c).div(p-1),o,0),g=[].concat(i_e(Bhe.rangeStep(new Sl(c),new Sl(u).sub(new Sl(.99).mul(f)),f)),[u]);return n>a?a_e(g):g}var Uds=rnt($ds),Vds=rnt(qds),Hds="Invariant failed";function d3(t,s){throw new Error(Hds)}var Gds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function mA(t){"@babel/helpers - typeof";return mA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},mA(t)}function Tce(){return Tce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Jds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function eus(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function tus(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,l=-1,i=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(i<=1)return 0;if(o&&o.axisType==="angleAxis"&&Math.abs(Math.abs(o.range[1]-o.range[0])-360)<=1e-6)for(var c=o.range,u=0;u0?a[u-1].coordinate:a[i-1].coordinate,f=a[u].coordinate,g=u>=i-1?a[0].coordinate:a[u+1].coordinate,v=void 0;if(Am(f-p)!==Am(g-f)){var _=[];if(Am(g-f)===Am(c[1]-c[0])){v=g;var w=f+c[1]-c[0];_[0]=Math.min(w,(w+p)/2),_[1]=Math.max(w,(w+p)/2)}else{v=p;var j=g+c[1]-c[0];_[0]=Math.min(f,(j+f)/2),_[1]=Math.max(f,(j+f)/2)}var k=[Math.min(f,(v+f)/2),Math.max(f,(v+f)/2)];if(s>k[0]&&s<=k[1]||s>=_[0]&&s<=_[1]){l=a[u].index;break}}else{var S=Math.min(p,g),M=Math.max(p,g);if(s>(S+f)/2&&s<=(M+f)/2){l=a[u].index;break}}}else for(var L=0;L0&&L(n[L].coordinate+n[L-1].coordinate)/2&&s<=(n[L].coordinate+n[L+1].coordinate)/2||L===i-1&&s>(n[L].coordinate+n[L-1].coordinate)/2){l=n[L].index;break}return l},nSe=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?xd(xd({},s.type.defaultProps),s.props):s.props,l=o.stroke,i=o.fill,c;switch(a){case"Line":c=l;break;case"Area":case"Radar":c=l&&l!=="none"?l:i;break;default:c=i;break}return c},yus=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),c=0,u=i.length;c=0});if(k&&k.length){var S=k[0].type.defaultProps,M=S!==void 0?xd(xd({},S),k[0].props):k[0].props,L=M.barSize,P=M[j];l[P]||(l[P]=[]);var O=$i(L)?r:L;l[P].push({item:k[0],stackList:k.slice(1),barSize:$i(O)?void 0:Em(O,n,0)})}}return l},vus=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,o=s.sizeList,l=o===void 0?[]:o,i=s.maxBarSize,c=l.length;if(c<1)return null;var u=Em(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var g=!1,v=a/c,_=l.reduce(function(L,P){return L+P.barSize||0},0);_+=(c-1)*u,_>=a&&(_-=(c-1)*u,u=0),_>=a&&v>0&&(g=!0,v*=.9,_=c*v);var w=(a-_)/2>>0,j={offset:w-u,size:0};p=l.reduce(function(L,P){var O={item:P.item,position:{offset:j.offset+j.size+u,size:g?v:P.barSize}},$=[].concat(lRe(L),[O]);return j=$[$.length-1].position,P.stackList&&P.stackList.length&&P.stackList.forEach(function(U){$.push({item:U,position:j})}),$},f)}else{var k=Em(n,a,0,!0);a-2*k-(c-1)*u<=0&&(u=0);var S=(a-2*k-(c-1)*u)/c;S>1&&(S>>=0);var M=i===+i?Math.min(S,i):S;p=l.reduce(function(L,P,O){var $=[].concat(lRe(L),[{item:P.item,position:{offset:k+(S+u)*O+(S-M)/2,size:M}}]);return P.stackList&&P.stackList.length&&P.stackList.forEach(function(U){$.push({item:U,position:$[$.length-1].position})}),$},f)}return p},bus=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=unt({children:o,legendWidth:c});if(u){var p=a||{},f=p.width,g=p.height,v=u.align,_=u.verticalAlign,w=u.layout;if((w==="vertical"||w==="horizontal"&&_==="middle")&&v!=="center"&&cn(s[v]))return xd(xd({},s),{},xT({},v,s[v]+(f||0)));if((w==="horizontal"||w==="vertical"&&v==="center")&&_!=="middle"&&cn(s[_]))return xd(xd({},s),{},xT({},_,s[_]+(g||0)))}return s},_us=function(s,r,n){return $i(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},hnt=function(s,r,n,a,o){var l=r.props.children,i=kf(l,NR).filter(function(u){return _us(a,o,u.props.direction)});if(i&&i.length){var c=i.map(function(u){return u.props.dataKey});return s.reduce(function(u,p){var f=wu(p,n);if($i(f))return u;var g=Array.isArray(f)?[Fhe(f),Rhe(f)]:[f,f],v=c.reduce(function(_,w){var j=wu(p,w,0),k=g[0]-Math.abs(Array.isArray(j)?j[0]:j),S=g[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(k,_[0]),Math.max(S,_[1])]},[1/0,-1/0]);return[Math.min(v[0],u[0]),Math.max(v[1],u[1])]},[1/0,-1/0])}return null},wus=function(s,r,n,a,o){var l=r.map(function(i){return hnt(s,i,n,o,a)}).filter(function(i){return!$i(i)});return l&&l.length?l.reduce(function(i,c){return[Math.min(i[0],c[0]),Math.max(i[1],c[1])]},[1/0,-1/0]):null},mnt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&hnt(s,c,u,a)||C8(s,u,n,o)});if(n==="number")return l.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var i={};return l.reduce(function(c,u){for(var p=0,f=u.length;p=2?Am(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var g=o?o.indexOf(f):f;return{coordinate:a(g)+u,value:f,offset:u}});return p.filter(function(f){return!xR(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,g){return{coordinate:a(f)+u,value:f,index:g,offset:u}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(f){return{coordinate:a(f)+u,value:f,offset:u}}):a.domain().map(function(f,g){return{coordinate:a(f)+u,value:o?o[f]:f,index:g,offset:u}})},yye=new WeakMap,Qz=function(s,r){if(typeof r!="function")return s;yye.has(s)||yye.set(s,new WeakMap);var n=yye.get(s);if(n.has(r))return n.get(r);var a=function(){s.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},xnt=function(s,r,n){var a=s.scale,o=s.type,l=s.layout,i=s.axisType;if(a==="auto")return l==="radial"&&i==="radiusAxis"?{scale:qD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:Nce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:S8(),realScaleType:"point"}:o==="category"?{scale:qD(),realScaleType:"band"}:{scale:Nce(),realScaleType:"linear"};if(i3(a)){var c="scale".concat(jhe(a));return{scale:(sRe[c]||S8)(),realScaleType:sRe[c]?c:"point"}}return Ti(a)?{scale:a}:{scale:S8(),realScaleType:"point"}},dRe=1e-4,gnt=function(s){var r=s.domain();if(!(!r||r.length<=2)){var n=r.length,a=s.range(),o=Math.min(a[0],a[1])-dRe,l=Math.max(a[0],a[1])+dRe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},jus=function(s,r){if(!s)return null;for(var n=0,a=s.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(s[i][n][0]=o,s[i][n][1]=o+c,o=s[i][n][1]):(s[i][n][0]=l,s[i][n][1]=l+c,l=s[i][n][1])}},Sus=function(s){var r=s.length;if(!(r<=0))for(var n=0,a=s[0].length;n=0?(s[l][n][0]=o,s[l][n][1]=o+i,o=s[l][n][1]):(s[l][n][0]=0,s[l][n][1]=0)}},Cus={sign:kus,expand:GQt,none:aA,silhouette:WQt,wiggle:KQt,positive:Sus},Mus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Cus[n],l=HQt().keys(a).value(function(i,c){return+wu(i,c,0)}).order(Lbe).offset(o);return l(s)},Tus=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,c={},u=i.reduce(function(f,g){var v,_=(v=g.type)!==null&&v!==void 0&&v.defaultProps?xd(xd({},g.type.defaultProps),g.props):g.props,w=_.stackId,j=_.hide;if(j)return f;var k=_[n],S=f[k]||{hasStack:!1,stackGroups:{}};if(Nu(w)){var M=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};M.items.push(g),S.hasStack=!0,S.stackGroups[w]=M}else S.stackGroups[CE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return xd(xd({},f),{},xT({},k,S))},c),p={};return Object.keys(u).reduce(function(f,g){var v=u[g];if(v.hasStack){var _={};v.stackGroups=Object.keys(v.stackGroups).reduce(function(w,j){var k=v.stackGroups[j];return xd(xd({},w),{},xT({},j,{numericAxisId:n,cateAxisId:a,items:k.items,stackedData:Mus(s,k.items,o)}))},_)}return xd(xd({},f),{},xT({},g,v))},p)},ynt=function(s,r){var n=r.realScaleType,a=r.type,o=r.tickCount,l=r.originalDomain,i=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var u=s.domain();if(!u.length)return null;var p=Uds(u,o,i);return s.domain([Fhe(p),Rhe(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),g=Vds(f,o,i);return{niceTicks:g}}return null};function uRe(t){var s=t.axis,r=t.ticks,n=t.bandSize,a=t.entry,o=t.index,l=t.dataKey;if(s.type==="category"){if(!s.allowDuplicatedCategory&&s.dataKey&&!$i(a[s.dataKey])){var i=rce(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=wu(a,$i(l)?s.dataKey:l);return $i(c)?null:s.scale(c)}var hRe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var c=wu(l,r.dataKey,r.domain[i]);return $i(c)?null:r.scale(c)-o/2+a},Aus=function(s){var r=s.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),o=Math.max(n[0],n[1]);return a<=0&&o>=0?0:o<0?o:a}return n[0]},Eus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?xd(xd({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(Nu(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},Pus=function(s){return s.reduce(function(r,n){return[Fhe(n.concat([r[0]]).filter(cn)),Rhe(n.concat([r[1]]).filter(cn))]},[1/0,-1/0])},vnt=function(s,r,n){return Object.keys(s).reduce(function(a,o){var l=s[o],i=l.stackedData,c=i.reduce(function(u,p){var f=Pus(p.slice(r,n+1));return[Math.min(u[0],f[0]),Math.max(u[1],f[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},mRe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,pRe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,d_e=function(s,r,n){if(Ti(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(cn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(mRe.test(s[0])){var o=+mRe.exec(s[0])[1];a[0]=r[0]-o}else Ti(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(cn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(pRe.test(s[1])){var l=+pRe.exec(s[1])[1];a[1]=r[1]+l}else Ti(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},Ece=function(s,r,n){if(s&&s.scale&&s.scale.bandwidth){var a=s.scale.bandwidth();if(!n||a>0)return a}if(s&&r&&r.length>=2){for(var o=P4e(r,function(f){return f.coordinate}),l=1/0,i=1,c=o.length;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},$us=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,p=Em(s.cx,l,l/2),f=Em(s.cy,i,i/2),g=wnt(l,i,n),v=Em(s.innerRadius,g,0),_=Em(s.outerRadius,g,g*.8),w=Object.keys(r);return w.reduce(function(j,k){var S=r[k],M=S.domain,L=S.reversed,P;if($i(S.range))a==="angleAxis"?P=[c,u]:a==="radiusAxis"&&(P=[v,_]),L&&(P=[P[1],P[0]]);else{P=S.range;var O=P,$=Dus(O,2);c=$[0],u=$[1]}var U=xnt(S,o),B=U.realScaleType,V=U.scale;V.domain(M).range(P),gnt(V);var X=ynt(V,Fv(Fv({},S),{},{realScaleType:B})),Y=Fv(Fv(Fv({},S),X),{},{range:P,radius:_,realScaleType:B,scale:V,cx:p,cy:f,innerRadius:v,outerRadius:_,startAngle:c,endAngle:u});return Fv(Fv({},j),{},_nt({},k,Y))},{})},qus=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return Math.sqrt(Math.pow(n-o,2)+Math.pow(a-l,2))},Uus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=qus({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var c=(n-o)/i,u=Math.acos(c);return a>l&&(u=2*Math.PI-u),{radius:i,angle:Bus(u),angleInRadian:u}},Vus=function(s){var r=s.startAngle,n=s.endAngle,a=Math.floor(r/360),o=Math.floor(n/360),l=Math.min(a,o);return{startAngle:r-l*360,endAngle:n-l*360}},Hus=function(s,r){var n=r.startAngle,a=r.endAngle,o=Math.floor(n/360),l=Math.floor(a/360),i=Math.min(o,l);return s+i*360},yRe=function(s,r){var n=s.x,a=s.y,o=Uus({x:n,y:a},r),l=o.radius,i=o.angle,c=r.innerRadius,u=r.outerRadius;if(lu)return!1;if(l===0)return!0;var p=Vus(r),f=p.startAngle,g=p.endAngle,v=i,_;if(f<=g){for(;v>g;)v-=360;for(;v=f&&v<=g}else{for(;v>f;)v-=360;for(;v=g&&v<=f}return _?Fv(Fv({},r),{},{radius:l,angle:Hus(v,r)}):null},jnt=function(s){return!N.isValidElement(s)&&!Ti(s)&&typeof s!="boolean"?s.className:""};function XD(t){"@babel/helpers - typeof";return XD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},XD(t)}var Gus=["offset"];function Wus(t){return Qus(t)||Yus(t)||Zus(t)||Kus()}function Kus(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zus(t,s){if(t){if(typeof t=="string")return u_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u_e(t,s)}}function Yus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Qus(t){if(Array.isArray(t))return u_e(t)}function u_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Jus(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function vRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function mu(t){for(var s=1;s=0?1:-1,M,L;a==="insideStart"?(M=v+S*l,L=w):a==="insideEnd"?(M=_-S*l,L=!w):a==="end"&&(M=_+S*l,L=w),L=k<=0?L:!L;var P=lc(u,p,j,M),O=lc(u,p,j,M+(L?1:-1)*359),$="M".concat(P.x,",").concat(P.y,` A`).concat(j,",").concat(j,",0,1,").concat(L?0:1,`, `).concat(O.x,",").concat(O.y),U=$i(s.id)?CE("recharts-radial-line-"):s.id;return ht.createElement("text",JD({},n,{dominantBaseline:"central",className:Vi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:U,d:$})),ht.createElement("textPath",{xlinkHref:"#".concat(U)},r))},ihs=function(s){var r=s.viewBox,n=s.offset,a=s.position,o=r,l=o.cx,i=o.cy,c=o.innerRadius,u=o.outerRadius,p=o.startAngle,f=o.endAngle,g=(p+f)/2;if(a==="outside"){var v=lc(l,i,u+n,g),_=v.x,w=v.y;return{x:_,y:w,textAnchor:_>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var j=(c+u)/2,k=lc(l,i,j,g),S=k.x,M=k.y;return{x:S,y:M,textAnchor:"middle",verticalAnchor:"middle"}},ohs=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,o=s.position,l=r,i=l.x,c=l.y,u=l.width,p=l.height,f=p>=0?1:-1,g=f*a,v=f>0?"end":"start",_=f>0?"start":"end",w=u>=0?1:-1,j=w*a,k=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var M={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:v};return mu(mu({},M),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var L={x:i+u/2,y:c+p+g,textAnchor:"middle",verticalAnchor:_};return mu(mu({},L),n?{height:Math.max(n.y+n.height-(c+p),0),width:u}:{})}if(o==="left"){var P={x:i-j,y:c+p/2,textAnchor:k,verticalAnchor:"middle"};return mu(mu({},P),n?{width:Math.max(P.x-n.x,0),height:p}:{})}if(o==="right"){var O={x:i+u+j,y:c+p/2,textAnchor:S,verticalAnchor:"middle"};return mu(mu({},O),n?{width:Math.max(n.x+n.width-O.x,0),height:p}:{})}var $=n?{width:u,height:p}:{};return o==="insideLeft"?mu({x:i+j,y:c+p/2,textAnchor:S,verticalAnchor:"middle"},$):o==="insideRight"?mu({x:i+u-j,y:c+p/2,textAnchor:k,verticalAnchor:"middle"},$):o==="insideTop"?mu({x:i+u/2,y:c+g,textAnchor:"middle",verticalAnchor:_},$):o==="insideBottom"?mu({x:i+u/2,y:c+p-g,textAnchor:"middle",verticalAnchor:v},$):o==="insideTopLeft"?mu({x:i+j,y:c+g,textAnchor:S,verticalAnchor:_},$):o==="insideTopRight"?mu({x:i+u-j,y:c+g,textAnchor:k,verticalAnchor:_},$):o==="insideBottomLeft"?mu({x:i+j,y:c+p-g,textAnchor:S,verticalAnchor:v},$):o==="insideBottomRight"?mu({x:i+u-j,y:c+p-g,textAnchor:k,verticalAnchor:v},$):jE(o)&&(cn(o.x)||P4(o.x))&&(cn(o.y)||P4(o.y))?mu({x:i+Em(o.x,u),y:c+Em(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):mu({x:i+u/2,y:c+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},lhs=function(s){return"cx"in s&&cn(s.cx)};function Xu(t){var s=t.offset,r=s===void 0?5:s,n=Xus(t,Gus),a=mu({offset:r},n),o=a.viewBox,l=a.position,i=a.value,c=a.children,u=a.content,p=a.className,f=p===void 0?"":p,g=a.textBreakAll;if(!o||$i(i)&&$i(c)&&!N.isValidElement(u)&&!Ti(u))return null;if(N.isValidElement(u))return N.cloneElement(u,a);var v;if(Ti(u)){if(v=N.createElement(u,a),N.isValidElement(v))return v}else v=rhs(a);var _=lhs(o),w=oi(a,!0);if(_&&(l==="insideStart"||l==="insideEnd"||l==="end"))return ahs(a,v,w);var j=_?ihs(a):ohs(a);return ht.createElement(l3,JD({className:Vi("recharts-label",f)},w,j,{breakAll:g}),v)}Xu.displayName="Label";var Nnt=function(s){var r=s.cx,n=s.cy,a=s.angle,o=s.startAngle,l=s.endAngle,i=s.r,c=s.radius,u=s.innerRadius,p=s.outerRadius,f=s.x,g=s.y,v=s.top,_=s.left,w=s.width,j=s.height,k=s.clockWise,S=s.labelViewBox;if(S)return S;if(cn(w)&&cn(j)){if(cn(f)&&cn(g))return{x:f,y:g,width:w,height:j};if(cn(v)&&cn(_))return{x:v,y:_,width:w,height:j}}return cn(f)&&cn(g)?{x:f,y:g,width:0,height:0}:cn(r)&&cn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||c||i||0,clockWise:k}:s.viewBox?s.viewBox:{}},chs=function(s,r){return s?s===!0?ht.createElement(Xu,{key:"label-implicit",viewBox:r}):Nu(s)?ht.createElement(Xu,{key:"label-implicit",viewBox:r,value:s}):N.isValidElement(s)?s.type===Xu?N.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Xu,{key:"label-implicit",content:s,viewBox:r}):Ti(s)?ht.createElement(Xu,{key:"label-implicit",content:s,viewBox:r}):jE(s)?ht.createElement(Xu,JD({viewBox:r},s,{key:"label-implicit"})):null:null},dhs=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!s||!s.children&&n&&!s.label)return null;var a=s.children,o=Nnt(s),l=kf(a,Xu).map(function(c,u){return N.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=chs(s.label,r||o);return[i].concat(Wus(l))};Xu.parseViewBox=Nnt;Xu.renderCallByParent=dhs;function uhs(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var hhs=uhs;const mhs=Po(hhs);function eO(t){"@babel/helpers - typeof";return eO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},eO(t)}var phs=["valueAccessor"],fhs=["data","dataKey","clockWise","id","textBreakAll"];function xhs(t){return bhs(t)||vhs(t)||yhs(t)||ghs()}function ghs(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yhs(t,s){if(t){if(typeof t=="string")return h_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h_e(t,s)}}function vhs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function bhs(t){if(Array.isArray(t))return h_e(t)}function h_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Nhs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var khs=function(s){return Array.isArray(s.value)?mhs(s.value):s.value};function N1(t){var s=t.valueAccessor,r=s===void 0?khs:s,n=wRe(t,phs),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=wRe(n,fhs);return!a||!a.length?null:ht.createElement(Zo,{className:"recharts-label-list"},a.map(function(p,f){var g=$i(o)?r(p,f):wu(p&&p.payload,o),v=$i(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Xu,Ice({},oi(p,!0),u,v,{parentViewBox:p.parentViewBox,value:g,textBreakAll:c,viewBox:Xu.parseViewBox($i(l)?p:_Re(_Re({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}N1.displayName="LabelList";function Shs(t,s){return t?t===!0?ht.createElement(N1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||Ti(t)?ht.createElement(N1,{key:"labelList-implicit",data:s,content:t}):jE(t)?ht.createElement(N1,Ice({data:s},t,{key:"labelList-implicit"})):null:null}function Chs(t,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,a=kf(n,N1).map(function(l,i){return N.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Shs(t.label,s);return[o].concat(xhs(a))}N1.renderCallByParent=Chs;function tO(t){"@babel/helpers - typeof";return tO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tO(t)}function m_e(){return m_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s180),",").concat(+(l>u),`, `).concat(f.x,",").concat(f.y,` `);if(a>0){var v=lc(r,n,a,l),_=lc(r,n,a,u);g+="L ".concat(_.x,",").concat(_.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(l<=u),`, `).concat(v.x,",").concat(v.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},Phs=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,o=s.outerRadius,l=s.cornerRadius,i=s.forceCornerRadius,c=s.cornerIsExternal,u=s.startAngle,p=s.endAngle,f=Am(p-u),g=Xz({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),v=g.circleTangency,_=g.lineTangency,w=g.theta,j=Xz({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:c}),k=j.circleTangency,S=j.lineTangency,M=j.theta,L=c?Math.abs(u-p):Math.abs(u-p)-w-M;if(L<0)return i?"M ".concat(_.x,",").concat(_.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):knt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var P="M ".concat(_.x,",").concat(_.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(v.x,",").concat(v.y,` A`).concat(o,",").concat(o,",0,").concat(+(L>180),",").concat(+(f<0),",").concat(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var O=Xz({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),$=O.circleTangency,U=O.lineTangency,B=O.theta,V=Xz({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),X=V.circleTangency,Y=V.lineTangency,ee=V.theta,Q=c?Math.abs(u-p):Math.abs(u-p)-B-ee;if(Q<0&&l===0)return"".concat(P,"L").concat(r,",").concat(n,"Z");P+="L".concat(Y.x,",").concat(Y.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(X.x,",").concat(X.y,` A`).concat(a,",").concat(a,",0,").concat(+(Q>180),",").concat(+(f>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(U.x,",").concat(U.y,"Z")}else P+="L".concat(r,",").concat(n,"Z");return P},Ihs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Snt=function(s){var r=NRe(NRe({},Ihs),s),n=r.cx,a=r.cy,o=r.innerRadius,l=r.outerRadius,i=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,p=r.startAngle,f=r.endAngle,g=r.className;if(l0&&Math.abs(p-f)<360?j=Phs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,_/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:p,endAngle:f}):j=knt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",m_e({},oi(r,!0),{className:v,d:j,role:"img"}))};function sO(t){"@babel/helpers - typeof";return sO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sO(t)}function p_e(){return p_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s0;)if(!r.equals(t[n],s[n],n,n,t,s,r))return!1;return!0}function Xhs(t,s){return I3(t.getTime(),s.getTime())}function Jhs(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function ems(t,s){return t===s}function PRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.entries(),l,i,c=0;(l=o.next())&&!l.done;){for(var u=s.entries(),p=!1,f=0;(i=u.next())&&!i.done;){if(a[f]){f++;continue}var g=l.value,v=i.value;if(r.equals(g[0],v[0],c,f,t,s,r)&&r.equals(g[1],v[1],g[0],v[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;c++}return!0}var tms=I3;function sms(t,s,r){var n=ERe(t),a=n.length;if(ERe(s).length!==a)return!1;for(;a-- >0;)if(!Ant(t,s,r,n[a]))return!1;return!0}function gI(t,s,r){var n=TRe(t),a=n.length;if(TRe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!Ant(t,s,r,o)||(l=ARe(t,o),i=ARe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function rms(t,s){return I3(t.valueOf(),s.valueOf())}function nms(t,s){return t.source===s.source&&t.flags===s.flags}function IRe(t,s,r){var n=t.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),o=t.values(),l,i;(l=o.next())&&!l.done;){for(var c=s.values(),u=!1,p=0;(i=c.next())&&!i.done;){if(!a[p]&&r.equals(l.value,i.value,l.value,i.value,t,s,r)){u=a[p]=!0;break}p++}if(!u)return!1}return!0}function ams(t,s){var r=t.length;if(s.length!==r)return!1;for(;r-- >0;)if(t[r]!==s[r])return!1;return!0}function ims(t,s){return t.hostname===s.hostname&&t.pathname===s.pathname&&t.protocol===s.protocol&&t.port===s.port&&t.hash===s.hash&&t.username===s.username&&t.password===s.password}function Ant(t,s,r,n){return(n===Yhs||n===Zhs||n===Khs)&&(t.$$typeof||s.$$typeof)?!0:Whs(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var oms="[object Arguments]",lms="[object Boolean]",cms="[object Date]",dms="[object Error]",ums="[object Map]",hms="[object Number]",mms="[object Object]",pms="[object RegExp]",fms="[object Set]",xms="[object String]",gms="[object URL]",yms=Array.isArray,LRe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,DRe=Object.assign,vms=Object.prototype.toString.call.bind(Object.prototype.toString);function bms(t){var s=t.areArraysEqual,r=t.areDatesEqual,n=t.areErrorsEqual,a=t.areFunctionsEqual,o=t.areMapsEqual,l=t.areNumbersEqual,i=t.areObjectsEqual,c=t.arePrimitiveWrappersEqual,u=t.areRegExpsEqual,p=t.areSetsEqual,f=t.areTypedArraysEqual,g=t.areUrlsEqual;return function(_,w,j){if(_===w)return!0;if(_==null||w==null)return!1;var k=typeof _;if(k!==typeof w)return!1;if(k!=="object")return k==="number"?l(_,w,j):k==="function"?a(_,w,j):!1;var S=_.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(_,w,j);if(yms(_))return s(_,w,j);if(LRe!=null&&LRe(_))return f(_,w,j);if(S===Date)return r(_,w,j);if(S===RegExp)return u(_,w,j);if(S===Map)return o(_,w,j);if(S===Set)return p(_,w,j);var M=vms(_);return M===cms?r(_,w,j):M===pms?u(_,w,j):M===ums?o(_,w,j):M===fms?p(_,w,j):M===mms?typeof _.then!="function"&&typeof w.then!="function"&&i(_,w,j):M===gms?g(_,w,j):M===dms?n(_,w,j):M===oms?i(_,w,j):M===lms||M===hms||M===xms?c(_,w,j):!1}}function _ms(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?gI:Qhs,areDatesEqual:Xhs,areErrorsEqual:Jhs,areFunctionsEqual:ems,areMapsEqual:n?MRe(PRe,gI):PRe,areNumbersEqual:tms,areObjectsEqual:n?gI:sms,arePrimitiveWrappersEqual:rms,areRegExpsEqual:nms,areSetsEqual:n?MRe(IRe,gI):IRe,areTypedArraysEqual:n?gI:ams,areUrlsEqual:ims};if(r&&(a=DRe({},a,r(a))),s){var o=e9(a.areArraysEqual),l=e9(a.areMapsEqual),i=e9(a.areObjectsEqual),c=e9(a.areSetsEqual);a=DRe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function wms(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function jms(t){var s=t.circular,r=t.comparator,n=t.createState,a=t.equals,o=t.strict;if(n)return function(c,u){var p=n(),f=p.cache,g=f===void 0?s?new WeakMap:void 0:f,v=p.meta;return r(c,u,{cache:g,equals:a,meta:v,strict:o})};if(s)return function(c,u){return r(c,u,{cache:new WeakMap,equals:a,meta:void 0,strict:o})};var l={cache:void 0,equals:a,meta:void 0,strict:o};return function(c,u){return r(c,u,l)}}var Nms=Ww();Ww({strict:!0});Ww({circular:!0});Ww({circular:!0,strict:!0});Ww({createInternalComparator:function(){return I3}});Ww({strict:!0,createInternalComparator:function(){return I3}});Ww({circular:!0,createInternalComparator:function(){return I3}});Ww({circular:!0,createInternalComparator:function(){return I3},strict:!0});function Ww(t){t===void 0&&(t={});var s=t.circular,r=s===void 0?!1:s,n=t.createInternalComparator,a=t.createState,o=t.strict,l=o===void 0?!1:o,i=_ms(t),c=bms(i),u=n?n(c):wms(c);return jms({circular:r,comparator:c,createState:a,equals:u,strict:l})}function kms(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function ORe(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(o){r<0&&(r=o),o-r>s?(t(o),r=-1):kms(a)};requestAnimationFrame(n)}function f_e(t){"@babel/helpers - typeof";return f_e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},f_e(t)}function Sms(t){return Ams(t)||Tms(t)||Mms(t)||Cms()}function Cms(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mms(t,s){if(t){if(typeof t=="string")return RRe(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return RRe(t,s)}}function RRe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:k<0?0:k},w=function(k){for(var S=k>1?1:k,M=S,L=0;L<8;++L){var P=f(M)-S,O=v(M);if(Math.abs(P-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,c=function(p,f,g){var v=-(p-f)*n,_=g*o,w=g+(v-_)*i/1e3,j=g*i/1e3+p;return Math.abs(j-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function ops(t,s){if(t==null)return{};var r={},n=Object.keys(t),a,o;for(o=0;o=0)&&(r[a]=t[a]);return r}function vye(t){return ups(t)||dps(t)||cps(t)||lps()}function lps(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cps(t,s){if(t){if(typeof t=="string")return b_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b_e(t,s)}}function dps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ups(t){if(Array.isArray(t))return b_e(t)}function b_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rce(t){return Rce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Rce(t)}var F0=function(t){xps(r,t);var s=gps(r);function r(n,a){var o;hps(this,r),o=s.call(this,n,a);var l=o.props,i=l.isActive,c=l.attributeName,u=l.from,p=l.to,f=l.steps,g=l.children,v=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(j_e(o)),o.changeStyle=o.changeStyle.bind(j_e(o)),!i||v<=0)return o.state={style:{}},typeof g=="function"&&(o.state={style:p}),w_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof g=="function")return o.state={style:u},w_e(o);o.state={style:c?BI({},c,u):u}}else o.state={style:{}};return o}return pps(r,[{key:"componentDidMount",value:function(){var a=this.props,o=a.isActive,l=a.canBegin;this.mounted=!0,!(!o||!l)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var o=this.props,l=o.isActive,i=o.canBegin,c=o.attributeName,u=o.shouldReAnimate,p=o.to,f=o.from,g=this.state.style;if(i){if(!l){var v={style:c?BI({},c,p):p};this.state&&g&&(c&&g[c]!==p||!c&&g!==p)&&this.setState(v);return}if(!(Nms(a.to,p)&&a.canBegin&&a.isActive)){var _=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=_||u?f:a.to;if(this.state&&g){var j={style:c?BI({},c,w):w};(c&&g[c]!==w||!c&&g!==w)&&this.setState(j)}this.runAnimation(Mg(Mg({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,c=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,g=a.onAnimationStart,v=nps(l,i,Wms(u),c,this.changeStyle),_=function(){o.stopJSAnimation=v()};this.manager.start([g,p,_,c,f])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,c=a.onAnimationStart,u=l[0],p=u.style,f=u.duration,g=f===void 0?0:f,v=function(w,j,k){if(k===0)return w;var S=j.duration,M=j.easing,L=M===void 0?"ease":M,P=j.style,O=j.properties,$=j.onAnimationEnd,U=k>0?l[k-1]:j,B=O||Object.keys(P);if(typeof L=="function"||L==="spring")return[].concat(vye(w),[o.runJSAnimation.bind(o,{from:U.style,to:P,duration:S,easing:L}),S]);var V=BRe(B,S,L),X=Mg(Mg(Mg({},U.style),P),{},{transition:V});return[].concat(vye(w),[X,S,$]).filter(Dms)};return this.manager.start([c].concat(vye(l.reduce(v,[p,Math.max(g,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Ems());var o=a.begin,l=a.duration,i=a.attributeName,c=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,g=a.steps,v=a.children,_=this.manager;if(this.unSubscribe=_.subscribe(this.handleStyleChange),typeof u=="function"||typeof v=="function"||u==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var w=i?BI({},i,c):c,j=BRe(Object.keys(w),l,u);_.start([p,o,Mg(Mg({},w),{},{transition:j}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=ips(a,aps),u=N.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(v){var _=v.props,w=_.style,j=w===void 0?{}:w,k=_.className,S=N.cloneElement(v,Mg(Mg({},c),{},{style:Mg(Mg({},j),p),className:k}));return S};return u===1?f(N.Children.only(o)):ht.createElement("div",null,N.Children.map(o,function(g){return f(g)}))}}]),r}(N.PureComponent);F0.displayName="Animate";F0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};F0.propTypes={from:dl.oneOfType([dl.object,dl.string]),to:dl.oneOfType([dl.object,dl.string]),attributeName:dl.string,duration:dl.number,begin:dl.number,easing:dl.oneOfType([dl.string,dl.func]),steps:dl.arrayOf(dl.shape({duration:dl.number.isRequired,style:dl.object.isRequired,easing:dl.oneOfType([dl.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),dl.func]),properties:dl.arrayOf("string"),onAnimationEnd:dl.func})),children:dl.oneOfType([dl.node,dl.func]),isActive:dl.bool,canBegin:dl.bool,onAnimationEnd:dl.func,shouldReAnimate:dl.bool,onAnimationStart:dl.func,onAnimationReStart:dl.func};function aO(t){"@babel/helpers - typeof";return aO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},aO(t)}function Fce(){return Fce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0?1:-1,c=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var f=[0,0,0,0],g=0,v=4;gl?l:o[g];p="M".concat(s,",").concat(r+i*f[0]),f[0]>0&&(p+="A ".concat(f[0],",").concat(f[0],",0,0,").concat(u,",").concat(s+c*f[0],",").concat(r)),p+="L ".concat(s+n-c*f[1],",").concat(r),f[1]>0&&(p+="A ".concat(f[1],",").concat(f[1],",0,0,").concat(u,`, `).concat(s+n,",").concat(r+i*f[1])),p+="L ".concat(s+n,",").concat(r+a-i*f[2]),f[2]>0&&(p+="A ".concat(f[2],",").concat(f[2],",0,0,").concat(u,`, `).concat(s+n-c*f[2],",").concat(r+a)),p+="L ".concat(s+c*f[3],",").concat(r+a),f[3]>0&&(p+="A ".concat(f[3],",").concat(f[3],",0,0,").concat(u,`, `).concat(s,",").concat(r+a-i*f[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var _=Math.min(l,o);p="M ".concat(s,",").concat(r+i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+c*_,",").concat(r,` L `).concat(s+n-c*_,",").concat(r,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*_,` L `).concat(s+n,",").concat(r+a-i*_,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s+n-c*_,",").concat(r+a,` L `).concat(s+c*_,",").concat(r+a,` A `).concat(_,",").concat(_,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*_," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},Cps=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.y,o=r.x,l=r.y,i=r.width,c=r.height;if(Math.abs(i)>0&&Math.abs(c)>0){var u=Math.min(o,o+i),p=Math.max(o,o+i),f=Math.min(l,l+c),g=Math.max(l,l+c);return n>=u&&n<=p&&a>=f&&a<=g}return!1},Mps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},aSe=function(s){var r=KRe(KRe({},Mps),s),n=N.useRef(),a=N.useState(-1),o=vps(a,2),l=o[0],i=o[1];N.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var L=n.current.getTotalLength();L&&i(L)}catch{}},[]);var c=r.x,u=r.y,p=r.width,f=r.height,g=r.radius,v=r.className,_=r.animationEasing,w=r.animationDuration,j=r.animationBegin,k=r.isAnimationActive,S=r.isUpdateAnimationActive;if(c!==+c||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var M=Vi("recharts-rectangle",v);return S?ht.createElement(F0,{canBegin:l>0,from:{width:p,height:f,x:c,y:u},to:{width:p,height:f,x:c,y:u},duration:w,animationEasing:_,isActive:S},function(L){var P=L.width,O=L.height,$=L.x,U=L.y;return ht.createElement(F0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,isActive:k,easing:_},ht.createElement("path",Fce({},oi(r,!0),{className:M,d:ZRe($,U,P,O,g),ref:n})))}):ht.createElement("path",Fce({},oi(r,!0),{className:M,d:ZRe(c,u,p,f,g)}))},Tps=["points","className","baseLinePoints","connectNulls"];function _M(){return _M=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Eps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function YRe(t){return Dps(t)||Lps(t)||Ips(t)||Pps()}function Pps(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ips(t,s){if(t){if(typeof t=="string")return N_e(t,s);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return N_e(t,s)}}function Lps(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Dps(t){if(Array.isArray(t))return N_e(t)}function N_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){QRe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),QRe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},T8=function(s,r){var n=Ops(s);r&&(n=[n.reduce(function(o,l){return[].concat(YRe(o),YRe(l))},[])]);var a=n.map(function(o){return o.reduce(function(l,i,c){return"".concat(l).concat(c===0?"M":"L").concat(i.x,",").concat(i.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},Rps=function(s,r,n){var a=T8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(T8(r.reverse(),n).slice(1))},Fps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=Aps(s,Tps);if(!r||!r.length)return null;var i=Vi("recharts-polygon",n);if(a&&a.length){var c=l.stroke&&l.stroke!=="none",u=Rps(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",_M({},oi(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?ht.createElement("path",_M({},oi(l,!0),{fill:"none",d:T8(r,o)})):null,c?ht.createElement("path",_M({},oi(l,!0),{fill:"none",d:T8(a,o)})):null)}var p=T8(r,o);return ht.createElement("path",_M({},oi(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function k_e(){return k_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Hps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Gps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Wps=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,o=a===void 0?0:a,l=s.top,i=l===void 0?0:l,c=s.left,u=c===void 0?0:c,p=s.width,f=p===void 0?0:p,g=s.height,v=g===void 0?0:g,_=s.className,w=Vps(s,zps),j=Bps({x:n,y:o,top:i,left:u,width:f,height:v},w);return!cn(n)||!cn(o)||!cn(f)||!cn(v)||!cn(i)||!cn(u)?null:ht.createElement("path",S_e({},oi(j,!0),{className:Vi("recharts-cross",_),d:Gps(n,o,f,v,i,u)}))},Kps=Ohe,Zps=Krt,Yps=G0;function Qps(t,s){return t&&t.length?Kps(t,Yps(s),Zps):void 0}var Xps=Qps;const Jps=Po(Xps);var efs=Ohe,tfs=G0,sfs=Zrt;function rfs(t,s){return t&&t.length?efs(t,tfs(s),sfs):void 0}var nfs=rfs;const afs=Po(nfs);var ifs=["cx","cy","angle","ticks","axisLine"],ofs=["ticks","tick","angle","tickFormatter","stroke"];function fA(t){"@babel/helpers - typeof";return fA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},fA(t)}function A8(){return A8=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function lfs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function cfs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function tFe(t,s){for(var r=0;rnFe?l=a==="outer"?"start":"end":o<-nFe?l=a==="outer"?"end":"start":l="middle",l}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,o=n.cy,l=n.radius,i=n.axisLine,c=n.axisLineType,u=K2(K2({},oi(this.props,!1)),{},{fill:"none"},oi(i,!1));if(c==="circle")return ht.createElement($he,y4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(g){return lc(a,o,l,g.coordinate)});return ht.createElement(Fps,y4({className:"recharts-polar-angle-axis-line"},u,{points:f}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,c=a.tickFormatter,u=a.stroke,p=oi(this.props,!1),f=oi(l,!1),g=K2(K2({},p),{},{fill:"none"},oi(i,!1)),v=o.map(function(_,w){var j=n.getTickLineCoord(_),k=n.getTickTextAnchor(_),S=K2(K2(K2({textAnchor:k},p),{},{stroke:"none",fill:u},f),{},{index:w,payload:_,x:j.x2,y:j.y2});return ht.createElement(Zo,y4({className:Vi("recharts-polar-angle-axis-tick",jnt(l)),key:"tick-".concat(_.coordinate)},o3(n.props,_,w)),i&&ht.createElement("line",y4({className:"recharts-polar-angle-axis-tick-line"},g,j)),l&&s.renderTickItem(l,S,c?c(_.value,w):_.value))});return ht.createElement(Zo,{className:"recharts-polar-angle-axis-ticks"},v)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ht.createElement(Zo,{className:Vi("recharts-polar-angle-axis",this.props.className)},l&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,o){var l;return ht.isValidElement(n)?l=ht.cloneElement(n,a):Ti(n)?l=n(a):l=ht.createElement(l3,y4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(N.PureComponent);Vhe(Hhe,"displayName","PolarAngleAxis");Vhe(Hhe,"axisType","angleAxis");Vhe(Hhe,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var Nfs=Vst,kfs=Nfs(Object.getPrototypeOf,Object),Sfs=kfs,Cfs=K1,Mfs=Sfs,Tfs=Z1,Afs="[object Object]",Efs=Function.prototype,Pfs=Object.prototype,$nt=Efs.toString,Ifs=Pfs.hasOwnProperty,Lfs=$nt.call(Object);function Dfs(t){if(!Tfs(t)||Cfs(t)!=Afs)return!1;var s=Mfs(t);if(s===null)return!0;var r=Ifs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&$nt.call(r)==Lfs}var Ofs=Dfs;const Rfs=Po(Ofs);var Ffs=K1,zfs=Z1,Bfs="[object Boolean]";function $fs(t){return t===!0||t===!1||zfs(t)&&Ffs(t)==Bfs}var qfs=$fs;const Ufs=Po(qfs);function oO(t){"@babel/helpers - typeof";return oO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},oO(t)}function $ce(){return $ce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0,from:{upperWidth:0,lowerWidth:0,height:g,x:c,y:u},to:{upperWidth:p,lowerWidth:f,height:g,x:c,y:u},duration:w,animationEasing:_,isActive:k},function(M){var L=M.upperWidth,P=M.lowerWidth,O=M.height,$=M.x,U=M.y;return ht.createElement(F0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,easing:_},ht.createElement("path",$ce({},oi(r,!0),{className:S,d:lFe($,U,L,P,O),ref:n})))}):ht.createElement("g",null,ht.createElement("path",$ce({},oi(r,!0),{className:S,d:lFe(c,u,p,f,g)})))},exs=["option","shapeType","propTransformer","activeClassName","isActive"];function lO(t){"@babel/helpers - typeof";return lO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},lO(t)}function txs(t,s){if(t==null)return{};var r=sxs(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function sxs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function cFe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function qce(t){for(var s=1;s0?Nf(M,"paddingAngle",0):0;if(P){var $=af(P.endAngle-P.startAngle,M.endAngle-M.startAngle),U=Yl(Yl({},M),{},{startAngle:S+O,endAngle:S+$(w)+O});j.push(U),S=U.endAngle}else{var B=M.endAngle,V=M.startAngle,X=af(0,B-V),Y=X(w),ee=Yl(Yl({},M),{},{startAngle:S+O,endAngle:S+Y+O});j.push(ee),S=ee.endAngle}}),ht.createElement(Zo,null,n.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!jR(l,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,o=a.hide,l=a.sectors,i=a.className,c=a.label,u=a.cx,p=a.cy,f=a.innerRadius,g=a.outerRadius,v=a.isAnimationActive,_=this.state.isAnimationFinished;if(o||!l||!l.length||!cn(u)||!cn(p)||!cn(f)||!cn(g))return null;var w=Vi("recharts-pie",i);return ht.createElement(Zo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(k){n.pieRef=k}},this.renderSectors(),c&&this.renderLabels(l),Xu.renderCallByParent(this.props,null,!1),(!v||_)&&N1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?S:S-1)*c,L=j-S*v-M,P=a.reduce(function(U,B){var V=wu(B,k,0);return U+(cn(V)?V:0)},0),O;if(P>0){var $;O=a.map(function(U,B){var V=wu(U,k,0),X=wu(U,p,B),Y=(cn(V)?V:0)/P,ee;B?ee=$.endAngle+Am(w)*c*(V!==0?1:0):ee=l;var Q=ee+Am(w)*((V!==0?v:0)+Y*L),ce=(ee+Q)/2,ne=(_.innerRadius+_.outerRadius)/2,re=[{name:X,value:V,payload:U,dataKey:k,type:g}],oe=lc(_.cx,_.cy,ne,ce);return $=Yl(Yl(Yl({percent:Y,cornerRadius:o,name:X,tooltipPayload:re,midAngle:ce,middleRadius:ne,tooltipPosition:oe},U),_),{},{value:wu(U,k),startAngle:ee,endAngle:Q,payload:U,paddingAngle:Am(w)*c}),$})}return Yl(Yl({},_),{},{sectors:O,data:a})});var jxs=Math.ceil,Nxs=Math.max;function kxs(t,s,r,n){for(var a=-1,o=Nxs(jxs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Sxs=kxs,Cxs=crt,mFe=1/0,Mxs=17976931348623157e292;function Txs(t){if(!t)return t===0?t:0;if(t=Cxs(t),t===mFe||t===-mFe){var s=t<0?-1:1;return s*Mxs}return t===t?t:0}var Hnt=Txs,Axs=Sxs,Exs=The,bye=Hnt;function Pxs(t){return function(s,r,n){return n&&typeof n!="number"&&Exs(s,r,n)&&(r=n=void 0),s=bye(s),r===void 0?(r=s,s=0):r=bye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),ef(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,o=a.endIndex,l=a.onDragEnd,i=a.startIndex;l==null||l({endIndex:o,startIndex:i})}),n.detachDragEndListener()}),ef(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),ef(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),ef(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),ef(n,"handleSlideDragStart",function(a){var o=yFe(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:o.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return Gxs(s,t),qxs(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,o=n.endX,l=this.state.scaleValues,i=this.props,c=i.gap,u=i.data,p=u.length-1,f=Math.min(a,o),g=Math.max(a,o),v=s.getIndexInRange(l,f),_=s.getIndexInRange(l,g);return{startIndex:v-v%c,endIndex:_===p?p:_-_%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=wu(o[n],i,n);return Ti(l)?l(c,n):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,o=a.slideMoveStartX,l=a.startX,i=a.endX,c=this.props,u=c.x,p=c.width,f=c.travellerWidth,g=c.startIndex,v=c.endIndex,_=c.onChange,w=n.pageX-o;w>0?w=Math.min(w,u+p-f-i,u+p-f-l):w<0&&(w=Math.max(w,u-l,u-i));var j=this.getIndex({startX:l+w,endX:i+w});(j.startIndex!==g||j.endIndex!==v)&&_&&_(j),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=yFe(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:o.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,o=a.brushMoveStartX,l=a.movingTravellerId,i=a.endX,c=a.startX,u=this.state[l],p=this.props,f=p.x,g=p.width,v=p.travellerWidth,_=p.onChange,w=p.gap,j=p.data,k={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+g-v-u):S<0&&(S=Math.max(S,f-u)),k[l]=u+S;var M=this.getIndex(k),L=M.startIndex,P=M.endIndex,O=function(){var U=j.length-1;return l==="startX"&&(i>c?L%w===0:P%w===0)||ic?P%w===0:L%w===0)||i>c&&P===U};this.setState(ef(ef({},l,u+S),"brushMoveStartX",n.pageX),function(){_&&O()&&_(M)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,c=l.startX,u=l.endX,p=this.state[a],f=i.indexOf(p);if(f!==-1){var g=f+n;if(!(g===-1||g>=i.length)){var v=i[g];a==="startX"&&v>=u||a==="endX"&&v<=c||this.setState(ef({},a,v),function(){o.props.onChange(o.getIndex({startX:o.state.startX,endX:o.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,c=n.fill,u=n.stroke;return ht.createElement("rect",{stroke:u,fill:c,x:a,y:o,width:l,height:i})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,c=n.data,u=n.children,p=n.padding,f=N.Children.only(u);return f?ht.cloneElement(f,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,c=this.props,u=c.y,p=c.travellerWidth,f=c.height,g=c.traveller,v=c.ariaLabel,_=c.data,w=c.startIndex,j=c.endIndex,k=Math.max(n,this.props.x),S=_ye(_ye({},oi(this.props,!1)),{},{x:k,y:u,width:p,height:f}),M=v||"Min value: ".concat((o=_[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=_[j])===null||l===void 0?void 0:l.name);return ht.createElement(Zo,{tabIndex:0,role:"slider","aria-label":M,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(P){["ArrowLeft","ArrowRight"].includes(P.key)&&(P.preventDefault(),P.stopPropagation(),i.handleTravellerMoveKeyboard(P.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(g,S))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,c=o.stroke,u=o.travellerWidth,p=Math.min(n,a)+u,f=Math.max(Math.abs(a-n)-u,0);return ht.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:p,y:l,width:f,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,c=n.travellerWidth,u=n.stroke,p=this.state,f=p.startX,g=p.endX,v=5,_={pointerEvents:"none",fill:u};return ht.createElement(Zo,{className:"recharts-brush-texts"},ht.createElement(l3,Hce({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,g)-v,y:l+i/2},_),this.getTextOfTick(a)),ht.createElement(l3,Hce({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,g)+c+v,y:l+i/2},_),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,c=n.y,u=n.width,p=n.height,f=n.alwaysShowText,g=this.state,v=g.startX,_=g.endX,w=g.isTextActive,j=g.isSlideMoving,k=g.isTravellerMoving,S=g.isTravellerFocused;if(!a||!a.length||!cn(i)||!cn(c)||!cn(u)||!cn(p)||u<=0||p<=0)return null;var M=Vi("recharts-brush",o),L=ht.Children.count(l)===1,P=Bxs("userSelect","none");return ht.createElement(Zo,{className:M,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:P},this.renderBackground(),L&&this.renderPanorama(),this.renderSlide(v,_),this.renderTravellerLayer(v,"startX"),this.renderTravellerLayer(_,"endX"),(w||j||k||S||f)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,c=n.stroke,u=Math.floor(o+i/2)-1;return ht.createElement(ht.Fragment,null,ht.createElement("rect",{x:a,y:o,width:l,height:i,fill:c,stroke:"none"}),ht.createElement("line",{x1:a+1,y1:u,x2:a+l-1,y2:u,fill:"none",stroke:"#fff"}),ht.createElement("line",{x1:a+1,y1:u+2,x2:a+l-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return ht.isValidElement(n)?o=ht.cloneElement(n,a):Ti(n)?o=n(a):o=s.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,c=n.travellerWidth,u=n.updateId,p=n.startIndex,f=n.endIndex;if(o!==a.prevData||u!==a.prevUpdateId)return _ye({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Kxs({data:o,width:l,x:i,travellerWidth:c,startIndex:p,endIndex:f}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([i,i+l-c]);var g=a.scale.domain().map(function(v){return a.scale(v)});return{prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:g}}return null}},{key:"getIndexInRange",value:function(n,a){for(var o=n.length,l=0,i=o-1;i-l>1;){var c=Math.floor((l+i)/2);n[c]>a?i=c:l=c}return a>=n[i]?i:l}}])}(N.PureComponent);ef(vA,"displayName","Brush");ef(vA,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var Zxs=E4e;function Yxs(t,s){var r;return Zxs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Qxs=Yxs,Xxs=Ost,Jxs=G0,egs=Qxs,tgs=Ip,sgs=The;function rgs(t,s,r){var n=tgs(t)?Xxs:egs;return r&&sgs(t,s,r)&&(s=void 0),n(t,Jxs(s))}var ngs=rgs;const ags=Po(ngs);var T0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},vFe=nrt;function igs(t,s,r){s=="__proto__"&&vFe?vFe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var ogs=igs,lgs=ogs,cgs=srt,dgs=G0;function ugs(t,s){var r={};return s=dgs(s),cgs(t,function(n,a,o){lgs(r,a,s(n,a,o))}),r}var hgs=ugs;const mgs=Po(hgs);function pgs(t,s){for(var r=-1,n=t==null?0:t.length;++r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Egs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Pgs(t,s){var r=t.x,n=t.y,a=Ags(t,Sgs),o="".concat(r),l=parseInt(o,10),i="".concat(n),c=parseInt(i,10),u="".concat(s.height||a.height),p=parseInt(u,10),f="".concat(s.width||a.width),g=parseInt(f,10);return yI(yI(yI(yI(yI({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:p,width:g,name:s.name,radius:s.radius})}function _Fe(t){return ht.createElement(qnt,E_e({shapeType:"rectangle",propTransformer:Pgs,activeClassName:"recharts-active-bar"},t))}var Igs=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var o=cn(n)||nYt(n);return o?s(n,a):(o||d3(),r)}},Lgs=["value","background"],Ynt;function bA(t){"@babel/helpers - typeof";return bA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},bA(t)}function Dgs(t,s){if(t==null)return{};var r=Ogs(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Ogs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Wce(){return Wce=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(Q)0&&(ee=Math.min(($e||0)-(Q[Me-1]||0),ee))}),Number.isFinite(ee)){var ce=ee/Y,ne=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=ce*ne/2),w.padding==="no-gap"){var re=Em(s.barCategoryGap,ce*ne),oe=ce*ne/2;$=oe-re-(oe-re)/ne*re}}}a==="xAxis"?U=[n.left+(M.left||0)+($||0),n.left+n.width-(M.right||0)-($||0)]:a==="yAxis"?U=c==="horizontal"?[n.top+n.height-(M.bottom||0),n.top+(M.top||0)]:[n.top+(M.top||0)+($||0),n.top+n.height-(M.bottom||0)-($||0)]:U=w.range,P&&(U=[U[1],U[0]]);var fe=xnt(w,o,g),ge=fe.scale,ue=fe.realScaleType;ge.domain(k).range(U),gnt(ge);var xe=ynt(ge,$g($g({},w),{},{realScaleType:ue}));a==="xAxis"?(X=j==="top"&&!L||j==="bottom"&&L,B=n.left,V=f[O]-X*w.height):a==="yAxis"&&(X=j==="left"&&!L||j==="right"&&L,B=f[O]-X*w.width,V=n.top);var _e=$g($g($g({},w),xe),{},{realScaleType:ue,x:B,y:V,scale:ge,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return _e.bandSize=Ece(_e,xe),!w.hide&&a==="xAxis"?f[O]+=(X?-1:1)*_e.height:w.hide||(f[O]+=(X?-1:1)*_e.width),$g($g({},v),{},Khe({},_,_e))},{})},tat=function(s,r){var n=s.x,a=s.y,o=r.x,l=r.y;return{x:Math.min(n,o),y:Math.min(a,l),width:Math.abs(o-n),height:Math.abs(l-a)}},Wgs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return tat({x:r,y:n},{x:a,y:o})},sat=function(){function t(s){Vgs(this,t),this.scale=s}return Hgs(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(r!==void 0){if(o)switch(o){case"start":return this.scale(r);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(r)+i}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?r>=a&&r<=o:r>=o&&r<=a}}],[{key:"create",value:function(r){return new t(r)}}])}();Khe(sat,"EPS",1e-4);var iSe=function(s){var r=Object.keys(s).reduce(function(n,a){return $g($g({},n),{},Khe({},a,sat.create(s[a])))},{});return $g($g({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return mgs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return Znt(a,function(o,l){return r[l].isInRange(o)})}})};function Kgs(t){return(t%180+180)%180}var Zgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Kgs(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var eys=Jgs,tys=Hnt;function sys(t){var s=tys(t),r=s%1;return s===s?r?s-r:s:0}var rys=sys,nys=Yst,ays=G0,iys=rys,oys=Math.max;function lys(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:iys(r);return a<0&&(a=oys(n+a,0)),nys(t,ays(s),a)}var cys=lys,dys=eys,uys=cys,hys=dys(uys),mys=hys;const pys=Po(mys);var fys=dZt(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),oSe=N.createContext(void 0),lSe=N.createContext(void 0),rat=N.createContext(void 0),nat=N.createContext({}),aat=N.createContext(void 0),iat=N.createContext(0),oat=N.createContext(0),SFe=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,o=r.offset,l=s.clipPathId,i=s.children,c=s.width,u=s.height,p=fys(o);return ht.createElement(oSe.Provider,{value:n},ht.createElement(lSe.Provider,{value:a},ht.createElement(nat.Provider,{value:o},ht.createElement(rat.Provider,{value:p},ht.createElement(aat.Provider,{value:l},ht.createElement(iat.Provider,{value:u},ht.createElement(oat.Provider,{value:c},i)))))))},xys=function(){return N.useContext(aat)},lat=function(s){var r=N.useContext(oSe);r==null&&d3();var n=r[s];return n==null&&d3(),n},gys=function(){var s=N.useContext(oSe);return f_(s)},yys=function(){var s=N.useContext(lSe),r=pys(s,function(n){return Znt(n.domain,Number.isFinite)});return r||f_(s)},cat=function(s){var r=N.useContext(lSe);r==null&&d3();var n=r[s];return n==null&&d3(),n},vys=function(){var s=N.useContext(rat);return s},bys=function(){return N.useContext(nat)},cSe=function(){return N.useContext(oat)},dSe=function(){return N.useContext(iat)};function _A(t){"@babel/helpers - typeof";return _A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},_A(t)}function _ys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function wys(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);rt*a)return!1;var o=r();return t*(s-t*o/2-n)>=0&&t*(s+t*o/2-a)<=0}function r0s(t,s){return xat(t,s+1)}function n0s(t,s,r,n,a){for(var o=(n||[]).slice(),l=s.start,i=s.end,c=0,u=1,p=l,f=function(){var _=n==null?void 0:n[c];if(_===void 0)return{v:xat(n,u)};var w=c,j,k=function(){return j===void 0&&(j=r(_,w)),j},S=_.coordinate,M=c===0||Xce(t,S,k,p,i);M||(c=0,p=l,u+=1),M&&(p=S+t*(k()/2+a),c+=u)},g;u<=o.length;)if(g=f(),g)return g.v;return[]}function mO(t){"@babel/helpers - typeof";return mO=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},mO(t)}function LFe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Uh(t){for(var s=1;s0?v.coordinate-j*t:v.coordinate})}else o[g]=v=Uh(Uh({},v),{},{tickCoord:v.coordinate});var k=Xce(t,v.tickCoord,w,i,c);k&&(c=v.tickCoord-t*(w()/2+a),o[g]=Uh(Uh({},v),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function c0s(t,s,r,n,a,o){var l=(n||[]).slice(),i=l.length,c=s.start,u=s.end;if(o){var p=n[i-1],f=r(p,i-1),g=t*(p.coordinate+t*f/2-u);l[i-1]=p=Uh(Uh({},p),{},{tickCoord:g>0?p.coordinate-g*t:p.coordinate});var v=Xce(t,p.tickCoord,function(){return f},c,u);v&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Uh(Uh({},p),{},{isShow:!0}))}for(var _=o?i-1:i,w=function(S){var M=l[S],L,P=function(){return L===void 0&&(L=r(M,S)),L};if(S===0){var O=t*(M.coordinate-t*P()/2-c);l[S]=M=Uh(Uh({},M),{},{tickCoord:O<0?M.coordinate-O*t:M.coordinate})}else l[S]=M=Uh(Uh({},M),{},{tickCoord:M.coordinate});var $=Xce(t,M.tickCoord,P,c,u);$&&(c=M.tickCoord+t*(P()/2+a),l[S]=Uh(Uh({},M),{},{isShow:!0}))},j=0;j<_;j++)w(j);return l}function mSe(t,s,r){var n=t.tick,a=t.ticks,o=t.viewBox,l=t.minTickGap,i=t.orientation,c=t.interval,u=t.tickFormatter,p=t.unit,f=t.angle;if(!a||!a.length||!n)return[];if(cn(c)||A3.isSsr)return r0s(a,typeof c=="number"&&cn(c)?c:0);var g=[],v=i==="top"||i==="bottom"?"width":"height",_=p&&v==="width"?k8(p,{fontSize:s,letterSpacing:r}):{width:0,height:0},w=function(M,L){var P=Ti(u)?u(M.value,L):M.value;return v==="width"?t0s(k8(P,{fontSize:s,letterSpacing:r}),_,f):k8(P,{fontSize:s,letterSpacing:r})[v]},j=a.length>=2?Am(a[1].coordinate-a[0].coordinate):1,k=s0s(o,j,v);return c==="equidistantPreserveStart"?n0s(j,k,w,a,l):(c==="preserveStart"||c==="preserveStartEnd"?g=c0s(j,k,w,a,l,c==="preserveStartEnd"):g=l0s(j,k,w,a,l),g.filter(function(S){return S.isShow}))}var d0s=["viewBox"],u0s=["viewBox"],h0s=["ticks"];function NA(t){"@babel/helpers - typeof";return NA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},NA(t)}function jM(){return jM=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function m0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function p0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function OFe(t,s){for(var r=0;r0?c(this.props):c(v)),l<=0||i<=0||!_||!_.length?null:ht.createElement(Zo,{className:Vi("recharts-cartesian-axis",u),ref:function(j){n.layerReference=j}},o&&this.renderAxisLine(),this.renderTicks(_,this.state.fontSize,this.state.letterSpacing),Xu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Vi(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,hu(hu({},a),{},{className:i})):Ti(n)?l=n(hu(hu({},a),{},{className:i})):l=ht.createElement(l3,jM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(N.Component);pSe(LE,"displayName","CartesianAxis");pSe(LE,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var _0s=["x1","y1","x2","y2","key"],w0s=["offset"];function u3(t){"@babel/helpers - typeof";return u3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},u3(t)}function RFe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Gh(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function S0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}var C0s=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,o=s.y,l=s.width,i=s.height,c=s.ry;return ht.createElement("rect",{x:a,y:o,ry:c,width:l,height:i,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function vat(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(Ti(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=FFe(s,_0s),u=oi(c,!1);u.offset;var p=FFe(u,w0s);r=ht.createElement("line",D4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function M0s(t){var s=t.x,r=t.width,n=t.horizontal,a=n===void 0?!0:n,o=t.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Gh(Gh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return vat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function T0s(t){var s=t.y,r=t.height,n=t.vertical,a=n===void 0?!0:n,o=t.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,c){var u=Gh(Gh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return vat(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function A0s(t){var s=t.horizontalFill,r=t.fillOpacity,n=t.x,a=t.y,o=t.width,l=t.height,i=t.horizontalPoints,c=t.horizontal,u=c===void 0?!0:c;if(!u||!s||!s.length)return null;var p=i.map(function(g){return Math.round(g+a-a)}).sort(function(g,v){return g-v});a!==p[0]&&p.unshift(0);var f=p.map(function(g,v){var _=!p[v+1],w=_?a+l-g:p[v+1]-g;if(w<=0)return null;var j=v%s.length;return ht.createElement("rect",{key:"react-".concat(v),y:g,x:n,height:w,width:o,stroke:"none",fill:s[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function E0s(t){var s=t.vertical,r=s===void 0?!0:s,n=t.verticalFill,a=t.fillOpacity,o=t.x,l=t.y,i=t.width,c=t.height,u=t.verticalPoints;if(!r||!n||!n.length)return null;var p=u.map(function(g){return Math.round(g+o-o)}).sort(function(g,v){return g-v});o!==p[0]&&p.unshift(0);var f=p.map(function(g,v){var _=!p[v+1],w=_?o+i-g:p[v+1]-g;if(w<=0)return null;var j=v%n.length;return ht.createElement("rect",{key:"react-".concat(v),x:g,y:l,width:w,height:c,stroke:"none",fill:n[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var P0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return fnt(mSe(Gh(Gh(Gh({},LE.defaultProps),n),{},{ticks:r1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},I0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return fnt(mSe(Gh(Gh(Gh({},LE.defaultProps),n),{},{ticks:r1(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},z5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function bat(t){var s,r,n,a,o,l,i=cSe(),c=dSe(),u=bys(),p=Gh(Gh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:z5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:z5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:z5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:z5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:z5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:z5.verticalFill,x:cn(t.x)?t.x:u.left,y:cn(t.y)?t.y:u.top,width:cn(t.width)?t.width:u.width,height:cn(t.height)?t.height:u.height}),f=p.x,g=p.y,v=p.width,_=p.height,w=p.syncWithTicks,j=p.horizontalValues,k=p.verticalValues,S=gys(),M=yys();if(!cn(v)||v<=0||!cn(_)||_<=0||!cn(f)||f!==+f||!cn(g)||g!==+g)return null;var L=p.verticalCoordinatesGenerator||P0s,P=p.horizontalCoordinatesGenerator||I0s,O=p.horizontalPoints,$=p.verticalPoints;if((!O||!O.length)&&Ti(P)){var U=j&&j.length,B=P({yAxis:M?Gh(Gh({},M),{},{ticks:U?j:M.ticks}):void 0,width:i,height:c,offset:u},U?!0:w);ny(Array.isArray(B),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(u3(B),"]")),Array.isArray(B)&&(O=B)}if((!$||!$.length)&&Ti(L)){var V=k&&k.length,X=L({xAxis:S?Gh(Gh({},S),{},{ticks:V?k:S.ticks}):void 0,width:i,height:c,offset:u},V?!0:w);ny(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(u3(X),"]")),Array.isArray(X)&&($=X)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(C0s,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(M0s,D4({},p,{offset:u,horizontalPoints:O,xAxis:S,yAxis:M})),ht.createElement(T0s,D4({},p,{offset:u,verticalPoints:$,xAxis:S,yAxis:M})),ht.createElement(A0s,D4({},p,{horizontalPoints:O})),ht.createElement(E0s,D4({},p,{verticalPoints:$})))}bat.displayName="CartesianGrid";var L0s=["type","layout","connectNulls","ref"],D0s=["key"];function kA(t){"@babel/helpers - typeof";return kA=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},kA(t)}function zFe(t,s){if(t==null)return{};var r=O0s(t,s),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function O0s(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function E8(){return E8=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);rf){v=[].concat(B5(c.slice(0,_)),[f-w]);break}var j=v.length%2===0?[0,g]:[g];return[].concat(B5(s.repeat(c,p)),B5(v),j).map(function(k){return"".concat(k,"px")}).join(", ")}),qg(r,"id",CE("recharts-line-")),qg(r,"pathRef",function(l){r.mainCurve=l}),qg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),qg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return G0s(s,t),q0s(s,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,c=o.yAxis,u=o.layout,p=o.children,f=kf(p,NR);if(!f)return null;var g=function(w,j){return{x:w.x,y:w.y,value:w.value,errorVal:wu(w.payload,j)}},v={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(Zo,v,f.map(function(_){return ht.cloneElement(_,{key:"bar-".concat(_.props.dataKey),data:l,xAxis:i,yAxis:c,layout:u,dataPointFormatter:g})}))}},{key:"renderDots",value:function(n,a,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,u=i.points,p=i.dataKey,f=oi(this.props,!1),g=oi(c,!0),v=u.map(function(w,j){var k=Xp(Xp(Xp({key:"dot-".concat(j),r:3},f),g),{},{index:j,cx:w.x,cy:w.y,value:w.value,dataKey:p,payload:w.payload,points:u});return s.renderDotItem(c,k)}),_={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(Zo,E8({className:"recharts-line-dots",key:"dots"},_),v)}},{key:"renderCurveStatically",value:function(n,a,o,l){var i=this.props,c=i.type,u=i.layout,p=i.connectNulls;i.ref;var f=zFe(i,L0s),g=Xp(Xp(Xp({},oi(f,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:c,layout:u,connectNulls:p});return ht.createElement(Lce,E8({},g,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var o=this,l=this.props,i=l.points,c=l.strokeDasharray,u=l.isAnimationActive,p=l.animationBegin,f=l.animationDuration,g=l.animationEasing,v=l.animationId,_=l.animateNewValues,w=l.width,j=l.height,k=this.state,S=k.prevPoints,M=k.totalLength;return ht.createElement(F0,{begin:p,duration:f,isActive:u,easing:g,from:{t:0},to:{t:1},key:"line-".concat(v),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var P=L.t;if(S){var O=S.length/i.length,$=i.map(function(Y,ee){var Q=Math.floor(ee*O);if(S[Q]){var ce=S[Q],ne=af(ce.x,Y.x),re=af(ce.y,Y.y);return Xp(Xp({},Y),{},{x:ne(P),y:re(P)})}if(_){var oe=af(w*2,Y.x),fe=af(j/2,Y.y);return Xp(Xp({},Y),{},{x:oe(P),y:fe(P)})}return Xp(Xp({},Y),{},{x:Y.x,y:Y.y})});return o.renderCurveStatically($,n,a)}var U=af(0,M),B=U(P),V;if(c){var X="".concat(c).split(/[,\s]+/gim).map(function(Y){return parseFloat(Y)});V=o.getStrokeDasharray(B,M,X)}else V=o.generateSimpleStrokeDasharray(M,B);return o.renderCurveStatically(i,n,a,{strokeDasharray:V})})}},{key:"renderCurve",value:function(n,a){var o=this.props,l=o.points,i=o.isAnimationActive,c=this.state,u=c.prevPoints,p=c.totalLength;return i&&l&&l.length&&(!u&&p>0||!jR(u,l))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(l,n,a)}},{key:"render",value:function(){var n,a=this.props,o=a.hide,l=a.dot,i=a.points,c=a.className,u=a.xAxis,p=a.yAxis,f=a.top,g=a.left,v=a.width,_=a.height,w=a.isAnimationActive,j=a.id;if(o||!i||!i.length)return null;var k=this.state.isAnimationFinished,S=i.length===1,M=Vi("recharts-line",c),L=u&&u.allowDataOverflow,P=p&&p.allowDataOverflow,O=L||P,$=$i(j)?this.id:j,U=(n=oi(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},B=U.r,V=B===void 0?3:B,X=U.strokeWidth,Y=X===void 0?2:X,ee=xYt(l)?l:{},Q=ee.clipDot,ce=Q===void 0?!0:Q,ne=V*2+Y;return ht.createElement(Zo,{className:M},L||P?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat($)},ht.createElement("rect",{x:L?g:g-v/2,y:P?f:f-_/2,width:L?v:v*2,height:P?_:_*2})),!ce&&ht.createElement("clipPath",{id:"clipPath-dots-".concat($)},ht.createElement("rect",{x:g-ne/2,y:f-ne/2,width:v+ne,height:_+ne}))):null,!S&&this.renderCurve(O,$),this.renderErrorBar(O,$),(S||l)&&this.renderDots(O,ce,$),(!w||k)&&N1.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var o=n.length%2!==0?[].concat(B5(n),[0]):n,l=[],i=0;it.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Dvs(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Ovs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Rvs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&cn(a)&&cn(o)?s.slice(a,o+1):[]};function Oat(t){return t==="number"?[0,"auto"]:void 0}var Y_e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Jhe(r,s);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(c,u){var p,f=(p=u.props.data)!==null&&p!==void 0?p:r;f&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(f=f.slice(s.dataStartIndex,s.dataEndIndex+1));var g;if(l.dataKey&&!l.allowDuplicatedCategory){var v=f===void 0?i:f;g=rce(v,l.dataKey,a)}else g=f&&f[n]||i[n];return g?[].concat(TA(c),[bnt(u,g)]):c},[])},WFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=Zvs(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,p=gus(l,i,u,c);if(p>=0&&u){var f=u[p]&&u[p].value,g=Y_e(s,r,p,f),v=Yvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:g,activeCoordinate:v}}return null},Qvs=function(s,r){var n=r.axes,a=r.graphicalItems,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=s.stackOffset,v=pnt(p,o);return n.reduce(function(_,w){var j,k=w.type.defaultProps!==void 0?wr(wr({},w.type.defaultProps),w.props):w.props,S=k.type,M=k.dataKey,L=k.allowDataOverflow,P=k.allowDuplicatedCategory,O=k.scale,$=k.ticks,U=k.includeHidden,B=k[l];if(_[B])return _;var V=Jhe(s.data,{graphicalItems:a.filter(function(xe){var _e,$e=l in xe.props?xe.props[l]:(_e=xe.type.defaultProps)===null||_e===void 0?void 0:_e[l];return $e===B}),dataStartIndex:c,dataEndIndex:u}),X=V.length,Y,ee,Q;jvs(k.domain,L,S)&&(Y=d_e(k.domain,null,L),v&&(S==="number"||O!=="auto")&&(Q=C8(V,M,"category")));var ce=Oat(S);if(!Y||Y.length===0){var ne,re=(ne=k.domain)!==null&&ne!==void 0?ne:ce;if(M){if(Y=C8(V,M,S),S==="category"&&v){var oe=iYt(Y);P&&oe?(ee=Y,Y=Vce(0,X)):P||(Y=fRe(re,Y,w).reduce(function(xe,_e){return xe.indexOf(_e)>=0?xe:[].concat(TA(xe),[_e])},[]))}else if(S==="category")P?Y=Y.filter(function(xe){return xe!==""&&!$i(xe)}):Y=fRe(re,Y,w).reduce(function(xe,_e){return xe.indexOf(_e)>=0||_e===""||$i(_e)?xe:[].concat(TA(xe),[_e])},[]);else if(S==="number"){var fe=wus(V,a.filter(function(xe){var _e,$e,Me=l in xe.props?xe.props[l]:(_e=xe.type.defaultProps)===null||_e===void 0?void 0:_e[l],Ie="hide"in xe.props?xe.props.hide:($e=xe.type.defaultProps)===null||$e===void 0?void 0:$e.hide;return Me===B&&(U||!Ie)}),M,o,p);fe&&(Y=fe)}v&&(S==="number"||O!=="auto")&&(Q=C8(V,M,"category"))}else v?Y=Vce(0,X):i&&i[B]&&i[B].hasStack&&S==="number"?Y=g==="expand"?[0,1]:vnt(i[B].stackGroups,c,u):Y=mnt(V,a.filter(function(xe){var _e=l in xe.props?xe.props[l]:xe.type.defaultProps[l],$e="hide"in xe.props?xe.props.hide:xe.type.defaultProps.hide;return _e===B&&(U||!$e)}),S,p,!0);if(S==="number")Y=W_e(f,Y,B,o,$),re&&(Y=d_e(re,Y,L));else if(S==="category"&&re){var ge=re,ue=Y.every(function(xe){return ge.indexOf(xe)>=0});ue&&(Y=ge)}}return wr(wr({},_),{},pi({},B,wr(wr({},k),{},{axisType:o,domain:Y,categoricalDomain:Q,duplicateDomain:ee,originalDomain:(j=k.domain)!==null&&j!==void 0?j:ce,isCategorical:v,layout:p})))},{})},Xvs=function(s,r){var n=r.graphicalItems,a=r.Axis,o=r.axisType,l=r.axisIdKey,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.layout,f=s.children,g=Jhe(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),v=g.length,_=pnt(p,o),w=-1;return n.reduce(function(j,k){var S=k.type.defaultProps!==void 0?wr(wr({},k.type.defaultProps),k.props):k.props,M=S[l],L=Oat("number");if(!j[M]){w++;var P;return _?P=Vce(0,v):i&&i[M]&&i[M].hasStack?(P=vnt(i[M].stackGroups,c,u),P=W_e(f,P,M,o)):(P=d_e(L,mnt(g,n.filter(function(O){var $,U,B=l in O.props?O.props[l]:($=O.type.defaultProps)===null||$===void 0?void 0:$[l],V="hide"in O.props?O.props.hide:(U=O.type.defaultProps)===null||U===void 0?void 0:U.hide;return B===M&&!V}),"number",p),a.defaultProps.allowDataOverflow),P=W_e(f,P,M,o)),wr(wr({},j),{},pi({},M,wr(wr({axisType:o},a.defaultProps),{},{hide:!0,orientation:Nf(Wvs,"".concat(o,".").concat(w%2),null),domain:P,originalDomain:L,isCategorical:_,layout:p})))}return j},{})},Jvs=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,o=r.AxisComp,l=r.graphicalItems,i=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,p=s.children,f="".concat(a,"Id"),g=kf(p,o),v={};return g&&g.length?v=Qvs(s,{axes:g,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(v=Xvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),v},e1s=function(s){var r=f_(s),n=r1(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:P4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Ece(r,n)}},KFe=function(s){var r=s.children,n=s.defaultShowTooltip,a=sf(r,vA),o=0,l=0;return s.data&&s.data.length!==0&&(l=s.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(o=a.props.startIndex),a.props.endIndex>=0&&(l=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:o,dataEndIndex:l,activeTooltipIndex:-1,isTooltipActive:!!n}},t1s=function(s){return!s||!s.length?!1:s.some(function(r){var n=w1(r&&r.type);return n&&n.indexOf("Bar")>=0})},ZFe=function(s){return s==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:s==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:s==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},s1s=function(s,r){var n=s.props,a=s.graphicalItems,o=s.xAxisMap,l=o===void 0?{}:o,i=s.yAxisMap,c=i===void 0?{}:i,u=n.width,p=n.height,f=n.children,g=n.margin||{},v=sf(f,vA),_=sf(f,mT),w=Object.keys(c).reduce(function(P,O){var $=c[O],U=$.orientation;return!$.mirror&&!$.hide?wr(wr({},P),{},pi({},U,P[U]+$.width)):P},{left:g.left||0,right:g.right||0}),j=Object.keys(l).reduce(function(P,O){var $=l[O],U=$.orientation;return!$.mirror&&!$.hide?wr(wr({},P),{},pi({},U,Nf(P,"".concat(U))+$.height)):P},{top:g.top||0,bottom:g.bottom||0}),k=wr(wr({},j),w),S=k.bottom;v&&(k.bottom+=v.props.height||vA.defaultProps.height),_&&r&&(k=bus(k,a,n,r));var M=u-k.left-k.right,L=p-k.top-k.bottom;return wr(wr({brushBottom:S},k),{},{width:Math.max(M,0),height:Math.max(L,0)})},r1s=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},fSe=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,o=a===void 0?"axis":a,l=s.validateTooltipEventTypes,i=l===void 0?["axis"]:l,c=s.axisComponents,u=s.legendContent,p=s.formatAxisMap,f=s.defaultProps,g=function(k,S){var M=S.graphicalItems,L=S.stackGroups,P=S.offset,O=S.updateId,$=S.dataStartIndex,U=S.dataEndIndex,B=k.barSize,V=k.layout,X=k.barGap,Y=k.barCategoryGap,ee=k.maxBarSize,Q=ZFe(V),ce=Q.numericAxisName,ne=Q.cateAxisName,re=t1s(M),oe=[];return M.forEach(function(fe,ge){var ue=Jhe(k.data,{graphicalItems:[fe],dataStartIndex:$,dataEndIndex:U}),xe=fe.type.defaultProps!==void 0?wr(wr({},fe.type.defaultProps),fe.props):fe.props,_e=xe.dataKey,$e=xe.maxBarSize,Me=xe["".concat(ce,"Id")],Ie=xe["".concat(ne,"Id")],ke={},pe=c.reduce(function(ct,Ue){var Ze=S["".concat(Ue.axisType,"Map")],Je=xe["".concat(Ue.axisType,"Id")];Ze&&Ze[Je]||Ue.axisType==="zAxis"||d3();var Ge=Ze[Je];return wr(wr({},ct),{},pi(pi({},Ue.axisType,Ge),"".concat(Ue.axisType,"Ticks"),r1(Ge)))},ke),we=pe[ne],Le=pe["".concat(ne,"Ticks")],Qe=L&&L[Me]&&L[Me].hasStack&&Eus(fe,L[Me].stackGroups),Te=w1(fe.type).indexOf("Bar")>=0,pt=Ece(we,Le),ye=[],qe=re&&yus({barSize:B,stackGroups:L,totalSize:r1s(pe,ne)});if(Te){var at,tt,Ae=$i($e)?ee:$e,rt=(at=(tt=Ece(we,Le,!0))!==null&&tt!==void 0?tt:Ae)!==null&&at!==void 0?at:0;ye=vus({barGap:X,barCategoryGap:Y,bandSize:rt!==pt?rt:pt,sizeList:qe[Ie],maxBarSize:Ae}),rt!==pt&&(ye=ye.map(function(ct){return wr(wr({},ct),{},{position:wr(wr({},ct.position),{},{offset:ct.position.offset-rt/2})})}))}var He=fe&&fe.type&&fe.type.getComposedData;He&&oe.push({props:wr(wr({},He(wr(wr({},pe),{},{displayedData:ue,props:k,dataKey:_e,item:fe,bandSize:pt,barPosition:ye,offset:P,stackedData:Qe,layout:V,dataStartIndex:$,dataEndIndex:U}))),{},pi(pi(pi({key:fe.key||"item-".concat(ge)},ce,pe[ce]),ne,pe[ne]),"animationId",O)),childIndex:vYt(fe,k.children),item:fe})}),oe},v=function(k,S){var M=k.props,L=k.dataStartIndex,P=k.dataEndIndex,O=k.updateId;if(!lDe({props:M}))return null;var $=M.children,U=M.layout,B=M.stackOffset,V=M.data,X=M.reverseStackOrder,Y=ZFe(U),ee=Y.numericAxisName,Q=Y.cateAxisName,ce=kf($,n),ne=Tus(V,ce,"".concat(ee,"Id"),"".concat(Q,"Id"),B,X),re=c.reduce(function(xe,_e){var $e="".concat(_e.axisType,"Map");return wr(wr({},xe),{},pi({},$e,Jvs(M,wr(wr({},_e),{},{graphicalItems:ce,stackGroups:_e.axisType===ee&&ne,dataStartIndex:L,dataEndIndex:P}))))},{}),oe=s1s(wr(wr({},re),{},{props:M,graphicalItems:ce}),S==null?void 0:S.legendBBox);Object.keys(re).forEach(function(xe){re[xe]=p(M,re[xe],oe,xe.replace("Map",""),r)});var fe=re["".concat(Q,"Map")],ge=e1s(fe),ue=g(M,wr(wr({},re),{},{dataStartIndex:L,dataEndIndex:P,updateId:O,graphicalItems:ce,stackGroups:ne,offset:oe}));return wr(wr({formattedGraphicalItems:ue,graphicalItems:ce,offset:oe,stackGroups:ne},ge),re)},_=function(j){function k(S){var M,L,P;return Ovs(this,k),P=zvs(this,k,[S]),pi(P,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),pi(P,"accessibilityManager",new wvs),pi(P,"handleLegendBBoxUpdate",function(O){if(O){var $=P.state,U=$.dataStartIndex,B=$.dataEndIndex,V=$.updateId;P.setState(wr({legendBBox:O},v({props:P.props,dataStartIndex:U,dataEndIndex:B,updateId:V},wr(wr({},P.state),{},{legendBBox:O}))))}}),pi(P,"handleReceiveSyncEvent",function(O,$,U){if(P.props.syncId===O){if(U===P.eventEmitterSymbol&&typeof P.props.syncMethod!="function")return;P.applySyncEvent($)}}),pi(P,"handleBrushChange",function(O){var $=O.startIndex,U=O.endIndex;if($!==P.state.dataStartIndex||U!==P.state.dataEndIndex){var B=P.state.updateId;P.setState(function(){return wr({dataStartIndex:$,dataEndIndex:U},v({props:P.props,dataStartIndex:$,dataEndIndex:U,updateId:B},P.state))}),P.triggerSyncEvent({dataStartIndex:$,dataEndIndex:U})}}),pi(P,"handleMouseEnter",function(O){var $=P.getMouseInfo(O);if($){var U=wr(wr({},$),{},{isTooltipActive:!0});P.setState(U),P.triggerSyncEvent(U);var B=P.props.onMouseEnter;Ti(B)&&B(U,O)}}),pi(P,"triggeredAfterMouseMove",function(O){var $=P.getMouseInfo(O),U=$?wr(wr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};P.setState(U),P.triggerSyncEvent(U);var B=P.props.onMouseMove;Ti(B)&&B(U,O)}),pi(P,"handleItemMouseEnter",function(O){P.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),pi(P,"handleItemMouseLeave",function(){P.setState(function(){return{isTooltipActive:!1}})}),pi(P,"handleMouseMove",function(O){O.persist(),P.throttleTriggeredAfterMouseMove(O)}),pi(P,"handleMouseLeave",function(O){P.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};P.setState($),P.triggerSyncEvent($);var U=P.props.onMouseLeave;Ti(U)&&U($,O)}),pi(P,"handleOuterEvent",function(O){var $=yYt(O),U=Nf(P.props,"".concat($));if($&&Ti(U)){var B,V;/.*touch.*/i.test($)?V=P.getMouseInfo(O.changedTouches[0]):V=P.getMouseInfo(O),U((B=V)!==null&&B!==void 0?B:{},O)}}),pi(P,"handleClick",function(O){var $=P.getMouseInfo(O);if($){var U=wr(wr({},$),{},{isTooltipActive:!0});P.setState(U),P.triggerSyncEvent(U);var B=P.props.onClick;Ti(B)&&B(U,O)}}),pi(P,"handleMouseDown",function(O){var $=P.props.onMouseDown;if(Ti($)){var U=P.getMouseInfo(O);$(U,O)}}),pi(P,"handleMouseUp",function(O){var $=P.props.onMouseUp;if(Ti($)){var U=P.getMouseInfo(O);$(U,O)}}),pi(P,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),pi(P,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.handleMouseDown(O.changedTouches[0])}),pi(P,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&P.handleMouseUp(O.changedTouches[0])}),pi(P,"handleDoubleClick",function(O){var $=P.props.onDoubleClick;if(Ti($)){var U=P.getMouseInfo(O);$(U,O)}}),pi(P,"handleContextMenu",function(O){var $=P.props.onContextMenu;if(Ti($)){var U=P.getMouseInfo(O);$(U,O)}}),pi(P,"triggerSyncEvent",function(O){P.props.syncId!==void 0&&jye.emit(Nye,P.props.syncId,O,P.eventEmitterSymbol)}),pi(P,"applySyncEvent",function(O){var $=P.props,U=$.layout,B=$.syncMethod,V=P.state.updateId,X=O.dataStartIndex,Y=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)P.setState(wr({dataStartIndex:X,dataEndIndex:Y},v({props:P.props,dataStartIndex:X,dataEndIndex:Y,updateId:V},P.state)));else if(O.activeTooltipIndex!==void 0){var ee=O.chartX,Q=O.chartY,ce=O.activeTooltipIndex,ne=P.state,re=ne.offset,oe=ne.tooltipTicks;if(!re)return;if(typeof B=="function")ce=B(oe,O);else if(B==="value"){ce=-1;for(var fe=0;fe=0){var Qe,Te;if(ee.dataKey&&!ee.allowDuplicatedCategory){var pt=typeof ee.dataKey=="function"?Le:"payload.".concat(ee.dataKey.toString());Qe=rce(fe,pt,ce),Te=ge&&ue&&rce(ue,pt,ce)}else Qe=fe==null?void 0:fe[Q],Te=ge&&ue&&ue[Q];if(Ie||Me){var ye=O.props.activeIndex!==void 0?O.props.activeIndex:Q;return[N.cloneElement(O,wr(wr(wr({},B.props),pe),{},{activeIndex:ye})),null,null]}if(!$i(Qe))return[we].concat(TA(P.renderActivePoints({item:B,activePoint:Qe,basePoint:Te,childIndex:Q,isRange:ge})))}else{var qe,at=(qe=P.getItemByXY(P.state.activeCoordinate))!==null&&qe!==void 0?qe:{graphicalItem:we},tt=at.graphicalItem,Ae=tt.item,rt=Ae===void 0?O:Ae,He=tt.childIndex,ct=wr(wr(wr({},B.props),pe),{},{activeIndex:He});return[N.cloneElement(rt,ct),null,null]}return ge?[we,null,null]:[we,null]}),pi(P,"renderCustomized",function(O,$,U){return N.cloneElement(O,wr(wr({key:"recharts-customized-".concat(U)},P.props),P.state))}),pi(P,"renderMap",{CartesianGrid:{handler:s9,once:!0},ReferenceArea:{handler:P.renderReferenceElement},ReferenceLine:{handler:s9},ReferenceDot:{handler:P.renderReferenceElement},XAxis:{handler:s9},YAxis:{handler:s9},Brush:{handler:P.renderBrush,once:!0},Bar:{handler:P.renderGraphicChild},Line:{handler:P.renderGraphicChild},Area:{handler:P.renderGraphicChild},Radar:{handler:P.renderGraphicChild},RadialBar:{handler:P.renderGraphicChild},Scatter:{handler:P.renderGraphicChild},Pie:{handler:P.renderGraphicChild},Funnel:{handler:P.renderGraphicChild},Tooltip:{handler:P.renderCursor,once:!0},PolarGrid:{handler:P.renderPolarGrid,once:!0},PolarAngleAxis:{handler:P.renderPolarAxis},PolarRadiusAxis:{handler:P.renderPolarAxis},Customized:{handler:P.renderCustomized}}),P.clipPathId="".concat((M=S.id)!==null&&M!==void 0?M:CE("recharts"),"-clip"),P.throttleTriggeredAfterMouseMove=drt(P.triggeredAfterMouseMove,(L=S.throttleDelay)!==null&&L!==void 0?L:1e3/60),P.state={},P}return qvs(k,j),Fvs(k,[{key:"componentDidMount",value:function(){var M,L;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(L=this.props.margin.top)!==null&&L!==void 0?L:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,L=M.children,P=M.data,O=M.height,$=M.layout,U=sf(L,hp);if(U){var B=U.props.defaultIndex;if(!(typeof B!="number"||B<0||B>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[B]&&this.state.tooltipTicks[B].value,X=Y_e(this.state,P,B,V),Y=this.state.tooltipTicks[B].coordinate,ee=(this.state.offset.top+O)/2,Q=$==="horizontal",ce=Q?{x:Y,y:ee}:{y:Y,x:ee},ne=this.state.formattedGraphicalItems.find(function(oe){var fe=oe.item;return fe.type.name==="Scatter"});ne&&(ce=wr(wr({},ce),ne.props.points[B].tooltipPosition),X=ne.props.points[B].tooltipPayload);var re={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:V,activePayload:X,activeCoordinate:ce};this.setState(re),this.renderCursor(U),this.accessibilityManager.setIndex(B)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,L){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==L.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var P,O;this.accessibilityManager.setDetails({offset:{left:(P=this.props.margin.left)!==null&&P!==void 0?P:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(M){kbe([sf(M.children,hp)],[sf(this.props.children,hp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=sf(this.props.children,hp);if(M&&typeof M.props.shared=="boolean"){var L=M.props.shared?"axis":"item";return i.indexOf(L)>=0?L:o}return o}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var L=this.container,P=L.getBoundingClientRect(),O=His(P),$={chartX:Math.round(M.pageX-O.left),chartY:Math.round(M.pageY-O.top)},U=P.width/L.offsetWidth||1,B=this.inRange($.chartX,$.chartY,U);if(!B)return null;var V=this.state,X=V.xAxisMap,Y=V.yAxisMap,ee=this.getTooltipEventType(),Q=WFe(this.state,this.props.data,this.props.layout,B);if(ee!=="axis"&&X&&Y){var ce=f_(X).scale,ne=f_(Y).scale,re=ce&&ce.invert?ce.invert($.chartX):null,oe=ne&&ne.invert?ne.invert($.chartY):null;return wr(wr({},$),{},{xValue:re,yValue:oe},Q)}return Q?wr(wr({},$),Q):null}},{key:"inRange",value:function(M,L){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,$=M/P,U=L/P;if(O==="horizontal"||O==="vertical"){var B=this.state.offset,V=$>=B.left&&$<=B.left+B.width&&U>=B.top&&U<=B.top+B.height;return V?{x:$,y:U}:null}var X=this.state,Y=X.angleAxisMap,ee=X.radiusAxisMap;if(Y&&ee){var Q=f_(Y);return yRe({x:$,y:U},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,L=this.getTooltipEventType(),P=sf(M,hp),O={};P&&L==="axis"&&(P.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var $=nce(this.props,this.handleOuterEvent);return wr(wr({},$),O)}},{key:"addListener",value:function(){jye.on(Nye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){jye.removeListener(Nye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,L,P){for(var O=this.state.formattedGraphicalItems,$=0,U=O.length;${const{data:S,error:M}=await H.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(M)throw M;return S}}),{data:n}=mt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("id, name, email");if(M)throw M;return S}});if(r)return e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading analytics..."});const a=s||[],o=new Map((n||[]).map(S=>[S.id,S])),l=a.reduce((S,M)=>S+(M.sent_count||0),0),i=a.reduce((S,M)=>S+(M.open_count||0),0),c=a.reduce((S,M)=>S+(M.click_count||0),0),u=a.reduce((S,M)=>S+(M.bounce_count||0),0),p=a.reduce((S,M)=>S+(M.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",g=l>0?(c/l*100).toFixed(1):"0.0",v=[{label:"Campaigns Sent",value:a.length,icon:$n,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:hr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:Dn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${g}%`,icon:Nh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Yu,color:"text-orange-600"},{label:"Complaints",value:p,icon:Jo,color:"text-destructive"}],_=new Map;a.forEach(S=>{var P,O;const M=S.user_id,L=_.get(M)||{name:((P=o.get(M))==null?void 0:P.name)||((O=o.get(M))==null?void 0:O.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};L.campaigns++,L.sent+=S.sent_count||0,L.opens+=S.open_count||0,L.clicks+=S.click_count||0,_.set(M,L)});const w=[..._.entries()].map(([S,M])=>({id:S,...M,openRate:M.sent>0?+(M.opens/M.sent*100).toFixed(1):0})).sort((S,M)=>M.sent-S.sent),j=w.slice(0,6).map(S=>({name:S.name,value:S.sent})),k=a.map(S=>{var M;return{name:S.name.length>20?S.name.slice(0,20)+"…":S.name,agent:((M=o.get(S.user_id))==null?void 0:M.name)||"Unknown",openRate:S.sent_count>0?+(S.open_count/S.sent_count*100).toFixed(1):0,clickRate:S.sent_count>0?+(S.click_count/S.sent_count*100).toFixed(1):0,sent:S.sent_count,date:S.sent_at?ms(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx($n,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No campaigns sent yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign analytics will appear here after the first send."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:v.map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx(S.icon,{className:`h-5 w-5 mx-auto mb-1 ${S.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})},S.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(pT,{width:"100%",height:"100%",children:e.jsxs(Rat,{data:k,children:[e.jsx(h3,{dataKey:"date",fontSize:11}),e.jsx(m3,{fontSize:11,unit:"%"}),e.jsx(hp,{formatter:S=>`${S}%`}),e.jsx(z1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(z1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(pT,{width:"100%",height:"100%",children:e.jsxs(Fat,{children:[e.jsx(W0,{data:j,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:M})=>`${S} (${(M*100).toFixed(0)}%)`,fontSize:11,children:j.map((S,M)=>e.jsx(yR,{fill:YFe[M%YFe.length]},M))}),e.jsx(hp,{})]})})})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(pT,{width:"100%",height:"100%",children:e.jsxs(n1s,{data:k,children:[e.jsx(h3,{dataKey:"date",fontSize:11}),e.jsx(m3,{fontSize:11}),e.jsx(hp,{}),e.jsx(kR,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:w.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(st,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,M)=>{const L=S.sent_count>0?S.open_count/S.sent_count:0;return(M.sent_count>0?M.open_count/M.sent_count:0)-L}).slice(0,10).map((S,M)=>{const L=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",P=S.sent_count>0?(S.click_count/S.sent_count*100).toFixed(1):"0.0",O=o.get(S.user_id);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/30 cursor-pointer",onClick:()=>t(`/admin/email-campaigns/${S.id}`),children:[e.jsxs("span",{className:"text-lg font-bold text-muted-foreground w-6",children:["#",M+1]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(O==null?void 0:O.name)||"Unknown"," · ",S.sent_at?ms(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",L,"%"]}),e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(Nh,{className:"h-3 w-3"})," ",P,"%"]})]})]},S.id)})})})]})]})})}const i1s=()=>e.jsx(Ts,{title:"Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Analytics & Activity"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Platform-wide usage statistics and user activity"})]}),e.jsxs(_a,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(ws,{value:"analytics",className:"space-y-4",children:e.jsx(kGt,{})}),e.jsx(ws,{value:"content",className:"space-y-4",children:e.jsx(CGt,{})}),e.jsx(ws,{value:"email-campaigns",className:"space-y-4",children:e.jsx(a1s,{})}),e.jsx(ws,{value:"activity",className:"space-y-4",children:e.jsx(NGt,{})}),e.jsx(ws,{value:"shares",className:"space-y-4",children:e.jsx(Ztt,{})})]})]})});function o1s(){const t=Xt(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,c]=N.useState(null),[u,p]=N.useState(""),[f,g]=N.useState([]),[v,_]=N.useState([]),[w,j]=N.useState([]),[k,S]=N.useState(!1),[M,L]=N.useState(null),[P,O]=N.useState(""),{data:$,isLoading:U}=mt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(pt)throw pt;return Te}}),{data:B}=mt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:V}=mt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:X}=mt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),{data:Y,isLoading:ee}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Te,error:pt}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(pt)throw pt;return Te}}),Q=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),p(""),g([]),_([]),j([]),a(null),O("")},ce=Te=>{a(Te),l({title:Te.title,description:Te.description||"",publish_date:Te.publish_date.split("T")[0],is_published:Te.is_published,category_id:Te.category_id||""}),p(Te.preview_image_url||""),O("");const pt=(B==null?void 0:B.filter(at=>at.resource_id===Te.id))||[];g(pt.map(at=>({id:at.id,name:at.name,file_url:at.file_url,file_size:at.file_size,sort_order:at.sort_order})));const ye=(V==null?void 0:V.filter(at=>at.resource_id===Te.id))||[];_(ye.map(at=>({id:at.id,title:at.title,video_url:at.video_url,sort_order:at.sort_order})));const qe=(X==null?void 0:X.filter(at=>at.resource_id===Te.id))||[];j(qe.map(at=>({id:at.id,title:at.title,canva_share_link:at.canva_share_link,sort_order:at.sort_order}))),r(!0)},ne=Te=>{var ye;const pt=(ye=Te.target.files)==null?void 0:ye[0];pt&&(c(pt),p(URL.createObjectURL(pt)))},re=()=>{g([...f,{name:"",file_url:"",sort_order:f.length}])},oe=Te=>{g(f.filter((pt,ye)=>ye!==Te))},fe=(Te,pt,ye)=>{const qe=[...f];if(pt==="file"&&ye instanceof File){const at=ye.name.replace(/\.[^/.]+$/,"");qe[Te]={...qe[Te],file:ye,file_size:ye.size,name:qe[Te].name||at}}else qe[Te]={...qe[Te],[pt]:ye};g(qe)},ge=()=>{_([...v,{title:"",video_url:"",sort_order:v.length}])},ue=Te=>{_(v.filter((pt,ye)=>ye!==Te))},xe=(Te,pt,ye)=>{const qe=[...v];pt==="file"&&ye instanceof File?qe[Te]={...qe[Te],file:ye}:qe[Te]={...qe[Te],[pt]:ye},_(qe)},_e=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},$e=Te=>{j(w.filter((pt,ye)=>ye!==Te))},Me=(Te,pt,ye)=>{const qe=[...w];qe[Te]={...qe[Te],[pt]:ye},j(qe)},Ie=async(Te,pt)=>{try{const ye=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Te.name}});if(ye.error)throw ye.error;const{videoId:qe,uploadUrl:at,libraryId:tt}=ye.data,Ae=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:qe,libraryId:tt}});if(Ae.error)throw Ae.error;const{uploadUrl:rt,apiKey:He}=Ae.data,ct=new XMLHttpRequest;return ct.open("PUT",rt,!0),ct.setRequestHeader("AccessKey",He),ct.upload.onprogress=Ue=>{if(Ue.lengthComputable){const Ze=Math.round(Ue.loaded/Ue.total*100),Je=[...v];Je[pt]={...Je[pt],uploadProgress:Ze},_(Je)}},await new Promise((Ue,Ze)=>{ct.onload=()=>ct.status>=200&&ct.status<300?Ue():Ze(new Error("Upload failed")),ct.onerror=()=>Ze(new Error("Upload failed")),ct.send(Te)}),`https://iframe.mediadelivery.net/embed/${tt}/${qe}`}catch(ye){throw console.error("Bunny upload error:",ye),ye}},ke=Lt({mutationFn:async Te=>{const{data:pt,error:ye}=await H.from("brokerage_resource_categories").insert({name:Te,sort_order:(Y==null?void 0:Y.length)||0}).select().single();if(ye)throw ye;return pt},onSuccess:Te=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Te.id}),O(""),me.success("Category created")},onError:Te=>{me.error("Failed to create category: "+Te.message)}}),pe=Lt({mutationFn:async()=>{S(!0);let Te=(n==null?void 0:n.preview_image_url)||null;if(i){const qe=i.name.split(".").pop(),at=`${Date.now()}.${qe}`,{error:tt}=await H.storage.from("brokerage-resources").upload(`previews/${at}`,i);if(tt)throw tt;const{data:Ae}=H.storage.from("brokerage-resources").getPublicUrl(`previews/${at}`);Te=Ae.publicUrl}const pt={title:o.title,description:o.description||null,preview_image_url:Te,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let ye;if(n){const{error:qe}=await H.from("brokerage_resources").update(pt).eq("id",n.id);if(qe)throw qe;ye=n.id;const at=(B==null?void 0:B.filter(Ge=>Ge.resource_id===n.id).map(Ge=>Ge.id))||[],tt=f.filter(Ge=>Ge.id).map(Ge=>Ge.id),Ae=at.filter(Ge=>!tt.includes(Ge));Ae.length>0&&await H.from("brokerage_resource_pdfs").delete().in("id",Ae);const rt=(V==null?void 0:V.filter(Ge=>Ge.resource_id===n.id).map(Ge=>Ge.id))||[],He=v.filter(Ge=>Ge.id).map(Ge=>Ge.id),ct=rt.filter(Ge=>!He.includes(Ge));ct.length>0&&await H.from("brokerage_resource_videos").delete().in("id",ct);const Ue=(X==null?void 0:X.filter(Ge=>Ge.resource_id===n.id).map(Ge=>Ge.id))||[],Ze=w.filter(Ge=>Ge.id).map(Ge=>Ge.id),Je=Ue.filter(Ge=>!Ze.includes(Ge));Je.length>0&&await H.from("brokerage_resource_links").delete().in("id",Je)}else{const{data:qe,error:at}=await H.from("brokerage_resources").insert(pt).select().single();if(at)throw at;ye=qe.id}for(let qe=0;qe{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success(n?"Resource updated":"Resource created"),r(!1),Q(),S(!1)},onError:Te=>{me.error("Failed to save resource: "+Te.message),S(!1)}}),we=Lt({mutationFn:async Te=>{const{error:pt}=await H.from("brokerage_resources").delete().eq("id",Te);if(pt)throw pt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:Te=>{me.error("Failed to delete: "+Te.message)}}),Le=Te=>{if(Te.preventDefault(),!o.title){me.error("Please enter a title");return}pe.mutate()},Qe=Te=>{const pt=(B==null?void 0:B.filter(at=>at.resource_id===Te).length)||0,ye=(V==null?void 0:V.filter(at=>at.resource_id===Te).length)||0,qe=(X==null?void 0:X.filter(at=>at.resource_id===Te).length)||0;return{pdfCount:pt,videoCount:ye,linkCount:qe}};return e.jsx(Ts,{title:"Brokerage Resources Management",description:"Create and manage resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Q(),r(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Content"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:U?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(Te=>{const{pdfCount:pt,videoCount:ye,linkCount:qe}=Qe(Te.id),at=Y==null?void 0:Y.find(tt=>tt.id===Te.category_id);return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Te.preview_image_url?e.jsx("img",{src:Te.preview_image_url,alt:Te.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Te.title}),Te.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Te.description})]})]})}),e.jsx(dt,{children:at?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:at.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-3.5 w-3.5"}),pt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),ye]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Bo,{className:"h-3.5 w-3.5"}),qe]})]})}),e.jsx(dt,{children:ms(new Date(Te.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Te.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Te.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{const tt=(B==null?void 0:B.filter(He=>He.resource_id===Te.id))||[],Ae=(V==null?void 0:V.filter(He=>He.resource_id===Te.id))||[],rt=(X==null?void 0:X.filter(He=>He.resource_id===Te.id))||[];L({...Te,pdfs:tt,videos:Ae,links:rt})},children:e.jsx(Dn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ce(Te),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&we.mutate(Te.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Te.id)})})]})})}),e.jsx(xs,{open:s,onOpenChange:r,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:Le,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[u?e.jsx("img",{src:u,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(th,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:ne})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:o.title,onChange:Te=>l({...o,title:Te.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Fm,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:o.category_id,onValueChange:Te=>l({...o,category_id:Te}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select a category"})}),e.jsx(Ws,{children:Y==null?void 0:Y.map(Te=>e.jsx(Mt,{value:Te.id,children:Te.name},Te.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Or create new category...",value:P,onChange:Te=>O(Te.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!P.trim()||ke.isPending,onClick:()=>ke.mutate(P.trim()),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:o.description,onChange:Te=>l({...o,description:Te}),placeholder:"Brief description of this resource",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:o.publish_date,onChange:Te=>l({...o,publish_date:Te.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(qr,{checked:o.is_published,onCheckedChange:Te=>l({...o,is_published:Te})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o.is_published?"Visible to brokerage managers":"Hidden from brokerage managers"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:re,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((Te,pt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"PDF Name",value:Te.name,onChange:ye=>fe(pt,"name",ye.target.value),className:"flex-1"}),e.jsx(ze,{type:"file",accept:".pdf",onChange:ye=>{var at;const qe=(at=ye.target.files)==null?void 0:at[0];qe&&fe(pt,"file",qe)},className:"flex-1"}),Te.file_url&&!Te.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>oe(pt),children:e.jsx(Mr,{className:"h-4 w-4"})})]},pt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",v.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ge,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),v.map((Te,pt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{placeholder:"Video Title",value:Te.title,onChange:ye=>xe(pt,"title",ye.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ue(pt),children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsx(ze,{type:"file",accept:"video/*",onChange:ye=>{var at;const qe=(at=ye.target.files)==null?void 0:at[0];qe&&xe(pt,"file",qe)}}),Te.uploadProgress!==void 0&&Te.uploadProgress>0&&e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${Te.uploadProgress}%`}})}),Te.video_url&&!Te.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},pt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((Te,pt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(ze,{placeholder:"Link Title",value:Te.title,onChange:ye=>Me(pt,"title",ye.target.value),className:"flex-1"}),e.jsx(ze,{placeholder:"Canva Share Link",value:Te.canva_share_link,onChange:ye=>Me(pt,"canva_share_link",ye.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$e(pt),children:e.jsx(Mr,{className:"h-4 w-4"})})]},pt))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:pe.isPending||k,children:pe.isPending||k?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(xs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:M==null?void 0:M.title})}),M&&e.jsxs("div",{className:"space-y-4",children:[M.preview_image_url&&e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-48 object-cover rounded-lg"}),M.description&&e.jsx("p",{className:"text-muted-foreground",children:M.description}),M.pdfs&&M.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),"PDF Documents (",M.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.pdfs.map(Te=>e.jsx("a",{href:Te.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Te.name},Te.id))})]}),M.videos&&M.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",M.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:M.videos.map(Te=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:Te.title})},Te.id))})]}),M.links&&M.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Bo,{className:"h-4 w-4"}),"Canva Links (",M.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:M.links.map(Te=>e.jsx("a",{href:Te.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Te.title},Te.id))})]})]})]})})]})})}const zat=[{value:"events",label:"After Events Section"},{value:"academy",label:"After Academy Section"},{value:"toolbox",label:"After Toolbox Section"},{value:"templates",label:"After Templates Section"},{value:"apps",label:"After Apps Section"}];function l1s(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,v]=N.useState(!1),[_,w]=N.useState(""),[j,k]=N.useState(""),[S,M]=N.useState(""),[L,P]=N.useState(""),[O,$]=N.useState("Learn More"),[U,B]=N.useState("top"),[V,X]=N.useState(""),[Y,ee]=N.useState(!0),[Q,ce]=N.useState(""),[ne,re]=N.useState("");N.useEffect(()=>{oe()},[]);const oe=async()=>{try{const{data:ke,error:pe}=await H.from("dashboard_banners").select("*").order("placement").order("sort_order");if(pe)throw pe;s(ke||[])}catch(ke){me.error("Failed to load banners: "+ke.message)}finally{n(!1)}},fe=()=>{w(""),k(""),M(""),P(""),$("Learn More"),B("top"),X(""),ee(!0),ce(""),re(""),u(null)},ge=ke=>{u(ke),w(ke.title),k(ke.description||""),M(ke.image_url),P(ke.link_url||""),$(ke.link_text||"Learn More"),B(ke.placement),X(ke.section_after||""),ee(ke.is_active),ce(ke.start_date?ms(new Date(ke.start_date),"yyyy-MM-dd'T'HH:mm"):""),re(ke.end_date?ms(new Date(ke.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ue=async ke=>{var we;const pe=(we=ke.target.files)==null?void 0:we[0];if(pe){f(!0);try{const Le=pe.name.split(".").pop(),Qe=`${Date.now()}.${Le}`,{error:Te}=await H.storage.from("banner-images").upload(Qe,pe);if(Te)throw Te;const{data:{publicUrl:pt}}=H.storage.from("banner-images").getPublicUrl(Qe);M(pt),me.success("Image uploaded successfully")}catch(Le){me.error("Failed to upload image: "+Le.message)}finally{f(!1)}}},xe=async()=>{if(!_.trim()||!S){me.error("Please fill in required fields (title and image)");return}v(!0);try{const ke={title:_.trim(),description:j.trim()||null,image_url:S,link_url:L.trim()||null,link_text:O.trim()||"Learn More",placement:U,section_after:U==="between"?V:null,is_active:Y,start_date:Q?new Date(Q).toISOString():null,end_date:ne?new Date(ne).toISOString():null};if(c){const{error:pe}=await H.from("dashboard_banners").update(ke).eq("id",c.id);if(pe)throw pe;me.success("Banner updated successfully")}else{const pe=t.filter(Le=>Le.placement===U).length,{error:we}=await H.from("dashboard_banners").insert({...ke,sort_order:pe});if(we)throw we;me.success("Banner created successfully")}o(!1),fe(),oe()}catch(ke){me.error("Failed to save banner: "+ke.message)}finally{v(!1)}},_e=async()=>{if(c)try{const{error:ke}=await H.from("dashboard_banners").delete().eq("id",c.id);if(ke)throw ke;me.success("Banner deleted successfully"),i(!1),u(null),oe()}catch(ke){me.error("Failed to delete banner: "+ke.message)}},$e=async ke=>{try{const{error:pe}=await H.from("dashboard_banners").update({is_active:!ke.is_active}).eq("id",ke.id);if(pe)throw pe;me.success(ke.is_active?"Banner deactivated":"Banner activated"),oe()}catch(pe){me.error("Failed to update banner: "+pe.message)}},Me=t.filter(ke=>ke.placement==="top"),Ie=t.filter(ke=>ke.placement==="between");return r?e.jsx(Ts,{title:"Dashboard Management",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):e.jsxs(Ts,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(gr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(xs,{open:a&&U==="top",onOpenChange:ke=>{ke||fe(),o(ke),ke&&B("top")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{fe(),B("top")},children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Wr,{children:"Configure the banner's content and display settings"})]}),e.jsx(QFe,{title:_,setTitle:w,description:j,setDescription:k,imageUrl:S,linkUrl:L,setLinkUrl:P,linkText:O,setLinkText:$,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:X,isActive:Y,setIsActive:ee,startDate:Q,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:ue,uploading:p,showPlacementOptions:!1}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),fe()},children:"Cancel"}),e.jsx(K,{onClick:xe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Me.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Me.map(ke=>e.jsx(XFe,{banner:ke,onEdit:()=>ge(ke),onDelete:()=>{u(ke),i(!0)},onToggleActive:()=>$e(ke)},ke.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(gr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(xs,{open:a&&U==="between",onOpenChange:ke=>{ke||fe(),o(ke),ke&&B("between")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{fe(),B("between")},children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Wr,{children:"Configure where this banner appears between sections"})]}),e.jsx(QFe,{title:_,setTitle:w,description:j,setDescription:k,imageUrl:S,linkUrl:L,setLinkUrl:P,linkText:O,setLinkText:$,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:X,isActive:Y,setIsActive:ee,startDate:Q,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:ue,uploading:p,showPlacementOptions:!0}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),fe()},children:"Cancel"}),e.jsx(K,{onClick:xe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Ie.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Ie.map(ke=>e.jsx(XFe,{banner:ke,onEdit:()=>ge(ke),onDelete:()=>{u(ke),i(!0)},onToggleActive:()=>$e(ke),showSection:!0},ke.id))})})]})]}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Delete Banner"}),e.jsxs(Wr,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:_e,children:"Delete"})]})]})})]})}function QFe({title:t,setTitle:s,description:r,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:c,placement:u,setPlacement:p,sectionAfter:f,setSectionAfter:g,isActive:v,setIsActive:_,startDate:w,setStartDate:j,endDate:k,setEndDate:S,handleImageUpload:M,uploading:L,showPlacementOptions:P}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",placeholder:"Banner headline...",value:t,onChange:O=>s(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",placeholder:"Optional banner description...",value:r,onChange:O=>n(O.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:M,disabled:L,className:"flex-1"}),L&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(ze,{id:"linkUrl",placeholder:"https://...",value:o,onChange:O=>l(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"linkText",children:"Button Text"}),e.jsx(ze,{id:"linkText",placeholder:"Learn More",value:i,onChange:O=>c(O.target.value)})]})]}),P&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Placement"}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select section placement..."})}),e.jsx(Ws,{children:zat.map(O=>e.jsx(Mt,{value:O.value,children:O.label},O.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(ze,{id:"startDate",type:"datetime-local",value:w,onChange:O=>j(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(ze,{id:"endDate",type:"datetime-local",value:k,onChange:O=>S(O.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"isActive",checked:v,onCheckedChange:_}),e.jsx(be,{htmlFor:"isActive",children:"Active"})]})})]})}function XFe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var c;const o=(c=zat.find(u=>u.value===t.section_after))==null?void 0:c.label,[l,i]=N.useState(null);return N.useEffect(()=>{(async()=>{const{count:p}=await H.from("content_engagement_logs").select("*",{count:"exact",head:!0}).eq("resource_id",t.id).eq("action_type","click_link");i(p??0)})()},[t.id]),e.jsxs("div",{className:"flex items-center gap-4 p-3 border rounded-lg bg-card hover:bg-accent/50 transition-colors",children:[e.jsx(Mu,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),e.jsx("img",{src:t.image_url,alt:t.title,className:"w-24 h-14 object-cover rounded"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:t.title}),!t.is_active&&e.jsx(st,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(st,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),l!==null&&e.jsxs("div",{className:"flex items-center gap-1 text-destructive",title:"Button clicks",children:[e.jsx(Tx,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-semibold",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(en,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(Dn,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]})}const r9={open:{label:"Open",icon:un,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:qc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:gi,color:"bg-green-500"},closed:{label:"Closed",icon:jc,color:"bg-muted-foreground"}},JFe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function c1s(){var O,$;const{user:t}=Os(),s=Xt(),[r,n]=N.useState(null),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState("all"),[p,f]=N.useState(!1),{data:g=[],isLoading:v}=mt({queryKey:["admin-support-tickets",l,c],queryFn:async()=>{let U=H.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(U=U.eq("status",l)),c!=="all"&&(U=U.eq("category",c));const{data:B,error:V}=await U;if(V)throw V;return B}}),{data:_=[]}=mt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:U,error:B}=await H.from("user_roles").select("user_id").eq("role","admin");if(B)throw B;const V=U.map(ne=>ne.user_id),{data:X,error:Y}=await H.from("profiles").select("id, name, email").in("id",V);if(Y)throw Y;const{data:ee,error:Q}=await H.from("support_notification_settings").select("user_id, receive_notifications");if(Q)throw Q;const ce=new Map((ee==null?void 0:ee.map(ne=>[ne.user_id,ne.receive_notifications]))||[]);return X.map(ne=>({...ne,receives_notifications:ce.get(ne.id)||!1}))}}),{data:w=[]}=mt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:U,error:B}=await H.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(B)throw B;return U},enabled:!!r}),j=Lt({mutationFn:async({userId:U,enabled:B})=>{const{data:V}=await H.from("support_notification_settings").select("id").eq("user_id",U).maybeSingle();if(V){const{error:X}=await H.from("support_notification_settings").update({receive_notifications:B}).eq("user_id",U);if(X)throw X}else{const{error:X}=await H.from("support_notification_settings").insert({user_id:U,receive_notifications:B});if(X)throw X}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),k=Lt({mutationFn:async({ticketId:U,status:B})=>{const{error:V}=await H.from("support_tickets").update({status:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),me.success("Status updated")},onError:()=>{me.error("Failed to update status")}}),S=Lt({mutationFn:async({ticketId:U,assignedTo:B})=>{const{error:V}=await H.from("support_tickets").update({assigned_to:B}).eq("id",U);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),M=Lt({mutationFn:async U=>{var V,X;if(!r||!t)throw new Error("Missing data");const{error:B}=await H.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:U,is_admin_reply:!0});if(B)throw B;try{await H.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:U,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(X=r.profiles)==null?void 0:X.name}})}catch(Y){console.error("Failed to send reply notification:",Y)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),L=()=>{a.trim()&&M.mutate(a)};N.useEffect(()=>{const U=H.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{H.removeChannel(U)}},[s]);const P=g.filter(U=>U.status==="open").length;return r?(r9[r.status].icon,e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>n(null),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",children:JFe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((O=r.profiles)==null?void 0:O.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(Ks,{value:r.status,onValueChange:U=>{k.mutate({ticketId:r.id,status:U}),n({...r,status:U})},children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"open",children:"Open"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"resolved",children:"Resolved"}),e.jsx(Mt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(Ks,{value:r.assigned_to||"unassigned",onValueChange:U=>{const B=U==="unassigned"?null:U;S.mutate({ticketId:r.id,assignedTo:B}),n({...r,assigned_to:B})},children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Unassigned"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"unassigned",children:"Unassigned"}),_.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(gr,{children:["Created on ",ms(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Ki,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map(U=>{var B,V;return e.jsxs("div",{className:`p-4 rounded-lg ${U.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:U.is_admin_reply?`${((B=U.profiles)==null?void 0:B.name)||"Admin"} (Support)`:((V=U.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(U.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:U.content})]},U.id)})})}),e.jsx(al,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pr,{placeholder:"Type your reply...",value:a,onChange:U=>o(U.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:L,disabled:!a.trim()||M.isPending,className:"self-end",children:e.jsx($n,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",P>0&&e.jsxs(st,{variant:"destructive",className:"ml-2",children:[P," open"]})]})]}),e.jsxs(xs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Qo,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Email Notification Settings"}),e.jsx(Wr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:_.map(U=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:U.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:U.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[U.receives_notifications?e.jsx(Lm,{className:"h-4 w-4 text-primary"}):e.jsx(i1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(qr,{checked:U.receives_notifications,onCheckedChange:B=>j.mutate({userId:U.id,enabled:B})})]})]},U.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(_a,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(fa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"open",children:"Open"}),e.jsx(ns,{value:"in_progress",children:"In Progress"}),e.jsx(ns,{value:"resolved",children:"Resolved"}),e.jsx(ns,{value:"closed",children:"Closed"})]})}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"All Categories"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),e.jsx(Mt,{value:"general",children:"General Support"}),e.jsx(Mt,{value:"technology",children:"Technology Support"}),e.jsx(Mt,{value:"crm",children:"CRM Support"}),e.jsx(Mt,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:v?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):g.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(qc,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets found"}),e.jsx("p",{className:"text-muted-foreground",children:"No support tickets match the current filters."})]})}):e.jsx("div",{className:"space-y-3",children:g.map(U=>{var V,X;const B=r9[U.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(U),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:U.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(st,{variant:"outline",className:"text-xs",children:JFe[U.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=U.profiles)==null?void 0:V.name," • ",ms(new Date(U.created_at),"MMM d, yyyy")]}),U.assigned_to&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Wi,{className:"h-3 w-3"}),((X=_.find(Y=>Y.id===U.assigned_to))==null?void 0:X.name)||"Assigned"]})]})]}),e.jsxs(st,{className:r9[U.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),r9[U.status].label]})]})})},U.id)})})})]})]})})}const Bat=Dh.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var s;return(s=t.style.color)===null||s===void 0?void 0:s.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:s})=>s().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});function d1s({content:t,onChange:s,variables:r}){const n=gke({extensions:[vke,Tke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),Ake.configure({types:["heading","paragraph"]}),Eke,Bat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});N.useEffect(()=>{n&&t!==n.getHTML()&&n.commands.setContent(t)},[t,n]);const a=l=>{n&&n.chain().focus().insertContent(`{{${l.key}}}`).run()},o=()=>{if(!n)return;const l=n.getAttributes("link").href,i=window.prompt("URL",l);if(i!==null){if(i===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}n.chain().focus().extendMarkRange("link").setLink({href:i}).run()}};return n?e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:e.jsx(tS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:e.jsx(oS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:e.jsx(rh,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:e.jsx(x0,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:e.jsx(X4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:e.jsx(Q4,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:e.jsx(J4,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:e.jsx(Bo,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:e.jsx(rS,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:e.jsx(wS,{className:"h-4 w-4"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:e.jsx(vS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(XM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Bd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Aa,{onClick:()=>a(l),className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-medium",children:l.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${l.key}}}`}),l.description&&e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:l.description})]},l.key))})]})]}),e.jsx(fke,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),r.length>0&&e.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(l=>e.jsx(st,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-xs",onClick:()=>{navigator.clipboard.writeText(`{{${l.key}}}`)},children:`{{${l.key}}}`},l.key))})]})]}):null}function u1s(){const t=Xt(),[s,r]=N.useState(null),[n,a]=N.useState(null),[o,l]=N.useState(""),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(!0),[v,_]=N.useState("visual"),{data:w,isLoading:j}=mt({queryKey:["email-templates"],queryFn:async()=>{const{data:P,error:O}=await H.from("email_templates").select("*").order("name");if(O)throw O;return P.map($=>({...$,available_variables:$.available_variables||[]}))}}),k=Lt({mutationFn:async P=>{const{error:O}=await H.from("email_templates").update({subject:P.subject,body_html:P.body_html,description:P.description,is_active:P.is_active}).eq("id",P.id);if(O)throw O},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:P=>{me.error("Failed to update template: "+P.message)}}),S=P=>{r(P),l(P.subject),c(P.body_html),p(P.description||""),g(P.is_active),_("visual")},M=()=>{s&&k.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},L=(P,O)=>{let $=P;return O.forEach(U=>{const B=`{{${U.key}}}`,V=`[${U.label}]`;$=$.replace(new RegExp(B.replace(/[{}]/g,"\\$&"),"g"),V)}),$};return s?e.jsxs(Ts,{title:"Edit Email Template",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",onClick:()=>r(null),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{variant:"outline",onClick:()=>a(s),children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:M,disabled:k.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-2"}),k.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),s.name]}),e.jsxs(gr,{className:"mt-1",children:["Template slug: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:s.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"active-toggle",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:f,onCheckedChange:g})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",value:u,onChange:P=>p(P.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"subject",children:"Email Subject"}),e.jsx(ze,{id:"subject",value:o,onChange:P=>l(P.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Email Body"}),e.jsx(_a,{value:v,onValueChange:P=>_(P),children:e.jsxs(fa,{className:"h-8",children:[e.jsxs(ns,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(xS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(ns,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(rS,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),v==="visual"?e.jsx(d1s,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Pr,{value:i,onChange:P=>c(P.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(xs,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Email Preview"}),e.jsxs(Wr,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(i,s.available_variables)}})})]})})]}):e.jsx(Ts,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),j?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((P,O)=>e.jsx(Ee,{children:e.jsxs(Pt,{children:[e.jsx(vs,{className:"h-5 w-48"}),e.jsx(vs,{className:"h-4 w-96"})]})},O))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(P=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(lr,{className:"h-5 w-5 text-muted-foreground"}),P.name,!P.is_active&&e.jsx(st,{variant:"secondary",children:"Inactive"})]}),e.jsx(gr,{children:P.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(P),children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>S(P),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:P.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:P.available_variables.map(O=>e.jsx(st,{variant:"outline",className:"font-mono text-xs",children:`{{${O.key}}}`},O.key))})]})]})})]},P.id))}),e.jsx(xs,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Wr,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:L(n.body_html,n.available_variables)}})})]})})]})})}function h1s(){const t=Xt(),[s,r]=N.useState("templates"),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[v,_]=N.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:X}=await H.from("email_template_categories").select("*").order("sort_order");if(X)throw X;return V}}),{data:j=[],isLoading:k}=mt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:X}=await H.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(X)throw X;return V}}),S=Lt({mutationFn:async V=>{const X={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:Y}=await H.from("agent_email_templates").update(X).eq("id",V.id);if(Y)throw Y}else{const{error:Y}=await H.from("agent_email_templates").insert(X);if(Y)throw Y}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),c(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),M=Lt({mutationFn:async V=>{const{error:X}=await H.from("agent_email_templates").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),L=Lt({mutationFn:async V=>{const X={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:Y}=await H.from("email_template_categories").update(X).eq("id",V.id);if(Y)throw Y}else{const Y=w.length>0?Math.max(...w.map(Q=>Q.sort_order))+1:0,{error:ee}=await H.from("email_template_categories").insert({...X,sort_order:Y});if(ee)throw ee}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),me.success(o?"Category updated":"Category created")},onError:()=>me.error("Failed to save category")}),P=Lt({mutationFn:async V=>{const{error:X}=await H.from("email_template_categories").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),me.success("Category deleted")}}),O=()=>{a(null),g({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),c(!0)},$=V=>{a(V),g({title:V.title,subject:V.subject,body:V.body,description:V.description||"",tone:V.tone||"",category_id:V.category_id||"",is_active:V.is_active}),c(!0)},U=()=>{l(null),_({name:"",description:"",icon:"📧"}),p(!0)},B=V=>{l(V),_({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(ch,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(_a,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"templates",className:"gap-2",children:[e.jsx(lr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(ns,{value:"categories",className:"gap-2",children:[e.jsx(Om,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(ws,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Template"}),e.jsx(St,{className:"hidden md:table-cell",children:"Category"}),e.jsx(St,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:k?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin mx-auto"})})}):j.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):j.map(V=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:V.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:V.subject})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.category?e.jsxs(st,{variant:"outline",className:"gap-1",children:[V.category.icon," ",V.category.name]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:V.tone?e.jsx(st,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(st,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(V),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&M.mutate(V.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs(ws,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:U,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(V=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>B(V),children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&P.mutate(V.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[j.filter(X=>X.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:n?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:V=>g(X=>({...X,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:f.category_id,onValueChange:V=>g(X=>({...X,category_id:V})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:w.map(V=>e.jsxs(Mt,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Subject Line"}),e.jsx(ze,{value:f.subject,onChange:V=>g(X=>({...X,subject:V.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Email Body"}),e.jsx(Pr,{value:f.body,onChange:V=>g(X=>({...X,body:V.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description (internal)"}),e.jsx(ze,{value:f.description,onChange:V=>g(X=>({...X,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Tone"}),e.jsx(ze,{value:f.tone,onChange:V=>g(X=>({...X,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:f.is_active,onCheckedChange:V=>g(X=>({...X,is_active:V}))}),e.jsx(be,{children:"Active"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>S.mutate({...f,id:n==null?void 0:n.id}),disabled:S.isPending||!f.title||!f.subject||!f.body,children:[S.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(xs,{open:u,onOpenChange:p,children:e.jsxs(fs,{className:"sm:max-w-[450px]",children:[e.jsx(js,{children:e.jsx(_s,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Icon"}),e.jsx(ze,{value:v.icon,onChange:V=>_(X=>({...X,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:v.name,onChange:V=>_(X=>({...X,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description"}),e.jsx(ze,{value:v.description,onChange:V=>_(X=>({...X,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate({...v,id:o==null?void 0:o.id}),disabled:L.isPending||!v.name,children:[L.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const m1s=({brokerageId:t})=>{var Fo,$t;const{toast:s}=Ha(),r=nr(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(""),[u,p]=N.useState("all"),[f,g]=N.useState(new Set),[v,_]=N.useState(!1),[w,j]=N.useState({}),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[P,O]=N.useState({email:"",name:"",password:"",phone:""}),[$,U]=N.useState(!1),[B,V]=N.useState(null),[X,Y]=N.useState(!1),[ee,Q]=N.useState(!1),[ce,ne]=N.useState(!1),[re,oe]=N.useState(""),[fe,ge]=N.useState(!1),[ue,xe]=N.useState([]),[_e,$e]=N.useState(!1),[Me,Ie]=N.useState(!1),[ke,pe]=N.useState(null),[we,Le]=N.useState({name:"",phone:"",email:""}),[Qe,Te]=N.useState(!1),[pt,ye]=N.useState(!1),[qe,at]=N.useState(null),[tt,Ae]=N.useState("asc"),[rt,He]=N.useState(!1),[ct,Ue]=N.useState(null),[Ze,Je]=N.useState(!1),[Ge,et]=N.useState(null),[it,Dt]=N.useState(""),[Vt,hs]=N.useState(!1),[As,Ms]=N.useState(null);N.useEffect(()=>{er(),cs()},[t]);const cs=async()=>{try{const{data:Se,error:Be}=await H.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Be)throw Be;xe((Se==null?void 0:Se.map(Ye=>Ye.user_id))||[])}catch(Se){console.error("Error loading brokerage managers:",Se)}},er=async()=>{try{l(!0);const{data:Se,error:Be}=await H.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Be)throw Be;const Ye=Se.agents||[];if(a(Ye),Ye.length>0){const bt=Ye.map(Ft=>Ft.id),{data:gt}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",bt);if(gt&>.length>0){const Ft=gt.map(Qt=>Qt.assistant_id),{data:Zt}=await H.from("profiles").select("id, name, email").in("id",Ft),Ut={};for(const Qt of gt){const Is=Zt==null?void 0:Zt.find(ys=>ys.id===Qt.assistant_id);Is&&(Ut[Qt.agent_id]={name:Is.name||"",email:Is.email||""})}j(Ut)}else j({})}}catch(Se){console.error("Error loading agents:",Se),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},xt=async()=>{if(!P.email||!P.name||!P.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}L(!0);try{const{data:{session:Se}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({...P,brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to create agent");s({title:"Success",description:`Agent ${P.email} created successfully`}),O({email:"",name:"",password:"",phone:""}),S(!1),er()}catch(Se){console.error("Error creating agent:",Se),s({title:"Error",description:Se.message||"Failed to create agent",variant:"destructive"})}finally{L(!1)}},Ps=async Se=>{try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({userId:Se})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(Be){console.error("Error resending welcome email:",Be),s({title:"Error",description:Be.message||"Failed to resend welcome email",variant:"destructive"})}},mr=async(Se,Be)=>{try{const{error:Ye}=await H.functions.invoke("send-password-reset",{body:{email:Se,redirectTo:window.location.origin}});if(Ye)throw Ye;s({title:"Password Reset Sent",description:`Password reset email sent to ${Be}`})}catch(Ye){console.error("Error sending password reset:",Ye),s({title:"Error",description:Ye.message||"Failed to send password reset email",variant:"destructive"})}},Tr=Se=>{V(Se),U(!0)},Dr=Se=>{pe(Se),Le({name:Se.name,phone:Se.phone||"",email:Se.email}),Ie(!0)},xn=async()=>{if(!ke)return;if(!we.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const Se=we.email.trim().toLowerCase()!==ke.email.toLowerCase();Te(!0);try{if(Se){if(!we.email.trim())throw new Error("Email is required");ye(!0);const{data:{session:Ye}}=await H.auth.getSession(),bt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ye==null?void 0:Ye.access_token}`},body:JSON.stringify({agentId:ke.id,newEmail:we.email.trim(),brokerageId:t})}),gt=await bt.json();if(ye(!1),!bt.ok)throw new Error(gt.error||"Failed to update email")}const{error:Be}=await H.from("profiles").update({name:we.name.trim(),phone:we.phone.trim()||null}).eq("id",ke.id);if(Be)throw Be;s({title:"Success",description:"Agent profile updated successfully"}),Ie(!1),pe(null),er()}catch(Be){console.error("Error updating agent:",Be),s({title:"Error",description:Be.message||"Failed to update agent",variant:"destructive"})}finally{Te(!1),ye(!1)}},Si=async()=>{if(!re){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ge(!0);try{const{data:{session:Se}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:re,role:"brokerage_manager",action:"add",brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),ne(!1),oe(""),cs()}catch(Se){console.error("Error adding brokerage manager:",Se),s({title:"Error",description:Se.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ge(!1)}},Ia=async Se=>{try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({userId:Se,role:"brokerage_manager",action:"remove",brokerageId:t})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),cs()}catch(Be){console.error("Error removing brokerage manager:",Be),s({title:"Error",description:Be.message||"Failed to remove brokerage manager",variant:"destructive"})}},ur=Se=>ue.includes(Se),Jr=Se=>{et(Se),Dt(""),Je(!0)},Gr=async()=>{if(!(!Ge||!it)){if(it.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}hs(!0);try{const{data:{session:Se}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({agentId:Ge.id,brokerageId:t,action:"set_password",newPassword:it})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to set password");s({title:"Success",description:`Password set for ${Ge.name}`}),Je(!1),et(null),Dt("")}catch(Se){console.error("Error setting password:",Se),s({title:"Error",description:Se.message||"Failed to set password",variant:"destructive"})}finally{hs(!1)}}},mn=async Se=>{Ms(Se.id);try{const{data:{session:Be}}=await H.auth.getSession(),Ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Be==null?void 0:Be.access_token}`},body:JSON.stringify({agentId:Se.id,brokerageId:t,action:"claim_account"})}),bt=await Ye.json();if(!Ye.ok)throw new Error(bt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${Se.name}`}),er()}catch(Be){console.error("Error claiming account:",Be),s({title:"Error",description:Be.message||"Failed to claim account",variant:"destructive"})}finally{Ms(null)}},Yr=async()=>{if(B){Y(!0);try{const{data:{session:Se}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se==null?void 0:Se.access_token}`},body:JSON.stringify({userId:B.id,brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to remove agent");s({title:"Success",description:`${B.name} has been removed from your brokerage`}),U(!1),V(null),er()}catch(Se){console.error("Error removing agent:",Se),s({title:"Error",description:Se.message||"Failed to remove agent",variant:"destructive"})}finally{Y(!1)}}},bi=Se=>{const Be=Se.trim().split(" ");return Be.length>1?Be[Be.length-1].toLowerCase():Se.toLowerCase()},ft=Se=>{qe===Se?Ae(tt==="asc"?"desc":"asc"):(at(Se),Ae("asc"))},or=Se=>qe!==Se?e.jsx(_d,{className:"ml-1 h-4 w-4"}):tt==="asc"?e.jsx(Su,{className:"ml-1 h-4 w-4"}):e.jsx(Kh,{className:"ml-1 h-4 w-4"}),Vn=n.filter(Se=>{if(u==="active"&&!Se.claimed||u==="pending"&&Se.claimed)return!1;if(!i)return!0;const Be=i.toLowerCase();return Se.name.toLowerCase().includes(Be)||Se.email.toLowerCase().includes(Be)}),Sr=[...Vn].sort((Se,Be)=>{if(!qe)return 0;let Ye=0;return qe==="name"?Ye=bi(Se.name).localeCompare(bi(Be.name)):qe==="status"&&(Ye=Se.claimed===Be.claimed?0:Se.claimed?-1:1),tt==="asc"?Ye:-Ye});Vn.filter(Se=>Se.claimed&&!ur(Se.id));const jr=Se=>{g(Be=>{const Ye=new Set(Be);return Ye.has(Se)?Ye.delete(Se):Ye.add(Se),Ye})},ea=()=>{f.size===Sr.length?g(new Set):g(new Set(Sr.map(Se=>Se.id)))},La=()=>{g(new Set)},Ii=async()=>{const Se=Array.from(f);if(Se.length===0)return;_(!0);let Be=0,Ye=0;try{const{data:{session:bt}}=await H.auth.getSession();for(const gt of Se)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${bt==null?void 0:bt.access_token}`},body:JSON.stringify({userId:gt})})).ok?Be++:Ye++}catch{Ye++}Be>0?s({title:"Success",description:`Welcome emails sent to ${Be} agent${Be>1?"s":""}${Ye>0?` (${Ye} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),La()}catch(bt){console.error("Error bulk sending welcome emails:",bt),s({title:"Error",description:bt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return o?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Agents"}),e.jsx(gr,{children:"Manage your brokerage's agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>ne(!0),children:[e.jsx(Au,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>Q(!0),children:[e.jsx(c1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>S(!0),children:[e.jsx(El,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:i,onChange:Se=>c(Se.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:u,onValueChange:Se=>p(Se),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Agents"}),e.jsx(Mt,{value:"active",children:"Active"}),e.jsx(Mt,{value:"pending",children:"Pending"})]})]})]}),f.size>0&&e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[f.size," agent",f.size>1?"s":""," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{const Be=n.filter(Ye=>f.has(Ye.id)&&Ye.email).map(Ye=>({email:Ye.email,name:Ye.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(Be)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:Be}})},disabled:v,children:[e.jsx(Ph,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Ii,disabled:v,children:[e.jsx(lr,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:La,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Sr.length>0&&f.size===Sr.length,onCheckedChange:ea,"aria-label":"Select all"})}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ft("name"),children:["Name (Last)",or("name")]})}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>ft("status"),children:["Status",or("status")]})}),e.jsx(St,{children:"Actions"})]})}),e.jsx(Bn,{children:Sr.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Sr.map(Se=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx(Oo,{checked:f.has(Se.id),onCheckedChange:()=>jr(Se.id),"aria-label":`Select ${Se.name}`})}),e.jsx(dt,{className:"font-medium",children:Se.name}),e.jsx(dt,{children:Se.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Se.claimed?e.jsx(st,{variant:"default",children:"Active"}):e.jsx(st,{variant:"secondary",children:"Pending"}),ur(Se.id)&&e.jsxs(st,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(qL,{className:"mr-1 h-3 w-3"}),"Manager"]}),w[Se.id]&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"mr-1 h-3 w-3"}),"Asst: ",w[Se.id].name||w[Se.id].email]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{Ue(Se),He(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(nu,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Dr(Se),title:"Edit agent",children:e.jsx(za,{className:"h-4 w-4"})}),!Se.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ps(Se.id),title:"Resend welcome email",children:e.jsx(lr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>mn(Se),title:"Claim account for agent",disabled:As===Se.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(X_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Jr(Se),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Eh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>mr(Se.email,Se.name),title:"Send password reset email",children:e.jsx(lS,{className:"h-4 w-4"})}),ur(Se.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ia(Se.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Au,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Tr(Se),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Se.id))})]})})]})]}),e.jsx(xs,{open:k,onOpenChange:S,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add New Agent"}),e.jsx(Wr,{children:"Create a new agent account. They'll receive an email to set up their account."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:P.name,onChange:Se=>O({...P,name:Se.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:P.email,onChange:Se=>O({...P,email:Se.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",value:P.phone,onChange:Se=>O({...P,phone:Se.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"password",children:"Temporary Password"}),e.jsx(ze,{id:"password",type:"password",value:P.password,onChange:Se=>O({...P,password:Se.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:xt,disabled:M,children:M?"Creating...":"Create Agent"})]})]})}),e.jsx(xs,{open:$,onOpenChange:U,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Remove Agent"}),e.jsxs(Wr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:B==null?void 0:B.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Yr,disabled:X,children:X?"Removing...":"Remove Agent"})]})]})}),e.jsx(vtt,{open:ee,onOpenChange:Q,fixedBrokerageId:t,onSuccess:er}),e.jsx(xs,{open:ce,onOpenChange:ne,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add Brokerage Manager"}),e.jsx(Wr,{children:"Promote an existing active agent to brokerage manager. They will be able to manage agents and view analytics."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(be,{children:"Select Agent"}),e.jsxs($o,{open:_e,onOpenChange:$e,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":_e,className:"w-full justify-between",children:[re?((Fo=n.find(Se=>Se.id===re))==null?void 0:Fo.name)+" ("+(($t=n.find(Se=>Se.id===re))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-full p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search by name or email..."}),e.jsxs(zx,{className:"max-h-[200px]",children:[e.jsx(Bx,{children:"No eligible agents found."}),e.jsx($x,{children:n.filter(Se=>!ur(Se.id)).map(Se=>e.jsxs(bp,{value:`${Se.name} ${Se.email}`,onSelect:()=>{oe(Se.id),$e(!1)},children:[e.jsx(ba,{className:`mr-2 h-4 w-4 ${re===Se.id?"opacity-100":"opacity-0"}`}),Se.name," (",Se.email,")"]},Se.id))})]})]})})]}),n.filter(Se=>!ur(Se.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(K,{onClick:Si,disabled:fe||!re,children:fe?"Adding...":"Add as Manager"})]})]})}),e.jsx(xs,{open:Me,onOpenChange:Ie,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Agent"}),e.jsxs(Wr,{children:["Update profile information for ",ke==null?void 0:ke.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:we.name,onChange:Se=>Le({...we,name:Se.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:we.email,onChange:Se=>Le({...we,email:Se.target.value}),placeholder:"agent@example.com"}),we.email.trim().toLowerCase()!==(ke==null?void 0:ke.email.toLowerCase())&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing email will update their login credentials"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:we.phone,onChange:Se=>Le({...we,phone:Se.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ie(!1),children:"Cancel"}),e.jsx(K,{onClick:xn,disabled:Qe||pt,children:pt?"Updating email...":Qe?"Saving...":"Save Changes"})]})]})}),ct&&e.jsx(btt,{open:rt,onOpenChange:Se=>{He(Se),Se||Ue(null)},userId:ct.id,userName:ct.name}),e.jsx(xs,{open:Ze,onOpenChange:Je,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Set Password"}),e.jsxs(Wr,{children:["Set a new password for ",Ge==null?void 0:Ge.name,". They will be able to log in with this password immediately."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"new-password",children:"New Password"}),e.jsx(ze,{id:"new-password",type:"password",value:it,onChange:Se=>Dt(Se.target.value),placeholder:"Enter new password (min 6 characters)"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure to communicate this password to the agent through a secure channel."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Je(!1),children:"Cancel"}),e.jsx(K,{onClick:Gr,disabled:Vt||!it||it.length<6,children:Vt?"Setting...":"Set Password"})]})]})})]})},p1s={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},f1s={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},x1s=t=>{switch(t){case"academy_video":return e.jsx(Cn,{className:"h-4 w-4"});case"template":return e.jsx(wn,{className:"h-4 w-4"});case"toolbox":return e.jsx(wn,{className:"h-4 w-4"});case"newsletter":return e.jsx(m1,{className:"h-4 w-4"});case"social_swag":return e.jsx(fn,{className:"h-4 w-4"});case"event":return e.jsx(hn,{className:"h-4 w-4"});default:return e.jsx(en,{className:"h-4 w-4"})}},g1s=({brokerageId:t})=>{const{toast:s}=Ha(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState([]),[c,u]=N.useState(!0),[p,f]=N.useState(null);N.useEffect(()=>{g()},[t]);const g=async()=>{try{u(!0);const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("brokerage_id",t);if(j)throw j;const k=w.map(X=>X.id),S=new Map(w.map(X=>[X.id,X]));if(k.length===0){n([]),o([]),i([]);return}const{data:M,error:L}=await H.from("activity_logs").select("*").in("user_id",k).order("launched_at",{ascending:!1});if(L)throw L;const P=M.map(X=>{var Y,ee;return{id:X.id,user_id:X.user_id,app_name:X.app_name,launched_at:X.launched_at,user_name:((Y=S.get(X.user_id))==null?void 0:Y.name)||"Unknown",user_email:((ee=S.get(X.user_id))==null?void 0:ee.email)||"Unknown"}});n(P);const{data:O,error:$}=await H.from("content_engagement_logs").select("*").in("user_id",k).order("created_at",{ascending:!1});if($)throw $;const U=(O||[]).map(X=>{var Y,ee;return{id:X.id,user_id:X.user_id,resource_type:X.resource_type,resource_id:X.resource_id,resource_title:X.resource_title,action_type:X.action_type,created_at:X.created_at,user_name:((Y=S.get(X.user_id))==null?void 0:Y.name)||"Unknown",user_email:((ee=S.get(X.user_id))==null?void 0:ee.email)||"Unknown"}});o(U);const B=new Map;w.forEach(X=>{B.set(X.id,{user_id:X.id,user_name:X.name,user_email:X.email,app_launches:0,content_views:0,last_activity:""})}),P.forEach(X=>{const Y=B.get(X.user_id);Y&&(Y.app_launches++,(!Y.last_activity||new Date(X.launched_at)>new Date(Y.last_activity))&&(Y.last_activity=X.launched_at))}),U.forEach(X=>{const Y=B.get(X.user_id);Y&&(Y.content_views++,(!Y.last_activity||new Date(X.created_at)>new Date(Y.last_activity))&&(Y.last_activity=X.created_at))});const V=Array.from(B.values()).filter(X=>X.app_launches>0||X.content_views>0).sort((X,Y)=>new Date(Y.last_activity).getTime()-new Date(X.last_activity).getTime());i(V)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},v=w=>r.filter(j=>j.user_id===w),_=w=>a.filter(j=>j.user_id===w);return c?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Activity"}),e.jsx(gr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"App Launches"}),e.jsx(St,{className:"text-center",children:"Content Views"}),e.jsx(St,{children:"Last Active"})]})}),e.jsx(Bn,{children:l.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(Cs,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(il,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(wn,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:w.last_activity&&Vc(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(xs,{open:!!p,onOpenChange:w=>!w&&f(null),children:e.jsxs(fs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Wr,{children:p==null?void 0:p.email})]}),e.jsxs(_a,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"content",children:"Content Engagement"}),e.jsx(ns,{value:"apps",children:"App Launches"})]}),e.jsx(ws,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Resource"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Bn,{children:p&&_(p.id).length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&_(p.id).map(w=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(dt,{children:e.jsxs(st,{variant:"outline",className:"gap-1",children:[x1s(w.resource_type),p1s[w.resource_type]||w.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:f1s[w.action_type]||w.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Vc(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx(ws,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"App"}),e.jsx(St,{children:"Time"})]})}),e.jsx(Bn,{children:p&&v(p.id).length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&v(p.id).map(w=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:w.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Vc(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},y1s=({brokerageId:t})=>{const{toast:s}=Ha(),[r,n]=N.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=N.useState(!0);N.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:c}=await H.from("profiles").select("id").eq("brokerage_id",t);if(c)throw c;const u=i.map(P=>P.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:g}=await H.from("profiles").select("id, email").in("id",u);if(g)throw g;const{count:v}=await H.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),_=v||0,w=p-_,{count:j}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),k=new Date;k.setDate(k.getDate()-7);const{count:S}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",k.toISOString()),M=new Date;M.setMonth(M.getMonth()-1);const{count:L}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",M.toISOString());n({totalAgents:p,activeAgents:_,pendingAgents:w,totalLaunches:j||0,launchesThisWeek:S||0,launchesThisMonth:L||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(gi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(un,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(Ch,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},v1s=({brokerageId:t})=>{const[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState({description:"",maxUses:""});N.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:k,error:S}=await H.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(k||[])}catch(k){console.error("Error loading invite codes:",k),me.error("Failed to load invite links")}finally{a(!1)}},g=()=>Math.random().toString(36).substring(2,8).toUpperCase(),v=async()=>{l(!0);try{const k=g(),{error:S}=await H.from("invite_codes").insert({code:k,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;me.success("Invite link created!"),c(!1),p({description:"",maxUses:""}),f()}catch(k){console.error("Error creating invite code:",k),me.error("Failed to create invite link")}finally{l(!1)}},_=async k=>{try{const{error:S}=await H.from("invite_codes").delete().eq("id",k);if(S)throw S;me.success("Invite link deleted"),r(s.filter(M=>M.id!==k))}catch(S){console.error("Error deleting invite code:",S),me.error("Failed to delete invite link")}},w=async(k,S)=>{try{const{error:M}=await H.from("invite_codes").update({is_active:!S}).eq("id",k);if(M)throw M;r(s.map(L=>L.id===k?{...L,is_active:!S}:L)),me.success(`Invite link ${S?"deactivated":"activated"}`)}catch(M){console.error("Error toggling invite code:",M),me.error("Failed to update invite link")}},j=k=>{const S=`${window.location.origin}/join?code=${k}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(gr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(xs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create Invite Link"}),e.jsx(Wr,{children:"Create a new invite link for agents to join your brokerage"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:k=>p({...u,description:k.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:k=>p({...u,maxUses:k.target.value})})]}),e.jsx(K,{onClick:v,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Bo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(k=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:k.code}),e.jsx(st,{variant:k.is_active?"default":"secondary",children:k.is_active?"Active":"Inactive"})]}),k.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:k.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[k.uses_count," uses",k.max_uses&&` / ${k.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(k.code),title:"Copy link",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(k.id,k.is_active),title:k.is_active?"Deactivate":"Activate",children:k.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(k.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},k.id))})})]})},b1s=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=N.useState(""),[u,p]=N.useState([]),[f,g]=N.useState(""),[v,_]=N.useState(!1),w=L=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(L),j=()=>{const L=i.trim().toLowerCase();if(L&&w(L)&&!u.includes(L)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,L]),c("")}else L&&!w(L)?me.error("Please enter a valid email address"):u.includes(L)&&me.error("Email already added")},k=L=>{p(u.filter(P=>P!==L))},S=L=>{(L.key==="Enter"||L.key===",")&&(L.preventDefault(),j())},M=async()=>{if(u.length===0){me.error("Please add at least one email address");return}_(!0);try{const{data:L,error:P}=await H.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(P)throw P;L.successCount===L.totalCount?me.success(`${L.successCount} invite${L.successCount>1?"s":""} sent successfully!`):me.warning(`${L.successCount} of ${L.totalCount} invites sent. Some failed.`),p([]),g(""),s(!1),l==null||l()}catch(L){console.error("Error sending invites:",L),me.error("Failed to send invites. Please try again.")}finally{_(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[550px]",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Wr,{children:"Send a personalized email invitation to broker owners you know. They'll receive a beautiful email highlighting LevelUp's features."})]}),e.jsxs("div",{className:"bg-gradient-to-r from-primary/10 to-primary/5 border border-primary/20 rounded-lg p-4 flex items-center gap-3",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(So,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"Earn $25/month for each referral!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When they sign up and stay for 30 days, you save on your membership forever."})]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:L=>c(L.target.value),onKeyDown:S,onBlur:j}),e.jsx(K,{type:"button",variant:"secondary",onClick:j,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(L=>e.jsxs(st,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[L,e.jsx("button",{type:"button",onClick:()=>k(L),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Mr,{className:"h-3 w-3"})})]},L))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Pr,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:L=>g(L.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:M,disabled:u.length===0||v,children:v?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},_1s=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=N.useState([]),[a,o]=N.useState(!0);N.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:c,error:u}=await H.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(c||[])}catch(c){console.error("Error fetching invites:",c)}finally{o(!1)}},i=c=>{switch(c){case"signed_up":return e.jsxs(st,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(gi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(st,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(jc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Pending"]})}};return a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(lr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No invites sent yet"}),e.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),r.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.recipient_email}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",ms(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},w1s=()=>{const{brokerageId:t,user:s}=Os(),[r,n]=N.useState(null),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState([]),[p,f]=N.useState(!0),[g,v]=N.useState(!1),[_,w]=N.useState(0);N.useEffect(()=>{t&&j()},[t]);const j=async()=>{try{const[O,$]=await Promise.all([H.from("brokerages").select("name").eq("id",t).single(),s?H.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);O.data&&o(O.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:U}=await H.from("referral_codes").select("code").eq("brokerage_id",t).single();if(U)n(U.code);else{const V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await H.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}const{data:B}=await H.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(B||[])}catch(O){console.error("Error fetching referral data:",O)}finally{f(!1)}},k=()=>{const O=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(O),me.success("Referral link copied to clipboard!")},S=c.filter(O=>O.status==="qualified").length,M=c.filter(O=>O.status==="pending").length,L=S*25,P=Math.max(0,Math.ceil((299-L)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(So,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",L]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),L>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(gi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),P>0&&L<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",P," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),L>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(fn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>v(!0),className:"w-full",size:"lg",children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:k,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Referral Link"]})]}),e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your Referral Link"}),e.jsxs("code",{className:"block px-3 py-2 bg-background rounded border text-sm break-all",children:["https://dashboard.relevelup.com/?ref=",r]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-green-50 dark:bg-green-950/20 rounded-lg border border-green-200 dark:border-green-900",children:[e.jsx(hl,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",L]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(hr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(un,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:M}),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),e.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[e.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"1"}),e.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"2"}),e.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"bg-primary text-primary-foreground rounded-full w-5 h-5 flex items-center justify-center text-xs shrink-0",children:"3"}),e.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),e.jsx(_1s,{brokerageId:t,refreshTrigger:_}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),c.slice(0,5).map(O=>{var $,U;return e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"text-sm truncate",children:(($=O.referred_brokerage)==null?void 0:$.name)||((U=O.referred_user)==null?void 0:U.email)||"Pending setup"}),e.jsxs(st,{variant:O.status==="qualified"?"default":O.status==="pending"?"secondary":"destructive",className:O.status==="qualified"?"bg-green-600":"",children:[O.status==="qualified"&&e.jsx(gi,{className:"h-3 w-3 mr-1"}),O.status]})]},O.id)})]})]})]}),e.jsx(b1s,{open:g,onOpenChange:v,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(O=>O+1)})]})},j1s=({brokerageId:t})=>{const s=nr(),{teams:r,isLoading:n}=M3(t),{data:a,isLoading:o}=mt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(O=>O.id),{data:f}=await H.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(O=>({team_id:O.id,team_name:O.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const g=f.map(O=>O.user_id),v=f.filter(O=>O.role==="team_leader").map(O=>O.user_id),{data:_}=await H.from("profiles").select("id, name, avatar_url").in("id",v),w=new Map((_||[]).map(O=>[O.id,O])),{data:j}=await H.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",g),{data:k}=await H.from("deal_pipeline").select("owner_user_id").in("owner_user_id",g),{data:S}=await H.from("agent_videos").select("owner_user_id").in("owner_user_id",g).eq("is_deleted",!1),M=new Map;(j||[]).forEach(O=>{M.set(O.owner_user_id,(M.get(O.owner_user_id)||0)+1)});const L=new Map;(k||[]).forEach(O=>{L.set(O.owner_user_id,(L.get(O.owner_user_id)||0)+1)});const P=new Map;return(S||[]).forEach(O=>{P.set(O.owner_user_id,(P.get(O.owner_user_id)||0)+1)}),r.map(O=>{const $=f.filter(Q=>Q.team_id===O.id),U=$.find(Q=>Q.role==="team_leader"),B=U?w.get(U.user_id):null,V=$.map(Q=>Q.user_id),X=V.reduce((Q,ce)=>Q+(M.get(ce)||0),0),Y=V.reduce((Q,ce)=>Q+(L.get(ce)||0),0),ee=V.reduce((Q,ce)=>Q+(P.get(ce)||0),0);return{team_id:O.id,team_name:O.name,member_count:$.length,leader_name:(B==null?void 0:B.name)||null,leader_avatar:(B==null?void 0:B.avatar_url)||null,total_contacts:X,total_deals:Y,total_videos:ee}})},enabled:r.length>0});if(n||o)return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(vs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(vs,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),c=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(aS,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(th,{className:"h-4 w-4"})," Total Deals"]}),e.jsx("p",{className:"text-2xl font-bold",children:u.toLocaleString()})]})})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:p.team_name}),e.jsxs(st,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:p.leader_avatar||""}),e.jsx(Sn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},N1s=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Os(),i=nr(),{toast:c}=Ha(),[u,p]=N.useState(""),[f,g]=N.useState(!0),v=o||(a.length>0?a[0].id:r);N.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),v?_():a.length===0&&!r&&g(!1)},[t,s,n,v,i,a,o]);const _=async()=>{if(!v){g(!1);return}try{const{data:w,error:j}=await H.from("brokerages").select("name").eq("id",v).single();if(j)throw j;p(w.name)}catch(w){console.error("Error loading brokerage info:",w),c({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{g(!1)}};return f?e.jsx(Ts,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):v?e.jsx(Ts,{title:u||"Manage Brokerages",description:"Brokerage Management Dashboard",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),e.jsxs(Ks,{value:o||"",onValueChange:l,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:a.map(w=>e.jsx(Mt,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(_a,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(ns,{value:"agents",children:"Agents"}),e.jsx(ns,{value:"teams",children:"Teams"}),e.jsx(ns,{value:"invite",children:"Invite Links"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"}),e.jsx(ns,{value:"activity",children:"Activity"}),e.jsx(ns,{value:"analytics",children:"Analytics"}),e.jsx(ns,{value:"shares",children:"Shares"})]}),e.jsx(ws,{value:"agents",className:"space-y-4",children:e.jsx(m1s,{brokerageId:v})}),e.jsx(ws,{value:"teams",className:"space-y-4",children:e.jsx(j1s,{brokerageId:v})}),e.jsx(ws,{value:"invite",className:"space-y-4",children:e.jsx(v1s,{brokerageId:v})}),e.jsx(ws,{value:"referrals",className:"space-y-4",children:e.jsx(w1s,{})}),e.jsx(ws,{value:"leaderboard",className:"space-y-4",children:e.jsx(Fet,{brokerageId:v,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(ws,{value:"activity",className:"space-y-4",children:e.jsx(g1s,{brokerageId:v})}),e.jsx(ws,{value:"analytics",className:"space-y-4",children:e.jsx(y1s,{brokerageId:v})}),e.jsx(ws,{value:"shares",className:"space-y-4",children:e.jsx(Ztt,{brokerageOnly:!0,brokerageId:v})})]})]})}):e.jsx(Ts,{title:"Manage Brokerages",description:"Brokerage Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ca,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You don't have any brokerages to manage."})]})})};function k1s({brokerageId:t,canManage:s}){const{user:r}=Os(),[n,a]=N.useState([]),[o,l]=N.useState(!0),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(null),[v,_]=N.useState(!1),[w,j]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(!1),P=async()=>{try{const{data:V,error:X}=await H.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(X)throw X;const Y=V;if(Y&&Y.length>0){const ee=[...new Set(Y.map(re=>re.created_by))],{data:Q}=await H.from("profiles").select("id, name, avatar_url").in("id",ee),ce=new Map((Q==null?void 0:Q.map(re=>[re.id,re]))||[]),ne=Y.map(re=>({...re,author:ce.get(re.created_by)||{name:"Unknown",avatar_url:null}}));a(ne)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};N.useEffect(()=>{P()},[t]);const O=()=>{j(""),S(""),L(!1),p(null)},$=V=>{V?(p(V),j(V.title),S(V.content),L(V.is_pinned)):O(),c(!0)},U=async()=>{if(!w.trim()||!k.trim()){me.error("Please fill in all fields");return}_(!0);try{if(u){const{error:V}=await H.from("brokerage_announcements").update({title:w.trim(),content:k.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;me.success("Announcement updated")}else{const{error:V}=await H.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:w.trim(),content:k.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null});if(V)throw V;me.success("Announcement created")}c(!1),O(),P()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{_(!1)}},B=async()=>{if(f)try{const{error:V}=await H.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;me.success("Announcement deleted"),P()}catch(V){console.error("Error deleting announcement:",V),me.error("Failed to delete announcement")}finally{g(null)}};return o?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ph,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Ph,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(V=>{var X,Y,ee,Q;return e.jsx("div",{className:`p-4 rounded-lg border ${V.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[V.is_pinned&&e.jsx(Q_,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("h4",{className:"font-semibold truncate",children:V.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:V.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs(kn,{className:"h-5 w-5",children:[e.jsx(Ua,{src:((X=V.author)==null?void 0:X.avatar_url)||void 0}),e.jsx(Sn,{className:"text-[10px]",children:((ee=(Y=V.author)==null?void 0:Y.name)==null?void 0:ee.charAt(0))||"?"})]}),e.jsx("span",{children:(Q=V.author)==null?void 0:Q.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ms(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(V),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>g(V.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:w,onChange:V=>j(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"content",children:"Content"}),e.jsx(Pr,{id:"content",value:k,onChange:V=>S(V.target.value),placeholder:"Write your announcement...",rows:4})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"pinned",checked:M,onCheckedChange:L}),e.jsxs(be,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Q_,{className:"h-4 w-4"}),"Pin to top"]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:U,disabled:v,children:v?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(Mc,{open:!!f,onOpenChange:()=>g(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Announcement"}),e.jsx(ic,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function S1s({brokerageId:t,canManage:s=!1}){const{startImpersonation:r,isLoading:n}=Vde(),{user:a}=Os(),[o,l]=N.useState([]),[i,c]=N.useState(!0),[u,p]=N.useState(""),[f,g]=N.useState(new Set);N.useEffect(()=>{(async()=>{try{const{data:w,error:j}=await H.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(j)throw j;if(l(w||[]),w&&w.length>0){const k=w.map(M=>M.id),{data:S}=await H.from("agent_assistant_assignments").select("agent_id").in("agent_id",k);S&&g(new Set(S.map(M=>M.agent_id)))}}catch(w){console.error("Error fetching agents:",w)}finally{c(!1)}})()},[t]);const v=o.filter(_=>{var w,j;return _.name.toLowerCase().includes(u.toLowerCase())||_.email.toLowerCase().includes(u.toLowerCase())||((w=_.title)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=_.areas_served)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))});return i?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},_))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",o.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:u,onChange:_=>p(_.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{children:v.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:u?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:v.map(_=>e.jsx(C1s,{agent:_,hasAssistant:f.has(_.id),canImpersonate:s&&_.id!==(a==null?void 0:a.id),onImpersonate:()=>r(_.id,"/my-brokerage"),impersonationLoading:n},_.id))})})]})}function C1s({agent:t,hasAssistant:s,canImpersonate:r,onImpersonate:n,impersonationLoading:a}){const o=t.name.split(" ").map(l=>l[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(kn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Ua,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(Sn,{className:"text-lg bg-primary/10 text-primary",children:o})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(st,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),t.bio&&e.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:t.bio}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[t.areas_served&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ia,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r&&e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:n,disabled:a,children:e.jsx(uS,{className:"h-4 w-4"})})}),e.jsxs(ec,{children:["Login as ",t.name]})]}),t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(Mn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`mailto:${t.email}`,title:`Email ${t.name}`,children:e.jsx(lr,{className:"h-4 w-4"})})}),t.linkedin_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:e.jsx(Mp,{className:"h-4 w-4"})})}),t.instagram_url&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:t.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:e.jsx(Tu,{className:"h-4 w-4"})})})]})]})}function M1s({brokerageId:t}){const[s,r]=N.useState([]),[n,a]=N.useState(!0);if(N.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){r([]),a(!1);return}const p=c.map(w=>w.id),{data:f,error:g}=await H.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(g)throw g;const v=new Map(c.map(w=>[w.id,w])),_=(f||[]).filter(w=>w.total_points>0).map(w=>{const j=v.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(j==null?void 0:j.name)||"Unknown",avatar_url:(j==null?void 0:j.avatar_url)||null}});r(_)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(h1,{className:It("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,c)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=c+1;return e.jsxs("div",{className:It("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[e.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:i.avatar_url||void 0}),e.jsx(Sn,{className:"text-xs",children:u})]}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:i.name}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[i.total_points.toLocaleString()," pts"]})]},i.user_id)})})})]})}function T1s({brokerageId:t}){const s=nr(),[r,n]=N.useState([]),[a,o]=N.useState(!0);N.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){n([]),o(!1);return}const p=c.map(w=>w.id),f=new Map(c.map(w=>[w.id,w])),{data:g,error:v}=await H.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(v)throw v;const _=(g||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:f.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(_)}catch(c){console.error("Error fetching listings:",c)}finally{o(!1)}})()},[t]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(dn,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Your First Listing"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:r.map(i=>e.jsxs("div",{onClick:()=>window.open(`https://listings.relevelup.com/${i.slug||i.id}`,"_blank"),className:"group cursor-pointer border rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"relative h-24 bg-muted",children:[i.photos&&i.photos.length>0?e.jsx("img",{src:i.photos[0].photo_url,alt:i.property_address||"Listing",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(dn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"text-[10px] font-medium bg-primary text-primary-foreground px-1.5 py-0.5 rounded uppercase",children:i.property_type.replace("_"," ")})})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),r.length>0&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>s("/mission-control/listings"),children:["View All Listings",e.jsx(en,{className:"h-3 w-3 ml-1"})]})]})]})}function A1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Os(),n=nr(),[a,o]=N.useState(!0),[l,i]=N.useState(null),[c,u]=N.useState(""),[p,f]=N.useState(0),[g,v]=N.useState(!1),[_,w]=N.useState(!1);return N.useEffect(()=>{(async()=>{if(t)try{const{data:k}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(k!=null&&k.brokerage_id)){o(!1);return}i(k.brokerage_id);const{data:S}=await H.from("brokerages").select("name").eq("id",k.brokerage_id).maybeSingle();S&&u(S.name);const{count:M}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",k.brokerage_id);if(f(M||0),s)v(!0),w(!0);else if(r){const{data:L}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",k.brokerage_id).maybeSingle();v(!!L),w(!!L)}}catch(k){console.error("Error fetching brokerage info:",k)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Ts,{title:"My Brokerage",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?e.jsx(Ts,{title:c||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),_&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(Th,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(dn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(k1s,{brokerageId:l,canManage:g}),e.jsx(S1s,{brokerageId:l,canManage:g}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(M1s,{brokerageId:l}),e.jsx(T1s,{brokerageId:l})]})]})}):e.jsx(Ts,{title:"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ca,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}function E1s(t){if(!t)return null;try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}function P1s(t){if(!t)return!1;try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}const e7e={video:{icon:il,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:wn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:ml,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function I1s({item:t,canManage:s}){const[r,n]=N.useState(!1),[a,o]=N.useState(null),l=qLt(),i=nr(),c=e7e[t.content_type]||e7e.link,u=c.icon,p=N.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?E1s(t.url):null,[t]);N.useEffect(()=>{p||!t.url||t.content_type!=="video"||!P1s(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(_=>_.ok?_.json():null).then(_=>{_!=null&&_.thumbnail_url&&o(_.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,g=()=>{i(`/brokerage-content/${t.id}`)},v=async()=>{try{await l.mutateAsync(t.id),me.success("Content deleted")}catch{me.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"group overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",onClick:g,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(st,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${c.color}`,children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),c.label]}),t.category&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[t.category.icon," ",t.category.name]})]}),e.jsx("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:t.description}),t.content_type==="event"&&t.event_date&&e.jsxs("p",{className:"text-xs text-primary mt-2 font-medium",children:["📅 ",ms(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ms(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,onClick:_=>_.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Aa,{onClick:_=>{_.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(Mc,{open:r,onOpenChange:n,children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Content"}),e.jsxs(ic,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:v,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function L1s(t){try{const s=new URL(t),r=s.hostname.replace("www.","");let n=null;if(r==="youtube.com"||r==="m.youtube.com"?n=s.searchParams.get("v"):r==="youtu.be"&&(n=s.pathname.slice(1)),n)return`https://img.youtube.com/vi/${n}/hqdefault.jpg`}catch{}return null}const t7e=[{value:"video",label:"🎥 Video",hint:"YouTube, Vimeo, or video URL"},{value:"pdf",label:"📄 Document / PDF",hint:"Upload a PDF or document"},{value:"link",label:"🔗 Link / Resource",hint:"External URL"},{value:"event",label:"📅 Event",hint:"Brokerage event with date"},{value:"graphic",label:"🎨 Graphic / Canva",hint:"Image, Canva share link, or social post"}];function D1s({brokerageId:t,categories:s}){var xe;const{user:r}=Os(),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(""),[u,p]=N.useState("📁"),[f,g]=N.useState(!1);N.useRef(null);const[v,_]=N.useState("video"),[w,j]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(""),[P,O]=N.useState(""),[$,U]=N.useState(""),[B,V]=N.useState(""),[X,Y]=N.useState(""),ee=$Lt(),Q=ULt(t),ce=VLt(),ne=HLt(t),re=()=>{_("video"),j(""),S(""),L(""),O(""),U(""),V(""),Y("")},oe=async(_e,$e)=>{var Ie;const Me=(Ie=_e.target.files)==null?void 0:Ie[0];if(Me){g(!0);try{const ke=Me.name.split(".").pop(),pe=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${ke}`,{error:we}=await H.storage.from("brokerage-content").upload(pe,Me);if(we)throw we;const{data:{publicUrl:Le}}=H.storage.from("brokerage-content").getPublicUrl(pe);$e==="file"?(O(Le),v==="graphic"&&!$&&U(Le)):U(Le),me.success("File uploaded")}catch(ke){me.error(ke.message||"Upload failed")}finally{g(!1)}}},fe=async()=>{if(!w.trim()){me.error("Title is required");return}if(r)try{await ee.mutateAsync({brokerage_id:t,category_id:X||null,content_type:v,title:w.trim(),description:k.trim()||null,url:M.trim()||null,file_url:P.trim()||null,thumbnail_url:$.trim()||null,event_date:B?new Date(B).toISOString():null,created_by:r.id}),me.success("Content added!"),re(),a(!1)}catch(_e){me.error(_e.message||"Failed to add content")}},ge=async()=>{if(i.trim())try{await Q.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),p("📁"),me.success("Category created")}catch(_e){me.error(_e.message||"Failed to create category")}},ue=async()=>{try{await ne.mutateAsync(),me.success("Default categories created")}catch{me.error("Failed to create defaults")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(xs,{open:n,onOpenChange:a,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Brokerage Content"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Content Type"}),e.jsxs(Ks,{value:v,onValueChange:_,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:t7e.map(_e=>e.jsx(Mt,{value:_e.value,children:_e.label},_e.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(xe=t7e.find(_e=>_e.value===v))==null?void 0:xe.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:X,onValueChange:Y,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select category (optional)"})}),e.jsx(Ws,{children:s.map(_e=>e.jsxs(Mt,{value:_e.id,children:[_e.icon," ",_e.name]},_e.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:w,onChange:_e=>j(_e.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:k,onChange:_e=>S(_e.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(v)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:v==="video"?"Video URL":v==="graphic"?"Canva / Image URL":v==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(ze,{value:M,onChange:_e=>{const $e=_e.target.value;if(L($e),v==="video"&&!$){const Me=L1s($e);Me&&U(Me)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(v)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:v==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",accept:v==="pdf"?".pdf,.doc,.docx":"image/*",onChange:_e=>oe(_e,"file"),disabled:f}),f&&e.jsx(bs,{className:"h-4 w-4 animate-spin"})]}),P&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Thumbnail Image (optional)"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:_e=>oe(_e,"thumbnail"),disabled:f}),$&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:$,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>U(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Mr,{className:"h-3 w-3"})})]})]}),v==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Event Date & Time"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:_e=>V(_e.target.value)})]}),e.jsxs(K,{onClick:fe,disabled:ee.isPending||!w.trim(),className:"w-full",children:[ee.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(xs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(Qo,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ue,disabled:ne.isPending,children:[ne.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(_e=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[_e.icon," ",_e.name]}),!_e.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(_e.id),me.success("Category deleted")},children:e.jsx(Mr,{className:"h-4 w-4"})})]},_e.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(ze,{value:u,onChange:_e=>p(_e.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(ze,{value:i,onChange:_e=>c(_e.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:_e=>_e.key==="Enter"&&ge()}),e.jsx(K,{size:"sm",onClick:ge,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function O1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Os(),[n,a]=N.useState(!0),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState(null),[v,_]=N.useState("");N.useEffect(()=>{(async()=>{if(t)try{const{data:L}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(L!=null&&L.brokerage_id)){a(!1);return}l(L.brokerage_id);const{data:P}=await H.from("brokerages").select("name").eq("id",L.brokerage_id).maybeSingle();if(P&&c(P.name),s)p(!0);else if(r){const{data:O}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",L.brokerage_id).maybeSingle();p(!!O)}}catch(L){console.error("Error fetching brokerage info:",L)}finally{a(!1)}})()},[t,s,r]);const{data:w=[]}=FLt(o),{data:j=[],isLoading:k}=zLt(o,f),S=N.useMemo(()=>{if(!v.trim())return j;const M=v.toLowerCase();return j.filter(L=>{var P;return L.title.toLowerCase().includes(M)||((P=L.description)==null?void 0:P.toLowerCase().includes(M))||L.content_type.toLowerCase().includes(M)})},[j,v]);return n?e.jsx(Ts,{title:"Brokerage Content",description:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):o?e.jsx(Ts,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(D1s,{brokerageId:o,categories:w}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search content...",value:v,onChange:M=>_(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{variant:f===null?"default":"outline",size:"sm",onClick:()=>g(null),children:"All"}),w.map(M=>e.jsxs(K,{variant:f===M.id?"default":"outline",size:"sm",onClick:()=>g(M.id),children:[e.jsx("span",{className:"mr-1",children:M.icon}),M.name]},M.id))]})]}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Om,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:v.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:v.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(M=>e.jsx(I1s,{item:M,canManage:u},M.id))})]})}):e.jsx(Ts,{title:"Brokerage Content",description:"Content Hub",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ca,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}const s7e={video:{icon:il,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:wn,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:ml,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:hn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Bl,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function R1s(t){try{const s=new URL(t),r=s.hostname.replace("www.","");if(s.pathname==="/playlist"){const n=s.searchParams.get("list");if(n)return`https://www.youtube.com/embed/videoseries?list=${n}`}if(r==="youtube.com"||r==="m.youtube.com"){const n=s.searchParams.get("v");if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtu.be"){const n=s.pathname.slice(1);if(n){const a=s.searchParams.get("list");let o=`https://www.youtube.com/embed/${n}`;return a&&(o+=`?list=${a}`),o}}if(r==="youtube.com"&&s.pathname.startsWith("/embed/"))return t}catch{}return null}function F1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function z1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function B1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function $1s(){const{contentId:t}=lo(),{data:s,isLoading:r}=mt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await H.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Ts,{title:"Brokerage Content",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!s)return e.jsx(Ts,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ca,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Content not found"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"This content may have been removed."}),e.jsx(K,{asChild:!0,className:"mt-4",children:e.jsx(pa,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=s7e[s.content_type]||s7e.link,a=n.icon,o=s.url||s.file_url,l=o&&F1s(o)?R1s(o):null,i=o&&z1s(o)?B1s(o):null,c=l||i;return e.jsx(Ts,{title:s.title,children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(pa,{to:"/brokerage-content",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(st,{variant:"secondary",className:`text-xs px-2 py-0.5 ${n.color}`,children:[e.jsx(a,{className:"h-3 w-3 mr-1"}),n.label]}),s.category&&e.jsxs(st,{variant:"outline",className:"text-xs px-2 py-0.5",children:[s.category.icon," ",s.category.name]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Added ",ms(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:c,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!c&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(hn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ms(new Date(s.event_date),"EEEE, MMMM d, yyyy · h:mm a")})]})]})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.file_url&&e.jsx(K,{asChild:!0,size:"lg",children:e.jsxs("a",{href:s.file_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),s.content_type==="pdf"?"Download Document":"Download File"]})}),s.url&&e.jsx(K,{variant:s.file_url?"outline":"default",asChild:!0,size:"lg",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),c?"Open on YouTube":s.content_type==="event"?"Join Event":s.content_type==="graphic"?"Open in Canva":"Open Link"]})})]})]})})}function q1s(){const t=nr(),[s,r]=N.useState(""),[n,a]=N.useState("grid"),{data:o,isLoading:l}=mt({queryKey:["newsletters"],queryFn:async()=>{const{data:M,error:L}=await H.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(L)throw L;return M}}),{data:i}=mt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_likes").select("newsletter_id");return M||[]}}),{data:c}=mt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:M}=await H.from("newsletter_comments").select("newsletter_id");return M||[]}}),{data:u}=mt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[M,L,P,O]=await Promise.all([H.from("newsletter_canva_links").select("newsletter_id"),H.from("newsletter_pdfs").select("newsletter_id"),H.from("newsletter_videos").select("newsletter_id"),H.from("newsletter_drive_links").select("newsletter_id")]);return{canva:M.data||[],pdfs:L.data||[],videos:P.data||[],drives:O.data||[]}}}),p=M=>(i==null?void 0:i.filter(L=>L.newsletter_id===M).length)||0,f=M=>(c==null?void 0:c.filter(L=>L.newsletter_id===M).length)||0,g=M=>{var L;return((L=u==null?void 0:u.canva)==null?void 0:L.filter(P=>P.newsletter_id===M).length)||0},v=M=>{var L;return((L=u==null?void 0:u.pdfs)==null?void 0:L.filter(P=>P.newsletter_id===M).length)||0},_=M=>{var L;return((L=u==null?void 0:u.videos)==null?void 0:L.filter(P=>P.newsletter_id===M).length)||0},w=M=>{var L;return((L=u==null?void 0:u.drives)==null?void 0:L.filter(P=>P.newsletter_id===M).length)||0},j=M=>g(M)+v(M)+_(M)+w(M),k=o==null?void 0:o.filter(M=>{var L;return M.title.toLowerCase().includes(s.toLowerCase())||((L=M.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))}),S=M=>{t(`/newsletters/${M}`)};return e.jsx(Ts,{title:"Newsletter Content",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search newsletters...",value:s,onChange:M=>r(M.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>r(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(k==null?void 0:k.length)||0," item",(k==null?void 0:k.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((M,L)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(vs,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(vs,{className:"h-5 w-3/4"}),e.jsx(vs,{className:"h-4 w-full"})]})]})},L))}),!l&&(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(wn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&k&&k.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:k.map(M=>{const L=j(M.id),P=g(M.id),O=v(M.id),$=_(M.id);return n==="grid"?e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(wn,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:M.description.replace(/<[^>]*>/g,"")}),L>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[P>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Bl,{className:"h-3 w-3"})," ",P," Template",P>1?"s":""]}),O>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(vi,{className:"h-3 w-3"})," ",O," PDF",O>1?"s":""]}),$>0&&e.jsxs(st,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(il,{className:"h-3 w-3"})," ",$," Video",$>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]},M.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(M.id),children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:M.preview_image_url?e.jsx("img",{src:M.preview_image_url,alt:M.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(wn,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:M.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(M.publish_date),"MMM d, yyyy")]})]}),M.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:M.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[L>0&&e.jsxs("span",{children:[L," resource",L>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]})},M.id)})})]})})}function U1s({rows:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.columns.some(n=>n.title||n.description||n.image_url));return s.length===0?null:e.jsx("div",{className:"space-y-6",children:s.map((r,n)=>{const a=r.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>e.jsxs(Ee,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function V1s(){const{id:t}=lo(),s=nr(),{user:r}=Os(),{toast:n}=Ha(),a=Xt(),{trackEngagement:o}=hE(),[l,i]=N.useState(""),{data:c,isLoading:u}=mt({queryKey:["newsletter",t],queryFn:async()=>{const{data:P,error:O}=await H.from("newsletter_content").select("*").eq("id",t).single();if(O)throw O;return P},enabled:!!t});N.useEffect(()=>{c&&o("newsletter",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p}=mt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:f}=mt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:g}=mt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:v}=mt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return P||[]},enabled:!!t}),{data:_}=mt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_likes").select("*").eq("newsletter_id",t);return P||[]},enabled:!!t}),{data:w}=mt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:P}=await H.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return P||[]},enabled:!!t}),j=_==null?void 0:_.some(P=>P.user_id===(r==null?void 0:r.id)),k=Lt({mutationFn:async()=>{j?await H.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await H.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Lt({mutationFn:async P=>{const{error:O}=await H.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:P});if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),M=Lt({mutationFn:async P=>{const{error:O}=await H.from("newsletter_comments").delete().eq("id",P);if(O)throw O},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),L=P=>{if(P.includes("player.mediadelivery.net")||P.includes("iframe.mediadelivery.net")){const O=P.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${O[1]}/${O[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(P.includes("youtube.com")||P.includes("youtu.be")){const O=P.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(O)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${O[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(il,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Ts,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-8 w-32"}),e.jsx(vs,{className:"h-64 w-full"}),e.jsx(vs,{className:"h-32 w-full"})]})}):c?e.jsx(Ts,{title:"",description:"",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/newsletters"),className:"mb-4",children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),c.preview_image_url&&e.jsx("img",{src:c.preview_image_url,alt:c.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:c.title}),e.jsx("p",{className:"text-muted-foreground mt-1",children:ms(new Date(c.publish_date),"MMMM d, yyyy")})]}),c.description&&e.jsx("div",{className:"text-lg text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&_p]:mb-4 [&_p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:c.description}}),e.jsx(U1s,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(gE,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:j?"default":"outline",size:"sm",onClick:()=>k.mutate(),children:[e.jsx(Ya,{className:`h-4 w-4 mr-1 ${j?"fill-current":""}`}),(_==null?void 0:_.length)||0," ",(_==null?void 0:_.length)===1?"Like":"Likes"]})]}),v&&v.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:v.map(P=>e.jsxs("a",{href:P.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Bl,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:P.title}),e.jsx(en,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},P.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.map(P=>e.jsxs("a",{href:P.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(en,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:P.title})]},P.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(P=>e.jsxs("a",{href:P.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(wn,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:P.name}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]},P.id))})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:g.map(P=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:P.title}),L(P.video_url)]},P.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Pr,{placeholder:"Write a comment...",value:l,onChange:P=>i(P.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx($n,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(P=>{var O,$,U;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{children:(($=(O=P.profiles)==null?void 0:O.name)==null?void 0:$[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((U=P.profiles)==null?void 0:U.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(P.created_at),"MMM d, yyyy")}),P.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>M.mutate(P.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:P.content})]})]},P.id)})})]})]})]})}):e.jsx(Ts,{title:"Not Found",description:"",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/newsletters"),children:"Back to Newsletters"})]})})}function H1s({rows:t,onChange:s}){const[r,n]=N.useState(null),a=()=>{s([...t,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=u=>{s(t.filter((p,f)=>f!==u))},l=(u,p,f,g)=>{const v=[...t];v[u]={...v[u],columns:v[u].columns.map((_,w)=>w===p?{..._,[f]:g}:_)},s(v)},i=async(u,p,f)=>{var _;const g=(_=f.target.files)==null?void 0:_[0];if(!g)return;const v=`${u}-${p}`;n(v);try{const w=`content-blocks/${Date.now()}-${g.name}`,{error:j}=await H.storage.from("newsletter-content").upload(w,g);if(!j){const{data:k}=H.storage.from("newsletter-content").getPublicUrl(w);l(u,p,"image_url",k.publicUrl)}}finally{n(null)}},c=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),t.map((u,p)=>e.jsxs(Ee,{className:"relative",children:[e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(Mr,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:u.columns.map((f,g)=>{const v=`${p}-${g}`;return e.jsxs("div",{className:"space-y-2 border border-border/50 rounded-md p-3 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["Column ",g+1]}),f.image_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:f.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(p,g),children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${v}`,onChange:_=>i(p,g,_)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===v,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${v}`,className:"cursor-pointer",children:r===v?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(vl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(ze,{placeholder:"Title",value:f.title,onChange:_=>l(p,g,"title",_.target.value),className:"h-8 text-sm"}),e.jsx(Pr,{placeholder:"Description",value:f.description,onChange:_=>l(p,g,"description",_.target.value),className:"text-sm min-h-[60px] resize-none"})]},g)})})]})]},p))]})}function G1s(){const{toast:t}=Ha(),s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(null),[l,i]=N.useState({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=N.useState(null),[p,f]=N.useState(null),[g,v]=N.useState([]),[_,w]=N.useState([]),[j,k]=N.useState([]),[S,M]=N.useState([]),[L,P]=N.useState([]),[O,$]=N.useState([]),[U,B]=N.useState(!1),{data:V,isLoading:X}=mt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Me,error:Ie}=await H.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ie)throw Ie;return Me}}),Y=Lt({mutationFn:async Me=>{const{data:Ie,error:ke}=await H.from("newsletter_content").insert({title:Me.title,description:Me.description||null,preview_image_url:Me.preview_image_url,publish_date:Me.publish_date,is_published:Me.is_published,content_blocks:Me.content_blocks}).select().single();if(ke)throw ke;return Ie},onSuccess:async Me=>{await ce(Me.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Me.is_published&&TVt(Me.title,Me.id),oe()},onError:Me=>{t({title:"Error creating newsletter",description:Me.message,variant:"destructive"})}}),ee=Lt({mutationFn:async Me=>{const{error:Ie}=await H.from("newsletter_content").update({title:Me.title,description:Me.description||null,preview_image_url:Me.preview_image_url,publish_date:Me.publish_date,is_published:Me.is_published,content_blocks:Me.content_blocks}).eq("id",Me.id);if(Ie)throw Ie;return Me.id},onSuccess:async Me=>{await ce(Me),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),oe()},onError:Me=>{t({title:"Error updating newsletter",description:Me.message,variant:"destructive"})}}),Q=Lt({mutationFn:async Me=>{const{error:Ie}=await H.from("newsletter_content").delete().eq("id",Me);if(Ie)throw Ie},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Me=>{t({title:"Error deleting newsletter",description:Me.message,variant:"destructive"})}}),ce=async Me=>{await H.from("newsletter_drive_links").delete().eq("newsletter_id",Me),await H.from("newsletter_pdfs").delete().eq("newsletter_id",Me),await H.from("newsletter_videos").delete().eq("newsletter_id",Me),await H.from("newsletter_canva_links").delete().eq("newsletter_id",Me);for(const Ie of O){const ke=`${Me}/${Date.now()}-${Ie.file.name}`,{error:pe}=await H.storage.from("newsletter-content").upload(ke,Ie.file);if(!pe){const{data:we}=H.storage.from("newsletter-content").getPublicUrl(ke);_.push({name:Ie.name,file_url:we.publicUrl,file_size:Ie.file.size,sort_order:_.length})}}g.length>0&&await H.from("newsletter_drive_links").insert(g.map((Ie,ke)=>({newsletter_id:Me,title:Ie.title,drive_url:Ie.drive_url,sort_order:ke}))),_.length>0&&await H.from("newsletter_pdfs").insert(_.map((Ie,ke)=>({newsletter_id:Me,name:Ie.name,file_url:Ie.file_url,file_size:Ie.file_size||null,sort_order:ke}))),j.length>0&&await H.from("newsletter_videos").insert(j.map((Ie,ke)=>({newsletter_id:Me,title:Ie.title,video_url:Ie.video_url,sort_order:ke}))),S.length>0&&await H.from("newsletter_canva_links").insert(S.map((Ie,ke)=>({newsletter_id:Me,title:Ie.title,canva_share_link:Ie.canva_share_link,sort_order:ke})))},ne=async Me=>{o(Me),i({title:Me.title,description:Me.description||"",publish_date:ms(new Date(Me.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Me.is_published}),f(Me.preview_image_url),P(Me.content_blocks||[]);const[Ie,ke,pe,we]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Me.id).order("sort_order")]);v(Ie.data||[]),w(ke.data||[]),k(pe.data||[]),M(we.data||[]),$([]),n(!0)},re=async Me=>{const[Ie,ke,pe,we]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Me.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Me.id).order("sort_order")]);o(null),i({title:`${Me.title} (Copy)`,description:Me.description||"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Me.preview_image_url),P(Me.content_blocks||[]),v((Ie.data||[]).map(({id:Le,...Qe})=>Qe)),w((ke.data||[]).map(({id:Le,...Qe})=>Qe)),k((pe.data||[]).map(({id:Le,...Qe})=>Qe)),M((we.data||[]).map(({id:Le,...Qe})=>Qe)),$([]),n(!0)},oe=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ms(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),v([]),w([]),k([]),M([]),P([]),$([])},fe=async Me=>{var ke;const Ie=(ke=Me.target.files)==null?void 0:ke[0];Ie&&(u(Ie),f(URL.createObjectURL(Ie)))},ge=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Me=p;if(c){const Ie=`previews/${Date.now()}-${c.name}`,{error:ke}=await H.storage.from("newsletter-content").upload(Ie,c);if(!ke){const{data:pe}=H.storage.from("newsletter-content").getPublicUrl(Ie);Me=pe.publicUrl}}a?ee.mutate({id:a.id,...l,preview_image_url:Me,content_blocks:L}):Y.mutate({...l,preview_image_url:Me,content_blocks:L}),B(!1)},ue=()=>v([...g,{title:"",drive_url:"",sort_order:g.length}]),xe=()=>k([...j,{title:"",video_url:"",sort_order:j.length}]),_e=()=>M([...S,{title:"",canva_share_link:"",sort_order:S.length}]),$e=Me=>{const Ie=Me.target.files;if(!Ie)return;const ke=Array.from(Ie).map(pe=>({file:pe,name:pe.name.replace(/\.[^/.]+$/,"")}));$([...O,...ke])};return e.jsx(Ts,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(xs,{open:r,onOpenChange:Me=>!Me&&oe(),children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(fs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:a?"Edit Newsletter":"Add Newsletter"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:l.title,onChange:Me=>i({...l,title:Me.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:l.publish_date,onChange:Me=>i({...l,publish_date:Me.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:l.description,onChange:Me=>i({...l,description:Me}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(Mr,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:fe,className:"hidden",id:"preview-upload"}),e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[e.jsx(di,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:l.is_published,onCheckedChange:Me=>i({...l,is_published:Me})}),e.jsx(be,{children:"Published"})]}),e.jsx(H1s,{rows:L,onChange:P}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((Me,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Me.title,onChange:ke=>{const pe=[...S];pe[Ie].title=ke.target.value,M(pe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Canva share link",value:Me.canva_share_link,onChange:ke=>{const pe=[...S];pe[Ie].canva_share_link=ke.target.value,M(pe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(S.filter((ke,pe)=>pe!==Ie)),children:e.jsx(Mr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),g.map((Me,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Me.title,onChange:ke=>{const pe=[...g];pe[Ie].title=ke.target.value,v(pe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Google Drive URL",value:Me.drive_url,onChange:ke=>{const pe=[...g];pe[Ie].drive_url=ke.target.value,v(pe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>v(g.filter((ke,pe)=>pe!==Ie)),children:e.jsx(Mr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:".pdf",multiple:!0,onChange:$e,className:"hidden",id:"pdf-upload"}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[e.jsx(di,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),_.map((Me,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Me.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(_.filter((ke,pe)=>pe!==Ie)),children:e.jsx(Mr,{className:"h-4 w-4"})})]},`existing-${Ie}`)),O.map((Me,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:Me.name,onChange:ke=>{const pe=[...O];pe[Ie].name=ke.target.value,$(pe)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(O.filter((ke,pe)=>pe!==Ie)),children:e.jsx(Mr,{className:"h-4 w-4"})})]},`pending-${Ie}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:xe,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),j.map((Me,Ie)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Video title",value:Me.title,onChange:ke=>{const pe=[...j];pe[Ie].title=ke.target.value,k(pe)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Video URL",value:Me.video_url,onChange:ke=>{const pe=[...j];pe[Ie].video_url=ke.target.value,k(pe)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(j.filter((ke,pe)=>pe!==Ie)),children:e.jsx(Mr,{className:"h-4 w-4"})})]},Ie))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:oe,children:"Cancel"}),e.jsx(K,{onClick:ge,disabled:U||Y.isPending||ee.isPending,children:U?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:X?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):V==null?void 0:V.map(Me=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.preview_image_url?e.jsx("img",{src:Me.preview_image_url,alt:Me.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(wn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.title}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:ms(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Me.is_published?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"}`,children:Me.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ne(Me),title:"Edit",children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>re(Me),title:"Duplicate",children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&Q.mutate(Me.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Me.id))})]})})})]})})}const r7e={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}};function W1s(){const{user:t}=Os(),{toast:s}=Ha(),r=nr(),n=Xt(),[a,o]=N.useState(""),[l,i]=N.useState("popular"),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState(!1),{data:j=[],isLoading:k}=mt({queryKey:["wishlist-items",l,_],queryFn:async()=>{let O=H.from("wishlist_items").select("*");_&&t&&(O=O.eq("user_id",t.id)),l==="latest"?O=O.order("created_at",{ascending:!1}):l==="popular"?O=O.order("vote_count",{ascending:!1}):l==="trending"&&(O=O.order("vote_count",{ascending:!1}));const{data:$,error:U}=await O;if(U)throw U;const B=[...new Set(($==null?void 0:$.map(ne=>ne.user_id))||[])],{data:V}=await H.from("profiles").select("id, name").in("id",B),X=new Map((V==null?void 0:V.map(ne=>[ne.id,ne]))||[]);let Y=[];if(t){const{data:ne}=await H.from("wishlist_votes").select("item_id").eq("user_id",t.id);Y=(ne==null?void 0:ne.map(re=>re.item_id))||[]}const ee=($==null?void 0:$.map(ne=>ne.id))||[],{data:Q}=await H.from("wishlist_comments").select("item_id").in("item_id",ee),ce=new Map;return Q==null||Q.forEach(ne=>{ce.set(ne.item_id,(ce.get(ne.item_id)||0)+1)}),$==null?void 0:$.map(ne=>{const re=X.get(ne.user_id),oe=(re==null?void 0:re.name)||"Unknown";return{...ne,user_name:oe,user_initials:oe.split(" ").map(fe=>fe[0]).join("").toUpperCase().slice(0,2),has_voted:Y.includes(ne.id),comment_count:ce.get(ne.id)||0}})}}),S=Lt({mutationFn:async({title:O,description:$})=>{const{error:U}=await H.from("wishlist_items").insert({user_id:t.id,title:O,description:$});if(U)throw U},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),v(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),M=Lt({mutationFn:async({itemId:O,hasVoted:$})=>{if($){const{error:U}=await H.from("wishlist_votes").delete().eq("item_id",O).eq("user_id",t.id);if(U)throw U;return{itemId:O,wasAdded:!1}}else{const{error:U}=await H.from("wishlist_votes").insert({item_id:O,user_id:t.id});if(U)throw U;return{itemId:O,wasAdded:!0}}},onSuccess:async O=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),O!=null&&O.wasAdded){const $=j.find(B=>B.id===O.itemId),U=(($==null?void 0:$.vote_count)||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:O.itemId,voteCount:U}}).catch(console.error)}},onError:O=>{s({title:"Error",description:O.message,variant:"destructive"})}}),L=j.filter(O=>O.title.toLowerCase().includes(a.toLowerCase())||O.description.toLowerCase().includes(a.toLowerCase())),P=()=>{if(!p.trim()||!g.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:p.trim(),description:g.trim()})};return e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Z_,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold",children:"Wishlist"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Share ideas and vote on what we build next"})]})]}),e.jsxs(xs,{open:c,onOpenChange:u,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Submit a New Idea"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:g,onChange:O=>v(O.target.value),rows:4})]}),e.jsx(K,{onClick:P,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas...",value:a,onChange:O=>o(O.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(_a,{value:l,onValueChange:O=>i(O),children:e.jsxs(fa,{children:[e.jsx(ns,{value:"popular",children:"Most Popular"}),e.jsx(ns,{value:"latest",children:"Latest"}),e.jsx(ns,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:_?"default":"outline",size:"sm",onClick:()=>w(!_),children:_?"Show All Ideas":"My Ideas"})}),k?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):L.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(Z_,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),e.jsxs(K,{onClick:()=>u(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:L.map(O=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${O.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),M.mutate({itemId:O.id,hasVoted:O.has_voted||!1})},className:It("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",O.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Su,{className:It("h-4 w-4",O.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:O.vote_count})]}),e.jsx(kn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(Sn,{className:"bg-primary/20 text-primary text-sm font-medium",children:O.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:O.title}),e.jsx(st,{className:It("text-xs",r7e[O.status].color),children:r7e[O.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:O.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:O.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(O.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(so,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:O.comment_count})]})]})},O.id))})]})})}const n7e={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}};function K1s(){const{itemId:t}=lo(),s=nr(),{user:r}=Os(),{toast:n}=Ha(),a=Xt(),[o,l]=N.useState(""),{data:i=!1}=mt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:j,error:k}=await H.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!k&&!!j},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:j,error:k}=await H.from("wishlist_items").select("*").eq("id",t).single();if(k)throw k;const{data:S}=await H.from("profiles").select("name").eq("id",j.user_id).single();let M=!1;if(r){const{data:L}=await H.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();M=!!L}return{...j,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),has_voted:M}}}),{data:p=[],isLoading:f}=mt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:j,error:k}=await H.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(k)throw k;const S=[...new Set((j==null?void 0:j.map(P=>P.user_id))||[])],{data:M}=await H.from("profiles").select("id, name").in("id",S),L=new Map((M==null?void 0:M.map(P=>[P.id,P]))||[]);return j==null?void 0:j.map(P=>{const O=L.get(P.user_id),$=(O==null?void 0:O.name)||"Unknown";return{...P,user_name:$,user_initials:$.split(" ").map(U=>U[0]).join("").toUpperCase().slice(0,2)}})}}),g=Lt({mutationFn:async j=>{if(j){const{error:k}=await H.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(k)throw k;return{wasAdded:!1}}else{const{error:k}=await H.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(k)throw k;return{wasAdded:!0}}},onSuccess:async j=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),j!=null&&j.wasAdded&&c){const k=(c.vote_count||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:k}}).catch(console.error)}},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),v=Lt({mutationFn:async j=>{const{error:k}=await H.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:j});if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),_=Lt({mutationFn:async j=>{const{error:k}=await H.from("wishlist_comments").delete().eq("id",j);if(k)throw k},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),w=()=>{o.trim()&&v.mutate(o.trim())};return u?e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(vs,{className:"h-8 w-32 mb-6"}),e.jsx(vs,{className:"h-48 w-full mb-6"}),e.jsx(vs,{className:"h-32 w-full"})]})}):c?e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/wishlist"),className:"mb-4",children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Wishlist"]}),e.jsx("div",{className:"bg-card border rounded-lg p-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:()=>g.mutate(c.has_voted),className:It("flex flex-col items-center justify-center min-w-[60px] py-3 px-4 rounded-lg border transition-colors",c.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Su,{className:It("h-5 w-5",c.has_voted&&"fill-current")}),e.jsx("span",{className:"text-lg font-bold",children:c.vote_count}),e.jsx("span",{className:"text-xs",children:"votes"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:c.title}),e.jsx(st,{className:It("text-xs",n7e[c.status].color),children:n7e[c.status].label})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:c.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(kn,{className:"h-6 w-6",children:e.jsx(Sn,{className:"bg-primary/20 text-primary text-xs",children:c.user_initials})}),e.jsx("span",{children:c.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(c.created_at).toLocaleDateString()})]})]})]})}),e.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsx(Qle,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:w,disabled:!o.trim()||v.isPending,size:"icon",className:"h-auto",children:v.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(j=>e.jsx(vs,{className:"h-20 w-full"},j))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(j=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{className:"bg-primary/20 text-primary text-xs",children:j.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:j.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsx(Wke,{content:j.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===j.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>_.mutate(j.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]},j.id))})]})]})}):e.jsx(Ts,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/wishlist"),children:"Go back to Wishlist"})]})})}const a7e={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}},i7e=["open","under_review","planned","in_progress","launched","declined"];function Z1s(){const{toast:t}=Ha(),s=nr(),r=Xt(),[n,a]=N.useState(""),[o,l]=N.useState("all"),[i,c]=N.useState(!1),[u,p]=N.useState(null),{data:f=[],isLoading:g}=mt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:k,error:S}=await H.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const M=[...new Set((k==null?void 0:k.map(B=>B.user_id))||[])],{data:L}=await H.from("profiles").select("id, name, email").in("id",M),P=new Map((L==null?void 0:L.map(B=>[B.id,B]))||[]),O=(k==null?void 0:k.map(B=>B.id))||[],{data:$}=await H.from("wishlist_comments").select("item_id").in("item_id",O),U=new Map;return $==null||$.forEach(B=>{U.set(B.item_id,(U.get(B.item_id)||0)+1)}),k==null?void 0:k.map(B=>{const V=P.get(B.user_id);return{...B,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:U.get(B.id)||0}})}}),v=Lt({mutationFn:async({itemId:k,status:S})=>{const{error:M}=await H.from("wishlist_items").update({status:S}).eq("id",k);if(M)throw M},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),_=Lt({mutationFn:async k=>{const{error:S}=await H.from("wishlist_items").delete().eq("id",k);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),c(!1),p(null),t({title:"Item deleted!"})},onError:k=>{t({title:"Error",description:k.message,variant:"destructive"})}}),w=f.filter(k=>{const S=k.title.toLowerCase().includes(n.toLowerCase())||k.description.toLowerCase().includes(n.toLowerCase())||k.user_name.toLowerCase().includes(n.toLowerCase()),M=o==="all"||k.status===o;return S&&M}),j={total:f.length,open:f.filter(k=>k.status==="open").length,inProgress:f.filter(k=>k.status==="in_progress").length,launched:f.filter(k=>k.status==="launched").length,highVotes:f.filter(k=>k.vote_count>=10).length};return e.jsx(Ts,{title:"Admin - Wishlist",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:j.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:j.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:j.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:j.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:j.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search ideas, users...",value:n,onChange:k=>a(k.target.value),className:"pl-10"})]}),e.jsxs(Ks,{value:o,onValueChange:k=>l(k),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),i7e.map(k=>e.jsx(Mt,{value:k,children:a7e[k].label},k))]})]})]}),g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(k=>e.jsx(vs,{className:"h-16 w-full"},k))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[60px]",children:"Votes"}),e.jsx(St,{children:"Title"}),e.jsx(St,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(St,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Bn,{children:w.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(k=>e.jsxs(Cs,{className:It(k.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(st,{variant:k.vote_count>=10?"default":"secondary",children:k.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:k.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:k.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:k.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:k.comment_count}),e.jsx(dt,{children:e.jsxs(Ks,{value:k.status,onValueChange:S=>v.mutate({itemId:k.id,status:S}),children:[e.jsx(Gs,{className:"w-[140px] h-8",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:i7e.map(S=>e.jsx(Mt,{value:S,children:a7e[S].label},S))})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${k.id}`,"_blank"),children:e.jsx(en,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(k.id),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},k.id))})]})}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&_.mutate(u),disabled:_.isPending,children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function Y1s(){const{user:t}=Os(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(!1),[f,g]=N.useState(null),[v,_]=N.useState(""),[w,j]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(""),[P,O]=N.useState(""),[$,U]=N.useState(!1),[B,V]=N.useState(""),[X,Y]=N.useState("once"),[ee,Q]=N.useState([]),[ce,ne]=N.useState([]),[re,oe]=N.useState(!1),[fe,ge]=N.useState(!1),[ue,xe]=N.useState([]),[_e,$e]=N.useState({total:0,dismissed:0});N.useEffect(()=>{Me()},[]);const Me=async()=>{const{data:Ze,error:Je}=await H.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Je?(me.error("Failed to fetch briefs"),console.error(Je)):r(Ze||[]),a(!1)},Ie=()=>{_(""),j(""),S(""),L(""),O(""),U(!1),V(new Date().toISOString().slice(0,16)),Y("once"),Q([]),ne([]),c(null)},ke=()=>{Ie(),l(!0)},pe=async Ze=>{c(Ze),_(Ze.title),j(Ze.description||""),S(Ze.video_url||""),L(Ze.graphic_url||""),O(Ze.graphic_link_url||""),U(Ze.is_published),V(Ze.publish_date.slice(0,16)),Y(Ze.show_frequency);const{data:Je}=await H.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");Q((Je==null?void 0:Je.map(et=>({title:et.title,url:et.url})))||[]);const{data:Ge}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(Ge){const et=[];for(const it of Ge){const{data:Dt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",it.id).order("sort_order");et.push({question:it.question,poll_type:it.poll_type,options:(Dt==null?void 0:Dt.map(Vt=>Vt.option_text))||[]})}ne(et)}l(!0)},we=async Ze=>{var Ge;const Je=(Ge=Ze.target.files)==null?void 0:Ge[0];if(Je){oe(!0);try{const et=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Je.name.replace(/\.[^/.]+$/,"")}});if(et.error)throw et.error;const{videoId:it,libraryId:Dt}=et.data,Vt=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:it}});if(Vt.error)throw Vt.error;const{uploadUrl:hs,apiKey:As}=Vt.data,Ms=new XMLHttpRequest;await new Promise((er,xt)=>{Ms.upload.addEventListener("progress",Ps=>{if(Ps.lengthComputable){const mr=Math.round(Ps.loaded/Ps.total*100);console.log("Upload progress:",mr)}}),Ms.addEventListener("load",()=>{Ms.status>=200&&Ms.status<300?er():xt(new Error(`Upload failed with status ${Ms.status}`))}),Ms.addEventListener("error",()=>xt(new Error("Upload failed"))),Ms.open("PUT",hs),Ms.setRequestHeader("AccessKey",As),Ms.send(Je)});const cs=`https://player.mediadelivery.net/embed/${Dt}/${it}`;S(cs),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(et){console.error("Upload error:",et),me.error("Failed to upload video")}finally{oe(!1)}}},Le=async()=>{if(!v.trim()){me.error("Title is required");return}try{let Ze;if(i){const{error:Je}=await H.from("levelup_briefs").update({title:v,description:w||null,video_url:k||null,graphic_url:M||null,graphic_link_url:P||null,is_published:$,publish_date:B,show_frequency:X}).eq("id",i.id);if(Je)throw Je;Ze=i.id,await H.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:Ge}=await H.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(Ge)for(const et of Ge)await H.from("levelup_brief_poll_options").delete().eq("poll_id",et.id);await H.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:Je,error:Ge}=await H.from("levelup_briefs").insert({title:v,description:w||null,video_url:k||null,graphic_url:M||null,graphic_link_url:P||null,is_published:$,publish_date:B,show_frequency:X,created_by:t==null?void 0:t.id}).select().single();if(Ge)throw Ge;Ze=Je.id}if(ee.length>0){const Je=ee.map((Ge,et)=>({brief_id:Ze,title:Ge.title,url:Ge.url,sort_order:et}));await H.from("levelup_brief_links").insert(Je)}for(let Je=0;Je0){const Dt=Ge.options.map((Vt,hs)=>({poll_id:et.id,option_text:Vt,sort_order:hs}));await H.from("levelup_brief_poll_options").insert(Dt)}}me.success(i?"Brief updated":"Brief created"),l(!1),Ie(),Me()}catch(Ze){console.error("Error saving brief:",Ze),me.error("Failed to save brief")}},Qe=async Ze=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Je}=await H.from("levelup_briefs").delete().eq("id",Ze);if(Je)throw Je;me.success("Brief deleted"),Me()}catch(Je){console.error("Error deleting brief:",Je),me.error("Failed to delete brief")}},Te=async Ze=>{g(Ze);const{count:Je}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id),{count:Ge}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);$e({total:Je||0,dismissed:Ge||0});const{data:et}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(et){const it=[];for(const Dt of et){const{data:Vt}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",Dt.id).order("sort_order"),{data:hs}=await H.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Dt.id),As=[...new Set((hs==null?void 0:hs.map(Ps=>Ps.user_id))||[])];let Ms={};if(As.length>0){const{data:Ps}=await H.from("profiles").select("id, name, email").in("id",As);Ps&&Ps.forEach(mr=>{Ms[mr.id]=mr.name||mr.email||"Unknown"})}const cs=(hs||[]).map(Ps=>({optionId:Ps.option_id,userName:Ms[Ps.user_id]||"Unknown",userId:Ps.user_id})),er={};let xt=0;Vt&&Vt.forEach(Ps=>{const mr=(hs==null?void 0:hs.filter(Tr=>Tr.option_id===Ps.id).length)||0;er[Ps.id]=mr,xt+=mr}),it.push({...Dt,options:Vt||[],results:er,respondents:cs,totalResponses:Dt.poll_type==="single"?new Set(hs==null?void 0:hs.map(Ps=>Ps.user_id)).size:xt})}xe(it)}p(!0)},pt=()=>{Q([...ee,{title:"",url:""}])},ye=(Ze,Je,Ge)=>{const et=[...ee];et[Ze][Je]=Ge,Q(et)},qe=Ze=>{Q(ee.filter((Je,Ge)=>Ge!==Ze))},at=()=>{ne([...ce,{question:"",poll_type:"single",options:["",""]}])},tt=(Ze,Je)=>{const Ge=[...ce];Ge[Ze].question=Je,ne(Ge)},Ae=(Ze,Je)=>{const Ge=[...ce];Ge[Ze].poll_type=Je,ne(Ge)},rt=Ze=>{const Je=[...ce];Je[Ze].options.push(""),ne(Je)},He=(Ze,Je,Ge)=>{const et=[...ce];et[Ze].options[Je]=Ge,ne(et)},ct=(Ze,Je)=>{const Ge=[...ce];Ge[Ze].options=Ge[Ze].options.filter((et,it)=>it!==Je),ne(Ge)},Ue=Ze=>{ne(ce.filter((Je,Ge)=>Ge!==Ze))};return e.jsxs(Ts,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:ke,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Frequency"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:n?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:Ze.title}),e.jsx(dt,{children:e.jsx(st,{variant:Ze.is_published?"default":"secondary",children:Ze.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"capitalize",children:Ze.show_frequency.replace("_"," ")}),e.jsx(dt,{children:ms(new Date(Ze.publish_date),"MMM d, yyyy h:mm a")}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Te(Ze),children:e.jsx(yo,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>pe(Ze),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Qe(Ze.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ze.id))})]})})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(_a,{defaultValue:"content",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"content",children:"Content"}),e.jsx(ns,{value:"media",children:"Media"}),e.jsx(ns,{value:"links",children:"Links"}),e.jsx(ns,{value:"polls",children:"Polls"})]}),e.jsxs(ws,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:v,onChange:Ze=>_(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:w,onChange:Ze=>j(Ze),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:Ze=>V(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Show Frequency"}),e.jsxs(Ks,{value:X,onValueChange:Y,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"once",children:"Once (until dismissed)"}),e.jsx(Mt,{value:"every_login",children:"Every login"}),e.jsx(Mt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qr,{checked:$,onCheckedChange:U}),e.jsx(be,{children:"Publish immediately"})]})]}),e.jsxs(ws,{value:"media",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Video (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"video/*",onChange:we,disabled:re})}),re&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Or paste embed URL"}),e.jsx(ze,{value:k,onChange:Ze=>S(Ze.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),k&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:k,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"image/*",onChange:async Ze=>{var Ge;const Je=(Ge=Ze.target.files)==null?void 0:Ge[0];if(Je){ge(!0);try{const et=Je.name.split(".").pop(),it=`brief-graphics/${Date.now()}.${et}`,{error:Dt}=await H.storage.from("banner-images").upload(it,Je,{upsert:!0});if(Dt)throw Dt;const{data:Vt}=H.storage.from("banner-images").getPublicUrl(it);L(Vt.publicUrl),me.success("Image uploaded!")}catch(et){console.error(et),me.error("Failed to upload image")}finally{ge(!1)}}},disabled:fe})}),fe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Or paste Image URL"}),e.jsx(ze,{value:M,onChange:Ze=>L(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Click-through Link (optional)"}),e.jsx(ze,{value:P,onChange:Ze=>O(Ze.target.value),placeholder:"https://example.com/landing-page"})]}),M&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:M,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs(ws,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:pt,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),ee.map((Ze,Je)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(ze,{value:Ze.title,onChange:Ge=>ye(Je,"title",Ge.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(ze,{value:Ze.url,onChange:Ge=>ye(Je,"url",Ge.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(Je),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},Je)),ee.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(ws,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(be,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:at,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Ze,Je)=>e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ze,{value:Ze.question,onChange:Ge=>tt(Je,Ge.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Ks,{value:Ze.poll_type,onValueChange:Ge=>Ae(Je,Ge),children:[e.jsx(Gs,{className:"w-32",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"single",children:"Single"}),e.jsx(Mt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ue(Je),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ze.options.map((Ge,et)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:Ge,onChange:it=>He(Je,et,it.target.value),placeholder:`Option ${et+1}`}),Ze.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(Je,et),children:e.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"})})]},et)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>rt(Je),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Je)),ce.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Le,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(xs,{open:u,onOpenChange:p,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:_e.total})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:_e.dismissed})})]})]}),ue.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ue.map(Ze=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ze.question}),e.jsx("div",{className:"space-y-2",children:Ze.options.map(Je=>{const Ge=Ze.results[Je.id]||0,et=Ze.totalResponses>0?Math.round(Ge/Ze.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:Je.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[Ge," (",et,"%)"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${et}%`}})}),Ge>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(it=>it.optionId===Je.id).map((it,Dt)=>e.jsx(st,{variant:"secondary",className:"text-xs font-normal",children:it.userName},Dt))})]},Je.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const Q1s=()=>{const{user:t}=Os(),{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=N.useState(null),[f,g]=N.useState(""),{data:v=[],isLoading:_}=mt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:P,error:O}=await H.from("additional_services").select("*").order("publish_date",{ascending:!1});if(O)throw O;return P}}),w=Lt({mutationFn:async P=>{let O=P.existingImageUrl;if(P.image){const U=P.image.name.split(".").pop(),B=`${Date.now()}-${Math.random().toString(36).substring(7)}.${U}`,{error:V}=await H.storage.from("service-images").upload(B,P.image);if(V)throw V;const{data:X}=H.storage.from("service-images").getPublicUrl(B);O=X.publicUrl}const $={name:P.item.name,description:P.item.description||null,preview_image_url:O,signup_link_url:P.item.signup_link_url,publish_date:P.item.publish_date?new Date(P.item.publish_date).toISOString():new Date().toISOString(),is_published:P.item.is_published,created_by:t==null?void 0:t.id};if(P.itemId){const{error:U}=await H.from("additional_services").update($).eq("id",P.itemId);if(U)throw U}else{const{error:U}=await H.from("additional_services").insert($);if(U)throw U}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),k()},onError:P=>{s({title:"Error saving service",description:P.message,variant:"destructive"})}}),j=Lt({mutationFn:async P=>{const{error:O}=await H.from("additional_services").delete().eq("id",P);if(O)throw O},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:P=>{s({title:"Error deleting service",description:P.message,variant:"destructive"})}}),k=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),l(null)},S=P=>{l(P),c({name:P.name,description:P.description||"",signup_link_url:P.signup_link_url,publish_date:P.publish_date?new Date(P.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:P.is_published}),g(P.preview_image_url||""),a(!0)},M=P=>{var $;const O=($=P.target.files)==null?void 0:$[0];O&&(p(O),g(URL.createObjectURL(O)))},L=P=>{if(P.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Ts,{title:"Manage Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:v.length})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:v.filter(P=>P.is_published).length})})]})]}),e.jsxs(xs,{open:n,onOpenChange:P=>{a(P),P||k()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:P=>c({...i,name:P.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(fy,{content:i.description,onChange:P=>c({...i,description:P}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(ze,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:P=>c({...i,signup_link_url:P.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:P=>c({...i,publish_date:P.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qr,{id:"is_published",checked:i.is_published,onCheckedChange:P=>c({...i,is_published:P})}),e.jsx(be,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),f?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:f,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),g("")},children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(vl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:M,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:_?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):v.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-16",children:"Preview"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Signup Link"}),e.jsx(St,{children:"Publish Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:v.map(P=>e.jsxs(Cs,{children:[e.jsx(dt,{children:P.preview_image_url?e.jsx("img",{src:P.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(vl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:P.name}),e.jsx(dt,{children:e.jsxs("a",{href:P.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(en,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(P.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(st,{variant:P.is_published?"default":"secondary",children:P.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(P),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&j.mutate(P.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},P.id))})]})})})]})})};function X1s(){const{toast:t}=Ha(),[s,r]=N.useState([]),[n,a]=N.useState(!0),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});N.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:j,error:k}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(k)throw k;r(j.coupons||[])}catch(j){console.error("Error fetching coupons:",j),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},g=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const j={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?j.percent_off=parseFloat(u.percentOff):(j.amount_off=Math.round(parseFloat(u.amountOff)*100),j.currency="usd"),u.duration==="repeating"&&(j.duration_in_months=parseInt(u.durationInMonths));const{data:k,error:S}=await H.functions.invoke("stripe-manage-coupons",{body:j});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),c(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(j){console.error("Error creating coupon:",j),t({title:"Error",description:j.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},v=async j=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:k}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:j}});if(k)throw k;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(k){console.error("Error deleting coupon:",k),t({title:"Error",description:k.message||"Failed to delete coupon",variant:"destructive"})}},_=j=>j.percent_off?`${j.percent_off}% off`:j.amount_off?`$${(j.amount_off/100).toFixed(2)} off`:"N/A",w=j=>{switch(j.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${j.duration_in_months} months`;default:return j.duration}};return e.jsx(Ts,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(xs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create New Coupon"}),e.jsx(Wr,{children:"Create a discount coupon that can be applied to subscriptions"})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Promotion Code (what users will type)"}),e.jsx(ze,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:j=>p({...u,promotionCode:j.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Coupon Name (internal label)"}),e.jsx(ze,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:j=>p({...u,name:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Discount Type"}),e.jsxs(Ks,{value:u.discountType,onValueChange:j=>{const k=j==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:j,duration:k})},children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(yS,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(Mt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(hl,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:j=>p({...u,percentOff:j.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Amount Off (USD)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(ze,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:j=>p({...u,amountOff:j.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Duration"}),e.jsxs(Ks,{value:u.duration,onValueChange:j=>p({...u,duration:j}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"once",children:"Once (first payment only)"}),e.jsx(Mt,{value:"repeating",children:"Multiple months"}),e.jsxs(Mt,{value:"forever",disabled:u.discountType==="amount",children:["Forever ",u.discountType==="amount"&&"(% discounts only)"]})]})]}),u.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),u.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Number of Months"}),e.jsx(ze,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:j=>p({...u,durationInMonths:j.target.value})})]}),e.jsx(K,{onClick:g,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Active Coupons"}),e.jsx(gr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Promo Code"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Discount"}),e.jsx(St,{children:"Duration"}),e.jsx(St,{children:"Redemptions"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:s.map(j=>{var k;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((k=j.promotion_codes)==null?void 0:k.length)>0?j.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:j.name||"-"}),e.jsx(dt,{children:_(j)}),e.jsx(dt,{children:w(j)}),e.jsx(dt,{children:j.times_redeemed}),e.jsx(dt,{children:e.jsx(st,{variant:j.valid?"default":"secondary",children:j.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(j.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})})]},j.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const Sye={prod_Tc07cYplXUGNkm:{name:"Individual Agent",price:"$39/mo",type:"individual"},prod_Tc08MupgoVySDG:{name:"Brokerage (Under 25)",price:"$299/mo",type:"brokerage"},prod_Tc09N1tJ4RrAFn:{name:"Brokerage (Over 25)",price:"$499/mo",type:"brokerage"}};function J1s(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState(null),{data:l,isLoading:i,refetch:c}=mt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:_,error:w}=await H.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return _}}),{data:u}=mt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:_,error:w}=await H.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((_||[]).map(async k=>{const{data:S}=await H.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",k.id),{data:M}=await H.from("user_roles").select("user_id").eq("role","brokerage_manager"),L=(M==null?void 0:M.map($=>$.user_id))||[],P=(S==null?void 0:S.filter($=>L.includes($.id)))||[],O=(S==null?void 0:S.length)||0;return{...k,managers:P,agentCount:O}}))}}),p=_=>{if(_.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(_.brokerage_id&&!_.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(_.is_trial&&_.trial_expires_at)return new Date(_.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(_.subscription_status==="active"||_.subscription_status==="trialing"){const w=Sye[_.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:_.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return _.subscription_status==="canceled"||_.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},f=l==null?void 0:l.filter(_=>{var j,k;if(!(((j=_.name)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||((k=_.email)==null?void 0:k.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(_),r){case"active":return _.subscription_status==="active";case"trialing":return _.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date;case"grandfathered":return _.is_grandfathered;case"brokerage":return _.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered;case"expired":return _.subscription_status==="canceled"||_.subscription_status==="past_due"||_.is_trial&&new Date(_.trial_expires_at)<=new Date;case"none":return!_.subscription_status||_.subscription_status==="none";default:return!0}}),g={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(_=>_.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(_=>_.subscription_status==="trialing"||_.is_trial&&new Date(_.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(_=>_.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(_=>_.brokerage_id&&!_.subscription_product_id&&!_.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&_.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(_=>_.subscription_status==="active"&&(_.subscription_product_id==="prod_Tc08MupgoVySDG"||_.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},v=_=>{window.open(`https://dashboard.stripe.com/customers/${_}`,"_blank")};return e.jsx(Ts,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>c(),variant:"outline",size:"sm",children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mx,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active Paid"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-green-600",children:g.activeSubscriptions})]})}),e.jsx(Ee,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:g.trials})]})}),e.jsx(Ee,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dm,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Grandfathered"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-purple-600",children:g.grandfathered})]})}),e.jsx(Ee,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:g.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X_,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Individual"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:g.brokerageSubscribers})]})})]}),e.jsxs(_a,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"users",children:"All Users"}),e.jsx(ns,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(ws,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:r,onValueChange:_=>n(_),children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Users"}),e.jsx(Mt,{value:"active",children:"Active Subscriptions"}),e.jsx(Mt,{value:"trialing",children:"Trials"}),e.jsx(Mt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(Mt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(Mt,{value:"expired",children:"Expired/Canceled"}),e.jsx(Mt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"User"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Plan"}),e.jsx(St,{children:"Brokerage"}),e.jsx(St,{children:"End Date"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:i?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(_=>{var k,S;const w=p(_),j=Sye[_.subscription_product_id];return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:_.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_.email})]})}),e.jsx(dt,{children:e.jsx(st,{variant:w.variant,children:w.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:_.is_grandfathered?"Legacy Access":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||w.status})}),e.jsx(dt,{children:(k=_.brokerages)!=null&&k.name?e.jsx("span",{className:"text-sm",children:_.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:_.subscription_end_date?e.jsx("span",{className:"text-sm",children:ms(new Date(_.subscription_end_date),"MMM d, yyyy")}):_.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ms(new Date(_.trial_expires_at),"MMM d, yyyy")]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[_.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(_.stripe_customer_id),children:e.jsx(en,{className:"h-4 w-4"})}),e.jsxs(xs,{children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(_),children:"Details"})}),e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Subscription Details"}),e.jsxs(Wr,{children:[_.name," (",_.email,")"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(st,{variant:w.variant,className:"mt-1",children:w.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:_.is_grandfathered?"Grandfathered (Legacy)":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||"None"})]}),_.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=_.brokerages)==null?void 0:S.name)||"Unknown"})]}),_.subscription_end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.subscription_end_date),"MMMM d, yyyy")})]}),_.trial_expires_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),e.jsx("p",{className:"font-medium",children:ms(new Date(_.trial_expires_at),"MMMM d, yyyy")})]}),_.stripe_customer_id&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),e.jsx("p",{className:"font-mono text-sm",children:_.stripe_customer_id})]})]}),_.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>v(_.stripe_customer_id),children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},_.id)})})]})})})]}),e.jsx(ws,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(_=>{var j,k;const w=(j=_.managers)==null?void 0:j.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Ca,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:_.name}),e.jsxs(gr,{children:[_.agentCount," agents"]})]})]}),e.jsx(st,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((k=_.managers)==null?void 0:k.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),_.managers.map(S=>{const M=Sye[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:M?e.jsxs("div",{children:[e.jsx(st,{variant:"default",children:M.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.price})]}):e.jsx(st,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},_.id)})})})]})]})})}function ebs(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(""),[l,i]=N.useState("all"),[c,u]=N.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});N.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:_,error:w}=await H.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(w)throw w;s(_||[]);const j=(_==null?void 0:_.filter(M=>M.status==="qualified").length)||0,k=(_==null?void 0:_.filter(M=>M.status==="pending").length)||0,S=(_==null?void 0:_.filter(M=>M.status==="cancelled").length)||0;u({total:(_==null?void 0:_.length)||0,qualified:j,pending:k,cancelled:S,totalDiscounts:j*25})}catch(_){console.error("Error fetching referrals:",_),me.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{me.loading("Processing qualifications...");const{error:_}=await H.functions.invoke("process-referral-qualifications");if(_)throw _;me.dismiss(),me.success("Qualifications processed successfully"),p()}catch(_){me.dismiss(),console.error("Error processing qualifications:",_),me.error("Failed to process qualifications")}},g=t.filter(_=>{var k,S,M,L,P,O;const w=((S=(k=_.referrer_brokerage)==null?void 0:k.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((L=(M=_.referred_brokerage)==null?void 0:M.name)==null?void 0:L.toLowerCase().includes(a.toLowerCase()))||((O=(P=_.referred_user)==null?void 0:P.email)==null?void 0:O.toLowerCase().includes(a.toLowerCase())),j=l==="all"||_.status===l;return w&&j}),v=_=>{switch(_){case"qualified":return e.jsxs(st,{className:"bg-green-100 text-green-800",children:[e.jsx(gi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(st,{variant:"secondary",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(st,{variant:"destructive",children:[e.jsx(jc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(st,{children:_})}};return e.jsx(Ts,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jc,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hl,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",c.totalDiscounts]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"All Referrals"}),e.jsx(gr,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by brokerage or email...",value:a,onChange:_=>o(_.target.value),className:"pl-10"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"qualified",children:"Qualified"}),e.jsx(Mt,{value:"cancelled",children:"Cancelled"})]})]})]}),r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Referrer"}),e.jsx(St,{children:"Referred"}),e.jsx(St,{children:"Signup Date"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Qualified Date"}),e.jsx(St,{children:"Discount"})]})}),e.jsx(Bn,{children:g.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):g.map(_=>{var w,j,k,S;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:((w=_.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((j=_.referred_brokerage)==null?void 0:j.name)||((k=_.referred_user)==null?void 0:k.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=_.referred_user)==null?void 0:S.email})]})}),e.jsx(dt,{children:ms(new Date(_.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:v(_.status)}),e.jsx(dt,{children:_.qualified_date?ms(new Date(_.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:_.discount_applied?e.jsx(st,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},_.id)})})]})]})]})]})})}const Cye=[{value:"add_agent",label:"Add Agent"},{value:"share_resource",label:"Share Resource"},{value:"post_community",label:"Post in Community"},{value:"register_event",label:"Register for Event"},{value:"view_template",label:"View Template"},{value:"watch_academy",label:"Watch Academy Video"},{value:"use_toolbox",label:"Use Toolbox"},{value:"launch_app",label:"Launch App"},{value:"add_contact",label:"Add Contact"},{value:"add_plan",label:"Add Touchpoint Plan"},{value:"create_video",label:"Create Video"},{value:"complete_touch",label:"Complete Touch"},{value:"add_transaction",label:"Add Transaction"},{value:"add_listing",label:"Add Listing"},{value:"schedule_popby",label:"Schedule Pop-by"}],tbs=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function sbs(){const[t,s]=N.useState([]),[r,n]=N.useState(!0),[a,o]=N.useState(!1),[l,i]=N.useState(null),[c,u]=N.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});N.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:S,error:M}=await H.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(M)throw M;s(S||[])}catch(S){console.error("Error fetching checklist items:",S),me.error("Failed to load checklist items")}finally{n(!1)}},f=()=>{i(null),u({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},g=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},v=async()=>{if(!c.title.trim()){me.error("Title is required");return}try{if(l){const{error:S}=await H.from("onboarding_checklist_items").update({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active}).eq("id",l.id);if(S)throw S;me.success("Checklist item updated")}else{const S=t.filter(L=>L.target_role===c.target_role).reduce((L,P)=>Math.max(L,P.sort_order),-1),{error:M}=await H.from("onboarding_checklist_items").insert({title:c.title,description:c.description||null,action_type:c.action_type,target_role:c.target_role,is_active:c.is_active,sort_order:S+1});if(M)throw M;me.success("Checklist item created")}o(!1),p()}catch(S){console.error("Error saving checklist item:",S),me.error("Failed to save checklist item")}},_=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:M}=await H.from("onboarding_checklist_items").delete().eq("id",S);if(M)throw M;me.success("Checklist item deleted"),p()}catch(M){console.error("Error deleting checklist item:",M),me.error("Failed to delete checklist item")}},w=async S=>{try{const{error:M}=await H.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(M)throw M;me.success(S.is_active?"Item deactivated":"Item activated"),p()}catch(M){console.error("Error toggling item:",M),me.error("Failed to update item")}},j=t.filter(S=>S.target_role==="brokerage_manager"),k=t.filter(S=>S.target_role==="agent");return e.jsxs(Ts,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(st,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:j.map((S,M)=>{var L;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((L=Cye.find(P=>P.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(st,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:k.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:k.map((S,M)=>{var L;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"text-muted-foreground",children:M+1}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:S.description})]})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((L=Cye.find(P=>P.value===S.action_type))==null?void 0:L.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(qr,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(S),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(xs,{open:a,onOpenChange:o,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:c.title,onChange:S=>u({...c,title:S.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",value:c.description,onChange:S=>u({...c,description:S.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Target Role"}),e.jsxs(Ks,{value:c.target_role,onValueChange:S=>u({...c,target_role:S}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:tbs.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Action Type"}),e.jsxs(Ks,{value:c.action_type,onValueChange:S=>u({...c,action_type:S}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Cye.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:c.is_active,onCheckedChange:S=>u({...c,is_active:S})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:v,children:l?"Save Changes":"Create Item"})]})]})})]})}function rbs(){const[t,s]=N.useState(""),[r,n]=N.useState("all"),[a,o]=N.useState("name"),[l,i]=N.useState("asc"),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState(""),{data:j}=mt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:X}=await H.from("brokerages").select("id, name").order("name");if(X)throw X;return V}}),k=async V=>{let Y=[],ee=0,Q=!0;for(;Q;){const{data:ce,error:ne}=await V(ee,ee+1e3-1);if(ne)throw ne;ce&&ce.length>0?(Y=[...Y,...ce],ee+=1e3,Q=ce.length===1e3):Q=!1}return Y},{data:S,isLoading:M}=mt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await k((pe,we)=>H.from("profiles").select("id, name, email, brokerage_id, created_at").range(pe,we)),{data:X}=await H.from("brokerages").select("id, name"),Y=new Map((X==null?void 0:X.map(pe=>[pe.id,pe.name]))||[]),[{data:ee},{data:Q},{data:ce},{data:ne},{data:re},{data:oe},{data:fe}]=await Promise.all([H.rpc("get_admin_contact_counts"),H.rpc("get_admin_video_counts"),H.rpc("get_admin_popby_counts"),H.rpc("get_admin_listing_counts"),H.rpc("get_admin_deal_counts"),H.rpc("get_admin_portal_counts"),H.rpc("get_admin_sendable_card_counts")]),ge=new Map;ee==null||ee.forEach(pe=>ge.set(pe.owner_user_id,pe.contact_count));const ue=new Map;Q==null||Q.forEach(pe=>ue.set(pe.owner_user_id,pe.video_count));const xe=new Map;ce==null||ce.forEach(pe=>xe.set(pe.owner_user_id,pe.popby_count));const _e=new Map;ne==null||ne.forEach(pe=>_e.set(pe.agent_id,pe.listing_count));const $e=new Map;re==null||re.forEach(pe=>$e.set(pe.owner_user_id,pe.deal_count));const Me=new Map;oe==null||oe.forEach(pe=>Me.set(pe.owner_user_id,{total:pe.portal_count,active:pe.active_portal_count}));const Ie=new Map;return fe==null||fe.forEach(pe=>Ie.set(pe.owner_user_id,{total:pe.card_count,sent:pe.sent_card_count,views:pe.total_card_views})),V.map(pe=>{const we=Me.get(pe.id),Le=Ie.get(pe.id);return{id:pe.id,name:pe.name||"Unknown",email:pe.email||"",brokerage_id:pe.brokerage_id,brokerage_name:pe.brokerage_id&&Y.get(pe.brokerage_id)||null,contact_count:ge.get(pe.id)||0,video_count:ue.get(pe.id)||0,popby_count:xe.get(pe.id)||0,listing_count:_e.get(pe.id)||0,deal_count:$e.get(pe.id)||0,portal_count:(we==null?void 0:we.total)||0,active_portal_count:(we==null?void 0:we.active)||0,card_count:(Le==null?void 0:Le.total)||0,sent_card_count:(Le==null?void 0:Le.sent)||0,total_card_views:(Le==null?void 0:Le.views)||0,created_at:pe.created_at}})}}),L=N.useMemo(()=>{if(!S)return[];let V=S.filter(X=>{const Y=t.toLowerCase(),ee=!t||X.name.toLowerCase().includes(Y)||X.email.toLowerCase().includes(Y),Q=r==="all"||r==="none"&&!X.brokerage_id||X.brokerage_id===r,ce=parseInt(c)||0,ne=parseInt(p)||0,re=parseInt(g)||0,oe=parseInt(_)||0,fe=X.contact_count>=ce&&X.video_count>=ne&&X.popby_count>=re&&X.listing_count>=oe;return ee&&Q&&fe});return V.sort((X,Y)=>{let ee=0;return a==="name"?ee=X.name.localeCompare(Y.name):ee=X[a]-Y[a],l==="asc"?ee:-ee}),V},[S,t,r,a,l,c,p,g,_]),P=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},O=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],X=L.map(ne=>[ne.name,ne.email,ne.brokerage_name||"None",ne.contact_count,ne.video_count,ne.popby_count,ne.listing_count,ne.deal_count,`${ne.portal_count} (${ne.active_portal_count})`,ne.card_count,ne.sent_card_count,ne.total_card_views]),Y=[V.join(","),...X.map(ne=>ne.map(re=>`"${re}"`).join(","))].join(` `),ee=new Blob([Y],{type:"text/csv"}),Q=URL.createObjectURL(ee),ce=document.createElement("a");ce.href=Q,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(Q)},$=N.useMemo(()=>L.length?L.reduce((V,X)=>({contacts:V.contacts+X.contact_count,videos:V.videos+X.video_count,popbys:V.popbys+X.popby_count,listings:V.listings+X.listing_count,deals:V.deals+X.deal_count,portals:V.portals+X.portal_count,activePortals:V.activePortals+X.active_portal_count,cards:V.cards+X.card_count,sentCards:V.sentCards+X.sent_card_count,cardViews:V.cardViews+X.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[L]),U=N.useMemo(()=>L.length?{portals:L.filter(V=>V.portal_count>0).length,cards:L.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[L]),B=({field:V,children:X})=>e.jsx(St,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>P(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[X,e.jsx(_d,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(G1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(l1,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:U.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:$.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(gr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:O,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:t,onChange:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsxs(Gs,{children:[e.jsx(Ca,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Brokerage"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),j==null?void 0:j.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min contacts",value:c,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min videos",value:p,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(ze,{type:"number",placeholder:"Min popbys",value:g,onChange:V=>v(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:L.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),M?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Brokerage"}),e.jsx(B,{field:"contact_count",children:"Contacts"}),e.jsx(B,{field:"video_count",children:"Videos"}),e.jsx(B,{field:"popby_count",children:"Popbys"}),e.jsx(B,{field:"listing_count",children:"Listings"}),e.jsx(B,{field:"deal_count",children:"Deals"}),e.jsx(B,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l1,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(B,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Bn,{children:L.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):L.map(V=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:V.name}),e.jsx(dt,{className:"text-muted-foreground",children:V.email}),e.jsx(dt,{children:V.brokerage_name?e.jsx(st,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(st,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(st,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(Nc,{children:[e.jsx(kc,{children:e.jsxs(st,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[V.portal_count,V.active_portal_count>0&&e.jsxs("span",{className:"ml-1 opacity-75",children:["(",V.active_portal_count," active)"]})]})}),e.jsxs(ec,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(st,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(Nc,{children:[e.jsx(kc,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(st,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:V.card_count}),V.sent_card_count>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[e.jsx($n,{className:"h-3 w-3"}),V.sent_card_count]}),V.total_card_views>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(Dn,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(ec,{children:[e.jsxs("p",{children:[V.card_count," cards created"]}),e.jsxs("p",{children:[V.sent_card_count," sent"]}),e.jsxs("p",{children:[V.total_card_views," total views"]})]})]}):e.jsx(st,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function nbs(){Ha(),Xt();const[t,s]=N.useState("user-analytics"),{data:r}=mt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:v,error:_}=await H.from("feature_flags").select("*").order("key");if(_)throw _;return v}}),{data:n,isLoading:a}=mt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:v,error:_}=await H.from("relationship_types").select("*").order("sort_order");if(_)throw _;return v}}),{data:o,isLoading:l}=mt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:v,error:_}=await H.from("action_types").select("*").order("sort_order");if(_)throw _;return v}}),{data:i,isLoading:c}=mt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:v,error:_}=await H.from("action_scripts").select("*, action_type:action_types(*)");if(_)throw _;return v}}),{data:u,isLoading:p}=mt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:v,error:_}=await H.from("touchpoint_plans").select("*").order("name");if(_)throw _;return v}}),{data:f,isLoading:g}=mt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:v,error:_}=await H.from("popby_items").select("*").is("owner_user_id",null).order("name");if(_)throw _;return v}});return e.jsx(Ts,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(_a,{value:t,onValueChange:s,children:[e.jsxs(fa,{className:"grid w-full grid-cols-9",children:[e.jsxs(ns,{value:"user-analytics",className:"gap-2",children:[e.jsx(yo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(ns,{value:"relationship-types",className:"gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(ns,{value:"action-types",className:"gap-2",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(ns,{value:"scripts",className:"gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(ns,{value:"video-scripts",className:"gap-2",children:[e.jsx(yu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(ns,{value:"plans",className:"gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(ns,{value:"popbys",className:"gap-2",children:[e.jsx(So,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(ns,{value:"settings",className:"gap-2",children:[e.jsx(Qo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(ns,{value:"feature-flags",className:"gap-2",children:[e.jsx(d1,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(ws,{value:"user-analytics",className:"mt-6",children:e.jsx(rbs,{})}),e.jsx(ws,{value:"relationship-types",className:"mt-6",children:e.jsx(abs,{types:n||[],isLoading:a})}),e.jsx(ws,{value:"action-types",className:"mt-6",children:e.jsx(ibs,{types:o||[],isLoading:l})}),e.jsx(ws,{value:"scripts",className:"mt-6",children:e.jsx(obs,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx(ws,{value:"video-scripts",className:"mt-6",children:e.jsx(ubs,{})}),e.jsx(ws,{value:"plans",className:"mt-6",children:e.jsx(lbs,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(ws,{value:"popbys",className:"mt-6",children:e.jsx(dbs,{items:f||[],isLoading:g})}),e.jsx(ws,{value:"settings",className:"mt-6",children:e.jsx(hbs,{})}),e.jsx(ws,{value:"feature-flags",className:"mt-6",children:e.jsx(cbs,{flags:r||[]})})]})]})})}function abs({types:t,isLoading:s}){const{toast:r}=Ha(),n=Xt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Lt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Relationship Types"}),e.jsx(gr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-12"}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(p=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(za,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Relationship Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function ibs({types:t,isLoading:s}){const{toast:r}=Ha(),n=Xt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Lt({mutationFn:async p=>{if(p.id){const{error:f}=await H.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await H.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await H.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Action Types"}),e.jsx(gr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Color"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(p=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:p.name}),e.jsx(dt,{className:"text-muted-foreground",children:p.description}),e.jsx(dt,{children:p.color&&e.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),e.jsx(dt,{children:e.jsx(qr,{checked:p.active,onCheckedChange:()=>u(p)})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:e.jsx(za,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Action Type"]})}),e.jsxs("form",{onSubmit:p=>{p.preventDefault();const f=new FormData(p.currentTarget);c.mutate({id:a==null?void 0:a.id,name:f.get("name"),description:f.get("description"),icon:f.get("icon"),color:f.get("color")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"icon",children:"Icon"}),e.jsx(ze,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"color",children:"Color"}),e.jsx(ze,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function obs({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ha(),a=Xt(),[o,l]=N.useState(null),[i,c]=N.useState(!1),u=Lt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(g)throw g}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),c(!1),l(null),n({title:"Saved successfully"})},onError:f=>{n({title:"Error",description:f.message,variant:"destructive"})}}),p=Lt({mutationFn:async f=>{const{error:g}=await H.from("action_scripts").delete().eq("id",f);if(g)throw g},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Script Library"}),e.jsx(gr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),c(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Action Type"}),e.jsx(St,{children:"Tone"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(f=>{var g;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",children:((g=f.action_type)==null?void 0:g.name)||"Unknown"})}),e.jsx(dt,{className:"text-muted-foreground",children:f.tone}),e.jsx(dt,{children:e.jsx(st,{variant:f.active?"default":"secondary",children:f.active?"Active":"Inactive"})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{l(f),c(!0)},children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:g.get("title"),action_type_id:g.get("action_type_id"),tone:g.get("tone"),script_body:g.get("script_body"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Ks,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select action type"})}),e.jsx(Ws,{children:s.map(f=>e.jsx(Mt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(ze,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Pr,{id:"script_body",name:"script_body",defaultValue:o==null?void 0:o.script_body,rows:8,required:!0,placeholder:`Use {{FirstName}}, {{LastName}}, and {{AgentName}} as placeholders. Example: Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in...`})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:u.isPending,children:[u.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function lbs({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ha(),o=Xt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(null),[g,v]=N.useState(!1),[_,w]=N.useState(null),[j,k]=N.useState(null),{data:S}=mt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:B,error:V}=await H.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return B},enabled:!!p}),M=Lt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plans").update({name:B.name,description:B.description,active:B.active}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plans").insert([{name:B.name,description:B.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),L=Lt({mutationFn:async B=>{if(B.id){const{error:V}=await H.from("touchpoint_plan_items").update({action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}).eq("id",B.id);if(V)throw V}else{const{error:V}=await H.from("touchpoint_plan_items").insert([{plan_id:B.plan_id,month_number:B.month_number,action_type_id:B.action_type_id,default_script_id:B.default_script_id,notes:B.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),P=Lt({mutationFn:async B=>{const{error:V}=await H.from("touchpoint_plan_items").delete().eq("id",B);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),O=Lt({mutationFn:async B=>{const{data:V,error:X}=await H.from("action_scripts").insert([{...B,active:!0}]).select().single();if(X)throw X;return V},onSuccess:async B=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),_&&await L.mutateAsync({id:_.itemId,plan_id:p,month_number:_.month,action_type_id:_.actionTypeId,default_script_id:B.id}),v(!1),w(null),a({title:"Script created and assigned"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),$=(B,V,X)=>{w({month:B,actionTypeId:V,itemId:X}),v(!0)},U=B=>r.find(V=>V.id===B);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Touchpoint Plans"}),e.jsx(gr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(B=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===B.id?"border-primary":""}`,onClick:()=>f(B.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:B.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(B),u(!0)},children:e.jsx(za,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:B.description}),e.jsx(st,{variant:B.active?"default":"secondary",className:"mt-2",children:B.active?"Active":"Inactive"})]})]},B.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Plan Schedule"}),e.jsx(gr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(B,V)=>V+1).map(B=>{const V=S==null?void 0:S.find(ee=>ee.month_number===B),X=V!=null&&V.default_script_id?U(V.default_script_id):null,Y=r.filter(ee=>ee.action_type_id===(V==null?void 0:V.action_type_id)&&ee.active);return e.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",B]}),e.jsxs(Ks,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:ee=>{ee==="none"&&V?P.mutate(V.id):ee!=="none"&&L.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:B,action_type_id:ee,default_script_id:null})},children:[e.jsx(Gs,{className:"w-40",children:e.jsx(Ys,{placeholder:"No action"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No action"}),s.filter(ee=>ee.active).map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[ee.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(Ks,{value:V.default_script_id||"none",onValueChange:ee=>{k(null),L.mutate({id:V.id,default_script_id:ee==="none"?null:ee})},children:[e.jsx(Gs,{className:"w-56",children:e.jsx(Ys,{placeholder:"Select script"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No default script"}),Y.map(ee=>e.jsxs(Mt,{value:ee.id,children:[ee.title," ",ee.tone&&`(${ee.tone})`]},ee.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>$(B,V.action_type_id,V.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"New Script"]}),X&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k((j==null?void 0:j.id)===X.id?null:X),children:(j==null?void 0:j.id)===X.id?"Hide":"Preview"})]})]}),j&&(V==null?void 0:V.default_script_id)===j.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{variant:"outline",children:j.title}),j.tone&&e.jsx(st,{variant:"secondary",children:j.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:j.script_body})]})]},B)})})})]}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);M.mutate({id:l==null?void 0:l.id,name:V.get("name"),description:V.get("description"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:M.isPending,children:[M.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(xs,{open:g,onOpenChange:v,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create New Script"}),e.jsxs(Wr,{children:["Create a script for Month ",_==null?void 0:_.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:B=>{B.preventDefault();const V=new FormData(B.currentTarget);O.mutate({title:V.get("title"),action_type_id:_.actionTypeId,tone:V.get("tone"),script_body:V.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_title",children:"Title"}),e.jsx(ze,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_tone",children:"Tone"}),e.jsx(ze,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Pr,{id:"script_body",name:"script_body",rows:6,required:!0,placeholder:"Hey {{FirstName}}, it's {{AgentName}}. I was thinking about you and wanted to check in..."})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:O.isPending,children:[O.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function cbs({flags:t}){const{toast:s}=Ha(),r=Xt(),n=async(a,o)=>{const{error:l}=await H.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Feature Flags"}),e.jsx(gr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Flag"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Notes"}),e.jsx(St,{children:"Last Updated"})]})}),e.jsx(Bn,{children:t.map(a=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx(qr,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(dt,{children:e.jsx(ze,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function dbs({items:t,isLoading:s}){const{toast:r}=Ha(),n=Xt(),[a,o]=N.useState(null),[l,i]=N.useState(!1),c=Lt({mutationFn:async f=>{if(f.id){const{error:g}=await H.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(g)throw g}else{const{error:g}=await H.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await H.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await H.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Popby Ideas"}),e.jsx(gr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No popby ideas yet. Add your first one!"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(f=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:f.name}),e.jsx(dt,{className:"text-muted-foreground",children:f.description}),e.jsx(dt,{children:e.jsx(qr,{checked:f.is_active,onCheckedChange:()=>u(f)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{o(f),i(!0)},children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const g=new FormData(f.currentTarget);c.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:c.isPending,children:[c.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function ubs(){var v;const{toast:t}=Ha(),s=Xt(),[r,n]=N.useState(null),[a,o]=N.useState(!1),{data:l,isLoading:i}=mt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:_,error:w}=await H.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return _}}),{data:c,isLoading:u}=mt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:_,error:w}=await H.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return _}}),p=Lt({mutationFn:async _=>{var w,j;if(_.id){const{error:k}=await H.from("video_scripts").update({title:_.title,script_text:_.script_text,category_id:_.category_id,tags:((w=_.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",_.id);if(k)throw k}else{const{error:k}=await H.from("video_scripts").insert([{title:_.title,script_text:_.script_text,category_id:_.category_id||null,tags:((j=_.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(k)throw k}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:_=>t({title:"Error",description:_.message,variant:"destructive"})}),f=async _=>{await H.from("video_scripts").update({is_active:!_.is_active}).eq("id",_.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},g=async _=>{confirm("Delete this video script?")&&(await H.from("video_scripts").delete().eq("id",_),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Video Scripts"}),e.jsx(gr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Title"}),e.jsx(St,{children:"Category"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"w-24",children:"Actions"})]})}),e.jsx(Bn,{children:c==null?void 0:c.map(_=>{var w;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:_.title}),e.jsx(dt,{className:"text-muted-foreground",children:((w=_.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx(qr,{checked:_.is_active,onCheckedChange:()=>f(_)})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(_),o(!0)},children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(_.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},_.id)})})]})}),e.jsx(xs,{open:a,onOpenChange:o,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const w=new FormData(_.currentTarget);p.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"category_id",children:"Category"}),e.jsxs(Ks,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:l==null?void 0:l.map(_=>e.jsx(Mt,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Pr,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(ze,{id:"tags",name:"tags",defaultValue:((v=r==null?void 0:r.tags)==null?void 0:v.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(Un,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[p.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function hbs(){const{toast:t}=Ha(),[s,r]=N.useState(""),[n,a]=N.useState(!0),[o,l]=N.useState(!1);N.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await H.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ia,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(gr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(ze,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:s,onChange:c=>r(c.target.value)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",e.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"}),". This token will be used by all agents for the popby map feature."]})]}),e.jsxs(K,{onClick:i,disabled:o,children:[o&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(st,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const mbs=()=>{const[t,s]=N.useState(""),[r,n]=N.useState("grid"),a=nr(),{data:o=[],isLoading:l}=mt({queryKey:["additional-services"],queryFn:async()=>{const{data:c,error:u}=await H.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(u)throw u;return c}}),i=o.filter(c=>{var p;return c.name.toLowerCase().includes(t.toLowerCase())||((p=c.description)==null?void 0:p.toLowerCase().includes(t.toLowerCase()))});return e.jsx(Ts,{title:"Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search services...",value:t,onChange:c=>s(c.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex gap-2",children:[t&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:r==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(rh,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((c,u)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(vs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(vs,{className:"h-5 w-3/4 mb-2"}),e.jsx(vs,{className:"h-4 w-full mb-4"})]})},u))}),!l&&i.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No services match your search":"No additional services available yet"}),t&&e.jsx(K,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:i.map(c=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${r==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${c.id}`),children:[e.jsx("div",{className:`relative overflow-hidden bg-muted ${r==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:c.preview_image_url?e.jsx("img",{src:c.preview_image_url,alt:c.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(fn,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:c.name}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:Lde(c.description)})]})]},c.id))})]})})},pbs=()=>{const{serviceId:t}=lo(),s=nr(),{data:r,isLoading:n}=mt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await H.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Ts,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(vs,{className:"h-8 w-48"}),e.jsx(vs,{className:"h-64 w-full rounded-lg"}),e.jsx(vs,{className:"h-24 w-full"})]})}):r?e.jsx(Ts,{title:r.name,children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/additional-services"),className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative bg-muted",children:r.preview_image_url?e.jsx("img",{src:r.preview_image_url,alt:r.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):e.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:e.jsx(fn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4 mr-1"}),"Published ",ms(new Date(r.publish_date),"MMMM d, yyyy")]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:r.description}}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs(K,{size:"lg",className:"gap-2",onClick:()=>window.open(r.signup_link_url,"_blank"),children:[e.jsx(en,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),e.jsxs(K,{onClick:()=>s("/additional-services"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},vI=[{id:"content-calendar",name:"Social Media Content Calendar Generator",iframe:``},{id:"property-promotion",name:"Property Promotion AI Tool",iframe:''},{id:"bio-boost",name:"Realtor Bio-Boost",iframe:''},{id:"market-report",name:"Market Report & Video Script Generator",iframe:''},{id:"property-description",name:"Property Description Writer",iframe:''},{id:"newsletter-generator",name:"Local Real Estate Newsletter Generator",iframe:''}];function fbs(){const[t,s]=N.useState(vI[0].id),r=vI.find(n=>n.id===t)||vI[0];return e.jsx(Ts,{title:"AI Toolkit",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(LM,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"AI Toolkit"}),e.jsx("p",{className:"text-muted-foreground",children:"Powerful AI tools to boost your real estate business"})]})]}),e.jsx("div",{className:"md:hidden",children:e.jsxs(Ks,{value:t,onValueChange:s,children:[e.jsx(Gs,{className:"w-full",children:e.jsx(Ys,{placeholder:"Select a tool"})}),e.jsx(Ws,{children:vI.map(n=>e.jsx(Mt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(_a,{value:t,onValueChange:s,className:"w-full",children:e.jsx(fa,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:vI.map(n=>e.jsx(ns,{value:n.id,className:"flex-1 min-w-[150px] text-xs lg:text-sm whitespace-normal h-auto py-2",children:n.name},n.id))})})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-full max-w-[700px]",dangerouslySetInnerHTML:{__html:r.iframe}})})]})})}const o7e="agent-os-onboarding-completed",n9=[{icon:v0,iconColor:"text-white",bgGradient:"from-primary via-primary/80 to-purple-600",title:"Welcome to Agent OS",description:"You've unlocked a powerful new tool designed to help you build stronger relationships and close more deals. Agent OS is currently in beta, and we're excited for you to try it!",highlights:["Manage your most important relationships","Stay in touch with automated reminders","Track your transactions and goals","Maximize referrals from your sphere"]},{icon:Yh,iconColor:"text-white",bgGradient:"from-pink-500 via-rose-500 to-red-500",title:"InnerCircle Home",description:"Your daily command center. See today's action items, track your momentum streak, and get a snapshot of your relationship health—all at a glance.",highlights:["Today's touchpoints and special dates","Momentum stats and streak tracking","Relationship health overview","Quick access to all features"]},{icon:hr,iconColor:"text-white",bgGradient:"from-blue-500 via-indigo-500 to-purple-500",title:"Contacts",description:"Import and organize your sphere of influence. Tag contacts by relationship type (Top 25, Past Clients, Referral Partners, etc.) to prioritize your outreach.",highlights:["Import contacts via CSV","Tag by relationship type","Track birthdays and home anniversaries","See relationship health scores"]},{icon:Od,iconColor:"text-white",bgGradient:"from-emerald-500 via-teal-500 to-cyan-500",title:"Touchpoint Plans",description:"Assign automated touchpoint schedules to your contact groups. Each plan tells you exactly who to reach out to and when—with pre-written scripts to make it easy.",highlights:["Pre-built 12-month plans","Create your own custom plans","Scripts for calls, texts, and emails","Automatic daily action items"]},{icon:So,iconColor:"text-white",bgGradient:"from-orange-500 via-amber-500 to-yellow-500",title:"Popbys",description:"Pop-by visits are one of the most powerful ways to stay top-of-mind. Track your gift drop-offs and see who's due for a visit on the map.",highlights:["Track pop-by gift ideas","Set visit frequency by contact type","Log completed pop-bys","Map view for route planning"]},{icon:yo,iconColor:"text-white",bgGradient:"from-purple-500 via-violet-500 to-indigo-500",title:"Scorecard",description:"Track your transactions, set goals, and see your progress over time. Know exactly where your business stands and where your deals are coming from.",highlights:["Log buyer and seller transactions","Set and track annual goals","See your top lead sources","Export data for your records"]}],xbs=()=>{const[t,s]=N.useState(!1),[r,n]=N.useState(0),[a,o]=N.useState(!1);N.useEffect(()=>{if(!localStorage.getItem(o7e)){const _=setTimeout(()=>s(!0),500);return()=>clearTimeout(_)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem(o7e,"true"),s(!1)},u=n9[r],p=u.icon,f=r===n9.length-1,g=v=>{v||c(),s(v)};return e.jsx(xs,{open:t,onOpenChange:g,children:e.jsxs(fs,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(fn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(js,{className:"text-center sm:text-center pb-2",children:[e.jsx(_s,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.title}),e.jsx(Wr,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((v,_)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+_*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(ba,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:v})]},_))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:n9.map((v,_)=>e.jsx("button",{onClick:()=>{_!==r&&(o(!0),setTimeout(()=>{n(_),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${_===r?"w-8 bg-gradient-to-r "+u.bgGradient:_{const{user:t}=Os();return mt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},ybs=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=Il(new Date,n);await H.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await H.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),jn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{jn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},vbs=()=>{const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),jn({title:"Snooze cancelled"})},onError:s=>{jn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},bbs=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function eme({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=N.useState(null),l=ybs(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ms(Il(new Date,u),"MMM d, yyyy");return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Wr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:bbs.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:It("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"Until ",c(u.days)]})]},u.days))}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const _bs={Crown:Dm,FileText:wn,Users:hr,Globe:ru,Star:Jn,Phone:Mn,MessageSquare:so,PenTool:Y_,Video:Cn,Gift:So};function wbs({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=nr(),[c,u]=N.useState("name"),[p,f]=N.useState("asc"),[g,v]=N.useState(null),[_,w]=N.useState(""),j=P=>{c===P?f(O=>O==="asc"?"desc":"asc"):(u(P),f("asc"))},k=N.useMemo(()=>[...t].sort((P,O)=>{var U,B;let $=0;switch(c){case"name":{const V=`${P.contact.first_name} ${P.contact.last_name||""}`.toLowerCase(),X=`${O.contact.first_name} ${O.contact.last_name||""}`.toLowerCase();$=V.localeCompare(X);break}case"relationship_type":$=(P.relationshipTypeName||"").localeCompare(O.relationshipTypeName||"");break;case"action_type":$=(((U=P.actionType)==null?void 0:U.name)||"").localeCompare(((B=O.actionType)==null?void 0:B.name)||"");break;case"last_touch":$=(P.monthNumber||0)-(O.monthNumber||0);break}return p==="asc"?$:-$}),[t,c,p]),S=P=>_bs[P||"Phone"]||Mn,M=({field:P,children:O})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>j(P),children:[O,c===P?p==="asc"?e.jsx(Su,{className:"ml-2 h-4 w-4"}):e.jsx(Kh,{className:"ml-2 h-4 w-4"}):e.jsx(_d,{className:"ml-2 h-4 w-4 opacity-50"})]}),L=(P,O,$)=>{v(P),w(`${O} ${$||""}`.trim())};return t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[180px]",children:e.jsx(M,{field:"name",children:"Contact"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(M,{field:"relationship_type",children:"Type"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(M,{field:"action_type",children:"Action"})}),e.jsx(St,{className:"w-[130px]",children:"Phone"}),e.jsx(St,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Bn,{children:k.map((P,O)=>{var Y,ee,Q,ce,ne,re;const $=P.isSpecialDate,U=P.specialDateType,B=$?U==="birthday"?Ah:dn:S(((Y=P.actionType)==null?void 0:Y.icon)||null),V=P.contact.phone,X=P.contact.email;return e.jsxs(Cs,{className:It("hover:bg-muted/50 transition-colors",$&&U==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&U==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(dt,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${P.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[P.contact.first_name," ",P.contact.last_name]})})}),e.jsx(dt,{children:P.relationshipTypeName?e.jsx(st,{variant:"secondary",className:"text-xs",children:P.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(st,{className:It("gap-1",U==="birthday"&&"bg-pink-500 hover:bg-pink-600",U==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:U==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ah,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(dn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(B,{className:"h-3 w-3"}),(ee=P.actionType)==null?void 0:ee.name]})})}),e.jsx(dt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:P.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${P.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Mn,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(P.contact.phone,(Q=P.script)==null?void 0:Q.script_body,P.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(so,{className:"h-3.5 w-3.5"})}),X&&(l?e.jsx("button",{onClick:()=>l({id:P.contact.id,first_name:P.contact.first_name,last_name:P.contact.last_name,email:P.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(lr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(P.contact.email,(ce=P.script)==null?void 0:ce.script_body,(ne=P.script)==null?void 0:ne.email_subject,(re=P.actionType)==null?void 0:re.name,P.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(lr,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const oe=`${P.contact.first_name}${P.contact.last_name?" "+P.contact.last_name:""}`,fe=U==="birthday"?"birthday":"home_anniversary",ge=new URLSearchParams({cardType:fe,contactId:P.contact.id,name:oe,...P.contact.address?{address:P.contact.address}:{},...U==="anniversary"&&P.contact.home_anniversary?{date:P.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${ge.toString()}`)},className:It("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",U==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${U==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(lr,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>L(P.contact.id,P.contact.first_name,P.contact.last_name),title:"Snooze",children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var oe;return s(P.contact.id,P.actionType.id,(oe=P.script)==null?void 0:oe.id)},disabled:n,children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${P.contact.id}-${O}`)})})]})}),e.jsx(eme,{open:!!g,onOpenChange:P=>!P&&v(null),contactId:g||"",contactName:_})]})}function Zx(){const{data:t,isLoading:s}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await H.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function jbs({onSelect:t}){const[s,r]=N.useState(null),{data:n=[],isLoading:a}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:c,error:u}=await H.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return c}}),{data:o=[],isLoading:l}=mt({queryKey:["agent-email-templates",s],queryFn:async()=>{let c=H.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");s&&(c=c.eq("category_id",s));const{data:u,error:p}=await c;if(p)throw p;return u}}),i=n.find(c=>c.id===s);return a?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):s?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Xo,{className:"h-3.5 w-3.5"}),"Back to categories"]}),e.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[e.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):e.jsx(Ki,{className:"max-h-[280px]",children:e.jsx("div",{className:"space-y-1",children:o.map(c=>e.jsxs("button",{onClick:()=>t(c),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm",children:c.title}),c.tone&&e.jsx(st,{variant:"secondary",className:"text-[10px] shrink-0",children:c.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:c.subject})]},c.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(c=>e.jsxs("button",{onClick:()=>r(c.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:c.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.name}),c.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:c.description})]})]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},c.id))})]})}function xSe(){var a;const{user:t}=Os(),{data:s,isLoading:r}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,g;const[o,l]=await Promise.all([H.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),H.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]),i=o.data,c=l.data;return{reply_to_email:((u=i==null?void 0:i.reply_to_email)==null?void 0:u.trim())||((p=c==null?void 0:c.email)==null?void 0:p.trim())||t.email||null,display_name:((f=i==null?void 0:i.display_name)==null?void 0:f.trim())||((g=c==null?void 0:c.name)==null?void 0:g.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}const Nbs=5*1024*1024,Ev=50,kbs=["application/pdf","image/jpeg","image/png","image/gif","image/webp","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv"];function Sbs(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function Cbs(t){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>{const a=n.result;s(a.split(",")[1])},n.onerror=r,n.readAsDataURL(t)})}function qb(t,s){let r=t.replace(/\{\{first_name\}\}/gi,s.first_name).replace(/\{\{last_name\}\}/gi,s.last_name||"").replace(/\{\{full_name\}\}/gi,`${s.first_name} ${s.last_name||""}`.trim());return s.updateLink&&(r=r.replace(/\{\{update_link\}\}/gi,s.updateLink)),r}function Kw({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Os(),u=Xt(),{isReady:p,settings:f}=xSe(),g=!!n&&n.length>0,v=g&&p,_=g?n:r?[r]:[],w=_[0],j=g?Math.ceil(_.length/Ev):1,k=g&&_.length>Ev,[S,M]=N.useState((w==null?void 0:w.email)||""),[L,P]=N.useState(a),[O,$]=N.useState(o),[U,B]=N.useState(!1),[V,X]=N.useState(!1),[Y,ee]=N.useState([]),[Q,ce]=N.useState(a),[ne,re]=N.useState(o),[oe,fe]=N.useState("composing"),[ge,ue]=N.useState(0),[xe,_e]=N.useState(0),[$e,Me]=N.useState(0),[Ie,ke]=N.useState(0),pe=N.useRef(!1),[we,Le]=N.useState(null);N.useEffect(()=>{t&&(M((w==null?void 0:w.email)||""),ce(a),re(o),P(qb(a,w||{first_name:""})),$(qb(o,w||{first_name:""})),X(!a&&!o),ee([]),fe("composing"),ue(0),_e(0),Me(0),ke(0),pe.current=!1,Le(null))},[t,w,a,o]);const Qe=async Je=>{const Ge=Je.target.files;if(!Ge)return;const et=Y.reduce((Dt,Vt)=>Dt+Vt.size,0),it=[];for(const Dt of Array.from(Ge)){if(!kbs.includes(Dt.type)){me.error(`${Dt.name}: Unsupported file type`);continue}if(et+Dt.size>Nbs){me.error("Total attachments exceed 5MB limit");break}try{const Vt=await Cbs(Dt);it.push({name:Dt.name,type:Dt.type,size:Dt.size,data:Vt})}catch{me.error(`Failed to read ${Dt.name}`)}}ee(Dt=>[...Dt,...it]),Je.target.value=""},Te=Je=>{ee(Ge=>Ge.filter((et,it)=>it!==Je))},pt=Je=>{ce(Je.subject),re(Je.body),P(qb(Je.subject,w||{first_name:""})),$(qb(Je.body,w||{first_name:""})),X(!1)},ye=Je=>Je.split(/\n\n+/).map(Ge=>`

${Ge.replace(/\n/g,"
")}

`).join(""),qe=async Je=>{const Ge=qb(Q,Je),et=qb(ne,Je),it=ye(et);try{if(v){const Dt=(f==null?void 0:f.display_name)||"ReLevelUp",Vt=`${Dt.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,hs=`${Dt} <${Vt}>`,{data:As,error:Ms}=await H.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Je.email,from_email:hs,subject:Ge,body_html:it,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(Ms)throw Ms;if(!(As!=null&&As.success))throw new Error((As==null?void 0:As.error)||"Failed to send")}else{const{data:Dt,error:Vt}=await H.functions.invoke("gmail-send",{body:{to:Je.email,subject:Ge,body:it,contactId:Je.id,attachments:Y.map(({name:hs,type:As,data:Ms})=>({name:hs,type:As,data:Ms}))}});if(Vt)throw Vt;if(!(Dt!=null&&Dt.success))throw new Error((Dt==null?void 0:Dt.error)||"Failed to send")}return c&&await H.from("bulk_email_sends").insert({user_id:c.id,contact_id:Je.id,contact_email:Je.email,subject:Ge,source:v?"ses_bulk":"sphere_gaps"}),!0}catch(Dt){return console.error("Send error:",Dt),me.error("Failed to send to "+Je.first_name+": "+(Dt instanceof Error?Dt.message:"Unknown error")),!1}},at=()=>{const Je=ge*Ev;return _.slice(Je,Je+Ev)},tt=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}const Je=at();B(!0),fe("sending");let Ge=0,et=0;for(let Dt=0;DtsetTimeout(hs,150));_e(Dt=>Dt+Ge),Me(Dt=>Dt+et),B(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),ge>=j-1||pe.current?fe("all_done"):fe("batch_complete")},Ae=async()=>{if(!L||!O){me.error("Please fill in subject and message");return}if(!g){B(!0);const Je=await qe(w);B(!1),Je&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await tt()},rt=async()=>{ue(Je=>Je+1),ke(0),await new Promise(Je=>setTimeout(Je,50)),await tt()};N.useEffect(()=>{},[ge]);const He=()=>{if(U){pe.current=!0;return}s(!1),i==null||i()},ct=ge*Ev,Ue=Math.min(ct+Ev,_.length),Ze=g&&_.length>0?Math.round((xe+$e)/_.length*100):0;return e.jsx(xs,{open:t,onOpenChange:He,children:e.jsxs(fs,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:`h-5 w-5 ${v?"text-orange-500":"text-red-500"}`}),g?`Send to ${_.length} Contacts`:"Compose Email"]}),v?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending via ",e.jsx("span",{className:"font-medium",children:"Mass Email"})," (reply-to: ",f==null?void 0:f.reply_to_email,")"]}):l?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:l})]}):null,g&&oe==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[_.length," contacts"]}),". You'll review each personalized email before sending."]})]}),oe==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(bs,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",ge+1," of ",j,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ie," of ",at().length," in this batch"]})]}),e.jsx(Bi,{value:Ie/at().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",xe+$e," / ",_.length]}),e.jsxs("span",{children:[xe," sent • ",$e," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{pe.current=!0},children:"Stop Sending"})]}),oe==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",ge+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[xe," sent, ",$e," failed so far"]})]}),e.jsx(Bi,{value:Ze,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[_.length-xe-$e," contacts remaining (",j-ge-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:He,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:rt,children:[e.jsx($n,{className:"h-4 w-4"}),"Send Next ",Math.min(Ev,_.length-Ue)," Contacts"]})]})]}),oe==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto"}),e.jsx("p",{className:"font-semibold text-lg",children:"All Done!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[xe," emails sent successfully",$e>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",$e," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:He,children:"Close"})]}),oe==="composing"&&e.jsxs("div",{className:"space-y-4",children:[V?e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(wn,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Mr,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(jbs,{onSelect:pt})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>X(!0),children:[e.jsx(wn,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(al,{}),!g&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"gmail-to",children:"To"}),e.jsx(ze,{id:"gmail-to",value:S,onChange:Je=>M(Je.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(ze,{id:"gmail-subject",value:L,onChange:Je=>{P(Je.target.value),ce(Je.target.value)},placeholder:"Enter subject..."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Je=>Je+"{{first_name}}"),re(Je=>Je+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(st,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Je=>Je+"{{last_name}}"),re(Je=>Je+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Pr,{id:"gmail-body",value:O,onChange:Je=>{$(Je.target.value),re(Je.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),g&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Je;return(Je=document.getElementById("gmail-attachments"))==null?void 0:Je.click()},disabled:U,children:[e.jsx(gS,{className:"h-4 w-4"}),"Attach Files"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),e.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:Qe})]}),Y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((Je,Ge)=>e.jsxs(st,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(gS,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Je.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",Sbs(Je.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Te(Ge),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Mr,{className:"h-3 w-3"})})]},Ge))})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),g?e.jsxs(K,{onClick:()=>{Le(_[0]||null),fe("reviewing")},disabled:!L||!O,className:"gap-2",children:["Review Emails",e.jsx(Sa,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Ae,disabled:U||!L||!O,className:"gap-2",children:[U?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),oe==="reviewing"&&g&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),k&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",_.length," contacts will be sent in ",j," batches of up to ",Ev,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{children:["Recipients (",_.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:_.map(Je=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(we==null?void 0:we.id)===Je.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>Le(Je),children:[Je.first_name," ",Je.last_name," — ",Je.email]},Je.id))})]}),we&&e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 space-y-2 animate-in fade-in slide-in-from-top-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"text-xs font-semibold text-primary flex items-center gap-1.5",children:[e.jsx(lr,{className:"h-3.5 w-3.5"}),"Preview for ",we.first_name," ",we.last_name]})}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"To:"})," ",we.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",qb(Q,we)]})]}),e.jsx(al,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:qb(ne,we)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{fe("composing"),Le(null)},children:[e.jsx(Qa,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Ae,disabled:U,className:"gap-2",children:[U?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"}),k?`Send First ${Ev}`:`Send to ${_.length}`]})]})]})]})})}function Mbs(){const t=nr(),{data:s}=Wm(),{data:r}=JO(),n=ONe(),{isGmailConnected:a,gmailEmail:o}=Zx(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(new Set),g=$m(new Date),v=Il(g,30),_=L=>{if(!L)return null;const P=L.split(/[-/T]/);if(P.length<3)return null;const O=parseInt(P[1],10)-1,$=parseInt(P[2],10);return isNaN(O)||isNaN($)?null:new Date(g.getFullYear(),O,$)},w=N.useMemo(()=>{if(!s)return[];const L=[];for(const P of s){if(P.birthday){const O=_(P.birthday);O&&(Tl(O,g)||ZS(O,g)&&YS(O,v))&&L.push({contact:P,type:"birthday",date:O,daysUntil:mf(O,g),dateStr:P.birthday})}if(P.home_anniversary){const O=_(P.home_anniversary);O&&(Tl(O,g)||ZS(O,g)&&YS(O,v))&&L.push({contact:P,type:"anniversary",date:O,daysUntil:mf(O,g),dateStr:P.home_anniversary})}}return L.sort((P,O)=>P.daysUntil-O.daysUntil),L},[s]),j=async L=>{const P=(r==null?void 0:r.find(O=>O.name==="Call"))||(r==null?void 0:r[0]);if(P)try{await n.mutateAsync({contactId:L.contact.id,actionTypeId:P.id,notes:`${L.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(O=>new Set(O).add(`${L.contact.id}-${L.type}`)),jn({title:"Touch logged!",description:`Logged outreach for ${L.contact.first_name}`})}catch{jn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},k=L=>{const P=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,O=L.type==="birthday"?"birthday":"home_anniversary",$=new URLSearchParams({cardType:O,contactId:L.contact.id,name:P,...L.contact.address?{address:L.contact.address}:{},...L.type==="anniversary"&&L.dateStr?{date:L.dateStr}:{}});t(`/mission-control/card-studio?${$.toString()}`)},S=L=>L===0?"Today!":L===1?"Tomorrow":`${L} days`,M=L=>L===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":L<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":L<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Od,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(st,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.length," event",w.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ah,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),w.map((L,P)=>{var B,V;const O=`${L.contact.id}-${L.type}`,$=p.has(O),U=`${((B=L.contact.first_name)==null?void 0:B[0])||""}${((V=L.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:It("p-3 rounded-lg border transition-colors",L.daysUntil===0&&L.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":L.daysUntil===0&&L.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":L.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(kn,{className:It("h-10 w-10",L.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(Sn,{className:It("text-xs font-medium",L.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:U})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:L.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[L.contact.first_name," ",L.contact.last_name||""]}),e.jsx(st,{variant:"outline",className:It("text-[10px] shrink-0 whitespace-nowrap",M(L.daysUntil)),children:S(L.daysUntil)})]}),e.jsxs("div",{className:It("text-xs flex items-center gap-1.5 mt-0.5",L.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[L.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Ah,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(dn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ms(L.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${L.contact.phone}`,children:e.jsx(Mn,{className:"h-3.5 w-3.5"})})}),L.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${L.contact.phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})}),L.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),u(!0)):window.location.href=`mailto:${L.contact.email}`},children:e.jsx(lr,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${L.contact.id}`),children:e.jsx(Cn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:It("h-7 px-2 gap-1 text-xs",L.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${L.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>k(L),children:[e.jsx(fn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:It("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>j(L),children:e.jsx(sa,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${L.contact.id}`),children:e.jsx(Dn,{className:"h-3.5 w-3.5"})})]})]},`${O}-${P}`)})]})]}),a&&l&&e.jsx(Kw,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}function Tbs(t){const[s,r]=N.useState([]),[n,a]=N.useState(!1),{data:o,isLoading:l}=mt({queryKey:["active-visitors",t],queryFn:async()=>{if(!t)return[];try{await H.rpc("cleanup_stale_visitors")}catch{}const{data:p}=await H.from("lead_site_active_visitors").select("*").eq("lead_site_id",t).gte("last_seen_at",new Date(Date.now()-2*60*1e3).toISOString()).order("last_seen_at",{ascending:!1});if(!p)return[];const f=p.map(_=>_.contact_id).filter(Boolean);let g={};if(f.length>0){const{data:_}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",f);(_||[]).forEach(w=>{g[w.id]=w})}const v=p.map(_=>_.auth_user_id).filter(Boolean);if(v.length>0){const{data:_}=await H.from("lead_site_consumer_profiles").select("user_id, name, phone, contact_id").eq("lead_site_id",t).in("user_id",v);(_||[]).forEach(w=>{const j=p.find(k=>k.auth_user_id===w.user_id);j&&!j.contact_id&&w.contact_id&&(j.contact_id=w.contact_id),j&&!g[j.contact_id||""]&&w.name&&(g[j.contact_id||j.auth_user_id||""]={first_name:w.name.split(" ")[0],last_name:w.name.split(" ").slice(1).join(" ")||null,email:null,phone:w.phone})})}return p.map(_=>{var w,j;return{..._,contact_name:g[_.contact_id||_.auth_user_id||""]?`${g[_.contact_id||_.auth_user_id||""].first_name} ${g[_.contact_id||_.auth_user_id||""].last_name||""}`.trim():null,contact_email:((w=g[_.contact_id||_.auth_user_id||""])==null?void 0:w.email)||null,contact_phone:((j=g[_.contact_id||_.auth_user_id||""])==null?void 0:j.phone)||null}})},enabled:!!t,refetchInterval:6e4});N.useEffect(()=>{if(!t)return;const p=H.channel(`active-visitors-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"lead_site_active_visitors",filter:`lead_site_id=eq.${t}`},f=>{f.eventType==="INSERT"?r(g=>g.find(_=>_.id===f.new.id)?g:[f.new,...g]):f.eventType==="UPDATE"?r(g=>g.map(v=>v.id===f.new.id?{...v,...f.new}:v)):f.eventType==="DELETE"&&r(g=>g.filter(v=>v.id!==f.old.id))}).subscribe(f=>{f==="SUBSCRIBED"&&a(!0)});return()=>{H.removeChannel(p)}},[t]);const i=n&&s.length>0?Abs([...s,...o||[]]):o||[],c=Date.now(),u=i.filter(p=>c-new Date(p.last_seen_at).getTime()<2*60*1e3);return{activeVisitors:u,isLoading:l,count:u.length}}function Abs(t){const s=new Set;return t.filter(r=>s.has(r.id)?!1:(s.add(r.id),!0))}const Ebs={property_view:{label:"Viewed",icon:Dn,color:"text-blue-500",bgColor:"bg-blue-500/10"},new_lead:{label:"New Lead",icon:El,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},saved_listing:{label:"Saved",icon:Ya,color:"text-rose-500",bgColor:"bg-rose-500/10"}};function Pbs(){const{user:t}=Os(),s=nr(),{isGmailConnected:r,gmailEmail:n}=Zx(),{leadSite:a}=uE(),{count:o}=Tbs(a==null?void 0:a.id),[l,i]=N.useState(!1),[c,u]=N.useState(null),{data:p,isLoading:f}=mt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:k,error:S}=await H.rpc("get_lead_site_activity",{_user_id:t.id});if(S)throw S;return k},enabled:!!t,refetchInterval:6e4});if(f||!(p!=null&&p.has_site))return null;const g=(p.activities||[]).filter(k=>k.visitor_name&&k.visitor_name!=="Site Visitor"),v=g.filter(k=>k.activity_type==="new_lead"),_=(p.activities||[]).filter(k=>k.activity_type==="property_view").length,w=(p.activities||[]).filter(k=>k.activity_type==="saved_listing").length,j=k=>{if(k.visitor_email)if(r){const S=(k.visitor_name||"").split(" ");u({id:k.contact_id||"",first_name:S[0]||"",last_name:S.slice(1).join(" ")||null,email:k.visitor_email}),i(!0)}else window.location.href=`mailto:${k.visitor_email}`};return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-primary/10 rounded-lg",children:e.jsx(ru,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Website Activity"}),o>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 text-[11px] font-semibold",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-emerald-500"})]}),o," Live"]})]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-primary gap-1",onClick:()=>s("/mission-control/website-activity"),children:["View All",e.jsx(Sa,{className:"h-4 w-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-500/5 border border-emerald-200 dark:border-emerald-800",children:[e.jsx(El,{className:"h-4 w-4 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-emerald-600 dark:text-emerald-400",children:v.length}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"New Leads"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-blue-500/5 border border-blue-200 dark:border-blue-800",children:[e.jsx(Dn,{className:"h-4 w-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-blue-600 dark:text-blue-400",children:_}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Views"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-rose-500/5 border border-rose-200 dark:border-rose-800",children:[e.jsx(Ya,{className:"h-4 w-4 text-rose-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-rose-600 dark:text-rose-400",children:w}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Saved"})]})]})]}),g.length>0?e.jsxs("div",{className:"space-y-2",children:[g.slice(0,5).map((k,S)=>{const M=Ebs[k.activity_type],L=M.icon,P=Vc(new Date(k.occurred_at),{addSuffix:!0});return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:shadow-sm transition-shadow",children:[e.jsx("div",{className:`p-1.5 rounded-md ${M.bgColor}`,children:e.jsx(L,{className:`h-3.5 w-3.5 ${M.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{className:"font-medium text-sm text-primary hover:underline text-left truncate block",onClick:()=>{k.contact_id&&s(`/mission-control/contacts/${k.contact_id}`)},children:k.visitor_name}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:M.label}),k.mls_number&&e.jsxs("span",{children:["· MLS# ",k.mls_number]}),k.lead_type&&e.jsxs("span",{children:["· ",k.lead_type]}),e.jsxs("span",{children:["· ",P]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[k.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>j(k),children:e.jsx(lr,{className:"h-3.5 w-3.5"})}),k.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`tel:${k.visitor_phone}`,children:e.jsx(Mn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-primary",onClick:()=>window.location.href=`sms:${k.visitor_phone}`,children:e.jsx(so,{className:"h-3.5 w-3.5"})})]}),k.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>s(`/mission-control/contacts/${k.contact_id}`),children:e.jsx(oa,{className:"h-3.5 w-3.5"})})]})]},`${k.activity_type}-${k.occurred_at}-${S}`)}),g.length>5&&e.jsxs(K,{variant:"outline",className:"w-full text-xs",onClick:()=>s("/mission-control/website-activity"),children:["View ",g.length-5," more activities",e.jsx(Sa,{className:"h-3.5 w-3.5 ml-1"})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 text-center",children:[e.jsx(Ch,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No actionable website activity yet."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:_>0?`${_} anonymous listing views recorded.`:"Lead engagement will appear here as visitors interact with your site."}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>s("/mission-control/website-activity"),children:["View Full Activity",e.jsx(Sa,{className:"h-3.5 w-3.5 ml-1"})]})]})}),r&&c&&e.jsx(Kw,{open:l,onOpenChange:i,contact:c,gmailEmail:n})]})}const l7e={Crown:Dm,FileText:wn,Users:hr,Globe:ru,Star:Jn,Phone:Mn,MessageSquare:so,PenTool:Y_,Video:Cn,Gift:So},Ibs={"Top 25":"bg-primary text-primary-foreground","Past Client":"bg-sky-500 text-white","Referral Partner":"bg-orange-500 text-white",Sphere:"bg-emerald-500 text-white",VIP:"bg-amber-500 text-white"};function Lbs(){var He,ct,Ue,Ze,Je,Ge;const t=nr(),{user:s}=Os(),{data:r}=Gx(),{data:n}=cQe(),{data:a}=Wm(),{data:o}=JO(),{data:l}=pQe(),i=OLt(),c=RNe(),u=LLt(90),p=ONe(),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(!1),[P,O]=N.useState(""),[$,U]=N.useState(ile()),[B,V]=N.useState("cards"),[X,Y]=N.useState(!1),[ee,Q]=N.useState(null),[ce,ne]=N.useState(null),[re,oe]=N.useState(""),{isGmailConnected:fe,gmailEmail:ge}=Zx(),ue=()=>{const et=parseInt(P,10);if(isNaN(et)||et<1){jn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}U(et),mQe(et),L(!1),jn({title:"Goal updated",description:`Weekly touch goal set to ${et}`})},xe=()=>{O($.toString()),L(!0)};N.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:it}=await H.from("profiles").select("name").eq("id",s.id).single();it!=null&&it.name&&S(it.name.split(" ")[0])})()},[s==null?void 0:s.id]),N.useEffect(()=>{i.mutate()},[]);const _e=$m(new Date),$e=Il(_e,7),Me=et=>{if(!et)return null;const it=et.split(/[-/T]/);if(it.length<3)return null;const Dt=parseInt(it[1],10)-1,Vt=parseInt(it[2],10);return isNaN(Dt)||isNaN(Vt)?null:new Date(_e.getFullYear(),Dt,Vt)},Ie=(a==null?void 0:a.filter(et=>{const it=Me(et.birthday),Dt=Me(et.home_anniversary);return it&&Tl(it,_e)||Dt&&Tl(Dt,_e)}))||[];a!=null&&a.filter(et=>{if(!et.birthday&&!et.home_anniversary)return!1;const it=Dt=>{if(!Dt)return!1;const Vt=Me(Dt);return Vt?ZS(Vt,_e)&&YS(Vt,$e):!1};return it(et.birthday)||it(et.home_anniversary)}).slice(0,5);const ke=[],pe=(o==null?void 0:o.find(et=>et.name==="Call"))||(o==null?void 0:o[0]);for(const et of Ie){const it=Me(et.birthday),Dt=Me(et.home_anniversary),Vt=it&&Tl(it,_e),hs=Dt&&Tl(Dt,_e);Vt&&ke.push({contact:et,actionType:pe||{id:"special-date-birthday",name:"Birthday Call",icon:"Cake",color:"#EC4899",description:"Wish them happy birthday!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🎂 Birthday Today!",relationshipTypeName:((Ue=(ct=(He=et.tags)==null?void 0:He[0])==null?void 0:ct.relationship_type)==null?void 0:Ue.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),hs&&ke.push({contact:et,actionType:pe||{id:"special-date-anniversary",name:"Anniversary Call",icon:"Home",color:"#8B5CF6",description:"Celebrate their home anniversary!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🏠 Home Anniversary!",relationshipTypeName:((Ge=(Je=(Ze=et.tags)==null?void 0:Ze[0])==null?void 0:Je.relationship_type)==null?void 0:Ge.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const Le=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((et,it)=>{var Vt,hs,As;const Dt=o==null?void 0:o[it%((o==null?void 0:o.length)||1)];return Dt?{contact:et,actionType:Dt,planName:"Quick Touch",relationshipTypeName:((As=(hs=(Vt=et.tags)==null?void 0:Vt[0])==null?void 0:hs.relationship_type)==null?void 0:As.name)||"",monthNumber:0}:null}).filter(Boolean))||[],Qe=[...ke,...Le],Te=async(et,it,Dt)=>{await p.mutateAsync({contactId:et,actionTypeId:it,scriptUsedId:Dt}),j(!1),_(null)},pt=et=>{et.script?(_(et),j(!0)):Te(et.contact.id,et.actionType.id)},ye=et=>l7e[et||"Phone"]||Mn,qe=et=>l7e[et||"Users"]||hr,at=(et,it)=>et.replace(/\{\{FirstName\}\}/g,it.first_name).replace(/\{\{LastName\}\}/g,it.last_name||"").replace(/\{\{AgentName\}\}/g,k||"there"),tt=(et,it)=>({Call:`Thinking of you, ${it}!`,Text:`Quick hello, ${it}`,Email:`Checking in, ${it}`,"Handwritten Note":`A note for ${it}`,Video:`Video message for ${it}`,Gift:`Something special for you, ${it}`})[et]||`Hello ${it}!`,Ae=(et,it,Dt)=>{const Vt=`sms:${et}`;if(it&&Dt){const hs=at(it,Dt);return`${Vt}?body=${encodeURIComponent(hs)}`}return Vt},rt=(et,it,Dt,Vt,hs)=>{const As=`mailto:${et}`,Ms=[];if(hs){const cs=Dt||tt(Vt||"Email",hs.first_name);if(Ms.push(`subject=${encodeURIComponent(cs)}`),it){const er=at(it,hs);Ms.push(`body=${encodeURIComponent(er)}`)}}return Ms.length>0?`${As}?${Ms.join("&")}`:As};return e.jsxs(e.Fragment,{children:[e.jsxs(Ts,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsx(Pbs,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Your Sphere"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r==null?void 0:r.filter(et=>et.active).map(et=>{const it=qe(et.icon),Dt=(n==null?void 0:n[et.id])||0,Vt=f===et.id,hs=Ibs[et.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Vt?(g(null),t("/mission-control/contacts")):(g(et.id),t(`/mission-control/contacts?type=${et.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Vt?hs:"bg-card hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:`text-sm ${Vt?"opacity-90":"text-muted-foreground"}`,children:[Dt," Contacts"]})]})]},et.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(yu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(oa,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(fn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:B==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(Cp,{className:"h-4 w-4"})}),e.jsx(K,{variant:B==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(rh,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:Qe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):B==="table"?e.jsx(wbs,{actions:Qe,onMarkComplete:Te,onViewScript:pt,isLoading:p.isPending,buildSmsLink:Ae,buildEmailLink:rt,onGmailCompose:fe?et=>{Q(et),Y(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[Qe.map((et,it)=>{var xt,Ps,mr,Tr,Dr,xn,Si;const Dt=et.isSpecialDate,Vt=et.specialDateType,hs=Dt?Vt==="birthday"?Ah:dn:ye(((xt=et.actionType)==null?void 0:xt.icon)||null),As=et.contact.phone,Ms=et.contact.email,cs=Dt?Vt==="birthday"?"#EC4899":"#8B5CF6":((Ps=et.actionType)==null?void 0:Ps.color)||"#3B82F6",er=Dt?Vt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(mr=et.actionType)==null?void 0:mr.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Dt?"ring-2 ring-offset-2":""}`,style:Dt?{"--tw-ring-color":cs}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:cs},children:[e.jsx(hs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:er})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${et.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[et.contact.first_name," ",et.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[As&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${et.contact.phone}`,className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-primary/10 hover:bg-primary/20 text-primary rounded text-xs font-medium transition-colors",title:"Call",children:[e.jsx(Mn,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Ae(et.contact.phone,(Tr=et.script)==null?void 0:Tr.script_body,et.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 rounded text-xs font-medium transition-colors",title:"Text",children:[e.jsx(so,{className:"h-3 w-3"}),"Text"]})]}),Ms&&(fe?e.jsxs("button",{onClick:()=>{Q({id:et.contact.id,first_name:et.contact.first_name,last_name:et.contact.last_name,email:et.contact.email}),Y(!0)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Compose Email",children:[e.jsx(lr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:rt(et.contact.email,(Dr=et.script)==null?void 0:Dr.script_body,(xn=et.script)==null?void 0:xn.email_subject,(Si=et.actionType)==null?void 0:Si.name,et.contact),className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Email",children:[e.jsx(lr,{className:"h-3 w-3"}),"Email"]}))]}),Dt&&e.jsxs("button",{onClick:()=>{const Ia=`${et.contact.first_name}${et.contact.last_name?" "+et.contact.last_name:""}`,ur=Vt==="birthday"?"birthday":"home_anniversary",Jr=new URLSearchParams({cardType:ur,contactId:et.contact.id,name:Ia,...et.contact.address?{address:et.contact.address}:{},...Vt==="anniversary"&&et.contact.home_anniversary?{date:et.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${Jr.toString()}`)},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 rounded text-xs font-semibold bg-gradient-to-r from-pink-500/15 to-violet-500/15 hover:from-pink-500/25 hover:to-violet-500/25 text-pink-600 dark:text-pink-400 transition-colors",children:[e.jsx(lr,{className:"h-3 w-3"}),"Send ",Vt==="birthday"?"Birthday":"Anniversary"," Card"]}),!As&&!Ms&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[et.relationshipTypeName&&e.jsx(st,{variant:"secondary",className:"text-xs",children:et.relationshipTypeName}),et.monthNumber>0&&e.jsxs(st,{variant:"outline",className:"text-xs",children:["Month ",et.monthNumber]})]}),et.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>pt(et),children:"View Script"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ne(et.contact.id),oe(`${et.contact.first_name} ${et.contact.last_name||""}`.trim())},children:[e.jsx(Rm,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Ia;return Te(et.contact.id,et.actionType.id,(Ia=et.script)==null?void 0:Ia.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},et.contact.id+it)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(xx,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Bd,{children:e.jsx(Aa,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{className:"text-lg",children:"Momentum"}),e.jsxs(xs,{open:M,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:xe,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(fs,{className:"sm:max-w-[360px]",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Set Weekly Goal"}),e.jsx(Wr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal-ic",type:"number",min:"1",value:P,onChange:et=>O(et.target.value),placeholder:"20",onKeyDown:et=>{et.key==="Enter"&&ue()}})]}),e.jsx(K,{onClick:ue,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Bi,{value:Math.min(c.actionsThisWeek/$*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(sh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[c.actionsThisWeek," / ",$]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),c.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",c.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(un,{className:"h-4 w-4 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[u.count," Contact",u.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(TQe,{}),e.jsx(Mbs,{})]})]}),e.jsx(xs,{open:w,onOpenChange:j,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{className:"flex items-center gap-2",children:v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:v.actionType.color||"#3B82F6"}}),v.actionType.name," Script"]})})}),v&&v.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[v.contact.first_name," ",v.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:at(v.script.script_body,v.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>j(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var et;return Te(v.contact.id,v.actionType.id,(et=v.script)==null?void 0:et.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(xbs,{})]}),fe&&ee&&e.jsx(Kw,{open:X,onOpenChange:Y,contact:ee,gmailEmail:ge}),e.jsx(eme,{open:!!ce,onOpenChange:et=>!et&&ne(null),contactId:ce||"",contactName:re})]})}var $at="Toggle",gSe=N.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=oh({prop:r,onChange:a,defaultProp:n??!1,caller:$at});return e.jsx(an.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Lr(t.onClick,()=>{t.disabled||i(!l)})})});gSe.displayName=$at;var qat=gSe,Zw="ToggleGroup",[Uat]=od(Zw,[Dw]),Vat=Dw(),ySe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(Dbs,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(Obs,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Zw}\``)});ySe.displayName=Zw;var[Hat,Gat]=Uat(Zw),Dbs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=oh({prop:r,defaultProp:n??"",onChange:a,caller:Zw});return e.jsx(Hat,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(Wat,{...o,ref:s})})}),Obs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=oh({prop:r,defaultProp:n??[],onChange:a,caller:Zw}),c=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(g=>g!==p)),[i]);return e.jsx(Hat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(Wat,{...o,ref:s})})});ySe.displayName=Zw;var[Rbs,Fbs]=Uat(Zw),Wat=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=Vat(r),p=Lw(l),f={role:"group",dir:p,...c};return e.jsx(Rbs,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Gde,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(an.div,{...f,ref:s})}):e.jsx(an.div,{...f,ref:s})})}),nde="ToggleGroupItem",Kat=ht.forwardRef((t,s)=>{const r=Gat(nde,t.__scopeToggleGroup),n=Fbs(nde,t.__scopeToggleGroup),a=Vat(t.__scopeToggleGroup),o=r.value.includes(t.value),l=n.disabled||t.disabled,i={...t,pressed:o,disabled:l},c=ht.useRef(null);return n.rovingFocus?e.jsx(Wde,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(c7e,{...i,ref:s})}):e.jsx(c7e,{...i,ref:s})});Kat.displayName=nde;var c7e=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=Gat(nde,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(gSe,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),Zat=ySe,Yat=Kat;const Qat=b3("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),zbs=N.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(qat,{ref:a,className:It(Qat({variant:s,size:r,className:t})),...n}));zbs.displayName=qat.displayName;const Xat=N.createContext({size:"default",variant:"default"}),Jat=N.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(Zat,{ref:o,className:It("flex items-center justify-center gap-1",t),...a,children:e.jsx(Xat.Provider,{value:{variant:s,size:r},children:n})}));Jat.displayName=Zat.displayName;const eit=N.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=N.useContext(Xat);return e.jsx(Yat,{ref:o,className:It(Qat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});eit.displayName=Yat.displayName;const Bbs=[{value:"bidirectional",label:"Two-Way",icon:_d,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Su,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Kh,tooltip:"Only pull BoldTrail → Agent OS"}];function Q_e({value:t,onChange:s,size:r="default"}){const n=r==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:`font-medium ${n} text-muted-foreground`,children:"Sync Direction"}),e.jsx(Jat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:Bbs.map(a=>e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(eit,{value:a.value,"aria-label":a.tooltip,className:`gap-1.5 ${n} border border-transparent data-[state=on]:!bg-primary data-[state=on]:!text-primary-foreground data-[state=on]:!border-primary data-[state=on]:shadow-sm`,children:[e.jsx(a.icon,{className:r==="sm"?"h-3 w-3":"h-4 w-4"}),a.label]})}),e.jsx(ec,{children:a.tooltip})]},a.value))})]})}function $bs(){const t=Xt(),[s,r]=N.useState(!1),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(null),[v,_]=N.useState(0),w=N.useRef(!1),{data:j}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(V)throw V;return B}}),k=(j==null?void 0:j.sync_direction)||"bidirectional",S=u??k,M=Lt({mutationFn:async()=>{const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);return B},onSuccess:B=>{p(null),a(B),r(!0)},onError:B=>{me.error(B.message||"Failed to generate sync preview")}}),L=Lt({mutationFn:async()=>{w.current=!1,g("Initializing sync..."),_(5);const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);const X=B;let Y=X.sync_log_id,ee=X.next_phase,Q=X.next_offset;const ce=X.push_total||0,ne=X.pull_total||0,re=X.update_total||0,oe=ce+ne+re;let fe=0,ge=0,ue=0;for(;ee!=="finalize"&&!w.current;){ee==="push"?(g(`Pushing contacts to BoldTrail... (${fe}/${ce})`),_(oe>0?fe/oe*90:0)):ee==="pull"?(g(`Pulling contacts from BoldTrail... (${ge}/${ne})`),_(oe>0?(ce+ge)/oe*90:0)):ee==="update"&&(g(`Updating existing contacts... (${ue}/${re})`),_(oe>0?(ce+ne+ue)/oe*90:0));const{data:$e,error:Me}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ee,offset:Q,sync_log_id:Y,sync_direction:S}});if(Me)throw Me;if($e!=null&&$e.error)throw new Error($e.error);const Ie=$e;fe+=Ie.chunk_pushed||0,ge+=Ie.chunk_pulled||0,ue+=Ie.chunk_updated||0,Ie.progress&&g(Ie.progress),ee=Ie.next_phase,Q=Ie.next_offset}g("Finalizing sync..."),_(95);const{data:xe,error:_e}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:Y,sync_direction:S}});if(_e)throw _e;return _(100),xe},onSuccess:B=>{g(null),_(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]});const V=[`Pushed ${B.contacts_pushed||0}`,`pulled ${B.contacts_pulled||0}`,`updated ${B.contacts_updated||0}`,`skipped ${B.contacts_skipped||0} duplicates`];me.success(`Sync complete! ${V.join(", ")}.`)},onError:B=>{g(null),_(0),me.error(B.message||"Sync failed")}});if(!(j!=null&&j.connected))return null;const P=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,O=S==="push_only"?0:(n==null?void 0:n.to_pull)??0,$=(n==null?void 0:n.to_update)??0,U=P>0||O>0||$>0;return e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,className:"shrink-0",children:M.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(_d,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(ec,{children:"Sync with BoldTrail"})]}),e.jsx(xs,{open:s,onOpenChange:B=>{L.isPending||r(B)},children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_d,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Wr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Q_e,{value:S,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:P}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Su,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:O}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Kh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:$}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(WM,{className:"h-3 w-3"})," To update"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),$>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center bg-amber-50 dark:bg-amber-950/30 rounded-md p-2",children:[e.jsx(WM,{className:"h-3 w-3 inline mr-1"}),$," contacts have missing fields that will be filled from the other system"]}),P>0&&e.jsxs(vf,{open:o,onOpenChange:l,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Su,{className:"h-3 w-3 text-emerald-600"}),P," contacts to push to BoldTrail"]}),e.jsx(oo,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(_f,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),O>0&&e.jsxs(vf,{open:i,onOpenChange:c,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kh,{className:"h-3 w-3 text-blue-600"}),O," contacts to pull from BoldTrail"]}),e.jsx(oo,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(_f,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map((B,V)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:B.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:B.email})]},V)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),!U&&!L.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer or update."}),L.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:v||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:L.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending||!U,className:"gap-2",children:[L.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(_d,{className:"h-4 w-4"}),L.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const qbs=()=>{const{user:t}=Os();return mt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},tme=t=>{const{user:s}=Os();return mt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=H.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},vSe=()=>{const{user:t}=Os();return mt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},tit=()=>{const{user:t}=Os();return mt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},Ubs=()=>{const{data:t}=Wm(),{data:s}=Gx(),{data:r}=tme(),{data:n}=tit(),{data:a}=vSe(),o=new Map;r==null||r.forEach(p=>{const f=o.get(p.contact_id);(!f||new Date(p.completed_at)>new Date(f))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const c=$m(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const j=p.tags.map(k=>l.get(k.relationship_type_id)).filter(k=>k!==void 0);j.length>0&&(f=Math.min(...j))}const g=o.get(p.id)||null,v=g?cy(c,$m(new Date(g))):null,_=v===null||v>=f,w=_&&v!==null?v-f:0;return{...p,lastPopby:g,daysSinceLastPopby:v,frequencyDays:f,isDue:_,daysOverdue:w}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},sit=()=>Ubs().filter(s=>s.isDue),Vbs=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{error:n}=await H.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),jn({title:"Popby item created!"})},onError:r=>{jn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},Hbs=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{error:n}=await H.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),jn({title:"Popby logged!"})},onError:r=>{jn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},Gbs=()=>{const t=Xt(),{user:s}=Os();return Lt({mutationFn:async r=>{const{error:n}=await H.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),jn({title:"Frequency updated!"})},onError:r=>{jn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},Wbs=()=>{const{data:t}=tme(30),s=sit(),r=new Date;r.setDate(r.getDate()-7);const n=(t==null?void 0:t.filter(o=>new Date(o.completed_at)>=r).length)||0,a=(t==null?void 0:t.length)||0;return{thisWeekCount:n,thisMonthCount:a,dueCount:s.length}};function Kbs(){const{user:t}=Os();return mt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function rit(t){const{data:s}=Kbs(),{data:r}=tit(),{data:n}=vSe(),{data:a}=gbs();return N.useMemo(()=>{const o=a==null?void 0:a.find(j=>j.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=$m(new Date);if(l&&!YS(l,i))return{nextTouchDate:l,daysUntil:cy(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(j=>j.contact_id===t.id))||[]).sort((j,k)=>new Date(k.completed_at).getTime()-new Date(j.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const g=r==null?void 0:r.find(j=>j.contact_id===t.id&&j.is_active);if(g)f=g.frequency_days;else if(t.tags&&t.tags.length>0){const j=t.tags.map(k=>{const S=n==null?void 0:n.find(M=>M.relationship_type_id===k.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(k=>k!==void 0);j.length>0&&(f=Math.min(...j))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const v=Il($m(p),f),_=cy(v,i);let w;return _<0?w="overdue":_<=7?w="due-soon":w="on-track",{nextTouchDate:v,daysUntil:_,status:w,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function X_e({contact:t}){const s=rit(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Cl,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:un,text:s.daysUntil===0?"Due today":`Due in ${s.daysUntil} days`,className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"};case"on-track":return{variant:"secondary",icon:sa,text:`Next touch in ${s.daysUntil} days`,className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400"};case"snoozed":return{variant:"secondary",icon:Rm,text:`Snoozed until ${ms(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:hn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(st,{variant:n.variant,className:It("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function Zbs({contact:t,onLogTouch:s,onSnooze:r}){const n=rit(t),a=vbs(),[o,l]=N.useState(!1),i=()=>{switch(n.status){case"overdue":return"text-destructive";case"due-soon":return"text-amber-600 dark:text-amber-400";case"on-track":return"text-emerald-600 dark:text-emerald-400";case"snoozed":return"text-slate-600 dark:text-slate-400";case"never-touched":return"text-muted-foreground"}},c=()=>{switch(n.status){case"overdue":return e.jsx(Cl,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(un,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(sa,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(Rm,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(hn,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:It("font-medium",i()),children:u()})]}),n.status==="snoozed"&&n.snoozedUntil&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",ms(n.snoozedUntil,"MMMM d, yyyy")]}),n.status!=="snoozed"&&n.nextTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Scheduled:"})," ",ms(n.nextTouchDate,"MMMM d, yyyy")]}),n.lastTouchDate&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Last touch:"})," ",ms(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Mr,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(Rm,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&s&&e.jsx(K,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:s,children:"Log Touch"})]})]})]}),e.jsx(eme,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const Mye=768;function DE(){const[t,s]=N.useState(void 0);return N.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Mye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function Ybs(){const{user:t}=Os(),{hasLeadSite:s,leadSite:r}=uE(),{data:n,isLoading:a}=mt({queryKey:["website-active-contacts",t==null?void 0:t.id,r==null?void 0:r.id],queryFn:async()=>{if(!r)return new Set;const{data:o}=await H.from("lead_site_visitors").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),{data:l}=await H.from("lead_site_consumer_profiles").select("contact_id").eq("lead_site_id",r.id).not("contact_id","is",null),i=new Set;return(o||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),(l||[]).forEach(c=>{c.contact_id&&i.add(c.contact_id)}),i},enabled:!!t&&s,staleTime:5*60*1e3});return{activeContactIds:n??new Set,hasLeadSite:s,isLoading:a}}const Qbs={warm:{label:"Warm",emoji:"🟢",bgClass:"bg-emerald-500",textClass:"text-emerald-600 dark:text-emerald-400",borderClass:"border-emerald-500",bgLightClass:"bg-emerald-500/10"},cooling:{label:"Cooling Off",emoji:"🟡",bgClass:"bg-amber-500",textClass:"text-amber-600 dark:text-amber-400",borderClass:"border-amber-500",bgLightClass:"bg-amber-500/10"},"at-risk":{label:"At Risk",emoji:"🔴",bgClass:"bg-red-500",textClass:"text-red-600 dark:text-red-400",borderClass:"border-red-500",bgLightClass:"bg-red-500/10"}},Xbs={sm:{dot:"h-2 w-2",text:"text-xs",badge:"px-1.5 py-0.5 gap-1"},md:{dot:"h-2.5 w-2.5",text:"text-sm",badge:"px-2 py-1 gap-1.5"},lg:{dot:"h-3 w-3",text:"text-base",badge:"px-3 py-1.5 gap-2"}};function P8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=Qbs[t.status],l=Xbs[n],i=e.jsxs("div",{className:It("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:It("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(G1,{children:e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:i}),e.jsx(ec,{side:"top",className:"w-64 p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold",children:"Relationship Score"}),e.jsxs("span",{className:It("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Bi,{value:t.score,className:"h-2"}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Recency"}),e.jsxs("span",{children:[t.breakdown.recency,"/40"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Touchpoints (12mo)"}),e.jsxs("span",{children:[t.breakdown.touchpoints,"/30"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transactions"}),e.jsxs("span",{children:[t.breakdown.transactions,"/20"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referrals"}),e.jsxs("span",{children:[t.breakdown.referrals,"/10"]})]})]}),t.daysSinceTouch!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground pt-1 border-t",children:["Last contact: ",t.daysSinceTouch===0?"Today":`${t.daysSinceTouch} days ago`]}),t.daysSinceTouch===null&&e.jsx("p",{className:"text-xs text-muted-foreground pt-1 border-t italic",children:"Never contacted"})]})})]})}):i}const Jbs=[{key:"first_name",label:"First Name",required:!0},{key:"last_name",label:"Last Name",required:!1},{key:"email",label:"Email",required:!1},{key:"phone",label:"Phone",required:!1},{key:"address",label:"Street Address",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1},{key:"zip",label:"Zip Code",required:!1},{key:"spouse_name",label:"Spouse Name",required:!1},{key:"spouse_email",label:"Spouse Email",required:!1},{key:"company_name",label:"Company",required:!1},{key:"job_title",label:"Job Title",required:!1},{key:"birthday",label:"Birthday",required:!1},{key:"home_anniversary",label:"Home Anniversary",required:!1},{key:"notes",label:"Notes",required:!1}],a9=t=>{if(!t||!t.trim())return null;const s=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=s.match(/^(\d{1,2})[\/\-](\d{1,2})(?:[\/\-](\d{2,4}))?$/);if(r){const a=r[1].padStart(2,"0"),o=r[2].padStart(2,"0");let l="2000";r[3]&&(l=r[3].length===2?(parseInt(r[3])>50?"19":"20")+r[3]:r[3]);const i=parseInt(a),c=parseInt(o);if(i>=1&&i<=12&&c>=1&&c<=31)return`${l}-${a}-${o}`}const n=new Date(s);return isNaN(n.getTime())?null:n.toISOString().split("T")[0]},e_s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Os(),{toast:o}=Ha(),l=N.useRef(null),[i,c]=N.useState("upload"),[u,p]=N.useState([]),[f,g]=N.useState([]),[v,_]=N.useState({}),[w,j]=N.useState([]),[k,S]=N.useState([]),[M,L]=N.useState(!1),[P,O]=N.useState(null),$=()=>{c("upload"),p([]),g([]),_({}),j([]),S([]),O(null),l.current&&(l.current.value="")},U=()=>{$(),s(!1)},B=ge=>{const ue=ge.split(` `).map(Me=>Me.trim()).filter(Me=>Me);if(ue.length===0)return{headers:[],data:[]};const xe=Me=>{const Ie=[];let ke="",pe=!1;for(let we=0;we{var _e;const ue=(_e=ge.target.files)==null?void 0:_e[0];if(!ue)return;const xe=new FileReader;xe.onload=$e=>{var we;const Me=(we=$e.target)==null?void 0:we.result,{headers:Ie,data:ke}=B(Me);if(Ie.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Ie),g(ke);const pe={};Ie.forEach(Le=>{const Qe=Le.toLowerCase().replace(/[_\s-]/g,"");Qe.includes("firstname")||Qe==="first"?pe.first_name=Le:Qe.includes("lastname")||Qe==="last"?pe.last_name=Le:Qe.includes("spouse")&&Qe.includes("email")?pe.spouse_email=Le:Qe.includes("spouse")||Qe.includes("partner")?pe.spouse_name=Le:Qe.includes("email")?pe.email=Le:Qe.includes("phone")||Qe.includes("mobile")||Qe.includes("cell")?pe.phone=Le:Qe.includes("address")||Qe.includes("street")?pe.address=Le:Qe==="city"?pe.city=Le:Qe==="state"||Qe==="province"?pe.state=Le:Qe==="zip"||Qe==="zipcode"||Qe==="postalcode"?pe.zip=Le:Qe.includes("company")||Qe.includes("organization")||Qe.includes("business")?pe.company_name=Le:Qe.includes("jobtitle")||Qe.includes("title")&&!Qe.includes("spouse")?pe.job_title=Le:Qe.includes("birthday")||Qe.includes("dob")||Qe.includes("birthdate")?pe.birthday=Le:Qe.includes("anniversary")||Qe.includes("homeanniversary")?pe.home_anniversary=Le:(Qe.includes("notes")||Qe.includes("comment"))&&(pe.notes=Le)}),_(pe),c("mapping")},xe.readAsText(ue)},X=(ge,ue)=>{_(xe=>{if(ue==="none"){const{[ge]:_e,...$e}=xe;return $e}return{...xe,[ge]:ue}})},Y=ge=>{j(ue=>ue.includes(ge)?ue.filter(xe=>xe!==ge):[...ue,ge])},ee=async()=>{if(!(a!=null&&a.id))return;const{data:ge}=await H.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ue=new Set((ge||[]).filter($e=>$e.email).map($e=>$e.email.toLowerCase())),xe=new Set((ge||[]).filter($e=>$e.phone).map($e=>$e.phone.replace(/[^0-9]/g,""))),_e=f.map($e=>{const Me=Qe=>{const Te=v[Qe];if(!Te)return"";const pt=u.indexOf(Te);return pt>=0?($e[pt]||"").trim():""},Ie=Me("first_name"),ke=Me("email"),pe=Me("phone"),we=Ie.length>0,Le=!!(ke&&ue.has(ke.toLowerCase())||pe&&xe.has(pe.replace(/[^0-9]/g,"")));return{first_name:Ie,last_name:Me("last_name"),email:ke,phone:pe,address:Me("address"),city:Me("city"),state:Me("state"),zip:Me("zip"),spouse_name:Me("spouse_name"),spouse_email:Me("spouse_email"),company_name:Me("company_name"),job_title:Me("job_title"),birthday:Me("birthday"),home_anniversary:Me("home_anniversary"),notes:Me("notes"),isValid:we,isDuplicate:Le,error:we?void 0:"First name is required"}});S(_e),c("preview")},Q=ge=>{const ue=ge.trim().split(/\s+/);return{first_name:ue[0],last_name:ue.length>1?ue.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const ge=k.filter($e=>$e.isValid);if(ge.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}L(!0);let ue=0,xe=0,_e=0;try{for(const $e of ge)try{let Me=null;if($e.email){const{data:pe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",$e.email).maybeSingle();Me=pe}if(!Me&&$e.phone){const pe=$e.phone.replace(/[^0-9]/g,""),{data:we}=await H.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(we){const Le=we.find(Qe=>Qe.phone&&Qe.phone.replace(/[^0-9]/g,"")===pe);Le&&(Me={id:Le.id})}}const Ie={owner_user_id:a.id,first_name:$e.first_name,last_name:$e.last_name||null,email:$e.email||null,phone:$e.phone||null,address:$e.address||null,city:$e.city||null,state:$e.state||null,zip:$e.zip||null,spouse_name:$e.spouse_name||null,spouse_email:$e.spouse_email||null,company_name:$e.company_name||null,job_title:$e.job_title||null,birthday:a9($e.birthday),home_anniversary:a9($e.home_anniversary),notes:$e.notes||null};let ke=null;if(Me){const{data:pe}=await H.from("innercircle_contacts").select("*").eq("id",Me.id).single();if(pe){const we={},Le=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const Qe of Le){const Te=pe[Qe],pt=Ie[Qe];(!Te||Te==="")&&pt&&(we[Qe]=pt)}Object.keys(we).length>0&&await H.from("innercircle_contacts").update(we).eq("id",Me.id)}ke=Me.id,xe++}else{const{data:pe,error:we}=await H.from("innercircle_contacts").insert(Ie).select("id").single();we?(console.error("Insert error for contact:",$e.first_name,we),_e++):pe?(ke=pe.id,w.length>0&&await H.from("innercircle_contact_tags").insert(w.map(Le=>({contact_id:pe.id,relationship_type_id:Le}))),ue++):_e++}if(ke&&$e.spouse_name){const pe=Q($e.spouse_name);let we=null;if($e.spouse_email){const{data:Qe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",$e.spouse_email).maybeSingle();we=Qe}if(!we){const{data:Qe}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",pe.first_name).eq("last_name",pe.last_name||$e.last_name||"").maybeSingle();we=Qe}let Le=null;if(we){Le=we.id;const Qe=a9($e.home_anniversary);Qe&&await H.from("innercircle_contacts").update({home_anniversary:Qe}).eq("id",we.id).is("home_anniversary",null)}else{const{data:Qe}=await H.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:pe.first_name,last_name:pe.last_name||$e.last_name||null,email:$e.spouse_email||null,address:$e.address||null,city:$e.city||null,state:$e.state||null,zip:$e.zip||null,home_anniversary:a9($e.home_anniversary),spouse_name:`${$e.first_name}${$e.last_name?" "+$e.last_name:""}`,spouse_email:$e.email||null,notes:`Spouse of ${$e.first_name} ${$e.last_name||""} (imported via CSV)`.trim()}).select("id").single();Qe&&(Le=Qe.id,ue++)}Le&&(await H.from("innercircle_contacts").update({spouse_contact_id:Le}).eq("id",ke),await H.from("innercircle_contacts").update({spouse_contact_id:ke}).eq("id",Le))}}catch(Me){console.error("Error importing contact:",Me),_e++}O({created:ue,updated:xe,failed:_e}),c("result"),(ue>0||xe>0)&&n(),o({title:"Import Complete",description:`${ue} created, ${xe} updated${_e>0?`, ${_e} failed`:""}.`})}catch($e){console.error("Import error:",$e),o({title:"Import Failed",description:$e.message||"Failed to import contacts",variant:"destructive"})}finally{L(!1)}},ne=k.filter(ge=>ge.isValid).length,re=k.filter(ge=>!ge.isValid).length,oe=k.filter(ge=>ge.isValid&&ge.isDuplicate).length,fe=ne-oe;return e.jsx(xs,{open:t,onOpenChange:U,children:e.jsxs(fs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(c1,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Wr,{children:"Upload a CSV file with your contacts. You can map columns and select relationship types."})]}),i==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:V,className:"hidden"}),e.jsx(di,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var ge;return(ge=l.current)==null?void 0:ge.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),e.jsx("p",{className:"text-muted-foreground text-xs mb-3",children:"First Name, Last Name, Email, Phone, Street Address, City, State, Zip, Spouse Name, Spouse Email, Company, Job Title, Birthday, Home Anniversary, Notes"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const ge=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,ue=new Blob([ge],{type:"text/csv"}),xe=URL.createObjectURL(ue),_e=document.createElement("a");_e.href=xe,_e.download="contact_import_template.csv",_e.click(),URL.revokeObjectURL(xe)},children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:Jbs.map(ge=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(be,{className:"w-40 text-sm",children:[ge.label,ge.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ks,{value:v[ge.key]||"none",onValueChange:ue=>X(ge.key,ue),children:[e.jsx(Gs,{className:"w-48",children:e.jsx(Ys,{placeholder:"Select column..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"-- Not mapped --"}),u.map(ue=>e.jsx(Mt,{value:ue,children:ue},ue))]})]})]},ge.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(ge=>e.jsx(st,{variant:w.includes(ge.id)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(ge.id),children:ge.name},ge.id))})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",f.length," row(s) found in CSV"]})})]}),i==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[fe," new"]})]}),oe>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Cl,{className:"h-4 w-4"}),e.jsxs("span",{children:[oe," existing (will merge gaps)"]})]}),re>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Cl,{className:"h-4 w-4"}),e.jsxs("span",{children:[re," invalid"]})]})]}),oe>0&&e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground",children:"Duplicates matched by email or phone will only fill in missing fields — your existing data won't be overwritten."}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/30",children:[e.jsx(St,{children:"First Name"}),e.jsx(St,{children:"Last Name"}),e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Phone"}),e.jsx(St,{children:"Status"})]})}),e.jsx(Bn,{children:k.slice(0,100).map((ge,ue)=>e.jsxs(Cs,{children:[e.jsx(dt,{children:ge.first_name}),e.jsx(dt,{children:ge.last_name}),e.jsx(dt,{children:ge.email}),e.jsx(dt,{children:ge.phone}),e.jsx(dt,{children:ge.isValid?ge.isDuplicate?e.jsx(st,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(st,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(st,{variant:"destructive",children:ge.error||"Invalid"})})]},ue))})]}),k.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",k.length," contacts"]})]})]}),i==="result"&&P&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(sa,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[P.created," created, ",P.updated," merged"]}),P.failed>0&&e.jsxs("p",{className:"text-destructive",children:[P.failed," failed to import"]})]}),e.jsxs(Un,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:U,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:$,children:"Back"}),e.jsx(K,{onClick:ee,disabled:!v.first_name,children:"Continue"})]}),i==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>c("mapping"),children:"Back"}),e.jsx(K,{onClick:ce,disabled:M||ne===0,children:M?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${ne} Contact${ne!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:U,children:"Done"})]})]})})};function t_s(){return"contacts"in navigator&&"ContactsManager"in window}function s_s(t){const s=[],r=t.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of r){const a=n.split(/\r?\n/);let o="",l="",i="",c="",u="";for(const p of a){const f=p.replace(/^\s+/,"");if(f.startsWith("N:")||f.startsWith("N;")){const v=f.substring(f.indexOf(":")+1).split(";");l=(v[0]||"").trim(),o=(v[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const v=f.substring(f.indexOf(":")+1).trim().split(" ");o=v[0]||"",l=v.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!c&&(c=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("ADR")||f.match(/^item\d+\.ADR/i))&&!u&&(u=f.substring(f.indexOf(":")+1).split(";").map(_=>_.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:c,address:u})}return s}function r_s({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Os(),{data:a}=Wm(),o=Iue(),l=N.useRef(null),[i,c]=N.useState("choose"),[u,p]=N.useState([]),[f,g]=N.useState(new Set),[v,_]=N.useState(0),[w,j]=N.useState(0),k=t_s(),S=N.useCallback(X=>{if(!a)return X;const Y=new Set(a.filter(Q=>Q.email).map(Q=>Q.email.toLowerCase())),ee=new Set(a.filter(Q=>Q.phone).map(Q=>Q.phone.replace(/\D/g,"")));return X.map(Q=>{var re,oe;const ce=(re=Q.email)==null?void 0:re.toLowerCase(),ne=(oe=Q.phone)==null?void 0:oe.replace(/\D/g,"");return ce&&Y.has(ce)?{...Q,isDuplicate:!0,duplicateField:"email"}:ne&&ne.length>=7&&ee.has(ne)?{...Q,isDuplicate:!0,duplicateField:"phone"}:Q})},[a]),M=async()=>{try{const X=["name","email","tel","address"],Y=await navigator.contacts.select(X,{multiple:!0});if(!Y||Y.length===0)return;const ee=Y.map(ne=>{var fe,ge,ue,xe;const oe=(((fe=ne.name)==null?void 0:fe[0])||"").split(" ");return{first_name:oe[0]||"",last_name:oe.slice(1).join(" "),email:((ge=ne.email)==null?void 0:ge[0])||"",phone:((ue=ne.tel)==null?void 0:ue[0])||"",address:(xe=ne.address)!=null&&xe[0]?[ne.address[0].streetAddress,ne.address[0].city,ne.address[0].region,ne.address[0].postalCode].filter(Boolean).join(", "):""}}),Q=S(ee);p(Q);const ce=new Set;Q.forEach((ne,re)=>{ne.isDuplicate||ce.add(re)}),g(ce),c("preview")}catch(X){console.error("Contact Picker error:",X),jn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},L=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;const ee=new FileReader;ee.onload=ce=>{var ge;const ne=(ge=ce.target)==null?void 0:ge.result,re=s_s(ne);if(re.length===0){jn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const oe=S(re);p(oe);const fe=new Set;oe.forEach((ue,xe)=>{ue.isDuplicate||fe.add(xe)}),g(fe),c("preview")},ee.readAsText(Y),l.current&&(l.current.value="")},P=async()=>{const X=u.filter((ee,Q)=>f.has(Q));if(X.length===0)return;c("importing");let Y=0;for(const ee of X)try{await o.mutateAsync({first_name:ee.first_name,last_name:ee.last_name||void 0,email:ee.email||void 0,phone:ee.phone||void 0,address:ee.address||void 0}),Y++,j(Math.round(Y/X.length*100))}catch(Q){console.error(`Failed to import ${ee.first_name} ${ee.last_name}:`,Q)}_(Y),c("done")},O=X=>{g(Y=>{const ee=new Set(Y);return ee.has(X)?ee.delete(X):ee.add(X),ee})},$=()=>{f.size===u.length?g(new Set):g(new Set(u.map((X,Y)=>Y)))},U=X=>{X||(c("choose"),p([]),g(new Set),_(0),j(0),i==="done"&&r()),s(X)},B=u.filter(X=>X.isDuplicate).length,V=f.size;return e.jsx(xs,{open:t,onOpenChange:U,children:e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_0,{className:"h-5 w-5 text-primary"}),i==="choose"&&"Import Phone Contacts",i==="preview"&&"Select Contacts to Import",i==="importing"&&"Importing Contacts...",i==="done"&&"Import Complete"]}),i==="choose"&&e.jsx(Wr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[k&&e.jsxs(K,{onClick:M,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(_0,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[k&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),k&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:k?"outline":"default",onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(di,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:k?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:L,className:"hidden"}),!k&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",B>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",B," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:$,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Ki,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((X,Y)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${X.isDuplicate?"opacity-60":""}`,onClick:()=>O(Y),children:[e.jsx(Oo,{checked:f.has(Y),onCheckedChange:()=>O(Y),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]}),X.isDuplicate&&e.jsxs(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",X.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[X.phone&&e.jsx("div",{children:X.phone}),X.email&&e.jsx("div",{className:"truncate",children:X.email})]})]})]},Y))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c("choose"),children:"Back"}),e.jsxs(K,{onClick:P,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(bs,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ba,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[v," contact",v!==1?"s":""," imported!"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),e.jsx(K,{onClick:()=>U(!1),className:"mt-2",children:"Done"})]})]})})}function sme(){const t=ri();return mt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function n_s(t){return mt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function bSe(){const t=Xt(),s=ri();return Lt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await H.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function a_s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function i_s(){const t=Xt();return Lt({mutationFn:async({id:s,name:r,color:n})=>{const a={};r!==void 0&&(a.name=r.trim()),n!==void 0&&(a.color=n);const{error:o}=await H.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function nit(){const t=Xt();return Lt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function o_s(){const t=Xt();return Lt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await H.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function l_s(){const t=ri();return mt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function c_s({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=nr(),{data:c}=Gx(),u=DNe(),p=Xt(),{isGmailConnected:f}=Zx(),{isReady:g}=xSe(),{data:v}=sme(),_=bSe(),w=nit(),[j,k]=N.useState(!1),[S,M]=N.useState(!1),[L,P]=N.useState(!1),[O,$]=N.useState(""),U=t.size;if(U===0)return null;const B=async ne=>{k(!0);try{const oe=Array.from(t).map(ge=>({contact_id:ge,relationship_type_id:ne})),{error:fe}=await H.from("innercircle_contact_tags").upsert(oe,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(fe)throw fe;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),jn({title:`Assigned type to ${U} contacts`}),r()}catch(re){jn({title:"Error assigning type",description:re.message,variant:"destructive"})}finally{k(!1)}},V=async ne=>{k(!0);try{const re=Array.from(t);for(const oe of re)try{await w.mutateAsync({contactId:oe,tagId:ne})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),jn({title:`Tagged ${U} contacts`}),P(!1),$("")}catch(re){jn({title:"Error adding tags",description:re.message,variant:"destructive"})}finally{k(!1)}},X=async()=>{if(O.trim()){k(!0);try{const ne=await _.mutateAsync({name:O.trim()});await V(ne.id)}catch(ne){jn({title:"Error creating tag",description:ne.message,variant:"destructive"}),k(!1)}}},Y=(v==null?void 0:v.filter(ne=>ne.name.toLowerCase().includes(O.toLowerCase())))||[],ee=v==null?void 0:v.find(ne=>ne.name.toLowerCase()===O.trim().toLowerCase()),Q=()=>{const ne=s.filter(_e=>t.has(_e.id)),re=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],oe=ne.map(_e=>{var $e;return[_e.first_name,_e.last_name||"",_e.email||"",_e.phone||"",_e.address||"",_e.birthday||"",_e.home_anniversary||"",_e.notes||"",(($e=_e.tags)==null?void 0:$e.map(Me=>{var Ie;return(Ie=Me.relationship_type)==null?void 0:Ie.name}).join("; "))||""]}),fe=[re.join(","),...oe.map(_e=>_e.map($e=>`"${($e||"").replace(/"/g,'""')}"`).join(","))].join(` `),ge=new Blob([fe],{type:"text/csv"}),ue=URL.createObjectURL(ge),xe=document.createElement("a");xe.href=ue,xe.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,xe.click(),URL.revokeObjectURL(ue),jn({title:`Exported ${U} contacts`})},ce=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){k(!0);try{const ne=Array.from(t);for(const re of ne)await u.mutateAsync(re);r()}catch(ne){jn({title:"Error deleting contacts",description:ne.message,variant:"destructive"})}finally{k(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(st,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs(Ks,{onValueChange:B,disabled:j,children:[e.jsx(Gs,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Fm,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Ws,{children:c==null?void 0:c.filter(ne=>ne.active).map(ne=>e.jsx(Mt,{value:ne.id,children:ne.name},ne.id))})]}),e.jsxs($o,{open:L,onOpenChange:P,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:j,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",children:[e.jsx(ze,{placeholder:"Search or create tag...",value:O,onChange:ne=>$(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&O.trim()&&!ee?(ne.preventDefault(),X()):ne.key==="Enter"&&ee&&(ne.preventDefault(),V(ee.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[Y.map(ne=>e.jsxs("button",{onClick:()=>V(ne.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:ne.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:ne.name})]},ne.id)),O.trim()&&!ee&&e.jsxs("button",{onClick:X,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),'Create "',O.trim(),'"']}),Y.length===0&&!O.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>M(!0),disabled:j,children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),g&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const ne=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${ne}`)},disabled:j,children:[e.jsx(Ph,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:j,children:[e.jsx(Jg,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:j,children:[e.jsx(a1,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Q,disabled:j,children:[e.jsx(vi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,disabled:j,className:"text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Mr,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(Kw,{open:S,onOpenChange:M,bulkContacts:Array.from(t).map(ne=>{const re=s.find(oe=>oe.id===ne);return re?{id:re.id,first_name:re.first_name,last_name:re.last_name,email:re.email||""}:null}).filter(ne=>ne!==null&&ne.email!==""),onSendComplete:()=>{M(!1),r()}})]})}function d7e({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=nr(),{isReady:u}=xSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(xx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Aa,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Mn,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Aa,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Aa,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(ia,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Aa,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Aa,{onClick:()=>n(t.id,p),children:[e.jsx(Rm,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Aa,{onClick:()=>a(t.id),children:[e.jsx(Jg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Aa,{onClick:()=>l(t.id),children:[e.jsx(a1,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Aa,{onClick:()=>s(t),children:[e.jsx(za,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Aa,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function d_s(){const{user:t}=Os();return mt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function u_s(){const t=Xt(),{user:s}=Os();return Lt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await H.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),jn({title:"Smart filter saved"})},onError:r=>{jn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function h_s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),jn({title:"Smart filter deleted"})}})}function m_s({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=d_s(),a=u_s(),o=h_s(),[l,i]=N.useState(!1),[c,u]=N.useState(""),p=t.search||t.type&&t.type!=="all"||t.status&&t.status!=="all",f=async()=>{c.trim()&&(await a.mutateAsync({name:c.trim(),filters:t,sort_by:s}),u(""),i(!1))};return e.jsxs(e.Fragment,{children:[e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ey,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(st,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(oo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Bd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(g=>e.jsxs(Aa,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(g.filters,g.sort_by),children:g.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:v=>{v.stopPropagation(),o.mutate(g.id)},children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]},g.id)),e.jsx(xw,{})]}):e.jsx(Aa,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Aa,{onClick:()=>i(!0),children:[e.jsx(oL,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ze,{placeholder:"e.g. Buyers in 40205",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>g.key==="Enter"&&f(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:f,disabled:!c.trim()||a.isPending,children:"Save"})]})]})]})})]})}function $I(t){if(!t)return null;try{const s=t.split(/[-/T]/);if(s.length<3)return null;const r=parseInt(s[1],10)-1,n=parseInt(s[2],10);if(isNaN(r)||isNaN(n))return null;const a=new Date;a.setHours(0,0,0,0);let o=new Date(a.getFullYear(),r,n);return o.setHours(0,0,0,0),or)return null;const a=s==="birthday"?"🎂":"🏡",o=n===0?s==="birthday"?"Birthday today!":"Anniversary today!":n===1?s==="birthday"?"Birthday tomorrow":"Anniversary tomorrow":`${a} in ${n}d`;return{emoji:a,label:o,daysUntil:n}}function h7e({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=nr(),i=u7e(t,"birthday",7),c=u7e(s,"anniversary",7);if(!i&&!c)return null;const u=(p,f)=>{f.stopPropagation();const g=new URLSearchParams;n&&g.set("contactId",n),a&&g.set("name",a),o&&g.set("address",o),p==="home_anniversary"&&s&&g.set("date",s),g.set("cardType",p),l(`/mission-control/card-studio?${g.toString()}`)};return e.jsxs("div",{className:It("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(st,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",i.daysUntil===0?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400 animate-pulse":"bg-pink-50 text-pink-600 dark:bg-pink-900/20 dark:text-pink-400"),children:i.label}),n&&e.jsxs("button",{onClick:p=>u("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[e.jsx(lr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(st,{variant:"secondary",className:It("text-[10px] gap-0.5 font-medium",c.daysUntil===0?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse":"bg-blue-50 text-blue-600 dark:bg-blue-900/20 dark:text-blue-400"),children:c.label}),n&&e.jsxs("button",{onClick:p=>u("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[e.jsx(lr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function m7e({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:s.color,color:s.color,backgroundColor:`${s.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:s.color}}),s.name]})}function p_s(){const t=ri();return mt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function f_s({contactId:t,compact:s=!1}){const{data:r}=sme(),{data:n}=n_s(t),a=bSe(),o=nit(),l=o_s(),[i,c]=N.useState(!1),[u,p]=N.useState(""),f=N.useRef(null),g=new Set((n==null?void 0:n.map(k=>k.tag_id))||[]),v=(r==null?void 0:r.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())))||[],_=r==null?void 0:r.find(k=>k.name.toLowerCase()===u.trim().toLowerCase()),w=async k=>{g.has(k.id)?await l.mutateAsync({contactId:t,tagId:k.id}):await o.mutateAsync({contactId:t,tagId:k.id})},j=async()=>{if(!(!u.trim()||_))try{const k=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:k.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(k=>{var S,M,L;return e.jsxs(st,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=k.tag)==null?void 0:S.color)||"#6366F1",color:((M=k.tag)==null?void 0:M.color)||"#6366F1"},children:[e.jsx(Fm,{className:"h-2.5 w-2.5"}),(L=k.tag)==null?void 0:L.name,e.jsx("button",{onClick:P=>{P.stopPropagation(),l.mutate({contactId:t,tagId:k.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Mr,{className:"h-2.5 w-2.5"})})]},k.id)}),e.jsxs($o,{open:i,onOpenChange:c,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:k=>k.stopPropagation(),children:[e.jsx(qs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(Ro,{className:"w-56 p-2",align:"start",onClick:k=>k.stopPropagation(),children:[e.jsx(ze,{ref:f,placeholder:"Search or create tag...",value:u,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&u.trim()&&!_?(k.preventDefault(),j()):k.key==="Enter"&&_&&!g.has(_.id)&&(k.preventDefault(),w(_))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[v.map(k=>e.jsxs("button",{onClick:()=>w(k),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:k.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:k.name}),g.has(k.id)&&e.jsx(ba,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},k.id)),u.trim()&&!_&&e.jsxs("button",{onClick:j,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),v.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function p7e({contactId:t,tags:s}){return!s||s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>{var n,a,o;return e.jsx(st,{variant:"outline",className:"text-[10px] gap-0.5",style:{borderColor:((n=r.tag)==null?void 0:n.color)||"#6366F1",color:((a=r.tag)==null?void 0:a.color)||"#6366F1"},children:(o=r.tag)==null?void 0:o.name},r.tag_id)})})}const i9=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function x_s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=sme(),a=bSe(),o=i_s(),l=a_s(),[i,c]=N.useState(""),[u,p]=N.useState(i9[0]),[f,g]=N.useState(null),[v,_]=N.useState(""),[w,j]=N.useState(""),k=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),p(i9[0]),jn({title:"Tag created"})}catch(P){jn({title:"Error",description:P.message,variant:"destructive"})}},S=async P=>{if(v.trim())try{await o.mutateAsync({id:P,name:v.trim(),color:w}),g(null),jn({title:"Tag updated"})}catch(O){jn({title:"Error",description:O.message,variant:"destructive"})}},M=async(P,O)=>{if(confirm(`Delete tag "${O}"? It will be removed from all contacts.`))try{await l.mutateAsync(P),jn({title:"Tag deleted"})}catch($){jn({title:"Error",description:$.message,variant:"destructive"})}},L=P=>{g(P.id),_(P.name),j(P.color)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New tag name...",value:i,onChange:P=>c(P.target.value),onKeyDown:P=>P.key==="Enter"&&k(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:k,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i9.map(P=>e.jsx("button",{onClick:()=>p(P),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===P?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:P}},P))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(P=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===P.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:i9.map(O=>e.jsx("button",{onClick:()=>j(O),className:`h-5 w-5 rounded-full border-2 ${w===O?"border-foreground":"border-transparent"}`,style:{backgroundColor:O}},O))}),e.jsx(ze,{value:v,onChange:O=>_(O.target.value),onKeyDown:O=>O.key==="Enter"&&S(P.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(P.id),children:e.jsx(ba,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>g(null),children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:P.color}}),e.jsx("span",{className:"flex-1 text-sm",children:P.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>L(P),children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>M(P.id,P.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})},P.id))]})]})})}function g_s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=mE(),a=FNe(),o=y8t(),l=v8t(),[i,c]=N.useState(""),[u,p]=N.useState(null),[f,g]=N.useState(""),v=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),c("")}catch(k){me.error(k.message||"Failed to add lead source")}},_=async k=>{if(f.trim())try{await o.mutateAsync({id:k,name:f.trim()}),p(null)}catch(S){me.error(S.message||"Failed to update")}},w=async(k,S)=>{if(confirm(`Remove lead source "${S}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(k)}catch(M){me.error(M.message||"Failed to remove")}},j=k=>{p(k.id),g(k.name)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:k=>c(k.target.value),onKeyDown:k=>k.key==="Enter"&&v(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:v,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(k=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===k.id?e.jsxs(e.Fragment,{children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&_(k.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>_(k.id),children:e.jsx(ba,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:k.name}),k.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>j(k),children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>w(k.id,k.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),!k.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},k.id))]})]})})}function ait({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=mE(),a=FNe(),[o,l]=N.useState(!1),[i,c]=N.useState(""),u=async()=>{if(i.trim())try{const p=await a.mutateAsync(i.trim());p&&(s(p.id),c(""),l(!1))}catch{}};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Ys,{placeholder:"Select lead source"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Mr,{className:"h-4 w-4"}):e.jsx(qs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),u())},className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:u,disabled:!i.trim()||a.isPending,children:"Add"})]})]})}function J_e({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=nr(),[c,u]=N.useState(!1),[p,f]=N.useState(""),{data:g}=mt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:_,error:w}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(w)throw w;return _},enabled:!!s}),{data:v}=mt({queryKey:["spouse-search",p],queryFn:async()=>{let _=H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(_=_.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:w,error:j}=await _;if(j)throw j;return w},enabled:c});if(s&&g){const _=`${g.first_name} ${g.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("button",{onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:_}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[g.phone,g.email].filter(Boolean).join(" · ")||"No contact info"})]}),l&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:o,className:"shrink-0 h-7 px-2",children:[e.jsx(jS,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${g.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Sa,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm",children:r}),n&&e.jsx("span",{className:"text-xs text-muted-foreground block truncate",children:n})]}),l&&e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(ml,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(Ro,{className:"w-72 p-2",align:"end",children:e.jsx(f7e,{search:p,setSearch:f,results:v,onSelect:_=>{a(_),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(ml,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(Ro,{className:"w-72 p-2",align:"start",children:e.jsx(f7e,{search:p,setSearch:f,results:v,onSelect:_=>{a(_),u(!1),f("")}})})]})]}):null}function f7e({search:t,setSearch:s,results:r,onSelect:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ki,{className:"max-h-48",children:r&&r.length>0?e.jsx("div",{className:"space-y-0.5",children:r.map(a=>e.jsxs("button",{onClick:()=>n(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[a.first_name," ",a.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[a.phone,a.email].filter(Boolean).join(" · ")||"No contact info"})]},a.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search contacts"})})]})}function y_s(){var bi;const t=nr(),[s]=uc(),{user:r}=Os(),n=DE(),a=Xt(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=Oue(),{activeContactIds:p,hasLeadSite:f}=Ybs(),{data:g}=Gx(),{data:v}=p_s(),{data:_}=sme(),{data:w}=l_s(),[j,k]=N.useState(new Set),[S,M]=N.useState("any"),L=Iue(),P=LNe(),O=DNe(),$=dQe(),[U,B]=N.useState(""),[V,X]=N.useState(o||"all"),[Y,ee]=N.useState(l||"all"),[Q,ce]=N.useState("date-added"),[ne,re]=N.useState(i),[oe,fe]=N.useState(null),[ge,ue]=N.useState(!1),[xe,_e]=N.useState(!1),[$e,Me]=N.useState(null),[Ie,ke]=N.useState(""),[pe,we]=N.useState(new Set),[Le,Qe]=N.useState(!1),[Te,pt]=N.useState(1),[ye,qe]=N.useState(50),[at,tt]=N.useState("my"),[Ae,rt]=N.useState(!1),[He,ct]=N.useState(!1),{data:Ue}=Ux(),{addToLeadPond:Ze}=_tt(Ue==null?void 0:Ue.teamId),Je=!!((bi=Ue==null?void 0:Ue.team)!=null&&bi.lead_pond_enabled&&(Ue!=null&&Ue.teamId)),Ge=!!(Ue!=null&&Ue.teamId),[et,it]=N.useState([]),[Dt,Vt]=N.useState(!1),hs=ft=>{it([ft]),Vt(!0)},As=ft=>{it(ft),Vt(!0)},Ms=ft=>{Ue!=null&&Ue.teamId&&Ze.mutate({contact_id:ft,team_id:Ue.teamId})},cs=ft=>{Ue!=null&&Ue.teamId&&ft.forEach(or=>{Ze.mutate({contact_id:or,team_id:Ue.teamId})})},er=N.useCallback(ft=>{Qe(!1),we(or=>{const Vn=new Set(or);return Vn.has(ft)?Vn.delete(ft):Vn.add(ft),Vn})},[]);N.useEffect(()=>{if(!(r!=null&&r.id))return;const ft=H.channel(`innercircle_contacts_inserts_${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${r.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{H.removeChannel(ft)}},[a,r==null?void 0:r.id]),N.useEffect(()=>{l&&ee(l)},[l]);const[xt,Ps]=N.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});N.useEffect(()=>{i&&re(!0)},[i]),N.useEffect(()=>{var ft;oe&&Ps({first_name:oe.first_name||"",last_name:oe.last_name||"",email:oe.email||"",phone:oe.phone||"",address:oe.address||"",city:oe.city||"",state:oe.state||"",zip_code:oe.zip_code||"",birthday:oe.birthday||"",home_anniversary:oe.home_anniversary||"",spouse_name:oe.spouse_name||"",spouse_email:oe.spouse_email||"",lead_source_id:oe.lead_source_id||"",notes:oe.notes||"",tagIds:((ft=oe.tags)==null?void 0:ft.map(or=>or.relationship_type_id))||[]})},[oe]);const mr=N.useMemo(()=>{if(!c)return[];let ft=c.filter(or=>{var ea,La,Ii;const Vn=U===""||`${or.first_name} ${or.last_name}`.toLowerCase().includes(U.toLowerCase())||((ea=or.email)==null?void 0:ea.toLowerCase().includes(U.toLowerCase()))||((La=or.phone)==null?void 0:La.includes(U)),Sr=V==="all"||((Ii=or.tags)==null?void 0:Ii.some(Fo=>Fo.relationship_type_id===V)),jr=j.size===0||(()=>{const Fo=(w==null?void 0:w.filter($t=>$t.contact_id===or.id).map($t=>$t.tag_id))||[];return S==="any"?Fo.some($t=>j.has($t)):Array.from(j).every($t=>Fo.includes($t))})();return Vn&&Sr&&jr});return Y==="not-touched-90"?ft=ft.filter(or=>{const Vn=or.relationshipScore.daysSinceTouch;return Vn===null||Vn>90}):Y==="at-risk"?ft=ft.filter(or=>or.relationshipScore.status==="at-risk"):Y==="cooling"?ft=ft.filter(or=>or.relationshipScore.status==="cooling"):Y==="warm"?ft=ft.filter(or=>or.relationshipScore.status==="warm"):Y==="has-deal"?ft=ft.filter(or=>v&&v[or.id]):Y==="no-deal"?ft=ft.filter(or=>!v||!v[or.id]):Y==="open-house"?ft=ft.filter(or=>{var Sr;return(((Sr=or.lead_source_ref)==null?void 0:Sr.name)||or.lead_source)==="Open House"}):Y==="website-active"&&(ft=ft.filter(or=>p.has(or.id))),ft=[...ft].sort((or,Vn)=>{switch(Q){case"important-dates":{const Sr=$I(or.birthday),jr=$I(Vn.birthday),ea=$I(or.home_anniversary),La=$I(Vn.home_anniversary),Ii=[Sr,ea].filter($t=>$t!==null).sort(($t,Se)=>($t??1/0)-(Se??1/0))[0]??1/0,Fo=[jr,La].filter($t=>$t!==null).sort(($t,Se)=>($t??1/0)-(Se??1/0))[0]??1/0;return Ii-Fo}case"last-touched":{const Sr=or.relationshipScore.lastTouchDate,jr=Vn.relationshipScore.lastTouchDate;return!Sr&&!jr?0:Sr?jr?new Date(Sr).getTime()-new Date(jr).getTime():1:-1}case"next-touch":{const Sr=or.relationshipScore.daysSinceTouch,jr=Vn.relationshipScore.daysSinceTouch;return Sr===null&&jr===null?0:Sr===null?-1:jr===null?1:jr-Sr}case"score":return or.relationshipScore.score-Vn.relationshipScore.score;case"date-added":{const Sr=or.created_at,jr=Vn.created_at;return!Sr&&!jr?0:Sr?jr?new Date(jr).getTime()-new Date(Sr).getTime():-1:1}case"name":default:{const Sr=`${or.first_name||""} ${or.last_name||""}`.toLowerCase(),jr=`${Vn.first_name||""} ${Vn.last_name||""}`.toLowerCase();return Sr.localeCompare(jr)}}}),ft},[c,U,V,j,S,Y,Q,v,w,p]),Tr=mr.length,Dr=Math.max(1,Math.ceil(Tr/ye)),xn=Math.min(Te,Dr),Si=N.useMemo(()=>{const ft=(xn-1)*ye;return mr.slice(ft,ft+ye)},[mr,xn,ye]);N.useEffect(()=>{pt(1)},[U,V,j,S,Y,Q]);const Ia=N.useCallback(()=>{Qe(!1),we(ft=>ft.size>0?new Set:new Set(Si.map(or=>or.id)))},[Si]),ur=N.useCallback(()=>{Qe(!0),we(new Set(mr.map(ft=>ft.id)))},[mr]),Jr=N.useCallback((ft,or)=>{B(ft.search||""),X(ft.type||"all"),ee(ft.status||"all"),ce(or||"name")},[]),Gr=()=>{Ps({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},mn=async ft=>{ft.preventDefault();const or={...xt,lead_source_id:xt.lead_source_id||null};oe?(await P.mutateAsync({id:oe.id,...or}),fe(null)):(await L.mutateAsync(or),re(!1)),Gr()},Yr=async ft=>{confirm("Are you sure you want to delete this contact?")&&await O.mutateAsync(ft)};return e.jsx(Ts,{title:"Contacts",description:"Manage your InnerCircle contacts",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),Ue&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>tt("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${at==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Ue.team.contact_visibility==="full_team"||Ue.team.contact_visibility==="leader_only"&&Ue.role==="team_leader")&&e.jsxs("button",{onClick:()=>tt("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),"Team"]}),Ue.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>tt("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${at==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Jg,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]})}),at==="team"?e.jsx(Kke,{}):at==="lead-pond"&&Ue?e.jsx(Zke,{teamId:Ue.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or phone...",value:U,onChange:ft=>B(ft.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>re(!0),className:"shrink-0",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>ue(!0),className:"shrink-0",children:[e.jsx(di,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>_e(!0),className:"shrink-0",children:[e.jsx(_0,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx($bs,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Ks,{value:V,onValueChange:X,children:[e.jsx(Gs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Ys,{placeholder:"Filter by type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),g==null?void 0:g.filter(ft=>ft.active).map(ft=>e.jsx(Mt,{value:ft.id,children:ft.name},ft.id))]})]}),_&&_.length>0&&e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Fm,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),j.size===0?"Filter by Tags":`${j.size} tag${j.size>1?"s":""}`]})}),e.jsx(Ro,{className:"w-60 p-3",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Tags"}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5",children:[e.jsx("button",{onClick:()=>M("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>M("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${S==="all"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"All"})]})]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:_.map(ft=>{const or=j.has(ft.id);return e.jsxs("button",{onClick:()=>{k(Vn=>{const Sr=new Set(Vn);return Sr.has(ft.id)?Sr.delete(ft.id):Sr.add(ft.id),Sr})},className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx(Oo,{checked:or,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:ft.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:ft.name})]},ft.id)})}),j.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>k(new Set),children:"Clear tags"})]})})]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Aa,{onClick:()=>rt(!0),children:[e.jsx(Fm,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Aa,{onClick:()=>ct(!0),children:[e.jsx(Jg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Ks,{value:Y,onValueChange:ee,children:[e.jsx(Gs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Ys,{placeholder:"Filter by status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"warm",children:"🟢 Warm"}),e.jsx(Mt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(Mt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(Mt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(Mt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(Mt,{value:"open-house",children:"🏠 Open House"}),f&&e.jsx(Mt,{value:"website-active",children:"🌐 Website Active"})]})]}),e.jsxs(Ks,{value:Q,onValueChange:ce,children:[e.jsx(Gs,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_d,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Ys,{placeholder:"Sort by"})]})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"name",children:"Name (A-Z)"}),e.jsx(Mt,{value:"important-dates",children:"Important Dates"}),e.jsx(Mt,{value:"last-touched",children:"Last Touched"}),e.jsx(Mt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(Mt,{value:"score",children:"Relationship Score"}),e.jsx(Mt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(m_s,{currentFilters:{search:U,type:V,status:Y},currentSortBy:Q,onApplySmartList:Jr})]})]})})}),e.jsx(c_s,{selectedIds:pe,contacts:mr,onClearSelection:()=>{we(new Set),Qe(!1)},showLeadPondAction:Je,onSendToLeadPond:cs,showTransferAction:Ge,onTransfer:As}),pe.size>0&&pe.size===Si.length&&!Le&&Tr>ye&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/5 border border-primary/20 rounded-lg text-sm",children:[e.jsxs("span",{children:["All ",Si.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:ur,children:["Select all ",Tr.toLocaleString()," matching contacts"]})]}),Le&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/10 border border-primary/30 rounded-lg text-sm font-medium",children:["All ",Tr.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{we(new Set),Qe(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):mr.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:U||V!=="all"||Y!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Si.map(ft=>{var Vn,Sr,jr;const{relationshipScore:or}=ft;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const ea=new URLSearchParams;U&&ea.set("search",U),V!=="all"&&ea.set("type",V),Y!=="all"&&ea.set("filter",Y);const La=ea.toString();t(`/mission-control/contacts/${ft.id}${La?`?${La}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[ft.first_name," ",ft.last_name]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[ft.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(lr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:ft.email})]}),ft.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Mn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:ft.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(P8,{score:or,size:"sm"}),e.jsx(X_e,{contact:ft}),(((Vn=ft.lead_source_ref)==null?void 0:Vn.name)||ft.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Sr=ft.lead_source_ref)==null?void 0:Sr.name)||ft.lead_source}),(jr=ft.tags)==null?void 0:jr.map(ea=>{var La;return e.jsx(st,{variant:"secondary",className:"text-xs",children:(La=ea.relationship_type)==null?void 0:La.name},ea.id)}),e.jsx(p7e,{contactId:ft.id,tags:w==null?void 0:w.filter(ea=>ea.contact_id===ft.id)}),e.jsx(m7e,{deal:v==null?void 0:v[ft.id]})]}),e.jsx(h7e,{birthday:ft.birthday,homeAnniversary:ft.home_anniversary,className:"mb-2",contactId:ft.id,contactName:`${ft.first_name}${ft.last_name?" "+ft.last_name:""}`,contactAddress:[ft.address,ft.city,ft.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[or.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(or.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),ft.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Rl(ft.birthday),"MMM d")]}),ft.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dn,{className:"h-3 w-3"}),ms(Rl(ft.home_anniversary),"MMM d")]}),ft.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Added ",ms(new Date(ft.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:ea=>ea.stopPropagation(),children:e.jsx(d7e,{contact:ft,onEdit:fe,onDelete:Yr,onSnooze:(ea,La)=>{Me(ea),ke(La)},showLeadPondAction:Je,onSendToLeadPond:Ms,showTransferAction:Ge,onTransfer:hs})})]})})},ft.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(Fn,{className:"min-w-[800px]",children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:Si.length>0&&Si.every(ft=>pe.has(ft.id)),onCheckedChange:()=>Ia()})}),e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Score"}),e.jsx(St,{children:"Contact Info"}),e.jsx(St,{children:"Types / Pipeline"}),e.jsx(St,{children:"Last Contact"}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>ce(Q==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",Q==="date-added"&&e.jsx(_d,{className:"h-3 w-3"})]})}),e.jsx(St,{children:"Important Dates"}),e.jsx(St,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Bn,{children:u?e.jsx(Cs,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):mr.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||V!=="all"||Y!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Si.map(ft=>{var Sr,jr,ea;const{relationshipScore:or}=ft,Vn=v==null?void 0:v[ft.id];return e.jsxs(Cs,{className:`cursor-pointer hover:bg-accent/50 ${pe.has(ft.id)?"bg-accent/30":""}`,onClick:()=>{const La=new URLSearchParams;U&&La.set("search",U),V!=="all"&&La.set("type",V),Y!=="all"&&La.set("status",Y);const Ii=La.toString();t(`/mission-control/contacts/${ft.id}${Ii?`?${Ii}`:""}`)},children:[e.jsx(dt,{onClick:La=>La.stopPropagation(),children:e.jsx(Oo,{checked:pe.has(ft.id),onCheckedChange:()=>er(ft.id)})}),e.jsxs(dt,{className:"font-medium",children:[ft.first_name," ",ft.last_name]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(P8,{score:or,size:"sm"}),e.jsx(X_e,{contact:ft})]})}),e.jsx(dt,{children:e.jsx(P8,{score:or,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[ft.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(lr,{className:"h-3 w-3"}),ft.email]}),ft.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Mn,{className:"h-3 w-3"}),ft.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Sr=ft.lead_source_ref)==null?void 0:Sr.name)||ft.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((jr=ft.lead_source_ref)==null?void 0:jr.name)||ft.lead_source}),(ea=ft.tags)==null?void 0:ea.map(La=>{var Ii;return e.jsx(st,{variant:"secondary",className:"text-xs",children:(Ii=La.relationship_type)==null?void 0:Ii.name},La.id)}),e.jsx(p7e,{contactId:ft.id,tags:w==null?void 0:w.filter(La=>La.contact_id===ft.id)}),e.jsx(m7e,{deal:Vn})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:or.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(or.lastTouchDate),"MMM d, yyyy")]}):e.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ft.created_at?ms(new Date(ft.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(h7e,{birthday:ft.birthday,homeAnniversary:ft.home_anniversary,contactId:ft.id,contactName:`${ft.first_name}${ft.last_name?" "+ft.last_name:""}`,contactAddress:[ft.address,ft.city,ft.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ft.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(Rl(ft.birthday),"MMM d")]}),ft.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dn,{className:"h-3 w-3"}),ms(Rl(ft.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(d7e,{contact:ft,onEdit:fe,onDelete:Yr,onSnooze:(La,Ii)=>{Me(La),ke(Ii)},showLeadPondAction:Je,onSendToLeadPond:Ms,showTransferAction:Ge,onTransfer:hs})})]},ft.id)})})]})})}),Tr>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",(xn-1)*ye+1,"–",Math.min(xn*ye,Tr)," of ",Tr.toLocaleString()," contacts"]}),e.jsxs(Ks,{value:String(ye),onValueChange:ft=>{qe(Number(ft)),pt(1)},children:[e.jsx(Gs,{className:"w-[80px] h-8",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"50",children:"50"}),e.jsx(Mt,{value:"100",children:"100"}),e.jsx(Mt,{value:"250",children:"250"})]})]}),e.jsx("span",{className:"text-xs",children:"per page"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:xn<=1,onClick:()=>pt(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:xn<=1,onClick:()=>pt(ft=>ft-1),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",xn," of ",Dr]}),e.jsx(K,{variant:"outline",size:"sm",disabled:xn>=Dr,onClick:()=>pt(ft=>ft+1),children:e.jsx(oa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:xn>=Dr,onClick:()=>pt(Dr),children:"Last"})]})]}),e.jsx(xs,{open:ne||!!oe,onOpenChange:ft=>{ft||(re(!1),fe(null),Gr())},children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:oe?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:mn,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"first_name",children:"First Name *"}),e.jsx(ze,{id:"first_name",value:xt.first_name,onChange:ft=>Ps({...xt,first_name:ft.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:xt.last_name,onChange:ft=>Ps({...xt,last_name:ft.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:xt.email,onChange:ft=>Ps({...xt,email:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:xt.phone,onChange:ft=>Ps({...xt,phone:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"address",children:"Address"}),e.jsx(ze,{id:"address",value:xt.address,onChange:ft=>Ps({...xt,address:ft.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:xt.city,onChange:ft=>Ps({...xt,city:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:xt.state,onChange:ft=>Ps({...xt,state:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"zip_code",children:"Zip"}),e.jsx(ze,{id:"zip_code",value:xt.zip_code,onChange:ft=>Ps({...xt,zip_code:ft.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:xt.birthday,onChange:ft=>Ps({...xt,birthday:ft.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:xt.home_anniversary,onChange:ft=>Ps({...xt,home_anniversary:ft.target.value})})]})]}),oe&&e.jsx(J_e,{contactId:oe.id,currentSpouseContactId:(oe==null?void 0:oe.spouse_contact_id)||null,currentSpouseName:(oe==null?void 0:oe.spouse_name)||null,currentSpouseEmail:(oe==null?void 0:oe.spouse_email)||null,onLink:ft=>$.mutate({contactId:oe.id,spouseContactId:ft}),onUnlink:()=>$.mutate({contactId:oe.id,spouseContactId:null}),isEditing:!0}),e.jsx(ait,{value:xt.lead_source_id,onChange:ft=>Ps({...xt,lead_source_id:ft})}),e.jsxs("div",{children:[e.jsx(be,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g==null?void 0:g.filter(ft=>ft.active).map(ft=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:xt.tagIds.includes(ft.id),onCheckedChange:or=>{Ps(or?{...xt,tagIds:[...xt.tagIds,ft.id]}:{...xt,tagIds:xt.tagIds.filter(Vn=>Vn!==ft.id)})}}),e.jsx("span",{className:"text-sm",children:ft.name})]},ft.id))})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Pr,{id:"notes",value:xt.notes,onChange:ft=>Ps({...xt,notes:ft.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{re(!1),fe(null),Gr()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:L.isPending||P.isPending,children:[oe?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(e_s,{open:ge,onOpenChange:ue,relationshipTypes:(g==null?void 0:g.filter(ft=>ft.active))||[],onSuccess:()=>{ue(!1)}}),e.jsx(r_s,{open:xe,onOpenChange:_e,onComplete:()=>_e(!1)}),e.jsx(eme,{open:!!$e,onOpenChange:ft=>{ft||Me(null)},contactId:$e||"",contactName:Ie}),e.jsx(x_s,{open:Ae,onOpenChange:rt}),e.jsx(g_s,{open:He,onOpenChange:ct}),e.jsx(wtt,{open:Dt,onOpenChange:Vt,contactIds:et,contactNames:et.map(ft=>{const or=mr.find(Vn=>Vn.id===ft);return or?`${or.first_name} ${or.last_name||""}`.trim():""}),onComplete:()=>{it([]),we(new Set),Qe(!1)}})]})]})})}function v_s(){return mt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function b_s(t){return mt({queryKey:["video-scripts",t],queryFn:async()=>{let s=H.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function __s(){const{user:t}=Os();return mt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function w_s(){const{user:t}=Os(),s=Xt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function j_s(t){const{user:s}=Os();return mt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function N_s(t){return mt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await H.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function L3(){const{user:t}=Os(),s=Xt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function k_s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function S_s(){const t=Xt();return Lt({mutationFn:async({id:s,bunnyVideoId:r,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:s,bunnyVideoId:r,hardDelete:n}),r){console.log("Calling bunny-upload delete for videoId:",r);const{data:a,error:o}=await H.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await H.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await H.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function rme(){const{user:t}=Os();return mt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function iit(){const{data:t,isLoading:s}=rme(),r=t?t.total_storage_mb0?t.total_storage_mb/t.max_storage_mb*100:0,o=a>=80;return{canRecord:r,remainingMb:n,usagePercent:a,isNearLimit:o,storage:t,isLoading:s}}async function SR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function CR(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function AA(t){const{data:s,error:r}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function C_s(){const{user:t}=Os(),s=Xt();return Lt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await H.from("action_types").select("id").eq("name","Video").single();if(!o)throw new Error("Video action type not found");const{data:l,error:i}=await H.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function M_s(t){return mt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function T_s(t){return mt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function _Se(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function MR(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function A_s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function E_s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function P_s(){const t=Xt();return Lt({mutationFn:async({id:s,dealId:r})=>{await H.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await H.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function oit(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function I_s(){const t=ri();return mt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function L_s(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function D_s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function O_s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function k1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function R_s({contactId:t}){const s=nr(),r=Xt(),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(null),w=MR(),j=oit(),{data:k,isLoading:S}=mt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:U,error:B}=await H.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(B)throw B;if(!U||U.length===0)return[];const V=U.map(ee=>ee.id),{data:X,error:Y}=await H.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(Y)throw Y;return(X||[]).map(ee=>({...ee,deal:U.find(Q=>Q.id===ee.deal_id)}))},enabled:!!t}),M=(k==null?void 0:k.map(U=>U.id))||[],{data:L}=mt({queryKey:["contact-portal-updates",M],queryFn:async()=>{if(M.length===0)return{};const{data:U,error:B}=await H.from("portal_updates").select("*").in("portal_id",M).order("created_at",{ascending:!1});if(B)throw B;const V={};return(U||[]).forEach(X=>{V[X.portal_id]||(V[X.portal_id]=X)}),V},enabled:M.length>0}),P=U=>{navigator.clipboard.writeText(k1(U)),a(U),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},O=async U=>{u.trim()&&(await j.mutateAsync({portal_id:U,title:u,content:f||void 0}),c(!1),p(""),g(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},$=async()=>{v&&(await w.mutateAsync({id:v.id,welcome_message:v.welcome_message,next_step_text:v.next_step_text,is_enabled:v.is_enabled,show_post_close_tips:v.show_post_close_tips,review_url:v.review_url}),l(!1),_(null),r.invalidateQueries({queryKey:["contact-portals",t]}),me.success("Portal settings updated!"))};return S||!k||k.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ru,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:k.map(U=>{var Y,ee,Q;const B=((Y=U.stage_mapping)==null?void 0:Y.length)>0?U.stage_mapping:pNe(((ee=U.deal)==null?void 0:ee.deal_type)||"buyer"),V=B==null?void 0:B[U.current_stage_index??0],X=L==null?void 0:L[U.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Q=U.deal)==null?void 0:Q.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(st,{variant:U.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:U.is_enabled?"Active":"Disabled"})]}),X&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:X.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ms(new Date(X.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>P(U.slug),children:[n===U.slug?e.jsx(ba,{className:"h-3 w-3 mr-1"}):e.jsx(yi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(k1(U.slug),"_blank"),children:[e.jsx(en,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(xs,{open:i,onOpenChange:c,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>c(!0),children:[e.jsx(so,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:u,onChange:ce=>p(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Details (optional)"}),e.jsx(Pr,{value:f,onChange:ce=>g(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>O(U.id),disabled:!u.trim()||j.isPending,className:"w-full",children:[e.jsx($n,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(xs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{_({...U}),l(!0)},children:[e.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Portal Settings"})}),v&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Portal Enabled"}),e.jsx(qr,{checked:v.is_enabled,onCheckedChange:ce=>_({...v,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),e.jsx(Pr,{value:v.welcome_message||"",onChange:ce=>_({...v,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Next Step"}),e.jsx(ze,{value:v.next_step_text||"",onChange:ce=>_({...v,next_step_text:ce.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review URL"}),e.jsx(ze,{value:v.review_url||"",onChange:ce=>_({...v,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Show Post-Close Tips"}),e.jsx(qr,{checked:v.show_post_close_tips,onCheckedChange:ce=>_({...v,show_post_close_tips:ce})})]}),e.jsx(al,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:$,disabled:w.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${U.deal_id}`),children:[e.jsx(Sa,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),k.length>1&&e.jsx(al,{})]},U.id)})})]})}function F_s({contactId:t}){const{data:s}=mt({queryKey:["agent-lead-sites-slugs"],queryFn:async()=>{const{data:l,error:i}=await H.from("lead_sites").select("id, subdomain_slug").eq("is_active",!0);if(i)throw i;return new Map((l||[]).map(c=>[c.id,c.subdomain_slug]))},staleTime:6e5}),r=s&&s.size>0,{data:n,isLoading:a}=mt({queryKey:["contact-property-views",t],queryFn:async()=>{const{data:l,error:i}=await H.rpc("get_contact_property_views",{p_contact_id:t});if(i)throw i;return l||[]},enabled:!!t&&!!r});if(!r||a||!n||n.length===0)return null;const o=l=>{const i=s==null?void 0:s.get(l.lead_site_id);return i?`https://${i}.thelocalmove.com/listing/${l.mls_number}`:null};return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Dn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(st,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l),c=l.property_address||`MLS# ${l.mls_number}`;return e.jsxs("a",{href:i||"#",target:"_blank",rel:"noopener noreferrer",onClick:u=>{i||u.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[l.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.jsx("img",{src:l.photo_url,alt:c,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-primary/15 to-primary/5 flex items-center justify-center flex-shrink-0",children:e.jsx(dn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:"font-medium text-sm truncate",children:c})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{title:ms(new Date(l.viewed_at),"PPp"),children:Vc(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(en,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const z_s=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function x7e({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=N.useState(!1),c=N.useRef(null),u=N.useRef(null);N.useEffect(()=>{const f=g=>{u.current&&!u.current.contains(g.target)&&c.current&&!c.current.contains(g.target)&&i(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const p=n.filter(f=>f.toLowerCase().includes(t.toLowerCase()));return e.jsxs("div",{className:"relative flex-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:c,value:t,onChange:f=>{s(f.target.value),i(!0)},onFocus:()=>i(!0),placeholder:a,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),p.length>0?r(p[0]):r(t))}}),n.length>0&&e.jsx(oo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>r(t),children:e.jsx(qs,{className:"h-4 w-4"})})]}),l&&p.length>0&&e.jsx("div",{ref:u,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:p.map(f=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>{r(f),i(!1)},children:[o||e.jsx(ia,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function B_s({contactId:t,contactName:s}){var B,V,X;const{user:r}=Os(),n=ri(),{hasLeadSite:a}=uE(),o=Xt(),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState(""),{data:g}=mt({queryKey:["agent-lead-site-config",n],queryFn:async()=>{const{data:Y,error:ee}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(ee||!Y)return{cities:[],zipCodes:[]};const Q=Y.theme_config||{},ce=Array.isArray(Q.searchCities)?Q.searchCities:[];Y.mls_market_area&&!ce.includes(Y.mls_market_area)&&ce.unshift(Y.mls_market_area);const ne=Array.isArray(Q.searchZipCodes)?Q.searchZipCodes:[];return{cities:ce,zipCodes:ne}},enabled:!!n}),{data:v,isLoading:_}=mt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:ee}=await H.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(ee)throw ee;return Y},enabled:!!t&&!!r}),[w,j]=N.useState({}),k=()=>{j({is_active:(v==null?void 0:v.is_active)??!0,min_price:(v==null?void 0:v.min_price)??null,max_price:(v==null?void 0:v.max_price)??null,min_beds:(v==null?void 0:v.min_beds)??null,min_baths:(v==null?void 0:v.min_baths)??null,min_sqft:(v==null?void 0:v.min_sqft)??null,max_sqft:(v==null?void 0:v.max_sqft)??null,cities:(v==null?void 0:v.cities)??[],zip_codes:(v==null?void 0:v.zip_codes)??[],property_types:(v==null?void 0:v.property_types)??[],frequency:(v==null?void 0:v.frequency)??"daily"}),i(!0)},S=Lt({mutationFn:async()=>{const Y={contact_id:t,owner_user_id:n,is_active:w.is_active??!0,min_price:w.min_price||null,max_price:w.max_price||null,min_beds:w.min_beds||null,min_baths:w.min_baths||null,min_sqft:w.min_sqft||null,max_sqft:w.max_sqft||null,cities:w.cities||[],zip_codes:w.zip_codes||[],property_types:w.property_types||[],frequency:w.frequency||"daily"};if(v!=null&&v.id){const{error:ee}=await H.from("contact_property_alerts").update(Y).eq("id",v.id);if(ee)throw ee}else{const{error:ee}=await H.from("contact_property_alerts").insert(Y);if(ee)throw ee}},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert saved!")},onError:Y=>{me.error(Y.message||"Failed to save alert")}}),M=Lt({mutationFn:async()=>{if(!(v!=null&&v.id))return;const{error:Y}=await H.from("contact_property_alerts").delete().eq("id",v.id);if(Y)throw Y},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-property-alert",t]}),i(!1),me.success("Property alert removed")}}),L=Y=>{var Q;const ee=Y.trim();ee&&!((Q=w.cities)!=null&&Q.includes(ee))&&j(ce=>({...ce,cities:[...ce.cities||[],ee]})),u("")},P=Y=>{var Q;const ee=Y.trim();ee&&!((Q=w.zip_codes)!=null&&Q.includes(ee))&&j(ce=>({...ce,zip_codes:[...ce.zip_codes||[],ee]})),f("")},O=Y=>{j(ee=>{const Q=ee.property_types||[];return{...ee,property_types:Q.includes(Y)?Q.filter(ce=>ce!==Y):[...Q,Y]}})};if(!a||_)return null;if(v&&!l)return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${v.is_active?"bg-green-500/10":"bg-muted"}`,children:v.is_active?e.jsx(Lm,{className:"h-4 w-4 text-green-600"}):e.jsx(i1,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(st,{variant:v.is_active?"default":"secondary",className:"text-xs ml-auto",children:[v.is_active?"Active":"Paused"," · ",v.frequency]})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[v.min_price||v.max_price?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(hl,{className:"h-3 w-3"}),v.min_price?`$${(v.min_price/1e3).toFixed(0)}k`:"$0"," - ",v.max_price?`$${(v.max_price/1e3).toFixed(0)}k`:"Any"]}):null,v.min_beds?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(eS,{className:"h-3 w-3"}),v.min_beds,"+ beds"]}):null,v.min_baths?e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(su,{className:"h-3 w-3"}),v.min_baths,"+ baths"]}):null,(B=v.cities)==null?void 0:B.map(Y=>e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),Y]},Y)),(V=v.zip_codes)==null?void 0:V.map(Y=>e.jsx(st,{variant:"outline",children:Y},Y)),(X=v.property_types)==null?void 0:X.map(Y=>e.jsx(st,{variant:"outline",children:Y},Y))]}),v.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(v.last_sent_at).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:k,className:"flex-1",children:"Manage Alert"}),e.jsxs(K,{variant:"destructive",size:"sm",onClick:()=>M.mutate(),disabled:M.isPending,className:"flex-1",children:[M.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Mr,{className:"h-4 w-4 mr-1"}),"Remove Alert"]})]})]})]});const $=((g==null?void 0:g.cities)||[]).filter(Y=>{var ee;return!((ee=w.cities)!=null&&ee.includes(Y))}),U=((g==null?void 0:g.zipCodes)||[]).filter(Y=>{var ee;return!((ee=w.zip_codes)!=null&&ee.includes(Y))});return l?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Lm,{className:"h-4 w-4 text-primary"}),v?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Alert Active"}),e.jsx(qr,{checked:w.is_active??!0,onCheckedChange:Y=>j(ee=>({...ee,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(hl,{className:"h-3.5 w-3.5"})," Price Range"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min price",value:w.min_price??"",onChange:Y=>j(ee=>({...ee,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max price",value:w.max_price??"",onChange:Y=>j(ee=>({...ee,max_price:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(eS,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Ks,{value:w.min_beds?String(w.min_beds):"any",onValueChange:Y=>j(ee=>({...ee,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Any"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,2,3,4,5].map(Y=>e.jsxs(Mt,{value:String(Y),children:[Y,"+"]},Y))]})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(su,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Ks,{value:w.min_baths?String(w.min_baths):"any",onValueChange:Y=>j(ee=>({...ee,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Any"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"any",children:"Any"}),[1,1.5,2,2.5,3,4].map(Y=>e.jsxs(Mt,{value:String(Y),children:[Y,"+"]},Y))]})]})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ax,{className:"h-3.5 w-3.5"})," Square Feet"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{type:"number",placeholder:"Min sqft",value:w.min_sqft??"",onChange:Y=>j(ee=>({...ee,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max sqft",value:w.max_sqft??"",onChange:Y=>j(ee=>({...ee,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ia,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(x7e,{value:c,onChange:u,onAdd:L,suggestions:$,placeholder:"Type to search cities..."}),w.cities&&w.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.cities.map(Y=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(ee=>{var Q;return{...ee,cities:(Q=ee.cities)==null?void 0:Q.filter(ce=>ce!==Y)}}),children:e.jsx(Mr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(x7e,{value:p,onChange:f,onAdd:P,suggestions:U,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),w.zip_codes&&w.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.zip_codes.map(Y=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(ee=>{var Q;return{...ee,zip_codes:(Q=ee.zip_codes)==null?void 0:Q.filter(ce=>ce!==Y)}}),children:e.jsx(Mr,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(dn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:z_s.map(Y=>{var ee;return e.jsx(st,{variant:(ee=w.property_types)!=null&&ee.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>O(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(be,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Ks,{value:w.frequency||"daily",onValueChange:Y=>j(ee=>({...ee,frequency:Y})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"daily",children:"Daily"}),e.jsx(Mt,{value:"weekly",children:"Weekly"})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>S.mutate(),disabled:S.isPending,className:"flex-1",children:[S.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Uc,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),v&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>M.mutate(),disabled:M.isPending,children:e.jsx(Mr,{className:"h-4 w-4"})})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(Lm,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Set Up Property Alerts"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Automatically email ",s," new listings matching their criteria"]})]})]})})})}function $_s({contactId:t,contactName:s}){var ne;const{user:r}=Os(),n=ri(),{hasLeadSite:a}=uE(),o=Xt(),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState([]),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(!1),[S,M]=N.useState(""),L=N.useRef(null),P=N.useRef(null),{data:O}=mt({queryKey:["agent-lead-site-cities",n],queryFn:async()=>{const{data:re,error:oe}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",n).eq("is_active",!0).order("created_at",{ascending:!0}).limit(1).maybeSingle();if(oe||!re)return[];const fe=re.theme_config||{},ge=Array.isArray(fe.searchCities)?fe.searchCities:[];return re.mls_market_area&&!ge.includes(re.mls_market_area)&&ge.unshift(re.mls_market_area),ge},enabled:!!n}),{data:$,isLoading:U}=mt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:re,error:oe}=await H.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(oe)throw oe;return re},enabled:!!t&&!!r});N.useEffect(()=>{const re=oe=>{P.current&&!P.current.contains(oe.target)&&L.current&&!L.current.contains(oe.target)&&w(!1)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[]);const B=()=>{v(($==null?void 0:$.market_report_enabled)??!1),f(($==null?void 0:$.market_report_cities)??[]),i(!0)},V=re=>{const oe=(re||c).trim();oe&&!p.includes(oe)&&f([...p,oe]),u(""),w(!1)},X=(O||[]).filter(re=>!p.includes(re)&&re.toLowerCase().includes(c.toLowerCase())),Y=Lt({mutationFn:async()=>{const{data:re,error:oe}=await H.functions.invoke("send-market-report",{body:{action:"preview",agentId:n,cities:($==null?void 0:$.market_report_cities)??[]}});if(oe)throw new Error(oe.message||"Failed to generate preview");if(re&&!re.ok&&re.error)throw new Error(re.error);return re},onSuccess:re=>{M(re.html),k(!0)},onError:re=>{me.error(re.message||"Failed to generate preview")}}),ee=Lt({mutationFn:async()=>{const{data:re,error:oe}=await H.functions.invoke("send-market-report",{body:{action:"send",agentId:n,cities:($==null?void 0:$.market_report_cities)??[],contactIds:[t]}});if(oe)throw new Error(oe.message||"Failed to send report");if(re&&!re.ok&&re.error)throw new Error(re.error);return re},onSuccess:()=>{me.success(`Market report sent to ${s}!`)},onError:re=>{me.error(re.message||"Failed to send report")}}),Q=Lt({mutationFn:async()=>{const{error:re}=await H.from("innercircle_contacts").update({market_report_enabled:g,market_report_cities:p}).eq("id",t);if(re)throw re},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),me.success(g?"Monthly market report enabled!":"Market report disabled")},onError:re=>{me.error(re.message||"Failed to save")}}),ce=Lt({mutationFn:async()=>{const{error:re}=await H.from("innercircle_contacts").update({market_report_enabled:!1,market_report_cities:[]}).eq("id",t);if(re)throw re},onSuccess:()=>{o.invalidateQueries({queryKey:["contact-market-report",t]}),i(!1),v(!1),f([]),me.success("Market report removed")},onError:re=>{me.error(re.message||"Failed to remove market report")}});return!a||U?null:$!=null&&$.market_report_enabled&&!l?e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg flex items-center justify-center bg-primary/10",children:e.jsx(yo,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(st,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Oe,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((ne=$.market_report_cities)==null?void 0:ne.length)>0?$.market_report_cities.map(re=>e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),re]},re)):e.jsx("span",{className:"text-muted-foreground",children:"Using default market area"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s," receives a branded market report on the 1st of each month."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,className:"flex-1",children:[Y.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Dn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>ee.mutate(),disabled:ee.isPending,className:"flex-1",children:[ee.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx($n,{className:"h-4 w-4 mr-1"}),"Send Now"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:B,className:"flex-1",children:"Manage"}),e.jsxs(K,{variant:"destructive",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,className:"flex-1",children:[ce.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Mr,{className:"h-4 w-4 mr-1"}),"Remove"]})]}),e.jsx(xs,{open:j,onOpenChange:k,children:e.jsxs(fs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(yo,{className:"h-5 w-5 text-primary"}),"Market Report Preview"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto -mx-6 px-6",children:e.jsx("div",{className:"border rounded-lg overflow-hidden",dangerouslySetInnerHTML:{__html:S}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(K,{onClick:()=>{k(!1),ee.mutate()},disabled:ee.isPending,className:"flex-1",children:[ee.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx($n,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>k(!1),children:"Close"})]})]})})]})]}):l?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(yo,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Send Monthly Report"}),e.jsx(qr,{checked:g,onCheckedChange:v})]}),g&&e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(ia,{className:"h-3.5 w-3.5"})," Report Cities"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select cities from your website's configured areas."}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ze,{ref:L,value:c,onChange:re=>{u(re.target.value),w(!0)},onFocus:()=>w(!0),placeholder:"Type to search cities...",onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),X.length>0?V(X[0]):V())}}),e.jsx(oo,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),_&&X.length>0&&e.jsx("div",{ref:P,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:X.map(re=>e.jsxs("button",{type:"button",className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground transition-colors flex items-center gap-2",onClick:()=>V(re),children:[e.jsx(ia,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),re]},re))})]}),p.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:p.map(re=>e.jsxs(st,{variant:"secondary",className:"gap-1",children:[re,e.jsx("button",{onClick:()=>f(p.filter(oe=>oe!==re)),children:e.jsx(Mr,{className:"h-3 w-3"})})]},re))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>Q.mutate(),disabled:Q.isPending,className:"flex-1",children:[Q.isPending?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Uc,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"})]})]})]}):e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("button",{onClick:B,className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed border-primary/30 hover:bg-primary/5 transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(yo,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Enable Monthly Market Report"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Auto-send ",s," a branded market report with real MLS data every month"]})]})]})})})}function q_s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=N_s(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{className:"w-full aspect-video rounded-lg"}),e.jsx(vs,{className:"h-4 w-1/3"})]});if(n||!s||s.is_deleted)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Yu,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This video has been deleted or is no longer available."})]});const a=i=>{let c=i;return c.includes("iframe.mediadelivery.net/play/")&&(c=c.replace("/play/","/embed/"),c+=(c.includes("?")?"&":"?")+"autoplay=true&responsive=true"),c},o=(l=s.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return e.jsxs("div",{className:"space-y-4",children:[s.playback_url?e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?e.jsx("iframe",{src:a(s.playback_url),title:s.title||"Video preview",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:s.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):e.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),s.title&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.notes})]})]})}function U_s({contactId:t}){const s=nr(),[r,n]=N.useState(!1),{data:a,isLoading:o}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),l=async(f,g)=>{const v=g==="done"?"todo":"done";await H.from("deal_tasks").update({status:v,completed_at:v==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=mt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:g}=await H.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(g)throw g;return f},enabled:!!t}),c={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"},u=(a==null?void 0:a.filter(f=>f.status!=="done"))||[],p=(a==null?void 0:a.filter(f=>f.status==="done"))||[];return e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ba,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(st,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(vs,{className:"h-8 w-full"}):u.length===0&&p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tasks yet"}):e.jsxs(e.Fragment,{children:[u.map(f=>e.jsxs("button",{onClick:async()=>{await l(f.id,f.status),i()},className:"w-full text-left flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors group",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border-2 border-muted-foreground/30 shrink-0 group-hover:border-primary"}),e.jsxs("span",{className:"text-sm flex-1 truncate",children:[c[f.priority]," ",f.title]}),f.due_date&&e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(f.due_date),"MMM d")})]},f.id)),p.length>0&&e.jsx("div",{className:"pt-1 border-t mt-1",children:e.jsxs("p",{className:"text-[10px] text-muted-foreground px-2 py-1",children:[p.length," completed"]})})]})}),r&&e.jsx(V_s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function V_s({contactId:t,open:s,onOpenChange:r}){const[n,a]=N.useState(""),[o,l]=N.useState("medium"),[i,c]=N.useState(),{data:u}=mt({queryKey:["session"],queryFn:async()=>{const{data:f}=await H.auth.getSession();return f.session}}),p=async()=>{var g;if(!n.trim()||!((g=u==null?void 0:u.user)!=null&&g.id))return;const{error:f}=await H.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ms(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(xs,{open:s,onOpenChange:r,children:e.jsxs(fs,{className:"sm:max-w-[400px]",children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:n,onChange:f=>a(f.target.value),placeholder:"Task title...",onKeyDown:f=>f.key==="Enter"&&p()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Priority"}),e.jsxs("select",{value:o,onChange:f=>l(f.target.value),className:"w-full h-10 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"low",children:"🟢 Low"}),e.jsx("option",{value:"medium",children:"🟡 Medium"}),e.jsx("option",{value:"high",children:"🟠 High"}),e.jsx("option",{value:"urgent",children:"🔴 Urgent"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date"}),e.jsx(ze,{type:"date",value:i?ms(i,"yyyy-MM-dd"):"",onChange:f=>c(f.target.value?new Date(f.target.value+"T00:00:00"):void 0)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(K,{onClick:p,disabled:!n.trim(),children:"Create Task"})]})]})]})})}function H_s({contactId:t}){const s=nr(),{data:r,isLoading:n}=mt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await H.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(th,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function G_s(){var He,ct,Ue,Ze,Je;const{contactId:t}=lo(),s=nr(),[r]=uc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=jLt(t||""),{data:c}=Gx(),{data:u}=JO(),{data:p}=eR(3650),{data:f}=tme(365),{data:g}=M_s(t),{contactsWithScores:v}=Oue(),_=LNe(),w=DNe(),j=ONe(),k=dQe(),[S,M]=N.useState(!1),[L,P]=N.useState({}),[O,$]=N.useState(!1),[U,B]=N.useState(null),[V,X]=N.useState(""),[Y,ee]=N.useState(void 0),[Q,ce]=N.useState(""),[ne,re]=N.useState(null),[oe,fe]=N.useState(!1),[ge,ue]=N.useState(null),{isGmailConnected:xe,gmailEmail:_e}=Zx(),{data:$e}=mt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:Ge,error:et}=await H.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(et)throw et;return Ge},enabled:!!t}),Me=Ge=>{if(!Ge)return null;const et=Ge.match(/Video ID:\s*([a-f0-9-]+)/i);return et?et[1]:null},Ie=N.useMemo(()=>{if(!v)return[];let Ge=v.filter(et=>{var Vt,hs,As;const it=n===""||`${et.first_name} ${et.last_name}`.toLowerCase().includes(n.toLowerCase())||((Vt=et.email)==null?void 0:Vt.toLowerCase().includes(n.toLowerCase()))||((hs=et.phone)==null?void 0:hs.includes(n)),Dt=a==="all"||((As=et.tags)==null?void 0:As.some(Ms=>Ms.relationship_type_id===a));return it&&Dt});return o==="not-touched-90"?Ge=Ge.filter(et=>{const it=et.relationshipScore.daysSinceTouch;return it===null||it>90}):o==="at-risk"?Ge=Ge.filter(et=>et.relationshipScore.status==="at-risk"):o==="cooling"?Ge=Ge.filter(et=>et.relationshipScore.status==="cooling"):o==="warm"&&(Ge=Ge.filter(et=>et.relationshipScore.status==="warm")),Ge.map(et=>et.id)},[v,n,a,o]),ke=Ie.indexOf(t||""),pe=ke>0?Ie[ke-1]:null,we=ke1&&ke!==-1,Qe=Ge=>{const et=new URLSearchParams;n&&et.set("search",n),a!=="all"&&et.set("type",a),o!=="all"&&et.set("status",o);const it=et.toString();return`/mission-control/contacts/${Ge}${it?`?${it}`:""}`},Te=N.useMemo(()=>{const Ge=((p==null?void 0:p.filter(it=>it.contact_id===t))||[]).map(it=>{var As,Ms,cs;const Dt=Me(it.notes);let Vt=((As=it.action_type)==null?void 0:As.name)||"Touch",hs=it.notes;if(Vt==="Other"&&((Ms=it.notes)!=null&&Ms.startsWith("["))){const er=it.notes.indexOf("]");er>0&&(Vt=it.notes.substring(1,er),hs=it.notes.substring(er+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:it.id,type:"touch",completed_at:it.completed_at,name:Vt,color:((cs=it.action_type)==null?void 0:cs.color)||"#3B82F6",notes:hs,videoId:Dt}}),et=((f==null?void 0:f.filter(it=>it.contact_id===t))||[]).map(it=>({id:it.id,type:"popby",completed_at:it.completed_at,name:"Pop-by",color:"#F97316",notes:it.notes,videoId:null}));return[...Ge,...et].sort((it,Dt)=>new Date(Dt.completed_at).getTime()-new Date(it.completed_at).getTime())},[p,f,t]),pt=()=>{var Ge;l&&(P({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((Ge=l.tags)==null?void 0:Ge.map(et=>et.relationship_type_id))||[]}),M(!0))},ye=async()=>{await _.mutateAsync({id:t,...L,lead_source_id:L.lead_source_id||null}),M(!1)},qe=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},tt=((He=u==null?void 0:u.find(Ge=>Ge.id===U))==null?void 0:He.name)==="Other",Ae=async()=>{if(!U||tt&&!Q.trim())return;const Ge=Y?new Date(Y.getFullYear(),Y.getMonth(),Y.getDate(),12,0,0).toISOString():void 0,et=tt?`[${Q.trim()}]${V?" — "+V:""}`:V;await j.mutateAsync({contactId:t,actionTypeId:U,notes:et,completedAt:Ge}),$(!1),B(null),X(""),ee(void 0),ce("")},rt=(Ge,et)=>{xe&&l?(ue({email:Ge,name:et||`${l.first_name} ${l.last_name||""}`.trim()}),fe(!0)):window.location.href=`mailto:${Ge}`};return i?e.jsx(Ts,{title:"Contact Details",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):l?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/contacts"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Le&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>pe&&s(Qe(pe)),disabled:!pe,className:"px-2",children:[e.jsx(Xo,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:"Prev"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[ke+1," of ",Ie.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>we&&s(Qe(we)),disabled:!we,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(oa,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>rt(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(lr,{className:"h-4 w-4 mr-1"}),"Email"]}),e.jsxs(K,{variant:"default",onClick:()=>s(`/mission-control/video/record?contact_id=${t}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[e.jsx(Cn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(xs,{open:O,onOpenChange:$,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(fs,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(Ge=>Ge.active).map(Ge=>e.jsxs("button",{onClick:()=>B(Ge.id),className:` p-3 rounded-lg border text-left transition-all ${U===Ge.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:Ge.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Ge.description})]},Ge.id))}),tt&&e.jsxs("div",{className:"mt-3",children:[e.jsx(be,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(ze,{id:"custom-action-name",value:Q,onChange:Ge=>ce(Ge.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Date (optional — backdate if needed)"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal mt-2",!Y&&"text-muted-foreground"),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),Y?ms(Y,"PPP"):"Today (default)"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:Y,onSelect:ee,disabled:Ge=>Ge>new Date,initialFocus:!0,className:It("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Pr,{id:"action-notes",value:V,onChange:Ge=>X(Ge.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Ae,disabled:!U||tt&&!Q.trim()||j.isPending,className:"w-full",children:[e.jsx(ba,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:pt,children:[e.jsx(md,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:qe,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),(((ct=l.lead_source_ref)==null?void 0:ct.name)||l.lead_source)&&e.jsx(st,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Ue=l.lead_source_ref)==null?void 0:Ue.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>rt(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(lr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.email})]}),l.phone&&e.jsxs("a",{href:`tel:${l.phone}`,className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(Mn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:l.phone})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(X_e,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(Ge=>{const et=c==null?void 0:c.find(it=>it.id===Ge.relationship_type_id);return et?e.jsx(st,{variant:"secondary",className:"text-xs",children:et.name},Ge.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(f_s,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"md:col-span-2",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Contact Information"})}),e.jsx(Oe,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"first_name",children:"First Name"}),e.jsx(ze,{id:"first_name",value:L.first_name,onChange:Ge=>P({...L,first_name:Ge.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:L.last_name,onChange:Ge=>P({...L,last_name:Ge.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:L.email,onChange:Ge=>P({...L,email:Ge.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:L.phone,onChange:Ge=>P({...L,phone:Ge.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"address",children:"Street Address"}),e.jsx(ze,{id:"address",value:L.address,onChange:Ge=>P({...L,address:Ge.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:L.city,onChange:Ge=>P({...L,city:Ge.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:L.state,onChange:Ge=>P({...L,state:Ge.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(ze,{id:"zip_code",value:L.zip_code,onChange:Ge=>P({...L,zip_code:Ge.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:L.birthday,onChange:Ge=>P({...L,birthday:Ge.target.value})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:L.home_anniversary,onChange:Ge=>P({...L,home_anniversary:Ge.target.value})})]})]}),e.jsx(al,{}),e.jsx(J_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:Ge=>k.mutate({contactId:t,spouseContactId:Ge}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"company_name",children:"Company"}),e.jsx(ze,{id:"company_name",value:L.company_name,onChange:Ge=>P({...L,company_name:Ge.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"job_title",children:"Job Title"}),e.jsx(ze,{id:"job_title",value:L.job_title,onChange:Ge=>P({...L,job_title:Ge.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(ait,{value:L.lead_source_id||"",onChange:Ge=>P({...L,lead_source_id:Ge})}),e.jsxs("div",{children:[e.jsx(be,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:c==null?void 0:c.filter(Ge=>Ge.active).map(Ge=>{var et;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:(et=L.tagIds)==null?void 0:et.includes(Ge.id),onCheckedChange:it=>{var Dt;P(it?{...L,tagIds:[...L.tagIds||[],Ge.id]}:{...L,tagIds:(Dt=L.tagIds)==null?void 0:Dt.filter(Vt=>Vt!==Ge.id)})}}),e.jsx("span",{className:"text-sm",children:Ge.name})]},Ge.id)})})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Pr,{id:"notes",value:L.notes,onChange:Ge=>P({...L,notes:Ge.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:ye,disabled:_.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>M(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[Te.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ms(new Date(Te[0].completed_at),"MMM d, yyyy")," ","(",Te[0].name,")"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:gap-6 gap-2",children:[l.email&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(lr,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>rt(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-primary hover:underline",children:l.phone})]})]}),(l.address||l.city||l.state||l.zip_code)&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ia,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ms(Rl(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ms(Rl(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ms(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(al,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(J_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:Ge=>k.mutate({contactId:t,spouseContactId:Ge}),onUnlink:()=>k.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:l.job_title&&l.company_name?`${l.job_title} at ${l.company_name}`:l.job_title||l.company_name})]})]}),e.jsx(al,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(Je=l.tags)!=null&&Je.length?l.tags.map(Ge=>{var et;return e.jsx(st,{variant:"secondary",children:(et=Ge.relationship_type)==null?void 0:et.name},Ge.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(al,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:l.notes})]})]})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Zbs,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(H_s,{contactId:t}),e.jsx(R_s,{contactId:t}),e.jsx(F_s,{contactId:t}),e.jsx(B_s,{contactId:t,contactName:l.first_name}),e.jsx($_s,{contactId:t,contactName:l.first_name}),e.jsx(U_s,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Activity Log"})}),e.jsx(Oe,{children:Te.length>0?e.jsx("div",{className:"space-y-4",children:Te.map(Ge=>{var et;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[e.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:Ge.color},children:Ge.type==="popby"?e.jsx(So,{className:"h-4 w-4"}):(et=Ge.name)==null?void 0:et.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:Ge.name}),Ge.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>re(Ge.videoId),children:[e.jsx(il,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(Ge.completed_at),"MMM d, yyyy h:mm a")}),Ge.notes&&!Ge.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ge.notes})]})]},Ge.id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),g&&g.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(so,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:g.map(Ge=>{var et,it;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(et=Ge.video)!=null&&et.thumbnail_url?e.jsx("img",{src:Ge.video.thumbnail_url,alt:Ge.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>re(Ge.video_id)}):e.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>re(Ge.video_id),children:e.jsx(Cn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:["Replied to: ",((it=Ge.video)==null?void 0:it.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>re(Ge.video_id),children:[e.jsx(il,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ms(new Date(Ge.created_at),"MMM d, yyyy h:mm a")}),Ge.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',Ge.message,'"']})]})]},Ge.id)})})})]}),$e&&$e.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx($n,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:$e.map(Ge=>e.jsxs(xs,{children:[e.jsx(qi,{asChild:!0,children:e.jsxs("button",{className:"w-full text-left flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors cursor-pointer",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-sky-500/10 flex items-center justify-center text-sky-600 flex-shrink-0",children:e.jsx(lr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ge.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",Ge.to_email," · ",ms(new Date(Ge.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5 text-sky-500"}),Ge.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",Ge.to_email," · ",ms(new Date(Ge.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden rounded-lg border bg-white",children:e.jsx("iframe",{srcDoc:Ge.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${Ge.subject}`})})]})]},Ge.id))})})]})]}),e.jsx(xs,{open:!!ne,onOpenChange:Ge=>!Ge&&re(null),children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsx(_s,{children:"Video Preview"})}),ne&&e.jsx(q_s,{videoId:ne})]})})]})]})}),xe&&l&&ge&&e.jsx(Kw,{open:oe,onOpenChange:fe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:ge.email},gmailEmail:_e})]}):e.jsx(Ts,{title:"Contact Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),e.jsx(K,{onClick:()=>s("/mission-control/contacts"),children:"Back to Contacts"})]})})}const g7e={Crown:Dm,FileText:wn,Users:hr,Globe:ru,Star:Jn,Phone:Mn,MessageSquare:so,PenTool:Y_,Video:Cn,Gift:So},Tye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function W_s(){var Je,Ge;const t=nr(),{user:s}=Os(),{data:r}=Gx(),{data:n}=kLt(),{data:a}=PLt(),{data:o}=cQe(),{data:l}=JO(),{data:i}=NLt(),c=ILt(),u=SLt(),p=MLt(),f=TLt(),g=ALt(),v=ELt(),_=CLt(),[w,j]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(null),[P,O]=N.useState(""),[$,U]=N.useState(""),[B,V]=N.useState([]),[X,Y]=N.useState(null),[ee,Q]=N.useState(null),[ce,ne]=N.useState(!1),[re,oe]=N.useState(""),[fe,ge]=N.useState(""),[ue,xe]=N.useState(""),[_e,$e]=N.useState(""),Me=(et,it)=>a==null?void 0:a.some(Dt=>Dt.plan_id===et&&Dt.relationship_type_id===it&&Dt.active),Ie=et=>a==null?void 0:a.find(it=>it.relationship_type_id===et&&it.active),ke=async(et,it)=>{const Dt=Me(et,it);await c.mutateAsync({planId:et,relationshipTypeId:it,active:!Dt})},pe=(n==null?void 0:n.filter(et=>et.active&&!et.owner_user_id))||[],we=(n==null?void 0:n.filter(et=>et.owner_user_id===(s==null?void 0:s.id)))||[],Le=r==null?void 0:r.find(et=>et.id===w),Qe=w?Ie(w):null,Te=n==null?void 0:n.find(et=>et.id===(Qe==null?void 0:Qe.plan_id)),pt=async()=>{if(!P.trim())return;const et=await u.mutateAsync({name:P,description:$});et&&B.length>0&&await g.mutateAsync({planId:et.id,items:B}),at()},ye=async()=>{!P.trim()||!M||(await p.mutateAsync({id:M,name:P,description:$}),await g.mutateAsync({planId:M,items:B}),at())},qe=et=>{var it;L(et.id),O(et.name),U(et.description||""),V(((it=et.items)==null?void 0:it.map(Dt=>({month_number:Dt.month_number,action_type_id:Dt.action_type_id,default_script_id:Dt.default_script_id||void 0,notes:Dt.notes||void 0})))||[]),S(!0)},at=()=>{S(!1),L(null),O(""),U(""),V([])},tt=(et,it)=>{Q(it)},Ae=(et,it,Dt)=>{V(Vt=>[...Vt.filter(As=>As.month_number!==et),{month_number:et,action_type_id:it,default_script_id:Dt}]),Y(null),Q(null)},rt=et=>{V(it=>it.filter(Dt=>Dt.month_number!==et))},He=async()=>{if(!re.trim()||!fe.trim()||!ee)return;const et=await v.mutateAsync({actionTypeId:ee,title:re,scriptBody:fe,emailSubject:ue||void 0,tone:_e||void 0});et&&X!==null&&Ae(X,ee,et.id),ne(!1),oe(""),ge(""),xe(""),$e("")},ct=ee?i==null?void 0:i.filter(et=>et.action_type_id===ee&&et.active):[],Ue=et=>g7e[et||"Phone"]||Mn,Ze=et=>g7e[et||"Users"]||hr;return e.jsxs(Ts,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control"),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),r==null?void 0:r.filter(et=>et.active).map(et=>{const it=Ze(et.icon),Dt=(o==null?void 0:o[et.id])||0,Vt=Ie(et.id),hs=n==null?void 0:n.find(Ms=>Ms.id===(Vt==null?void 0:Vt.plan_id)),As=w===et.id;return e.jsxs("button",{onClick:()=>j(et.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${As?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(it,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Dt," contacts"]})]}),hs?e.jsxs(st,{variant:"secondary",className:"text-xs",children:[e.jsx(gi,{className:"h-3 w-3 mr-1"}),hs.name.split(" ")[0]]}):e.jsx(st,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},et.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&Le?e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[(()=>{const et=Ze(Le.icon);return e.jsx(et,{className:"h-5 w-5"})})(),Le.name," Touchpoint Plan"]}),e.jsxs(gr,{children:["Choose a plan for your ",Le.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[Te&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(gi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Te.name]}),Te.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Te.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>ke(Te.id,w),children:"Disable"})]}),Te.items&&Te.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Tye.map((et,it)=>{var As,Ms;const Dt=((As=Te.items)==null?void 0:As.filter(cs=>cs.month_number===it+1))||[],Vt=(Ms=Dt[0])==null?void 0:Ms.action_type,hs=Vt?Ue(Vt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Dt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:et}),hs&&e.jsx(hs,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Vt==null?void 0:Vt.color)||"#3B82F6"}})]},it)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Te?"Switch to a Different Plan":"Choose a Plan"}),pe.length>0&&e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Pre-built Templates"}),pe.map(et=>{var Dt;const it=(Te==null?void 0:Te.id)===et.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Dt=et.items)==null?void 0:Dt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:_.isPending,onClick:()=>{const Vt=`${et.name} (Copy)`;_.mutate({sourcePlanId:et.id,newName:Vt})},children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>ke(et.id,w),children:it?"Active":"Use This"})]})]},et.id)})]}),we.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),we.map(et=>{var Dt;const it=(Te==null?void 0:Te.id)===et.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${it?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:et.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Dt=et.items)==null?void 0:Dt.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>qe(et),children:e.jsx(s0,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(et.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:it?"outline":"default",disabled:it||c.isPending,onClick:()=>ke(et.id,w),children:it?"Active":"Use This"})]})]},et.id)})]}),pe.length===0&&we.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(hn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(xs,{open:k,onOpenChange:et=>{et?S(!0):at()},children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:M?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(ze,{id:"plan-name",value:P,onChange:et=>O(et.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Pr,{id:"plan-description",value:$,onChange:et=>U(et.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"12-Month Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Click on a month to add a touchpoint"}),e.jsx("div",{className:"grid grid-cols-6 gap-2",children:Tye.map((et,it)=>{const Dt=it+1,Vt=B.find(Ms=>Ms.month_number===Dt),hs=Vt?l==null?void 0:l.find(Ms=>Ms.id===Vt.action_type_id):null,As=hs?Ue(hs.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>Y(X===Dt?null:Dt),className:` w-full p-3 rounded-lg border text-center transition-all ${Vt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${X===Dt?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:et}),As?e.jsx(As,{className:"h-5 w-5 mx-auto mt-1",style:{color:(hs==null?void 0:hs.color)||"#3B82F6"}}):e.jsx(qs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Vt&&e.jsx("button",{type:"button",onClick:Ms=>{Ms.stopPropagation(),rt(Dt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Mr,{className:"h-3 w-3"})})]},it)})}),X!==null&&!ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",Tye[X-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(et=>et.active).map(et=>{const it=Ue(et.icon);return e.jsxs("button",{type:"button",onClick:()=>tt(X,et.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(it,{className:"h-4 w-4",style:{color:et.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:et.name})]},et.id)})})]}),X!==null&&ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Q(null),children:[e.jsx(Xo,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Ae(X,ee),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),ct==null?void 0:ct.map(et=>e.jsx("button",{type:"button",onClick:()=>Ae(X,ee,et.id),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:et.title}),et.tone&&e.jsx(st,{variant:"secondary",className:"text-xs mt-1",children:et.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[et.script_body.substring(0,100),"..."]})]})},et.id)),e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[e.jsx(qs,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),B.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[B.length," touchpoint",B.length!==1?"s":""," per year"]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:at,children:"Cancel"}),e.jsxs(K,{onClick:M?ye:pt,disabled:!P.trim()||u.isPending||p.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-2"}),M?"Save Changes":"Create Plan"]})]})]})}),e.jsx(xs,{open:ce,onOpenChange:ne,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsx(_s,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-title",children:"Script Title"}),e.jsx(ze,{id:"script-title",value:re,onChange:et=>oe(et.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Ks,{value:_e,onValueChange:$e,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select tone..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"friendly",children:"Friendly"}),e.jsx(Mt,{value:"professional",children:"Professional"}),e.jsx(Mt,{value:"casual",children:"Casual"}),e.jsx(Mt,{value:"formal",children:"Formal"})]})]})]}),((Ge=(Je=l==null?void 0:l.find(et=>et.id===ee))==null?void 0:Je.name)==null?void 0:Ge.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(ze,{id:"script-email-subject",value:ue,onChange:et=>xe(et.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Pr,{id:"script-body",value:fe,onChange:et=>ge(et.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsxs(K,{onClick:He,disabled:!re.trim()||!fe.trim()||v.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const K_s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",Z_s=[{value:"30",label:"Monthly (30 days)"},{value:"60",label:"Bi-Monthly (60 days)"},{value:"90",label:"Quarterly (90 days)"},{value:"180",label:"Twice a Year (180 days)"},{value:"365",label:"Yearly (365 days)"}];function Y_s(){const t=nr(),s=sit(),{data:r}=qbs(),{data:n}=Gx(),{data:a}=vSe(),{data:o}=tme(90),{data:l}=Wm(),i=Wbs(),c=Hbs(),u=Vbs(),p=Gbs(),{data:f=[],isLoading:g}=mt({queryKey:["popby-templates"],queryFn:async()=>{const{data:ce,error:ne}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",K_s).order("publish_date",{ascending:!1});if(ne)throw ne;const{data:re}=await H.from("template_likes").select("template_id"),{data:oe}=await H.from("template_comments").select("template_id"),fe=new Map;re==null||re.forEach(ue=>{fe.set(ue.template_id,(fe.get(ue.template_id)||0)+1)});const ge=new Map;return oe==null||oe.forEach(ue=>{ge.set(ue.template_id,(ge.get(ue.template_id)||0)+1)}),(ce||[]).map(ue=>({...ue,likesCount:fe.get(ue.id)||0,commentsCount:ge.get(ue.id)||0}))}}),v=ce=>{const ne=l==null?void 0:l.find(re=>re.id===ce);return ne?`${ne.first_name} ${ne.last_name||""}`.trim():"Unknown"},_=ce=>{if(!ce)return null;const ne=r==null?void 0:r.find(re=>re.id===ce);return(ne==null?void 0:ne.name)||null},[w,j]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),[P,O]=N.useState(!1),[$,U]=N.useState({popby_item_id:"",notes:""}),[B,V]=N.useState({name:"",description:""}),X=async()=>{w&&(await c.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),S(!1),j(null),U({popby_item_id:"",notes:""}))},Y=async()=>{B.name.trim()&&(await u.mutateAsync({name:B.name.trim(),description:B.description.trim()||void 0}),O(!1),V({name:"",description:""}))},ee=async(ce,ne)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ne)})},Q=ce=>{var re;const ne=a==null?void 0:a.find(oe=>oe.relationship_type_id===ce);return((re=ne==null?void 0:ne.frequency_days)==null?void 0:re.toString())||"90"};return e.jsx(Ts,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(ia,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>L(!0),children:[e.jsx(Qo,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>O(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(_a,{defaultValue:"due",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"due",children:"Due for Popby"}),e.jsx(ns,{value:"activity",children:"Recent Activity"}),e.jsx(ns,{value:"library",children:"Popby Library"}),e.jsx(ns,{value:"templates",children:"Popby Templates"})]}),e.jsx(ws,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contacts due for a popby right now!"}),e.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):e.jsx("div",{className:"space-y-3",children:s.map(ce=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[ce.first_name," ",ce.last_name]}),ce.daysOverdue>0&&e.jsxs(st,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[ce.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),ce.city||ce.address]}),ce.tags&&ce.tags.length>0&&e.jsx("span",{children:ce.tags.map(ne=>{var re;return(re=ne.relationship_type)==null?void 0:re.name}).join(", ")})]}),ce.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ms(new Date(ce.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ce.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${ce.phone}`,children:e.jsx(Mn,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{j(ce),S(!0)},children:[e.jsx(gi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})}),e.jsx(ws,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(un,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby activity yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(ce=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(So,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:v(ce.contact_id)}),_(ce.popby_item_id)&&e.jsx(st,{variant:"secondary",className:"text-xs",children:_(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ms(new Date(ce.completed_at),"MMM d, yyyy h:mm a")}),ce.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ce.notes})]})]},ce.id))})]})}),e.jsx(ws,{value:"library",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[r==null?void 0:r.map(ce=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(So,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:ce.description}),!ce.owner_user_id&&e.jsx(st,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>O(!0),children:e.jsx(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(qs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs(ws,{value:"templates",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[f.length," template",f.length!==1?"s":""," found"]}),g&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(4)].map((ce,ne)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(vs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(vs,{className:"h-5 w-3/4 mb-2"}),e.jsx(vs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(vs,{className:"h-5 w-16"}),e.jsx(vs,{className:"h-5 w-20"})]})]})},ne))}),!g&&f.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Al,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby templates available yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!g&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(ce=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${ce.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:ce.preview_image_url?e.jsx("img",{src:ce.preview_image_url,alt:ce.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Oe,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:ce.name}),ce.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Lde(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(st,{variant:"secondary",className:"text-xs",children:"PopBys"})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nh,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qc,{className:"h-3.5 w-3.5"}),ce.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:ne=>{ne.stopPropagation(),t(`/templates/${ce.id}`)},children:[e.jsx(en,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(xs,{open:k,onOpenChange:S,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Popby Item (optional)"}),e.jsxs(Ks,{value:$.popby_item_id,onValueChange:ce=>U(ne=>({...ne,popby_item_id:ce})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a popby item..."})}),e.jsx(Ws,{children:r==null?void 0:r.map(ce=>e.jsx(Mt,{value:ce.id,children:ce.name},ce.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes (optional)"}),e.jsx(Pr,{placeholder:"Any notes about this popby...",value:$.notes,onChange:ce=>U(ne=>({...ne,notes:ce.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(xs,{open:M,onOpenChange:L,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Popby Frequency Settings"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default popby frequency for each relationship type. You can override these per-contact."}),n==null?void 0:n.map(ce=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(be,{className:"font-medium",children:ce.name}),e.jsxs(Ks,{value:Q(ce.id),onValueChange:ne=>ee(ce.id,ne),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Z_s.map(ne=>e.jsx(Mt,{value:ne.value,children:ne.label},ne.value))})]})]},ce.id))]}),e.jsx(Un,{children:e.jsx(K,{onClick:()=>L(!1),children:"Done"})})]})}),e.jsx(xs,{open:P,onOpenChange:O,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Name *"}),e.jsx(ze,{placeholder:"e.g., Homemade cookies",value:B.name,onChange:ce=>V(ne=>({...ne,name:ce.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{placeholder:"Optional description...",value:B.description,onChange:ce=>V(ne=>({...ne,description:ce.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const Q_s=N3({property_address:_c().min(1,"Property address is required"),city:_c().optional(),state:_c().optional(),zip:_c().optional(),transaction_type:QWe(["buyer","seller"]),close_date:_c().min(1,"Close date is required"),sale_price:n8().min(0,"Sale price must be positive"),commission_amount:n8().optional(),lead_source_id:_c().optional(),client_type_id:_c().optional(),contact_id:_c().optional(),notes:_c().optional(),is_win:NCt()});function lit({open:t,onOpenChange:s,transaction:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(!1),[u,p]=N.useState(""),f=Lue(),g=b8t(),{data:v}=mE(),{data:_}=Gx(),{data:w}=Wm(),j=Iue(),k=FNe(),{data:S}=Due(),M=(S==null?void 0:S.show_commission)??!0,L=kue({resolver:Sue(Q_s),defaultValues:{property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1}});N.useEffect(()=>{r?L.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):L.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,L]);const P=async B=>{const V={property_address:B.property_address,transaction_type:B.transaction_type,close_date:B.close_date,sale_price:B.sale_price,is_win:B.is_win,commission_amount:B.commission_amount||null,lead_source_id:B.lead_source_id||null,client_type_id:B.client_type_id||null,contact_id:B.contact_id||null,city:B.city||null,state:B.state||null,zip:B.zip||null,notes:B.notes||null};r?await g.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},O=async()=>{if(!o.trim())return;const[B,...V]=o.trim().split(" "),X=V.join(" ")||null,Y=await j.mutateAsync({first_name:B,last_name:X,tagIds:[]});Y&&(L.setValue("contact_id",Y.id),l(""),c(!1),a(!1))},$=async()=>{if(!u.trim())return;const B=await k.mutateAsync(u.trim());B&&(L.setValue("lead_source_id",B.id),p(""))},U=w==null?void 0:w.find(B=>B.id===L.watch("contact_id"));return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(js,{children:e.jsx(_s,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Ki,{className:"max-h-[70vh] pr-4",children:e.jsx(Cue,{...L,children:e.jsxs("form",{onSubmit:L.handleSubmit(P),className:"space-y-4",children:[e.jsx(Yc,{control:L.control,name:"property_address",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Property Address *"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"123 Main St",...B})}),e.jsx(Cm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Yc,{control:L.control,name:"city",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"City"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"City",...B})})]})}),e.jsx(Yc,{control:L.control,name:"state",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"State"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"TX",...B})})]})}),e.jsx(Yc,{control:L.control,name:"zip",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Zip"}),e.jsx(Rc,{children:e.jsx(ze,{placeholder:"75001",...B})})]})})]}),e.jsx(Yc,{control:L.control,name:"transaction_type",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Transaction Type *"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value,children:[e.jsx(Rc,{children:e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select type"})})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsx(Cm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Yc,{control:L.control,name:"close_date",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Close Date *"}),e.jsx(Rc,{children:e.jsx(ze,{type:"date",...B})}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:L.control,name:"sale_price",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Sale Price *"}),e.jsx(Rc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,onChange:V=>B.onChange(Number(V.target.value))})}),e.jsx(Cm,{})]})})]}),M&&e.jsx(Yc,{control:L.control,name:"commission_amount",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Commission"}),e.jsx(Rc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,value:B.value??"",onChange:V=>B.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Yc,{control:L.control,name:"lead_source_id",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Lead Source"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Rc,{children:e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select source"})})}),e.jsx(Ws,{children:v==null?void 0:v.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add custom source...",value:u,onChange:B=>p(B.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!u.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsx(Yc,{control:L.control,name:"client_type_id",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Client Type"}),e.jsxs(Ks,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Rc,{children:e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select client type"})})}),e.jsx(Ws,{children:_==null?void 0:_.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Yc,{control:L.control,name:"contact_id",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Client Contact"}),e.jsxs($o,{open:n,onOpenChange:a,children:[e.jsx(qo,{asChild:!0,children:e.jsx(Rc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:It("w-full justify-between",!B.value&&"text-muted-foreground"),children:[U?`${U.first_name} ${U.last_name||""}`.trim():"Select contact",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(Ro,{className:"w-full p-0",align:"start",children:[e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search contacts..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:e.jsxs("div",{className:"p-2 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx($x,{children:w==null?void 0:w.map(V=>e.jsxs(bp,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{B.onChange(V.id),a(!1)},children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",V.id===B.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(ze,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:O,disabled:!o.trim()||j.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Yc,{control:L.control,name:"notes",render:({field:B})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Notes"}),e.jsx(Rc,{children:e.jsx(Pr,{placeholder:"Any notes about this transaction...",...B})})]})}),e.jsx(Yc,{control:L.control,name:"is_win",render:({field:B})=>e.jsxs(Dc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Oc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Rc,{children:e.jsx(qr,{checked:B.value,onCheckedChange:B.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||g.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function wSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=N.useState(null),[i,c]=N.useState(null),[u,p]=N.useState(""),[f,g]=N.useState("all"),[v,_]=N.useState("all"),[w,j]=N.useState("all"),[k,S]=N.useState(!1),M=_8t(),L=Lue(),{data:P}=mE(),{data:O}=Gx(),$=DE(),U=X=>{const{id:Y,created_at:ee,updated_at:Q,lead_source:ce,client_type:ne,contact:re,...oe}=X;L.mutate(oe)},B=()=>{i&&(M.mutate(i),c(null))},V=t.filter(X=>{var re,oe,fe,ge;const Y=u===""||X.property_address.toLowerCase().includes(u.toLowerCase())||((oe=(re=X.contact)==null?void 0:re.first_name)==null?void 0:oe.toLowerCase().includes(u.toLowerCase()))||((ge=(fe=X.contact)==null?void 0:fe.last_name)==null?void 0:ge.toLowerCase().includes(u.toLowerCase())),ee=f==="all"||X.transaction_type===f,Q=v==="all"||X.lead_source_id===v,ce=w==="all"||X.client_type_id===w,ne=!k||X.is_win;return Y&&ee&&Q&&ce&&ne});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(X=>e.jsx(vs,{className:"h-16 w-full"},X))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs(Rt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search...",value:u,onChange:X=>p(X.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-[100px]",children:e.jsx(Ys,{placeholder:"Type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsxs(Ks,{value:v,onValueChange:_,children:[e.jsx(Gs,{className:"w-[130px]",children:e.jsx(Ys,{placeholder:"Lead Source"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Sources"}),P==null?void 0:P.map(X=>e.jsx(Mt,{value:X.id,children:X.name},X.id))]})]}),e.jsxs(K,{variant:k?"default":"outline",size:"sm",onClick:()=>S(!k),children:[e.jsx(tc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):$?e.jsx("div",{className:"space-y-3",children:V.map(X=>e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:X.property_address}),X.is_win&&e.jsx(tc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]}),e.jsx(st,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),ZAe(X.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Xl(X.sale_price)]}),s&&X.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Xl(X.commission_amount)]}),X.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),X.lead_source.name]}),X.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),X.contact.first_name," ",X.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[X.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l(X),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>U(X),children:e.jsx(yi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(X.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},X.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[n&&e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Type"}),e.jsx(St,{children:"Close Date"}),e.jsx(St,{children:"Sale Price"}),s&&e.jsx(St,{children:"Commission"}),e.jsx(St,{children:"Lead Source"}),e.jsx(St,{children:"Client"}),!a&&e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(Bn,{children:V.map(X=>{var Y;return e.jsxs(Cs,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[X.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.is_win&&e.jsx(tc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:X.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(st,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})}),e.jsx(dt,{children:ZAe(X.close_date)}),e.jsx(dt,{children:Xl(X.sale_price)}),s&&e.jsx(dt,{children:X.commission_amount?Xl(X.commission_amount):"-"}),e.jsx(dt,{children:((Y=X.lead_source)==null?void 0:Y.name)||"-"}),e.jsx(dt,{children:X.contact?`${X.contact.first_name} ${X.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Aa,{onClick:()=>l(X),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Aa,{onClick:()=>U(X),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Aa,{onClick:()=>c(X.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},X.id)})})]})})})]}),e.jsx(lit,{open:!!o,onOpenChange:X=>!X&&l(null),transaction:o||void 0}),e.jsx(Mc,{open:!!i,onOpenChange:X=>!X&&c(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Transaction?"}),e.jsx(ic,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:B,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function cit({goals:t,stats:s,year:r,showCommission:n}){const a=new Date().getMonth()+1,o=new Date().getFullYear()===r?a:12,l=12-o,i=(g,v)=>{if(!v||v===0)return null;const _=Math.min(g/v*100,100),w=Math.max(v-g,0),j=l>0?w/l:0,k=o/12*100,S=_>=k?"ahead":_>=k*.8?"on-track":"behind";return{percent:_,remaining:w,pace:j,status:S}},c=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=g=>{switch(g){case"ahead":return e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(Jo,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(st,{variant:"secondary",children:[e.jsx(y0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(st,{variant:"destructive",children:[e.jsx(_S,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-5 w-5 text-primary"}),e.jsxs(Rt,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(c.status)]}),e.jsx(Bi,{value:c.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[s.totalTransactions," of ",t.transactions_goal]}),e.jsxs("span",{children:[Math.round(c.percent),"%"]})]}),c.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(c.pace),"/month to hit goal"]})]}),t.volume_goal&&u&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Volume"}),f(u.status)]}),e.jsx(Bi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Xl(s.totalVolume,!0)," of ",Xl(t.volume_goal,!0)]}),e.jsxs("span",{children:[Math.round(u.percent),"%"]})]}),u.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Xl(u.pace,!0),"/month"]})]}),n&&t.gci_goal&&p&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"GCI"}),f(p.status)]}),e.jsx(Bi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[Xl(s.totalCommission,!0)," of ",Xl(t.gci_goal,!0)]}),e.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Xl(p.pace,!0),"/month"]})]})]})})]})}const X_s={light:"",dark:".dark"},dit=N.createContext(null);function uit(){const t=N.useContext(dit);if(!t)throw new Error("useChart must be used within a ");return t}const hit=N.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=N.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(dit.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:It("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...a,children:[e.jsx(J_s,{id:i,config:n}),e.jsx(pT,{children:r})]})})});hit.displayName="Chart";const J_s=({id:t,config:s})=>{const r=Object.entries(s).filter(([n,a])=>a.theme||a.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(X_s).map(([n,a])=>` ${a} [data-chart=${t}] { ${r.map(([o,l])=>{var c;const i=((c=l.theme)==null?void 0:c[n])||l.color;return i?` --color-${o}: ${i};`:null}).join(` `)} } `).join(` `)}}):null},mit=N.forwardRef(({active:t,payload:s,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:c,formatter:u,color:p,nameKey:f,labelKey:g},v)=>{const{config:_}=uit(),w=N.useMemo(()=>{var P;if(a||!(s!=null&&s.length))return null;const[k]=s,S=`${g||k.dataKey||k.name||"value"}`,M=ewe(_,k,S),L=!g&&typeof l=="string"?((P=_[l])==null?void 0:P.label)||l:M==null?void 0:M.label;return i?e.jsx("div",{className:It("font-medium",c),children:i(L,s)}):L?e.jsx("div",{className:It("font-medium",c),children:L}):null},[l,i,s,a,c,_,g]);if(!t||!(s!=null&&s.length))return null;const j=s.length===1&&n!=="dot";return e.jsxs("div",{ref:v,className:It("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[j?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((k,S)=>{const M=`${f||k.name||k.dataKey||"value"}`,L=ewe(_,k,M),P=p||k.payload.fill||k.color;return e.jsx("div",{className:It("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(k==null?void 0:k.value)!==void 0&&k.name?u(k.value,k.name,k,S,k.payload):e.jsxs(e.Fragment,{children:[L!=null&&L.icon?e.jsx(L.icon,{}):!o&&e.jsx("div",{className:It("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":j&&n==="dashed"}),style:{"--color-bg":P,"--color-border":P}}),e.jsxs("div",{className:It("flex flex-1 justify-between leading-none",j?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[j?w:null,e.jsx("span",{className:"text-muted-foreground",children:(L==null?void 0:L.label)||k.name})]}),k.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:k.value.toLocaleString()})]})]})},k.dataKey)})})]})});mit.displayName="ChartTooltip";const ews=N.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=uit();return r!=null&&r.length?e.jsx("div",{ref:o,className:It("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",t),children:r.map(i=>{const c=`${a||i.dataKey||"value"}`,u=ewe(l,i,c);return e.jsxs("div",{className:It("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[u!=null&&u.icon&&!s?e.jsx(u.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),u==null?void 0:u.label]},i.value)})}):null});ews.displayName="ChartLegend";function ewe(t,s,r){if(typeof s!="object"||s===null)return;const n="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let a=r;return r in s&&typeof s[r]=="string"?a=s[r]:n&&r in n&&typeof n[r]=="string"&&(a=n[r]),a in t?t[a]:t[r]}const o9=["hsl(var(--primary))","hsl(var(--secondary))","hsl(210, 70%, 50%)","hsl(170, 60%, 45%)","hsl(280, 60%, 55%)","hsl(30, 70%, 50%)","hsl(340, 65%, 55%)","hsl(200, 65%, 50%)"];function jSe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(hit,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(pT,{width:"100%",height:"100%",children:e.jsxs(Rat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(bat,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(h3,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(m3,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(hp,{content:e.jsx(mit,{})}),e.jsx(z1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(pT,{width:"100%",height:"100%",children:e.jsxs(Fat,{children:[e.jsx(W0,{data:t.leadSourceBreakdown,dataKey:"count",nameKey:"name",cx:"50%",cy:"50%",outerRadius:80,label:({name:a,percent:o})=>o>.05?`${a} (${(o*100).toFixed(0)}%)`:"",labelLine:!1,children:t.leadSourceBreakdown.map((a,o)=>e.jsx(yR,{fill:o9[o%o9.length]},`cell-${o}`))}),e.jsx(hp,{formatter:(a,o)=>[`${a} deals`,o]})]})})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 justify-center",children:t.leadSourceBreakdown.slice(0,6).map((a,o)=>e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:o9[o%o9.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function tws(t){if(!t||!t.trim())return null;const s=t.trim(),r=["yyyy-MM-dd","M/d/yyyy","MM/dd/yyyy","M-d-yyyy","MM-dd-yyyy","MM/dd/yy","M/d/yy"];for(const n of r)try{const a=Pje(s,n,new Date);if(Vve(a))return ms(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Vve(n))return ms(n,"yyyy-MM-dd")}catch{}return null}const sws=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function rws({open:t,onOpenChange:s}){const[r,n]=N.useState([]),[a,o]=N.useState(!1),[l,i]=N.useState(0),{data:c}=mE(),{data:u}=Gx(),p=Lue(),f=()=>{const k=sws.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),M=`${k} ${S}`,L=new Blob([M],{type:"text/csv"}),P=URL.createObjectURL(L),O=document.createElement("a");O.href=P,O.download="transaction-import-template.csv",O.click(),URL.revokeObjectURL(P)},g=k=>{const S=k.split(` `).filter(L=>L.trim());if(S.length<2)return[];const M=S[0].split(",").map(L=>L.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((L,P)=>{var re,oe,fe,ge;const O=[];let $="",U=!1;for(const ue of L)ue==='"'?U=!U:ue===","&&!U?(O.push($.trim()),$=""):$+=ue;O.push($.trim());const B=ue=>{var _e;const xe=M.indexOf(ue);return xe>=0?(_e=O[xe])==null?void 0:_e.replace(/^["']|["']$/g,"").trim():""},V=(re=B("transaction_type"))==null?void 0:re.toLowerCase(),X=(oe=B("sale_price"))==null?void 0:oe.replace(/[$,]/g,""),Y=(fe=B("commission_amount"))==null?void 0:fe.replace(/[$,]/g,""),ee=(ge=B("is_win"))==null?void 0:ge.toLowerCase(),Q=B("close_date"),ce=tws(Q);let ne;return B("property_address")?["buyer","seller"].includes(V)?ce?(!X||isNaN(Number(X)))&&(ne="Invalid sale price"):ne=`Invalid date format: "${Q}" - use MM/DD/YYYY or YYYY-MM-DD`:ne='Transaction type must be "buyer" or "seller"':ne="Missing property address",{property_address:B("property_address"),city:B("city"),state:B("state"),zip:B("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:ce||"",sale_price:Number(X)||0,commission_amount:Y?Number(Y):null,lead_source_name:B("lead_source"),client_type_name:B("client_type"),is_win:["yes","true","1"].includes(ee),notes:B("notes"),error:ne}})},v=k=>{var L;const S=(L=k.target.files)==null?void 0:L[0];if(!S)return;const M=new FileReader;M.onload=P=>{var U;const O=(U=P.target)==null?void 0:U.result,$=g(O);n($)},M.readAsText(S)},_=async()=>{const k=r.filter(L=>!L.error);if(k.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let S=0,M=0;for(let L=0;LU.name.toLowerCase()===P.lead_source_name.toLowerCase()),$=u==null?void 0:u.find(U=>U.name.toLowerCase()===P.client_type_name.toLowerCase());await p.mutateAsync({property_address:P.property_address,city:P.city||null,state:P.state||null,zip:P.zip||null,transaction_type:P.transaction_type,close_date:P.close_date,sale_price:P.sale_price,commission_amount:P.commission_amount,lead_source_id:(O==null?void 0:O.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:P.notes||null,is_win:P.is_win}),S++}catch(O){M++,console.error("Failed to import transaction:",O)}i(Math.round((L+1)/k.length*100))}o(!1),S>0&&me.success(`Imported ${S} transaction${S>1?"s":""}`),M>0&&me.error(`Failed to import ${M} transaction${M>1?"s":""}`),n([]),s(!1)},w=r.filter(k=>!k.error).length,j=r.filter(k=>k.error).length;return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Import Transactions"}),e.jsx(Wr,{children:"Upload a CSV file with your past transactions"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Download Template"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get a CSV template with the correct format"})]}),e.jsxs(K,{variant:"outline",onClick:f,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(ze,{id:"csv-file",type:"file",accept:".csv",onChange:v})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(st,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(ba,{className:"h-3 w-3 mr-1"}),w," valid"]}),j>0&&e.jsxs(st,{variant:"destructive",children:[e.jsx(Cl,{className:"h-3 w-3 mr-1"}),j," errors"]})]}),e.jsx(Ki,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((k,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${k.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:k.property_address||"(no address)"}),e.jsx(st,{variant:k.transaction_type==="buyer"?"default":"secondary",children:k.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[k.close_date," • $",k.sale_price.toLocaleString()]}),k.error&&e.jsx(Vke,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(Hke,{className:"text-xs",children:k.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:_,disabled:w===0||a,children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const nws=N3({transactions_goal:n8().min(0).optional(),volume_goal:n8().min(0).optional(),gci_goal:n8().min(0).optional()});function aws({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=w8t(),{data:o}=Due(),l=(o==null?void 0:o.show_commission)??!0,i=kue({resolver:Sue(nws),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});N.useEffect(()=>{n?i.reset({transactions_goal:n.transactions_goal??void 0,volume_goal:n.volume_goal?Number(n.volume_goal):void 0,gci_goal:n.gci_goal?Number(n.gci_goal):void 0}):i.reset({transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0})},[n,i,t]);const c=async u=>{await a.mutateAsync({year:r,transactions_goal:u.transactions_goal??null,volume_goal:u.volume_goal??null,gci_goal:l?u.gci_goal??null:null}),s(!1)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:[r," Goals"]}),e.jsx(Wr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(Cue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Yc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Transactions Goal"}),e.jsx(Rc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 24",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Lie,{children:"Total number of deals you want to close"}),e.jsx(Cm,{})]})}),e.jsx(Yc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"Volume Goal ($)"}),e.jsx(Rc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 5000000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Lie,{children:"Total sales volume you want to achieve"}),e.jsx(Cm,{})]})}),l&&e.jsx(Yc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(Dc,{children:[e.jsx(Oc,{children:"GCI Goal ($)"}),e.jsx(Rc,{children:e.jsx(ze,{type:"number",placeholder:"e.g., 150000",...u,value:u.value??"",onChange:p=>u.onChange(p.target.value?Number(p.target.value):void 0)})}),e.jsx(Lie,{children:"Gross commission income target"}),e.jsx(Cm,{})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function NSe({transactions:t,isLoading:s}){const r=N.useRef(null),n=N.useRef(null),a=N.useRef([]),o=N.useRef(null),{isAdmin:l}=Os(),[i,c]=N.useState(""),[u,p]=N.useState(!0),[f,g]=N.useState(0),[v,_]=N.useState(!1),w=t.filter(k=>k.latitude!=null&&k.longitude!=null),j=t.filter(k=>k.latitude==null||k.longitude==null);return N.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&c(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),N.useEffect(()=>{if(!i||j.length===0||v)return;(async()=>{var M;_(!0);let S=0;for(const L of j){const P=[L.property_address,L.city,L.state,L.zip].filter(Boolean).join(", ");if(P)try{const $=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(P)}.json?access_token=${i}&limit=1`)).json();if((M=$.features)!=null&&M[0]){const[U,B]=$.features[0].center;await H.from("scorecard_transactions").update({latitude:B,longitude:U}).eq("id",L.id),L.latitude=B,L.longitude=U,S++}}catch(O){console.error("Geocode error:",O)}}g(S),_(!1)})()},[i,t]),N.useEffect(()=>{if(!r.current||!i||n.current)return;Eo.accessToken=i;const k=t.filter(L=>L.latitude!=null&&L.longitude!=null);let S=[-98.5795,39.8283],M=4;if(k.length>0){const L=k.reduce((O,$)=>O+$.longitude,0)/k.length,P=k.reduce((O,$)=>O+$.latitude,0)/k.length;S=[L,P],M=k.length===1?12:10}return n.current=new Eo.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:S}),n.current.addControl(new Eo.NavigationControl,"top-right"),()=>{var L;(L=n.current)==null||L.remove(),n.current=null}},[i]),N.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(M=>M.remove()),a.current=[],(S=o.current)==null||S.remove();const k=t.filter(M=>M.latitude!=null&&M.longitude!=null);if(k.forEach(M=>{var B;const L=M.transaction_type==="buyer",P=L?"#3B82F6":"#10B981",O=document.createElement("div");O.className="cursor-pointer",O.innerHTML=`
${L?'':''}
`;const $=new Eo.Popup({offset:25,closeButton:!0}).setHTML(`
${M.property_address}
${M.city?`
${M.city}${M.state?", "+M.state:""} ${M.zip||""}
`:""}
${L?"Buyer":"Seller"} $${Number(M.sale_price).toLocaleString()}
Closed: ${Rl(M.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(B=M.lead_source)!=null&&B.name?" · "+M.lead_source.name:""}
${M.contact?`
Client: ${M.contact.first_name} ${M.contact.last_name||""}
`:""}
`),U=new Eo.Marker(O).setLngLat([M.longitude,M.latitude]).setPopup($).addTo(n.current);a.current.push(U)}),k.length>1){const M=new Eo.LngLatBounds;k.forEach(L=>M.extend([L.longitude,L.latitude])),n.current.fitBounds(M,{padding:60,maxZoom:13})}else k.length===1&&n.current.flyTo({center:[k[0].longitude,k[0].latitude],zoom:12})},[t,i,v]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(ia,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",v&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Cl,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in the Popby Map to enable maps across the platform.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}const pit=()=>{const{data:t}=Ux();return mt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await H.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await H.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},iws=t=>{const{data:s}=Ux(),{data:r}=pit();return mt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await H.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function ows(t,s){const r=s.filter(o=>o.owner_user_id===t.id),n=r.reduce((o,l)=>o+Number(l.sale_price),0),a=r.reduce((o,l)=>o+(Number(l.commission_amount)||0),0);return{member:t,totalTransactions:r.length,buyerCount:r.filter(o=>o.transaction_type==="buyer").length,sellerCount:r.filter(o=>o.transaction_type==="seller").length,totalVolume:n,averagePrice:r.length>0?n/r.length:0,totalGCI:a}}function lws(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function cws({year:t}){var g;const{data:s,isLoading:r}=pit(),{data:n,isLoading:a}=iws(t),o=nr(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:p,teamChartStats:f}=N.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const v=s.map(V=>ows(V,n));v.sort((V,X)=>X.totalVolume-V.totalVolume);const _={};s.forEach(V=>{_[V.id]=V.name||V.email});const w=n.length,j=n.reduce((V,X)=>V+Number(X.sale_price),0),k=n.reduce((V,X)=>V+(Number(X.commission_amount)||0),0),S=n.filter(V=>V.transaction_type==="buyer").length,M=n.filter(V=>V.transaction_type==="seller").length,L={};n.forEach(V=>{var Y;const X=((Y=V.lead_source)==null?void 0:Y.name)||"Unknown";L[X]=(L[X]||0)+1});const P=Object.entries(L).sort((V,X)=>X[1]-V[1])[0],O={};n.forEach(V=>{const X=Rl(V.close_date).toLocaleString("default",{month:"short"});O[X]=(O[X]||0)+1});const U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:O[V]||0})),B=Object.entries(L).map(([V,X])=>({name:V,count:X})).sort((V,X)=>X.count-V.count);return{aggregate:{totalTxns:w,buyerCount:S,sellerCount:M,totalVolume:j,avgPrice:w>0?j/w:0,totalGCI:k,topSource:P?{name:P[0],count:P[1]}:null,memberCount:s.length},memberStats:v,topPerformer:v[0]||null,agentNameMap:_,teamChartStats:{transactionsByMonth:U,leadSourceBreakdown:B}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(v=>e.jsx(vs,{className:"h-24"},v))}),e.jsx(vs,{className:"h-64"})]}):!i||c.length===0?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No Team Data"}),e.jsxs("p",{className:"text-muted-foreground",children:["No scorecard transactions found for your team members in ",t,"."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Members"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.memberCount})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.totalTxns}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.buyerCount,"B / ",i.sellerCount,"S"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(tc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((g=i.topSource)==null?void 0:g.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(vo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground",children:["Top Performer — ",t]}),e.jsx("p",{className:"text-lg font-bold",children:u.member.name||u.member.email})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.totalTransactions," deals"]}),e.jsx("p",{className:"font-semibold",children:Xl(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Transactions"}),e.jsx(St,{className:"text-center",children:"B / S"}),e.jsx(St,{className:"text-right",children:"Volume"}),e.jsx(St,{className:"text-right",children:"Avg Price"}),e.jsx(St,{className:"text-right",children:"GCI"}),e.jsx(St,{className:"text-right"})]})}),e.jsx(Bn,{children:c.map((v,_)=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[_===0&&v.totalTransactions>0&&e.jsx(vo,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:v.member.avatar_url||void 0}),e.jsx(Sn,{className:"text-xs",children:lws(v.member.name,v.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:v.member.name||v.member.email}),v.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:v.member.email})]})]})}),e.jsx(dt,{className:"text-center font-semibold",children:v.totalTransactions}),e.jsxs(dt,{className:"text-center text-sm",children:[v.buyerCount," / ",v.sellerCount]}),e.jsx(dt,{className:"text-right font-medium",children:Xl(v.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:Xl(v.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:Xl(v.totalGCI,!0)}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${v.member.id}`),children:e.jsx(Dn,{className:"h-4 w-4"})})})]},v.member.id))})]})})})]}),e.jsxs(_a,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"transactions",children:[e.jsx(rh,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(ns,{value:"charts",children:[e.jsx(yo,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(ns,{value:"map",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(wSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(ws,{value:"charts",children:f&&e.jsx(jSe,{stats:f,year:t})}),e.jsx(ws,{value:"map",children:e.jsx(NSe,{transactions:n||[],isLoading:a})})]})]})}const fit=new Date().getFullYear(),y7e=Array.from({length:10},(t,s)=>fit-s);function dws(){var B;const[t,s]=N.useState(fit),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(!1),[p,f]=N.useState("my"),{data:g}=Ux(),v=(g==null?void 0:g.role)==="team_leader",{data:_,isLoading:w}=zNe(t),{yearStats:j,lifetimeStats:k,showCommission:S}=MQe(t),{data:M,isLoading:L}=CQe(t),{data:P}=Due(),O=j8t(),$=()=>{if(!_||_.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],X=_.map(ne=>{var re,oe;return[ne.property_address,ne.city||"",ne.state||"",ne.zip||"",ne.transaction_type,ne.close_date,ne.sale_price,...S?[ne.commission_amount||""]:[],((re=ne.lead_source)==null?void 0:re.name)||"",((oe=ne.client_type)==null?void 0:oe.name)||"",ne.contact?`${ne.contact.first_name} ${ne.contact.last_name||""}`.trim():"",ne.is_win?"Yes":"No",ne.notes||""]}),Y=[V,...X].map(ne=>ne.map(re=>`"${String(re).replace(/"/g,'""')}"`).join(",")).join(` `),ee=new Blob([Y],{type:"text/csv"}),Q=URL.createObjectURL(ee),ce=document.createElement("a");ce.href=Q,ce.download=`transactions-${t}.csv`,ce.click(),URL.revokeObjectURL(Q)},U=!_||_.length===0;return e.jsxs(Ts,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),v&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(hr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&v?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs(Ks,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:y7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]})]}),e.jsx(cws,{year:t})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Ks,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:y7e.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(Qo,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(qr,{checked:(P==null?void 0:P.show_commission)??!0,onCheckedChange:V=>O.mutate({show_commission:V})})]})})]}),U&&!w?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(yo,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mt-1",children:"Add your past transactions to see your performance metrics, track your goals, and celebrate your wins."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]}),e.jsxs("div",{className:"pt-4 border-t mt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Need help formatting your data?"}),e.jsx(K,{variant:"link",className:"h-auto p-0",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(zm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:$,disabled:U,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Export"]}),e.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:j.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[j.buyerCount,"/",j.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(j.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Xl(k.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(j.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(tc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((B=j.topLeadSource)==null?void 0:B.name)||"-"}),j.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.topLeadSource.count," deals"]})]})}),S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(j.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Xl(k.totalCommission,!0)," lifetime"]})]})}),S&&j.totalNetToAgent>0&&j.totalNetToAgent!==j.totalCommission&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Net to Agent"})]}),e.jsx("p",{className:"text-2xl font-bold text-teal-600 dark:text-teal-400",children:Xl(j.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Xl(k.totalNetToAgent,!0)," lifetime"]})]})})]}),M&&e.jsx(cit,{goals:M,stats:j,year:t,showCommission:S}),e.jsxs(_a,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(wSe,{transactions:_||[],showCommission:S,isLoading:w})}),e.jsx(ws,{value:"charts",children:e.jsx(jSe,{stats:j,year:t})}),e.jsx(ws,{value:"map",children:e.jsx(NSe,{transactions:_||[],isLoading:w})})]})]})]})]}),e.jsx(lit,{open:r,onOpenChange:n}),e.jsx(rws,{open:a,onOpenChange:o}),e.jsx(aws,{open:l,onOpenChange:i,year:t,existingGoals:M})]})}function xit({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Os(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(!1);N.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:j,error:k}=await H.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(k)throw k;if(j&&j.share_token)i(j);else if(j&&!j.share_token){const{data:S,error:M}=await H.from("listing_shares").update({share_type:"referral_link"}).eq("id",j.id).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}else{const{data:S,error:M}=await H.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(S)}}catch(j){console.error("Error creating share link:",j),me.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const g=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",v=async()=>{try{await navigator.clipboard.writeText(g),f(!0),me.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{me.error("Failed to copy link")}},_=w=>{const j=encodeURIComponent(g),k=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${k}&body=${j}`);break;case"text":window.open(`sms:?body=${k}%20${j}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${j}`,"_blank");break}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Wr,{children:"Share this listing with your network. When someone submits a lead through your link, they'll become your contact!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:"How it works:"})," The listing still shows the original agent's info, but any leads from your unique link go directly to you!"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:c?"Generating...":g,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:v,disabled:c||!g,variant:p?"default":"outline",children:p?e.jsx(ba,{className:"h-4 w-4"}):e.jsx(yi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("email"),disabled:c,children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("text"),disabled:c,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("facebook"),disabled:c,children:[e.jsx(Cu,{className:"h-4 w-4 mr-2"}),"Facebook"]})]})]}),l&&(l.click_count>0||l.lead_count>0)&&e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(be,{className:"mb-2 block",children:"Your Share Performance"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-muted-foreground mb-1",children:[e.jsx(Dn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Clicks"})]}),e.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Leads"})]}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const uws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},hws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},mws={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function l9({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,j;const{user:o}=Os(),{data:l}=_Qe(t.id),i=bQe(),[c,u]=N.useState(!1),p=k=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(k),f=((w=t.photos)==null?void 0:w.find(k=>k.is_primary))||((j=t.photos)==null?void 0:j[0]),g=(o==null?void 0:o.id)===t.agent_id,v=async k=>{k.stopPropagation();try{const S=await i.mutateAsync(t.id);me.success(S.saved?"Listing saved!":"Listing removed from saved")}catch{me.error("Failed to save listing")}},_=k=>{if(k.stopPropagation(),o)u(!0);else{const S=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")}};return e.jsxs(Ee,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:s,children:[e.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[f?e.jsx("img",{src:f.photo_url,alt:t.property_address||t.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(w0,{className:"h-12 w-12"})}),e.jsx(st,{className:`absolute top-2 left-2 ${uws[t.status]} text-white border-0`,children:hws[t.status]}),t.is_featured&&e.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:e.jsx(Jn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:v,children:e.jsx(Ya,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,title:g?"Copy link":"Share & earn leads",children:g?e.jsx(nd,{className:"h-4 w-4"}):e.jsx(fn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(xit,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),e.jsxs("div",{children:[t.property_address&&e.jsx("p",{className:"font-medium truncate",children:t.property_address}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),t.city,", ",t.state,t.neighborhood&&` • ${t.neighborhood}`]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[t.bedrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mh,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(su,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(w0,{className:"h-4 w-4"}),t.square_footage.toLocaleString()," sqft"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:mws[t.property_type]}),t.agent&&e.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:t.agent.name})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ya,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:k=>{k.stopPropagation(),r()},children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:k=>{k.stopPropagation(),n()},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]})}const pws=[{value:"active",label:"Active"},{value:"coming_soon",label:"Coming Soon"},{value:"price_improvement",label:"Price Improvement"},{value:"under_contract",label:"Under Contract"},{value:"sold",label:"Sold"}],fws=[{value:"single_family",label:"Single Family"},{value:"condo",label:"Condo"},{value:"townhouse",label:"Townhouse"},{value:"land",label:"Land"},{value:"multi_family",label:"Multi-Family"},{value:"luxury",label:"Luxury"},{value:"commercial",label:"Commercial"},{value:"other",label:"Other"}];function xws({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Rt,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Mr,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"All statuses"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),pws.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Type"}),e.jsxs(Ks,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"All types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),fws.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Min Price"}),e.jsx(ze,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Max Price"}),e.jsx(ze,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(qr,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function gws({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(vo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(h1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(tc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(st,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(nd,{className:"h-6 w-6 text-emerald-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Listing Amplifier"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Share 10+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-sky-500/10 to-sky-500/5 border border-sky-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-sky-500/20 flex items-center justify-center",children:e.jsx(dn,{className:"h-6 w-6 text-sky-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Top Contributor"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add 5+ listings"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-purple-500/10 to-purple-500/5 border border-purple-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-purple-500/20 flex items-center justify-center",children:e.jsx(h1,{className:"h-6 w-6 text-purple-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Referral Connector"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send 3+ referrals"})]}),e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-amber-500/10 to-amber-500/5 border border-amber-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-amber-500/20 flex items-center justify-center",children:e.jsx(vo,{className:"h-6 w-6 text-amber-500"})}),e.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(_a,{defaultValue:"sharers",children:[e.jsxs(fa,{className:"w-full",children:[e.jsxs(ns,{value:"sharers",className:"flex-1",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(ns,{value:"listers",className:"flex-1",children:[e.jsx(dn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(ws,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(ws,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const v7e={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},b7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function yws(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function vws({listings:t,isLoading:s}){const r=nr(),n=N.useRef(null),a=N.useRef(null),o=N.useRef([]),{isAdmin:l}=Os(),[i,c]=N.useState(""),[u,p]=N.useState(!0),[f,g]=N.useState(!1),v=t.filter(w=>w.latitude!=null&&w.longitude!=null),_=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return N.useEffect(()=>{(async()=>{p(!0);try{const{data:j}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&c(j.value)}catch(j){console.error("Error fetching mapbox token:",j)}p(!1)})()},[]),N.useEffect(()=>{if(!i||_.length===0||f)return;(async()=>{var j;g(!0);for(const k of _){const S=[k.property_address,k.city,k.state].filter(Boolean).join(", ");if(S)try{const L=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((j=L.features)!=null&&j[0]){const[P,O]=L.features[0].center;await H.from("listings").update({latitude:O,longitude:P}).eq("id",k.id),k.latitude=O,k.longitude=P}}catch(M){console.error("Geocode error:",M)}}g(!1)})()},[i,t]),N.useEffect(()=>{if(!n.current||!i||a.current)return;Eo.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let j=[-98.5795,39.8283],k=4;if(w.length>0){const S=w.reduce((L,P)=>L+P.longitude,0)/w.length,M=w.reduce((L,P)=>L+P.latitude,0)/w.length;j=[S,M],k=w.length===1?12:10}return a.current=new Eo.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:k,center:j}),a.current.addControl(new Eo.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),N.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(j=>j.remove()),o.current=[];const w=t.filter(j=>j.latitude!=null&&j.longitude!=null);if(w.forEach(j=>{var O,$,U;const k=v7e[j.status]||"#10B981",S=((O=j.photos)==null?void 0:O.find(B=>B.is_primary))||(($=j.photos)==null?void 0:$[0]),M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const L=new Eo.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${yws(j.price)}
${j.property_address||""}
${j.city}, ${j.state}
${b7e[j.status]||j.status} ${j.bedrooms?`${j.bedrooms} bed`:""} ${j.bathrooms?`${j.bathrooms} bath`:""}
${(U=j.agent)!=null&&U.name?`
Listed by ${j.agent.name}
`:""}
Click to view details →
`),P=new Eo.Marker(M).setLngLat([j.longitude,j.latitude]).setPopup(L).addTo(a.current);o.current.push(P)}),w.length>1){const j=new Eo.LngLatBounds;w.forEach(k=>j.extend([k.longitude,k.latitude])),a.current.fitBounds(j,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,f]),N.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(ia,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Listings Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add listings to see them on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[Object.entries(v7e).map(([w,j])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:j}}),e.jsx("span",{className:"text-xs",children:b7e[w]})]},w)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[v.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Cl,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Set up your Mapbox token in Settings to enable maps.":"The map feature has not been configured yet. Please contact your administrator."})]})]})})}function bws(){var B,V,X,Y,ee,Q,ce,ne;const t=nr(),{brokerageId:s}=Os(),{data:r,isLoading:n}=fQe(),[a,o]=N.useState("feed"),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState({sortBy:"newest"}),{data:g,isLoading:v}=xQe({...p,city:c||p.city}),{data:_,isLoading:w}=a8t(),{data:j,isLoading:k}=gQe(),{data:S,isLoading:M}=c8t(),{data:L,isLoading:P}=h8t(),{data:O}=u8t(),$=vQe(),U=async re=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(re),me.success("Listing deleted successfully")}catch{me.error("Failed to delete listing")}};return n?e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):r?e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(dn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(g==null?void 0:g.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Ya,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(_==null?void 0:_.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(sS,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(hr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((B=S==null?void 0:S.sent)==null?void 0:B.length)||0)+(((V=S==null?void 0:S.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(_a,{value:a,onValueChange:o,children:[e.jsxs(fa,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(ns,{value:"feed",children:"Community Feed"}),s&&e.jsx(ns,{value:"brokerage",children:"Brokerage"}),e.jsx(ns,{value:"my-listings",children:"My Listings"}),e.jsx(ns,{value:"saved",children:"Saved"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"map",children:"Map"}),e.jsx(ns,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(ws,{value:"feed",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city or neighborhood...",value:c,onChange:re=>u(re.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:p.sortBy,onValueChange:re=>f({...p,sortBy:re}),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Sort by"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"updated",children:"Recently Updated"}),e.jsx(Mt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(Mt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(ey,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(xws,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),v?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((re,oe)=>e.jsxs(Ee,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(vs,{className:"h-5 w-3/4"}),e.jsx(vs,{className:"h-4 w-1/2"}),e.jsx(vs,{className:"h-4 w-1/4"})]})]},oe))}):(g==null?void 0:g.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(dn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:g==null?void 0:g.map(re=>e.jsx(l9,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.id))})]}),e.jsx(ws,{value:"my-listings",className:"space-y-4",children:k?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,oe)=>e.jsxs(Ee,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(vs,{className:"h-5 w-3/4"}),e.jsx(vs,{className:"h-4 w-1/2"})]})]},oe))}):(j==null?void 0:j.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(sS,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j==null?void 0:j.map(re=>e.jsx(l9,{listing:re,showActions:!0,onClick:()=>t(`/mission-control/listings/${re.id}`),onEdit:()=>t(`/mission-control/listings/${re.id}/edit`),onDelete:()=>U(re.id)},re.id))})}),e.jsx(ws,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,oe)=>e.jsxs(Ee,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(vs,{className:"h-5 w-3/4"}),e.jsx(vs,{className:"h-4 w-1/2"})]})]},oe))}):(_==null?void 0:_.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Ya,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:_==null?void 0:_.map(re=>e.jsx(l9,{listing:re.listing,onClick:()=>t(`/mission-control/listings/${re.listing.id}`)},re.id))})}),e.jsx(ws,{value:"referrals",className:"space-y-6",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4"}),"Referrals Sent (",((X=S==null?void 0:S.sent)==null?void 0:X.length)||0,")"]}),((Y=S==null?void 0:S.sent)==null?void 0:Y.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(ee=S==null?void 0:S.sent)==null?void 0:ee.map(re=>{var oe,fe;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:re.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((oe=re.listing)==null?void 0:oe.property_address)||((fe=re.listing)==null?void 0:fe.city)})]}),e.jsx(st,{variant:re.status==="closed"?"default":"secondary",children:re.status.replace("_"," ")})]})})},re.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Referrals Received (",((Q=S==null?void 0:S.received)==null?void 0:Q.length)||0,")"]}),((ce=S==null?void 0:S.received)==null?void 0:ce.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ne=S==null?void 0:S.received)==null?void 0:ne.map(re=>{var oe;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:re.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(oe=re.sender)==null?void 0:oe.name]})]}),e.jsx(st,{variant:re.status==="closed"?"default":"secondary",children:re.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${re.listing_id}`),children:"View Listing"})]})},re.id)})})]})]})}),s&&e.jsx(ws,{value:"brokerage",className:"space-y-4",children:P?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,oe)=>e.jsxs(Ee,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(vs,{className:"h-5 w-3/4"}),e.jsx(vs,{className:"h-4 w-1/2"})]})]},oe))}):(L==null?void 0:L.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(sS,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L==null?void 0:L.map(re=>e.jsx(l9,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.id))})}),e.jsx(ws,{value:"map",children:e.jsx(vws,{listings:g||[],isLoading:v})}),e.jsx(ws,{value:"leaderboard",children:e.jsx(gws,{leaderboard:O})})]})]})}):e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(dn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Coming Soon"}),e.jsx("p",{className:"text-muted-foreground",children:"Listing Exchange is currently in development. Check back soon!"})]})})})}function bx(t){const s=t.expected_commission;if(!s)return null;if((t.commission_calc_method||"standard")==="referral_first"){let a=s;t.referral_fee_pct&&(a-=s*(t.referral_fee_pct/100));let o=a;return t.brokerage_split_pct&&(o-=a*(t.brokerage_split_pct/100)),t.team_split_pct&&(o-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(o-=s*(t.franchise_fee_pct/100)),t.transaction_fee&&(o-=t.transaction_fee),Math.max(0,o)}let n=s;return t.brokerage_split_pct&&(n-=s*(t.brokerage_split_pct/100)),t.team_split_pct&&(n-=s*(t.team_split_pct/100)),t.franchise_fee_pct&&(n-=s*(t.franchise_fee_pct/100)),t.referral_fee_pct&&(n-=s*(t.referral_fee_pct/100)),t.transaction_fee&&(n-=t.transaction_fee),Math.max(0,n)}function nme(){const t=ri();return mt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function git(){const t=ri(),s=Xt();return Lt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await H.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function ame(){const t=ri();return mt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function yit(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await H.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function vit(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function _ws(){const t=Xt();return Lt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await H.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await H.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function wws(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function jws(t){return mt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Nws(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function kws(t){return mt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Sws(){const t=Xt();return Lt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await H.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function Cws(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function Mws(){const t=ri();return mt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("deal_pipeline").select("*, deal_pipeline_stages(name, is_won_stage, is_lost_stage)").eq("owner_user_id",t);if(r)throw r;const n=(s==null?void 0:s.filter(i=>{var c,u,p;return!((c=i.deal_pipeline_stages)!=null&&c.is_won_stage)&&!((u=i.deal_pipeline_stages)!=null&&u.is_lost_stage)&&((p=i.deal_pipeline_stages)==null?void 0:p.name)!=="Cancelled"}))||[],a=(s==null?void 0:s.filter(i=>{var c;return(c=i.deal_pipeline_stages)==null?void 0:c.is_won_stage}))||[],o=new Date().getFullYear(),l=a.filter(i=>{const c=i.actual_close_date;return c?new Date(c).getFullYear()===o:!0});return{totalDeals:(s==null?void 0:s.length)||0,activeDeals:n.length,wonDeals:a.length,pipelineValue:n.reduce((i,c)=>i+(c.expected_price||0),0),expectedCommission:n.reduce((i,c)=>i+(c.expected_commission||0),0),expectedNetToAgent:n.reduce((i,c)=>i+(bx(c)||0),0),wonValue:a.reduce((i,c)=>i+(c.expected_price||0),0),weightedGCI:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(c.expected_commission||0)*u},0),weightedNet:n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(bx(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(bx(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(bx(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(bx(c)||0)*u},0)}},enabled:!!t})}function Tws(t){const s=ri();return mt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await H.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function Aws(){const t=Xt();return Lt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await H.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function Ews(){const t=Xt();return Lt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await H.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function Pws({listing:t}){const s=nr(),[r,n]=N.useState(""),[a,o]=N.useState(!1),{data:l,isLoading:i}=Tws(t.id),{data:c,isLoading:u}=nme(),{data:p,isLoading:f}=ame(),g=git(),v=Aws(),_=Ews(),w=yit(),j=(p==null?void 0:p.filter(P=>!P.listing_id))||[],k=P=>{if(!(c!=null&&c.length))return null;switch(P){case"coming_soon":case"active":case"price_improvement":return c.find(O=>O.name==="Active");case"under_contract":return c.find(O=>O.name==="Under Contract");case"sold":return c.find(O=>O.is_won_stage);default:return c.find(O=>O.name==="Active")}},S=async()=>{o(!0);try{c!=null&&c.length||await g.mutateAsync();const P=k(t.status);await w.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(P==null?void 0:P.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),me.success("Deal created and linked to listing!")}catch(P){console.error("Failed to create deal:",P),me.error("Failed to create deal")}finally{o(!1)}},M=async()=>{if(!r){me.error("Please select a deal");return}try{await v.mutateAsync({dealId:r,listingId:t.id}),me.success("Listing linked to deal!"),n("")}catch{me.error("Failed to link listing")}},L=async()=>{if(l)try{await _.mutateAsync({dealId:l.id,listingId:t.id}),me.success("Listing unlinked from deal")}catch{me.error("Failed to unlink listing")}};return i||u?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(f0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(ml,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(st,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Sa,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:L,disabled:_.isPending,children:_.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(jS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"flex items-center gap-2 text-base",children:[e.jsx(f0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"flex-1 text-sm",children:e.jsx(Ys,{placeholder:"Link to existing deal..."})}),e.jsx(Ws,{children:j.map(P=>e.jsx(Mt,{value:P.id,children:P.deal_name},P.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:M,disabled:!r||v.isPending,children:v.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(ml,{className:"h-4 w-4"})})]})]})]})]})}const Iws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Lws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},_7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Dws(){var ee,Q,ce,ne,re,oe,fe,ge,ue;const{listingId:t}=lo(),s=nr(),{user:r}=Os(),{data:n,isLoading:a}=yQe(t||""),{data:o}=_Qe(t||""),{data:l}=o8t(t||""),i=bQe(),c=i8t(),u=l8t(),p=vQe(),f=d8t(),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(!1),[S,M]=N.useState(null),[L,P]=N.useState({buyerName:"",buyerType:"",notes:""}),O=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=xe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(xe),U=async xe=>{const _e=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,$e=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:xe});try{switch(xe){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(_e)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(_e),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${$e} ${_e}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(`Check out this listing: ${_e}`)}`);break}}catch(Me){console.error("Share error:",Me),me.error("Failed to share")}},B=async()=>{try{await p.mutateAsync(n.id),me.success("Listing deleted"),s("/mission-control/listings")}catch{me.error("Failed to delete listing")}},V=async()=>{if(!L.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:L.buyerName,buyerType:L.buyerType||void 0,notes:L.notes||void 0}),me.success("Referral sent successfully!"),w(!1),P({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},X=xe=>{var we,Le;const _e=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,$e=$((n==null?void 0:n.price)||0),Me=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ie=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",ke=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",pe=[Me,Ie,ke].filter(Boolean).join(" | ");switch(xe){case"just_listed":return`🏡 JUST LISTED! ${_e} ${$e} ${pe} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(we=n==null?void 0:n.city)==null?void 0:we.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${_e} Now ${$e}! ${pe} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${_7e[(n==null?void 0:n.property_type)||"single_family"].toLowerCase()} in ${n==null?void 0:n.city}? 👀 I've got just the one for you! ${pe} DM me for details! 📩 #ComingSoon #RealEstate #${(Le=n==null?void 0:n.city)==null?void 0:Le.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Ts,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-10 w-32"}),e.jsx(vs,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(vs,{className:"h-48"}),e.jsx(vs,{className:"h-48"}),e.jsx(vs,{className:"h-48"})]})]})});if(!n)return e.jsx(Ts,{title:"Listing Not Found",description:"",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const Y=((ee=n.photos)==null?void 0:ee.find(xe=>xe.is_primary))||((Q=n.photos)==null?void 0:Q[0]);return e.jsxs(Ts,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>Y&&M(Y.photo_url),children:Y?e.jsx("img",{src:Y.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(ce=n.photos)==null?void 0:ce.slice(1,5).map((xe,_e)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>M(xe.photo_url),children:e.jsx("img",{src:xe.photo_url,alt:`Photo ${_e+2}`,className:"w-full h-full object-cover"})},xe.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{className:`${Iws[n.status]} text-white border-0`,children:Lws[n.status]}),n.is_featured&&e.jsxs(st,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(st,{variant:"outline",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(n.price)}),n.property_address&&e.jsx("p",{className:"text-xl font-medium",children:n.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Ya,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>c.mutate(n.id),children:l?e.jsx(i1,{className:"h-4 w-4"}):e.jsx(Lm,{className:"h-4 w-4"})}),!O&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>k(!0),children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(nd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Bd,{children:[e.jsxs(Aa,{onClick:()=>U("copy"),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Aa,{onClick:()=>U("facebook"),children:[e.jsx(Cu,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Aa,{onClick:()=>U("text"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Aa,{onClick:()=>U("email"),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),O&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(md,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>v(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[n.bedrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(Mh,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bedrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Beds"})]}),n.bathrooms&&e.jsxs("div",{className:"text-center",children:[e.jsx(su,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.bathrooms}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Baths"})]}),n.square_footage&&e.jsxs("div",{className:"text-center",children:[e.jsx(w0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(st,{variant:"secondary",children:[e.jsx(Ca,{className:"h-3 w-3 mr-1"}),_7e[n.property_type]]}),n.lot_size&&e.jsxs(st,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(st,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]}),e.jsxs("div",{className:"flex items-center gap-4 pt-4 mt-4 border-t text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(nd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ya,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(xe=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("p",{className:"font-medium text-sm capitalize",children:[xe.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(X(xe)),me.success("Caption copied!")},children:e.jsx(yi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:X(xe)})]},xe))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((re=(ne=n.agent)==null?void 0:ne.name)==null?void 0:re.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((oe=n.agent)==null?void 0:oe.name)||"Unknown"}),((ge=(fe=n.agent)==null?void 0:fe.brokerage)==null?void 0:ge.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!O&&e.jsx("div",{className:"space-y-2",children:((ue=n.agent)==null?void 0:ue.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),O&&e.jsx(Pws,{listing:n}),!O&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(xs,{open:!!S,onOpenChange:()=>M(null),children:e.jsx(fs,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(xs,{open:g,onOpenChange:v,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Delete Listing"}),e.jsx(Wr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(xs,{open:_,onOpenChange:w,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Send Buyer Referral"}),e.jsx(Wr,{children:"Submit buyer information to the listing agent"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buyer Name *"}),e.jsx(ze,{value:L.buyerName,onChange:xe=>P({...L,buyerName:xe.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buyer Type"}),e.jsxs(Ks,{value:L.buyerType,onValueChange:xe=>P({...L,buyerType:xe}),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(Mt,{value:"investor",children:"Investor"}),e.jsx(Mt,{value:"relocating",children:"Relocating"}),e.jsx(Mt,{value:"upgrade",children:"Upgrading"}),e.jsx(Mt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes"}),e.jsx(Pr,{value:L.notes,onChange:xe=>P({...L,notes:xe.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(xit,{open:j,onOpenChange:k,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function Ows({onImport:t}){const[s,r]=N.useState(""),[n,a]=N.useState([]),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(null),f=N.useRef(),g=N.useRef(null);N.useEffect(()=>{const S=M=>{g.current&&!g.current.contains(M.target)&&c(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const v=async S=>{if(S.trim().length<3){a([]),c(!1);return}l(!0);try{const{data:M,error:L}=await H.functions.invoke("mls-listing-search",{body:{query:S}});if(L)throw L;a((M==null?void 0:M.listings)||[]),c(!0)}catch(M){console.error("MLS search error:",M),a([])}finally{l(!1)}},_=S=>{r(S),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>v(S),400)},w=S=>{p(S.mlsNumber),t(S),c(!1),r(`${S.address}, ${S.city}`),me.success(`Imported: ${S.address}`,{description:"Property details and photos have been auto-filled."}),p(null)},j=S=>S?`$${S.toLocaleString()}`:"",k=S=>{const M=(S||"").toLowerCase();return M.includes("single")||M.includes("detached")?"Single Family":M.includes("condo")?"Condo":M.includes("town")?"Townhouse":M.includes("land")||M.includes("lot")?"Land":M.includes("multi")?"Multi-Family":M.includes("commercial")?"Commercial":S||"Other"};return e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4 text-primary"}),"Import from MLS"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Search by address to auto-fill property details and photos from MLS"})]}),e.jsx(Oe,{children:e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:s,onChange:S=>_(S.target.value),onFocus:()=>n.length>0&&c(!0),placeholder:"Start typing a property address...",className:"pl-9 pr-9"}),o&&e.jsx(bs,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground"}),s&&!o&&e.jsx("button",{type:"button",onClick:()=>{r(""),a([]),c(!1)},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Mr,{className:"h-4 w-4"})})]}),i&&e.jsx("div",{className:"absolute z-50 w-full mt-1 bg-popover border rounded-lg shadow-lg max-h-[400px] overflow-y-auto",children:n.length===0&&!o?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No properties found. Try a different address."}):n.map(S=>e.jsxs("button",{type:"button",onClick:()=>w(S),disabled:u===S.mlsNumber,className:"w-full text-left p-3 hover:bg-accent/50 transition-colors border-b last:border-0 flex items-start gap-3",children:[S.photos[0]?e.jsx("img",{src:S.photos[0],alt:"",className:"w-16 h-12 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-12 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(ia,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:S.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[S.city,", ",S.state," ",S.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:j(S.price)}),S.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Mh,{className:"h-3 w-3"})," ",S.bedrooms]}),S.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(su,{className:"h-3 w-3"})," ",S.bathrooms]}),S.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ax,{className:"h-3 w-3"})," ",S.sqft.toLocaleString()]})]})]}),e.jsxs("div",{className:"flex-shrink-0 flex flex-col items-end gap-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:k(S.propertyType)}),S.photos.length>0&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[S.photos.length," photos"]})]})]},S.mlsNumber))})]})})]})}function Rws({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=l4e({id:t.id}),u={transform:a3.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:It("relative aspect-square rounded-lg overflow-hidden bg-muted group",c&&"opacity-50 ring-2 ring-primary z-50"),children:[e.jsx("img",{src:t.photo_url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...n,...a,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>s(t.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mr,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]}):e.jsx("button",{type:"button",onClick:()=>r(t.id),className:"absolute bottom-1 left-1 text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded opacity-0 group-hover:opacity-100 transition-opacity hover:bg-black/80",children:"Set as Primary"})]})}function Fws({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=e4e(ece(mR,{activationConstraint:{distance:5}})),i=[...t].sort((u,p)=>(u.sort_order??0)-(p.sort_order??0)),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.findIndex(k=>k.id===p.id),v=i.findIndex(k=>k.id===f.id),_=[...i],[w]=_.splice(g,1);_.splice(v,0,w);const j=_.map((k,S)=>({...k,sort_order:S}));a(j)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(a4e,{sensors:l,collisionDetection:t4e,onDragEnd:c,children:e.jsx(o4e,{items:i.map(u=>u.id),strategy:pR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(Rws,{photo:u,onRemove:n,onSetPrimary:o},u.id)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[s?e.jsx(bs,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>r(u.target.files),disabled:s})]})]})})})]})}function zws({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=nr(),{user:a}=Os(),[o,l]=N.useState(!1),[i,c]=N.useState([]),[u,p]=N.useState(!1),[f,g]=N.useState(null),[v,_]=N.useState({});N.useEffect(()=>{t&&a?w():g(null)},[t,a]);const w=async()=>{if(!t)return;const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!V&&B&&(g(B),j(B))},j=async B=>{try{const{data:V,error:X}=await H.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:B.bunny_video_id,isAgentVideo:!0}});!X&&(V!=null&&V.thumbnailUrl)&&_(Y=>({...Y,[B.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},k=async()=>{if(a){p(!0);try{const{data:B,error:V}=await H.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;c(B||[]),B!=null&&B.length&&S(B)}catch(B){console.error("Error fetching videos:",B),me.error("Failed to load videos")}finally{p(!1)}}},S=async B=>{var V;try{const X=B.map(ne=>ne.bunny_video_id),{data:Y,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:X,isAgentVideo:!0}});if(ee)throw ee;const Q=(Y==null?void 0:Y.assets)||{},ce={};for(const ne of B)(V=Q[ne.bunny_video_id])!=null&&V.thumbnailUrl&&(ce[ne.id]={thumbnailUrl:Q[ne.bunny_video_id].thumbnailUrl});_(ne=>({...ne,...ce}))}catch(X){console.warn("Failed to bulk-fetch signed URLs",X)}},M=()=>{l(!0),k()},L=B=>{s(B.id),g(B),l(!1),me.success("Video selected")},P=()=>{s(null),g(null)},O=()=>{const B=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(B)}`)},$=B=>{if(!B)return"0:00";const V=Math.floor(B/60),X=B%60;return`${V}:${X.toString().padStart(2,"0")}`},U=B=>{var V;return((V=v[B.id])==null?void 0:V.thumbnailUrl)||B.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[U(f)?e.jsx("img",{src:U(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:e.jsx(il,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:M,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:P,className:"text-destructive hover:text-destructive",children:e.jsx(Mr,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Cn,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[e.jsxs(K,{type:"button",variant:"outline",onClick:M,className:"gap-2",children:[e.jsx(UM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:O,className:"gap-2",children:[e.jsx(ff,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(UM,{className:"h-5 w-5"}),"Select a Video"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:u?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:O,className:"gap-2",children:[e.jsx(ff,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(B=>e.jsxs("button",{type:"button",onClick:()=>L(B),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===B.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[U(B)?e.jsx("img",{src:U(B),alt:B.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:e.jsx(il,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),B.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(B.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:B.title||"Untitled Video"})})]},B.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:O,className:"gap-2",children:[e.jsx(ff,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const Bws=[{value:"active",label:"Active"},{value:"coming_soon",label:"Coming Soon"},{value:"price_improvement",label:"Price Improvement"},{value:"under_contract",label:"Under Contract"},{value:"sold",label:"Sold"}],$ws=[{value:"single_family",label:"Single Family"},{value:"condo",label:"Condo"},{value:"townhouse",label:"Townhouse"},{value:"land",label:"Land"},{value:"multi_family",label:"Multi-Family"},{value:"luxury",label:"Luxury"},{value:"commercial",label:"Commercial"},{value:"other",label:"Other"}];function qws({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:u}=l4e({id:t}),p={transform:a3.Transform.toString(i),transition:c};return e.jsxs("div",{ref:l,style:p,className:`relative aspect-square rounded-lg overflow-hidden bg-muted group ${u?"opacity-50 ring-2 ring-primary z-50":""}`,children:[e.jsx("img",{src:s,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",...a,...o,className:"absolute top-1 left-1 p-1 bg-black/60 text-white rounded cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>n(r),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mr,{className:"h-3 w-3"})}),r===0&&e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Jn,{className:"h-2.5 w-2.5 fill-current"})," Primary"]})]})}function Uws({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=e4e(ece(mR,{activationConstraint:{distance:5}})),i=t.map((u,p)=>`pending-${p}`),c=u=>{const{active:p,over:f}=u;if(!f||p.id===f.id)return;const g=i.indexOf(p.id),v=i.indexOf(f.id),_=[...t],w=[...s],[j]=_.splice(g,1),[k]=w.splice(g,1);_.splice(v,0,j),w.splice(v,0,k),n(_,w)};return e.jsxs("div",{className:"space-y-2",children:[t.length>1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. First photo will be primary."}),e.jsx(a4e,{sensors:l,collisionDetection:t4e,onDragEnd:c,children:e.jsx(o4e,{items:i,strategy:pR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(qws,{id:i[p],url:u,index:p,onRemove:r},i[p])),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[a?e.jsx(bs,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-8 w-8"}),e.jsx("span",{className:"text-xs",children:"Upload"})]}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:u=>o(u.target.files),disabled:a})]})]})})}),s.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[s.length," photo",s.length!==1?"s":""," will be uploaded when you save."]})]})}function w7e(){const{listingId:t}=lo(),[s]=uc(),r=s.get("brokerage"),n=nr(),{user:a}=Os(),{hasLeadSite:o}=uE(),l=!!t&&t!=="new",i=!!r&&!l,[c,u]=N.useState([]),{data:p,isLoading:f}=yQe(l?t:""),g=XLt(),v=JLt(),_=e8t(),w=t8t(),j=s8t(),k=r8t(),S=n8t(),{data:M=[]}=mt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ue,error:xe}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(xe)throw xe;return ue||[]},enabled:i}),[L,P]=N.useState(""),[O,$]=N.useState(!1),[U,B]=N.useState([]),[V,X]=N.useState([]),[Y,ee]=N.useState({property_address:"",city:"",state:"",neighborhood:"",price:"",property_type:"single_family",status:"active",bedrooms:"",bathrooms:"",square_footage:"",lot_size:"",year_built:"",has_hoa:!1,description:"",agent_notes:"",agent_notes_public:!1,mls_link:"",video_link:"",video_id:null,allow_sharing:!0,open_to_referrals:!0,open_to_social_promotion:!0,share_with_brokerage:!1,is_public:!0});N.useEffect(()=>{var ue,xe,_e,$e,Me;p&&l&&ee({property_address:p.property_address||"",city:p.city||"",state:p.state||"",neighborhood:p.neighborhood||"",price:((ue=p.price)==null?void 0:ue.toString())||"",property_type:p.property_type,status:p.status,bedrooms:((xe=p.bedrooms)==null?void 0:xe.toString())||"",bathrooms:((_e=p.bathrooms)==null?void 0:_e.toString())||"",square_footage:(($e=p.square_footage)==null?void 0:$e.toString())||"",lot_size:p.lot_size||"",year_built:((Me=p.year_built)==null?void 0:Me.toString())||"",has_hoa:p.has_hoa,description:p.description||"",agent_notes:p.agent_notes||"",agent_notes_public:p.agent_notes_public,mls_link:p.mls_link||"",video_link:p.video_link||"",video_id:p.video_id||null,allow_sharing:p.allow_sharing,open_to_referrals:p.open_to_referrals,open_to_social_promotion:p.open_to_social_promotion,share_with_brokerage:p.share_with_brokerage??!1,is_public:p.is_public})},[p,l]);const Q=ue=>{var Me,Ie;const xe={"single family":"single_family",detached:"single_family",residential:"single_family",condo:"condo",condominium:"condo",apartment:"condo",townhouse:"townhouse",townhome:"townhouse",land:"land",lot:"land","lots and land":"land","multi-family":"multi_family","multi family":"multi_family",duplex:"multi_family",commercial:"commercial"},_e=(ue.propertyType||"").toLowerCase(),$e=((Me=Object.entries(xe).find(([ke])=>_e.includes(ke)))==null?void 0:Me[1])||"other";ee(ke=>({...ke,property_address:ue.address||ke.property_address,city:ue.city||ke.city,state:ue.state||ke.state,price:ue.price?String(ue.price):ke.price,property_type:$e,bedrooms:ue.bedrooms?String(ue.bedrooms):ke.bedrooms,bathrooms:ue.bathrooms?String(ue.bathrooms):ke.bathrooms,square_footage:ue.sqft?String(ue.sqft):ke.square_footage,lot_size:ue.lotSize?String(ue.lotSize):ke.lot_size,year_built:ue.yearBuilt?String(ue.yearBuilt):ke.year_built,description:ue.description||ke.description})),((Ie=ue.photos)==null?void 0:Ie.length)>0&&(u(ue.photos),V.forEach(ke=>URL.revokeObjectURL(ke)),B([]),X([]))},ce=ue=>{if(!ue)return;const xe=Array.from(ue);B($e=>[...$e,...xe]);const _e=xe.map($e=>URL.createObjectURL($e));X($e=>[...$e,..._e])},ne=ue=>{URL.revokeObjectURL(V[ue]),B(xe=>xe.filter((_e,$e)=>$e!==ue)),X(xe=>xe.filter((_e,$e)=>$e!==ue))},re=async ue=>{var xe;if(!(!ue||!p)){$(!0);try{for(const _e of Array.from(ue)){const $e=_e.name.split(".").pop(),Me=`${a==null?void 0:a.id}/${p.id}/${Date.now()}.${$e}`,{error:Ie}=await H.storage.from("listing-photos").upload(Me,_e);if(Ie)throw Ie;const{data:{publicUrl:ke}}=H.storage.from("listing-photos").getPublicUrl(Me);await w.mutateAsync({listingId:p.id,photoUrl:ke,isPrimary:!((xe=p.photos)!=null&&xe.length)})}me.success("Photos uploaded!")}catch(_e){console.error("Upload error:",_e),me.error("Failed to upload photos")}finally{$(!1)}}},oe=async ue=>{for(let xe=0;xe{if(p)try{await j.mutateAsync({photoId:ue,listingId:p.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},ge=async ue=>{if(ue.preventDefault(),!Y.city.trim()||!Y.state.trim()||!Y.price){me.error("Please fill in required fields (City, State, Price)");return}if(i&&!L){me.error("Please select an agent to assign this listing to");return}try{const xe={property_address:Y.property_address||null,city:Y.city,state:Y.state,neighborhood:Y.neighborhood||null,price:Number(Y.price),property_type:Y.property_type,status:Y.status,bedrooms:Y.bedrooms?Number(Y.bedrooms):null,bathrooms:Y.bathrooms?Number(Y.bathrooms):null,square_footage:Y.square_footage?Number(Y.square_footage):null,lot_size:Y.lot_size||null,year_built:Y.year_built?Number(Y.year_built):null,has_hoa:Y.has_hoa,description:Y.description||null,agent_notes:Y.agent_notes||null,agent_notes_public:Y.agent_notes_public,mls_link:Y.mls_link||null,video_link:Y.video_link||null,video_id:Y.video_id||null,allow_sharing:Y.allow_sharing,open_to_referrals:Y.open_to_referrals,open_to_social_promotion:Y.open_to_social_promotion,share_with_brokerage:Y.share_with_brokerage,is_public:Y.is_public};if(l)await _.mutateAsync({id:t,...xe}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{$(!0);let _e;if(i&&L?_e=await v.mutateAsync({agentId:L,...xe}):_e=await g.mutateAsync(xe),U.length>0)try{await oe(_e.id),V.forEach($e=>URL.revokeObjectURL($e)),B([]),X([])}catch($e){console.error("Photo upload error:",$e),me.error("Listing created but some photos failed to upload")}if(c.length>0)try{for(let $e=0;$en(i?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),i?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[i&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(Ks,{value:L,onValueChange:P,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select an agent..."})}),e.jsx(Ws,{children:M.map(ue=>e.jsx(Mt,{value:ue.id,children:ue.name||ue.email},ue.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),!l&&o&&!i&&e.jsx(Ows,{onImport:Q}),c.length>0&&e.jsxs(Ee,{className:"border-primary/30 bg-primary/5",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4 text-primary"}),"MLS Photos (",c.length,")"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These photos will be imported when you save the listing."})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:[c.slice(0,12).map((ue,xe)=>e.jsx("div",{className:"aspect-square rounded overflow-hidden bg-muted",children:e.jsx("img",{src:ue,alt:"",className:"w-full h-full object-cover"})},xe)),c.length>12&&e.jsxs("div",{className:"aspect-square rounded bg-muted flex items-center justify-center text-sm text-muted-foreground font-medium",children:["+",c.length-12]})]}),e.jsxs(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2 text-destructive",onClick:()=>u([]),children:[e.jsx(Mr,{className:"h-3 w-3 mr-1"})," Clear MLS photos"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:Y.property_address,onChange:ue=>ee({...Y,property_address:ue.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"City *"}),e.jsx(ze,{value:Y.city,onChange:ue=>ee({...Y,city:ue.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"State *"}),e.jsx(ze,{value:Y.state,onChange:ue=>ee({...Y,state:ue.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Neighborhood"}),e.jsx(ze,{value:Y.neighborhood,onChange:ue=>ee({...Y,neighborhood:ue.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Price *"}),e.jsx(ze,{type:"number",value:Y.price,onChange:ue=>ee({...Y,price:ue.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Type"}),e.jsxs(Ks,{value:Y.property_type,onValueChange:ue=>ee({...Y,property_type:ue}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:$ws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:Y.status,onValueChange:ue=>ee({...Y,status:ue}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Bws.map(ue=>e.jsx(Mt,{value:ue.value,children:ue.label},ue.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Bedrooms"}),e.jsx(ze,{type:"number",value:Y.bedrooms,onChange:ue=>ee({...Y,bedrooms:ue.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Bathrooms"}),e.jsx(ze,{type:"number",step:"0.5",value:Y.bathrooms,onChange:ue=>ee({...Y,bathrooms:ue.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Sq Ft"}),e.jsx(ze,{type:"number",value:Y.square_footage,onChange:ue=>ee({...Y,square_footage:ue.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Lot Size"}),e.jsx(ze,{value:Y.lot_size,onChange:ue=>ee({...Y,lot_size:ue.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Year Built"}),e.jsx(ze,{type:"number",value:Y.year_built,onChange:ue=>ee({...Y,year_built:ue.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(qr,{checked:Y.has_hoa,onCheckedChange:ue=>ee({...Y,has_hoa:ue})}),e.jsx(be,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:Y.description,onChange:ue=>ee({...Y,description:ue.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Agent Notes"}),e.jsx(Pr,{value:Y.agent_notes,onChange:ue=>ee({...Y,agent_notes:ue.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:Y.agent_notes_public,onCheckedChange:ue=>ee({...Y,agent_notes_public:ue})}),e.jsx(be,{className:"text-sm text-muted-foreground",children:"Make notes visible to other agents"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"MLS Link"}),e.jsx(ze,{value:Y.mls_link,onChange:ue=>ee({...Y,mls_link:ue.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video Link"}),e.jsx(ze,{value:Y.video_link,onChange:ue=>ee({...Y,video_link:ue.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(zws,{selectedVideoId:Y.video_id,onVideoSelect:ue=>ee({...Y,video_id:ue}),listingId:l?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Photos"})}),e.jsx(Oe,{children:l&&(p!=null&&p.photos)?e.jsx(Fws,{photos:p.photos,uploading:O,onUpload:ue=>re(ue),onRemove:ue=>fe(ue),onReorder:ue=>{k.mutate({photos:ue.map(xe=>({id:xe.id,sort_order:xe.sort_order,is_primary:xe.is_primary}))})},onSetPrimary:ue=>{p&&S.mutate({photoId:ue,listingId:p.id})}}):e.jsx(Uws,{photoUrls:V,onRemove:ne,onReorder:(ue,xe)=>{X(ue),B(xe)},pendingPhotos:U,uploading:O,onUpload:ce})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(qr,{checked:Y.allow_sharing,onCheckedChange:ue=>ee({...Y,allow_sharing:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(qr,{checked:Y.open_to_referrals,onCheckedChange:ue=>ee({...Y,open_to_referrals:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(qr,{checked:Y.open_to_social_promotion,onCheckedChange:ue=>ee({...Y,open_to_social_promotion:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(qr,{checked:Y.share_with_brokerage,onCheckedChange:ue=>ee({...Y,share_with_brokerage:ue})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(qr,{checked:Y.is_public,onCheckedChange:ue=>ee({...Y,is_public:ue})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:g.isPending||_.isPending,children:g.isPending||_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):l?"Update Listing":"Create Listing"})]})]})]})})}let op=null;function Vws(){if(op)return op;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return op={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},op;const r=s.getExtension("WEBGL_debug_renderer_info"),n=r?s.getParameter(r.UNMASKED_RENDERER_WEBGL):"Unknown",a=["swiftshader","llvmpipe","software","microsoft basic render"],o=(n||"").toLowerCase();if(a.some(c=>o.includes(c)))return op={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},op;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(op={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},op):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(op={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},op):(op={canRunVirtualBg:!0,renderer:n},op)}catch{return op={canRunVirtualBg:!0},op}}const Hws=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function Gws({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=N.useRef(null),[l,i]=N.useState(!1),[c]=N.useState(()=>Vws()),u=!c.canRunVirtualBg,{data:p=[],refetch:f}=mt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:j}}=await H.auth.getUser();if(!j)return[];const{data:k,error:S}=await H.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return S?(console.error("Failed to load backgrounds:",S),[]):k||[]}}),g=p.map(j=>({type:"image",label:j.name,imageUrl:j.image_url,thumbnail:j.thumbnail_url||j.image_url})),v=[...Hws,...g],_=j=>j.type!==t.type?!1:j.type==="image"?j.imageUrl===t.imageUrl:!0,w=async j=>{var S;const k=(S=j.target.files)==null?void 0:S[0];if(k){if(!k.type.startsWith("image/")){me.error("Please select an image file");return}if(k.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:M}}=await H.auth.getUser();if(!M)throw new Error("Not authenticated");const L=k.name.split(".").pop()||"jpg",P=`${M.id}/${crypto.randomUUID()}.${L}`,{error:O}=await H.storage.from("video-backgrounds").upload(P,k,{contentType:k.type});if(O)throw O;const{data:$}=H.storage.from("video-backgrounds").getPublicUrl(P),U=$.publicUrl,{error:B}=await H.from("video_backgrounds").insert({name:k.name.replace(/\.[^.]+$/,""),image_url:U,thumbnail_url:U,category:"custom",is_stock:!1,user_id:M.id});if(B)throw B;await f(),s({type:"image",imageUrl:U,blurRadius:15}),me.success("Background uploaded!")}catch(M){console.error("Upload error:",M),me.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:It("flex flex-col gap-1",a),children:[u&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/30 dark:text-amber-400 rounded px-2 py-1",children:[e.jsx(Yu,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:c.reason||"Virtual backgrounds may cause lag on this device"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto py-2 px-1 scrollbar-none",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap mr-1 font-medium",children:"Background:"}),r&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(bs,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),v.map((j,k)=>{const S=_(j);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:j.type,imageUrl:j.imageUrl,blurRadius:15}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",S?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[j.type==="none"&&e.jsx(iL,{className:"h-4 w-4 text-muted-foreground"}),j.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),j.type==="image"&&j.thumbnail&&e.jsx("img",{src:j.thumbnail,alt:j.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:j.label})]},`${j.type}-${j.imageUrl||k}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var j;return(j=o.current)==null?void 0:j.click()},className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 border-dashed p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30","border-muted-foreground/30 bg-muted/30",(n||l)&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:l?e.jsx(bs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(qs,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l?"Uploading":"Custom"})]}),e.jsx("input",{ref:o,type:"file",accept:"image/*",className:"hidden",onChange:w}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:It("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all ml-1","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",t.mirror?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"w-12 h-8 rounded flex items-center justify-center",children:e.jsx(yL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var EA=typeof self<"u"?self:{};function bit(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=EA,a=0;a>6|192;else{if(s>=55296&&s<=57343){if(s<=56319&&a=56320&&o<=57343){s=1024*(s-55296)+o-56320+65536,n[r++]=s>>18|240,n[r++]=s>>12&63|128,n[r++]=s>>6&63|128,n[r++]=63&s|128;continue}a--}s=65533}n[r++]=s>>12|224,n[r++]=s>>6&63|128}n[r++]=63&s|128}}t=r===n.length?n:n.subarray(0,r)}return t}function wit(t){EA.setTimeout(()=>{throw t},0)}var twe,Yws=bit(610401301,!1),N7e=bit(748402147,!0);function k7e(){var t=EA.navigator;return t&&(t=t.userAgent)?t:""}const S7e=EA.navigator;function ime(t){return ime[" "](t),t}twe=S7e&&S7e.userAgentData||null,ime[" "]=function(){};const jit={};let qI=null;function Qws(t){const s=t.length;let r=3*s/4;r%3?r=Math.floor(r):"=.".indexOf(t[s-1])!=-1&&(r="=.".indexOf(t[s-2])!=-1?r-2:r-1);const n=new Uint8Array(r);let a=0;return function(o,l){function i(u){for(;c>4),f!=64&&(l(p<<4&240|f>>2),g!=64&&l(f<<6&192|g))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function Nit(){if(!qI){qI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));jit[r]=n;for(let a=0;a0)&&(k7e().indexOf("Trident")!=-1||k7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const C7e=/[-_.]/g,Jws={"-":"+",_:"/",".":"="};function e2s(t){return Jws[t]||""}function Sit(t){if(!kit)return Qws(t);t=C7e.test(t)?t.replace(C7e,e2s):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,Mit(t=Error(),"incident"),wit(t))}}function OE(){return typeof BigInt=="function"}var RE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function K0(t,s,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&t?Symbol.for(t):t!=null?Symbol(t):Symbol():s}var r2s=K0("jas",void 0,!0),M7e=K0(void 0,"0di"),bI=K0(void 0,"1oa"),Sf=K0(void 0,Symbol()),n2s=K0(void 0,"0ub"),a2s=K0(void 0,"0ubs"),rwe=K0(void 0,"0ubsb"),i2s=K0(void 0,"0actk"),LA=K0("m_m","Pa",!0),T7e=K0();const Tit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Ait=Object.defineProperties,Ea=RE?r2s:"Ga";var D3;const A7e=[];function TR(t,s){RE||Ea in t||Ait(t,Tit),t[Ea]|=s}function Lu(t,s){RE||Ea in t||Ait(t,Tit),t[Ea]=s}function AR(t){return TR(t,34),t}function xO(t){return TR(t,8192),t}Lu(A7e,7),D3=Object.freeze(A7e);var DA={};function Af(t,s){return s===void 0?t.h!==f3&&!!(2&(0|t.v[Ea])):!!(2&s)&&t.h!==f3}const f3={};function CSe(t,s){if(t!=null){if(typeof t=="string")t=t?new A0(t,PA):p3();else if(t.constructor!==A0)if(kSe(t))t=t.length?new A0(new Uint8Array(t),PA):p3();else{if(!s)throw Error();t=void 0}}return t}class E7e{constructor(s,r,n){this.g=s,this.h=r,this.l=n}next(){const s=this.g.next();return s.done||(s.value=this.h.call(this.l,s.value)),s}[Symbol.iterator](){return this}}var o2s=Object.freeze({});function Eit(t,s,r){const n=128&s?0:-1,a=t.length;var o;(o=!!a)&&(o=(o=t[a-1])!=null&&typeof o=="object"&&o.constructor===Object);const l=a+(o?-1:0);for(s=128&s?1:0;stypeof t=="number"),P7e=ome(t=>typeof t=="string"),c2s=ome(t=>typeof t=="boolean"),lme=typeof EA.BigInt=="function"&&typeof EA.BigInt(0)=="bigint";function Cf(t){var s=t;if(P7e(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(l2s(s)&&!Number.isSafeInteger(s))throw Error(String(s));return lme?BigInt(t):t=c2s(t)?t?"1":"0":P7e(t)?t.trim()||"0":String(t)}var nwe=ome(t=>lme?t>=u2s&&t<=m2s:t[0]==="-"?I7e(t,d2s):I7e(t,h2s));const d2s=Number.MIN_SAFE_INTEGER.toString(),u2s=lme?BigInt(Number.MIN_SAFE_INTEGER):void 0,h2s=Number.MAX_SAFE_INTEGER.toString(),m2s=lme?BigInt(Number.MAX_SAFE_INTEGER):void 0;function I7e(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Xc=s,Xd=(t-s)/4294967296>>>0}function OA(t){if(t<0){L7e(-t);const[s,r]=ASe(Xc,Xd);Xc=s>>>0,Xd=r>>>0}else L7e(t)}function MSe(t){const s=f2s||(f2s=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Xd=0,Xc=s.getUint32(0,!0)}function Iit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:gO(t,s)}function x2s(t,s){return Cf(OE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):gO(t,s))}function Lit(t,s){return OE()?Cf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else OE()?r=""+(BigInt(s)<>>24|s<<8))+6710656*(s=s>>16&65535),r+=8147497*s,s*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(s+=r/1e7>>>0,r%=1e7),r=s+D7e(r)+D7e(t));return r}function D7e(t){return t=String(t),"0000000".slice(t.length)+t}function TSe(t,s){if(2147483648&s)if(OE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=ASe(t,s);t="-"+gO(r,n)}else t=gO(t,s);return t}function cme(t){if(t.length<16)OA(Number(t));else if(OE())t=BigInt(t),Xc=Number(t&BigInt(4294967295))>>>0,Xd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Xd=Xc=0;const r=t.length;for(let n=s,a=(r-s)%6+s;a<=r;n=a,a+=6){const o=Number(t.slice(n,a));Xd*=1e6,Xc=1e6*Xc+o,Xc>=4294967296&&(Xd+=Math.trunc(Xc/4294967296),Xd>>>=0,Xc>>>=0)}if(s){const[n,a]=ASe(Xc,Xd);Xc=n,Xd=a}}}function ASe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function ay(t){return Array.prototype.slice.call(t)}const ER=typeof BigInt=="function"?BigInt.asIntN:void 0,g2s=typeof BigInt=="function"?BigInt.asUintN:void 0,x3=Number.isSafeInteger,dme=Number.isFinite,RA=Math.trunc,y2s=Cf(0);function UI(t){if(t!=null&&typeof t!="number")throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function h0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function yO(t){if(t!=null&&typeof t!="boolean"){var s=typeof t;throw Error(`Expected boolean but got ${s!="object"?s:t?Array.isArray(t)?"array":s:"null"}: ${t}`)}return t}function Dit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const v2s=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function PR(t){switch(typeof t){case"bigint":return!0;case"number":return dme(t);case"string":return v2s.test(t);default:return!1}}function zE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return dme(t)?0|t:void 0}function Oit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return dme(t)?t>>>0:void 0}function Rit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(cme(t),TSe(Xc,Xd))}function ESe(t){if(t=RA(t),!x3(t)){OA(t);var s=Xc,r=Xd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=Iit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Fit(t){var s=RA(Number(t));return x3(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Rit(t))}function zit(t){var s=RA(Number(t));return x3(s)?Cf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),OE()?Cf(ER(64,BigInt(t))):Cf(Rit(t)))}function Bit(t){return x3(t)?t=Cf(ESe(t)):(t=RA(t),x3(t)?t=String(t):(OA(t),t=TSe(Xc,Xd)),t=Cf(t)),t}function ade(t){const s=typeof t;return t==null?t:s==="bigint"?Cf(ER(64,t)):PR(t)?s==="string"?zit(t):Bit(t):void 0}function $it(t){if(typeof t!="string")throw Error();return t}function IR(t){if(t!=null&&typeof t!="string")throw Error();return t}function Ih(t){return t==null||typeof t=="string"?t:void 0}function PSe(t,s,r,n){return t!=null&&t[LA]===DA?t:Array.isArray(t)?((n=(r=0|t[Ea])|32&n|2&n)!==r&&Lu(t,n),new s(t)):(r?2&n?((t=s[M7e])||(AR((t=new s).v),t=s[M7e]=t),s=t):s=new s:s=void 0,s)}function b2s(t,s,r){if(s)e:{if(!PR(s=t))throw swe("int64");switch(typeof s){case"string":s=zit(s);break e;case"bigint":s=Cf(ER(64,s));break e;default:s=Bit(s)}}else s=ade(t);return(t=s)==null?r?y2s:void 0:t}const _2s={};let w2s=function(){try{return ime(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Eye{constructor(){this.g=new Map}get(s){return this.g.get(s)}set(s,r){return this.g.set(s,r),this.size=this.g.size,this}delete(s){return s=this.g.delete(s),this.size=this.g.size,s}clear(){this.g.clear(),this.size=this.g.size}has(s){return this.g.has(s)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(s,r){return this.g.forEach(s,r)}[Symbol.iterator](){return this.entries()}}const j2s=w2s?(Object.setPrototypeOf(Eye.prototype,Map.prototype),Object.defineProperties(Eye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Eye):class extends Map{constructor(){super()}};function O7e(t){return t}function Pye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var B1=class extends j2s{constructor(t,s,r=O7e,n=O7e){super(),this.J=0|t[Ea],this.K=s,this.S=r,this.fa=this.K?N2s:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return Pye(this),(t=this.S(t,!0,!1))==null?this:s==null?(super.delete(t),this):super.set(t,this.fa(s,!0,!0,this.K,!1,this.J))}Ma(t){const s=this.S(t[0],!1,!0);t=t[1],t=this.K?t===void 0?null:t:this.fa(t,!1,!0,void 0,!1,this.J),super.set(s,t)}has(t){return super.has(this.S(t,!1,!1))}get(t){t=this.S(t,!1,!1);const s=super.get(t);if(s!==void 0){var r=this.K;return r?((r=this.fa(s,!1,!0,r,this.ra,this.J))!==s&&super.set(t,r),r):s}}[Symbol.iterator](){return this.entries()}};function N2s(t,s,r,n,a,o){return t=PSe(t,n,r,o),a&&(t=LSe(t)),t}function k2s(t){return[t,this.get(t)]}let S2s;function R7e(){return S2s||(S2s=new B1(AR([]),void 0,void 0,void 0,_2s))}function ume(t){return Sf?t[Sf]:void 0}function ide(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}B1.prototype.toJSON=void 0;var awe=class{};const C2s={Ka:!0};function M2s(t,s){s<100||IA(a2s,1)}function hme(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=Sf;!a&&RE&&l&&(o=t[l])&&ide(o,M2s),l=[];var i=t.length;let c;o=4294967295;let u=!1;const p=!!(64&s),f=p?128&s?0:-1:void 0;1&s||(c=i&&t[i-1],c!=null&&typeof c=="object"&&c.constructor===Object?o=--i:c=void 0,!p||128&s||a||(u=!0,o=o-f+f)),s=void 0;for(var g=0;g=o){const _=g-f;(s??(s={}))[_]=v}else l[g]=v}if(c)for(let v in c){if((i=c[v])==null||(i=r(i,n))==null)continue;let _;g=+v,p&&!Number.isNaN(g)&&(_=g+f){_[j]=ay(k)}),_.da=v.da,_}(t)),l}function T2s(t){return t[0]=vO(t[0]),t[1]=vO(t[1]),t}function vO(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return nwe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[Ea];return t.length===0&&1&s?void 0:hme(t,s,vO)}if(t!=null&&t[LA]===DA)return qit(t);if(t instanceof A0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(kit){for(var r="",n=0,a=s.length-10240;n>2];o=r[(3&o)<<4|l>>4],l=r[(15&l)<<2|i>>6],i=r[63&i],n[p++]=c+o+l+i}switch(c=0,i=a,s.length-u){case 2:i=r[(15&(c=s[u+1]))<<2]||a;case 1:s=s[u],n[p]=r[s>>2]+r[(3&s)<<4|c>>4]+i+a}s=n.join("")}t=t.g=s}return t}return t instanceof B1?t=t.size!==0?t.V(T2s):void 0:void 0}return t}let A2s,E2s;function qit(t){return hme(t=t.v,0|t[Ea],vO)}function IS(t,s){return Uit(t,s[0],s[1])}function Uit(t,s,r,n=0){if(t==null){var a=32;r?(t=[r],a|=128):t=[],s&&(a=-16760833&a|(1023&s)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(a=0|t[Ea],N7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(N7e)throw Error("carr");IA(i2s,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&Lu(t,a|n),t;if(r&&(a|=128,r!==t[0]))throw Error("mid");e:{a|=64;var o=(r=t).length;if(o){var l=o-1;const c=r[l];if(c!=null&&typeof c=="object"&&c.constructor===Object){if((l-=s=128&a?0:-1)>=1024)throw Error("pvtlmt");for(var i in c)(o=+i)1024)throw Error("spvt");a=-16760833&a|(1023&i)<<14}}}return Lu(t,64|a|n),t}function P2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[Ea];return t.length===0&&1&r?void 0:F7e(t,r,s)}if(t!=null&&t[LA]===DA)return z7e(t);if(t instanceof B1){if(2&(s=t.J))return t;if(!t.size)return;if(r=AR(t.V()),t.K)for(t=0;t=o)if(l=t[o],l!=null&&typeof l=="object"&&l.constructor===Object)r=l[s],i=!0;else{if(a!==o)return;r=l}else r=t[a];if(n&&r!=null){if((n=n(r))==null)return n;if(!Object.is(n,r))return i?l[s]=n:t[a]=n,n}return r}}function Ml(t,s,r,n){qE(t),Pu(t=t.v,0|t[Ea],s,r,n)}function Pu(t,s,r,n,a){const o=r+(a?0:-1);var l=t.length-1;if(l>=1+(a?0:-1)&&o>=l){const i=t[l];if(i!=null&&typeof i=="object"&&i.constructor===Object)return i[r]=n,s}return o<=l?(t[o]=n,s):(n!==void 0&&(r>=(l=(s??(s=0|t[Ea]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function O4(){return o2s===void 0?2:4}function R4(t,s,r,n,a){let o=t.v,l=0|o[Ea];n=Af(t,l)?1:n,a=!!a||n===3,n===2&&$E(t)&&(o=t.v,l=0|o[Ea]);let i=(t=OSe(o,s))===D3?7:0|t[Ea],c=RSe(i,l);var u=!(4&c);if(u){4&c&&(t=ay(t),i=0,c=DS(c,l),l=Pu(o,l,s,t));let p=0,f=0;for(;p{const i=PSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!Af(n)&&O3(t,s),n}function Yo(t,s,r,n){let a=t.v,o=0|a[Ea];if((s=Zit(a,o,s,r,n))==null)return s;if(o=0|a[Ea],!Af(t,o)){const l=LSe(s);l!==s&&($E(t)&&(a=t.v,o=0|a[Ea]),o=Pu(a,o,r,s=l,n),O3(a,o))}return s}function Yit(t,s,r,n,a,o,l,i){var c=Af(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&$E(t)&&(r=0|(s=t.v)[Ea]);var u=(t=OSe(s,a))===D3?7:0|t[Ea],p=RSe(u,r);if(i=!(4&p)){var f=t,g=r;const v=!!(2&p);v&&(g|=2);let _=!v,w=!0,j=0,k=0;for(;j32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function VSe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function lde(t){var s=t.h;const r=t.g;var n=s[r],a=s[r+1];const o=s[r+2];return s=s[r+3],OS(t,t.g+4),t=2*((a=(n<<0|a<<8|o<<16|s<<24)>>>0)>>31)+1,n=a>>>23&255,a&=8388607,n==255?a?NaN:t*(1/0):n==0?1401298464324817e-60*t*a:t*Math.pow(2,n-150)*(a+8388608)}function I2s(t){return Nw(t)}function OS(t,s){if(t.g=s,s>t.l)throw Error()}function Xit(t,s){if(s<0)throw Error();const r=t.g;if((s=r+s)>t.l)throw Error();return t.g=s,r}function Jit(t,s){if(s==0)return p3();var r=Xit(t,s);return t.Y&&t.j?r=t.h.subarray(r,r+s):(t=t.h,r=r===(s=r+s)?new Uint8Array(0):p2s?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?p3():new A0(r,PA)}var B7e=[];function eot(t,s,r,n){if(cde.length){const a=cde.pop();return a.o(n),a.g.init(t,s,r,n),a}return new L2s(t,s,r,n)}function tot(t){t.g.clear(),t.l=-1,t.h=-1,cde.length<100&&cde.push(t)}function sot(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=z0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Hie(t){switch(t.h){case 0:t.h!=0?Hie(t):VSe(t.g);break;case 1:OS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Hie(t);else{var s=z0(t.g);OS(t=t.g,t.g+s)}break;case 5:OS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!sot(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Hie(t)}break;default:throw Error()}}function LR(t,s,r){const n=t.g.l;var a=z0(t.g);let o=(a=t.g.g+a)-n;if(o<=0&&(t.g.l=a,r(s,t,void 0,void 0,void 0),o=a-t.g.g),o)throw Error();return t.g.g=a,t.g.l=n,s}function HSe(t){var s=z0(t.g),r=Xit(t=t.g,s);if(t=t.h,Wws){var n,a=t;(n=Aye)||(n=Aye=new TextDecoder("utf-8",{fatal:!0})),s=r+s,a=r===0&&s===a.length?a:a.subarray(r,s);try{var o=n.decode(a)}catch(i){if(c9===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),c9=!0}catch{c9=!1}}throw!c9&&(Aye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?Z2():(i=t[o++],l<194||(192&i)!=128?(o--,Z2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?Z2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,Z2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?Z2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,Z2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):Z2(),r.length>=8192&&(c=j7e(c,r),r.length=0)}o=j7e(c,r)}return o}function rot(t){const s=z0(t.g);return Jit(t.g,s)}function pme(t,s,r){var n=z0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let D2s;function q7e(t){return t?/^-?\d+$/.test(t)?(cme(t),new owe(Xc,Xd)):null:O2s||(O2s=new owe(0,0))}var owe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let O2s;function gT(t,s,r){for(;r>0||s>127;)t.g.push(127&s|128),s=(s>>>7|r<<25)>>>0,r>>>=7;t.g.push(s)}function VE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function fme(t,s){if(s>=0)VE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function GSe(t){var s=Xc;t.g.push(s>>>0&255),t.g.push(s>>>8&255),t.g.push(s>>>16&255),t.g.push(s>>>24&255)}function FA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Yx(t,s,r){VE(t.g,8*s+r)}function WSe(t,s){return Yx(t,s,2),s=t.g.end(),FA(t,s),s.push(t.h),s}function KSe(t,s){var r=s.pop();for(r=t.h+t.g.length()-r;r>127;)s.push(127&r|128),r>>>=7,t.h++;s.push(r),t.h++}function xme(t,s,r){Yx(t,s,2),VE(t.g,r.length),FA(t,t.g.end()),FA(t,r)}function dde(t,s,r,n){r!=null&&(s=WSe(t,s),n(r,t),KSe(t,s))}function Z0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var ZSe=Z0(),not=Z0(),YSe=Z0(),QSe=Z0(),XSe=Z0(),aot=Z0(),R2s=Z0(),gme=Z0(),iot=Z0(),oot=Z0();function Y0(t,s,r){var n=t.v;Sf&&Sf in n&&(n=n[Sf])&&delete n[s.g],s.h?s.j(t,s.h,s.g,r,s.l):s.j(t,s.g,r,s.l)}var Pa=class{constructor(t,s){this.v=Uit(t,s,void 0,2048)}toJSON(){return qit(this)}j(){var a;var t=yjs,s=this.v,r=t.g,n=Sf;if(RE&&n&&((a=s[n])==null?void 0:a[r])!=null&&IA(n2s,3),s=t.g,T7e&&Sf&&T7e===void 0&&(n=(r=this.v)[Sf])&&(n=n.da))try{n(r,s,C2s)}catch(o){wit(o)}return t.h?t.m(this,t.h,t.g,t.l):t.m(this,t.g,t.defaultValue,t.l)}clone(){const t=this.v,s=0|t[Ea];return DSe(this,t,s)?ISe(this,t,!0):new this.constructor(BE(t,s,!1))}};Pa.prototype[LA]=DA,Pa.prototype.toString=function(){return this.v.toString()};var HE=class{constructor(t,s,r){this.g=t,this.h=s,t=ZSe,this.l=!!t&&r===t||!1}};function yme(t,s){return new HE(t,s,ZSe)}function lot(t,s,r,n,a){dde(t,r,hot(s,n),a)}const F2s=yme(function(t,s,r,n,a){return t.h===2&&(LR(t,BSe(s,n,r),a),!0)},lot),z2s=yme(function(t,s,r,n,a){return t.h===2&&(LR(t,BSe(s,n,r),a),!0)},lot);var vme=Symbol(),bme=Symbol(),lwe=Symbol(),U7e=Symbol(),V7e=Symbol();let cot,dot;function R3(t,s,r,n){var a=n[t];if(a)return a;(a={}).qa=n,a.T=function(f){switch(typeof f){case"boolean":return A2s||(A2s=[0,void 0,!0]);case"number":return f>0?void 0:f===0?E2s||(E2s=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(n[0]);var o=n[1];let l=1;o&&o.constructor===Object&&(a.ba=o,typeof(o=n[++l])=="function"&&(a.ma=!0,cot??(cot=o),dot??(dot=n[l+1]),o=n[l+=2]));const i={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;ca(o,l,i,n):a}function e3e(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,p)=>o(c,u,p,i||(i=R3(bme,JSe,e3e,n).T),l||(l=t3e(n)),a)}function t3e(t){let s=t[lwe];if(s!=null)return s;const r=R3(bme,JSe,e3e,t);return s=r.ma?(n,a)=>cot(n,a,r):(n,a)=>{for(;sot(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=$2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Hie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=Jit(i.g,c);l=void 0,i=n,c&&((l=i[Sf]??(i[Sf]=new awe))[o]??(l[o]=[])).push(c)}}return(n=ume(n))&&(n.da=r.qa[V7e]),!0},t[lwe]=s,t[V7e]=B2s.bind(t),s}function B2s(t,s,r,n){var a=this[bme];const o=this[lwe],l=IS(void 0,a.T),i=ume(t);if(i){var c=!1,u=a.ba;if(u){if(a=(p,f,g)=>{if(g.length!==0)if(u[f])for(const v of g){p=eot(v);try{c=!0,o(l,p)}finally{tot(p)}}else n==null||n(t,f,g)},s==null)ide(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(c){let p=0|t[Ea];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=FE(p),g=(v,_)=>{if($1(t,v,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}_!=null&&(p=Pu(t,p,v,_,f)),delete i[v]};s==null?Eit(l,0|l[Ea],(v,_)=>{g(v,_)}):g(s,$1(l,s,f))}}}}function $2s(t){const s=(t=uot(t))[0].g;if(t=t[1]){const r=t3e(t),n=R3(bme,JSe,e3e,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function _me(t,s,r){t[s]=r.h}function wme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=R3(vme,_me,wme,n).T),a||(a=mot(n)))}function mot(t){let s=t[U7e];if(!s){const r=R3(vme,_me,wme,t);s=(n,a)=>pot(n,a,r),t[U7e]=s}return s}function pot(t,s,r){Eit(t,0|t[Ea],(n,a)=>{if(a!=null){var o=function(l,i){var c=l[i];if(c)return c;if((c=l.ba)&&(c=c[i])){var u=(c=uot(c))[0].h;if(c=c[1]){const p=mot(c),f=R3(vme,_me,wme,c).T;c=l.ma?dot(f,p):(g,v,_)=>u(g,v,_,f,p)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||IA(rwe,3)}}),(t=ume(t))&&ide(t,(n,a,o)=>{for(FA(s,s.g.end()),n=0;n{dde(t,r,IS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),gT(t.g,r.h,r.g);break;default:r=q7e(s),gT(t.g,r.h,r.g)}}function got(t,s,r){(s=zE(s))!=null&&s!=null&&(Yx(t,r,0),fme(t.g,s))}function yot(t,s,r){(s=Dit(s))!=null&&(Yx(t,r,0),t.g.g.push(s?1:0))}function vot(t,s,r){(s=Ih(s))!=null&&xme(t,r,_it(s))}function bot(t,s,r,n,a){dde(t,r,hot(s,n),a)}function _ot(t,s,r){(s=s==null||typeof s=="string"||s instanceof A0?s:void 0)!=null&&xme(t,r,qSe(s,!0).buffer)}function wot(t,s,r){(s=Oit(s))!=null&&s!=null&&(Yx(t,r,0),VE(t.g,s))}function jot(t,s,r){return(t.h===5||t.h===2)&&(s=UE(s,0|s[Ea],r),t.h==2?pme(t,lde,s):s.push(lde(t.g)),!0)}var tu=nm(function(t,s,r){return t.h===5&&(am(s,r,lde(t.g)),!0)},fot,gme),V2s=WE(jot,function(t,s,r){if((s=GE(h0,s))!=null)for(let l=0;l=0?n=String(a):((a=n.indexOf("."))!==-1&&(n=n.substring(0,a)),(a=n[0]!=="-"&&((a=n.length)<20||a===20&&n<="18446744073709551615"))||(cme(n),n=gO(Xc,Xd))),n;if(a==="number")return(n=RA(n))>=0&&x3(n)||(OA(n),n=Iit(Xc,Xd)),n}}(s),s!=null&&(typeof s=="string"&&$7e(s),s!=null))switch(Yx(t,r,0),typeof s){case"number":t=t.g,OA(s),gT(t,Xc,Xd);break;case"bigint":r=BigInt.asUintN(64,s),r=new iwe(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),gT(t.g,r.h,r.g);break;default:r=$7e(s),gT(t.g,r.h,r.g)}},R2s),ku=nm(function(t,s,r){return t.h===0&&(am(s,r,Nw(t.g)),!0)},got,QSe),DR=WE(function(t,s,r){return(t.h===0||t.h===2)&&(s=UE(s,0|s[Ea],r),t.h==2?pme(t,Nw,s):s.push(Nw(t.g)),!0)},function(t,s,r){if((s=GE(zE,s))!=null&&s.length){r=WSe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=eot(r,void 0,void 0,o);try{const l=new t,i=l.v;t3e(s)(i,r);var a=l}finally{tot(r)}}return a}}function jme(t){return function(){const s=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const l=this.g;return this.g=[],l}}}};pot(this.v,s,R3(vme,_me,wme,t)),FA(s,s.g.end());const r=new Uint8Array(s.h),n=s.l,a=n.length;let o=0;for(let l=0;la;r=W7e.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=Dye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function d9(t,...s){if(s.length===0)return K7e(t[0]);let r=t[0];for(let n=0;n({index:Nx(n,1)??0??-1,score:Pd(n,2)??0,categoryName:Ih(td(n,3))??""??"",displayName:Ih(td(n,4))??""??""})),headIndex:s,headName:r}}function wjs(t){const s={classifications:q1(t,rjs,1).map(r=>{var n;return d3e(((n=Yo(r,Pot,4))==null?void 0:n.g())??[],Nx(r,2)??0,Ih(td(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(nwe(r)?r=Number(r):(r=ER(64,r),r=nwe(r)?Number(r):String(r)),r):PR(r)?typeof r=="number"?ESe(r):Fit(r):void 0}(td(t,2,void 0,void 0,ade))!=null&&(s.timestampMs=alt(td(t,2,void 0,void 0,ade)??Vit)),s}function ilt(t){var l,i;var s=R4(t,3,h0,O4()),r=R4(t,2,zE,O4()),n=R4(t,1,Ih,O4()),a=R4(t,9,Ih,O4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function ize(t,s){if(t.length!==s.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${s.length}).`);let r=0,n=0,a=0;for(let o=0;o=1&&Number(t[1])>=17))}async function oze(t){if(typeof importScripts!="function"){const s=document.createElement("script");return s.src=t.toString(),s.crossOrigin="anonymous",new Promise((r,n)=>{s.addEventListener("load",()=>{r()},!1),s.addEventListener("error",a=>{n(a)},!1),document.body.appendChild(s)})}try{importScripts(t.toString())}catch(s){if(!(s instanceof TypeError))throw s;await self.import(t.toString())}}function clt(t){return t.videoWidth!==void 0?[t.videoWidth,t.videoHeight]:t.naturalWidth!==void 0?[t.naturalWidth,t.naturalHeight]:t.displayWidth!==void 0?[t.displayWidth,t.displayHeight]:[t.width,t.height]}function Fa(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(s=t.i.stringToNewUTF8(s)),t.i._free(s)}function lze(t,s,r){if(!t.i.canvas)throw Error("No OpenGL canvas configured.");if(r?t.i._bindTextureToStream(r):t.i._bindTextureToCanvas(),!(r=t.i.canvas.getContext("webgl2")||t.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,s),t.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[n,a]=clt(s);return!t.l||n===t.i.canvas.width&&a===t.i.canvas.height||(t.i.canvas.width=n,t.i.canvas.height=a),[n,a]}function cze(t,s,r){t.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const n=new Uint32Array(s.length);for(let a=0;a>2),r(s);for(const a of n)t.i._free(a);t.i._free(s)}function Uy(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function Vb(t,s,r){let n=[];t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=(a,o,l)=>{o?(r(n,l),n=[]):n.push(a)}}eM.forVisionTasks=function(t,s=!1){return h9("vision",t??d9``,s)},eM.forTextTasks=function(t,s=!1){return h9("text",t??d9``,s)},eM.forGenAiTasks=function(t,s=!1){return h9("genai",t??d9``,s)},eM.forAudioTasks=function(t,s=!1){return h9("audio",t??d9``,s)},eM.isSimdSupported=function(t=!1){return olt(t)};async function Njs(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await oze(o),!self.ModuleFactory||l&&(await oze(l),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((o=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new a(c,i)})(t,r.wasmLoaderPath,r.assetLoaderPath,s,{locateFile:a=>a.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&a.endsWith(".data")?r.assetBinaryPath.toString():a}),await t.o(n),t}function Fye(t,s){const r=Yo(t.baseOptions,ude,1)||new ude;typeof s=="string"?(Ml(r,2,IR(s)),Ml(r,1)):s instanceof Uint8Array&&(Ml(r,1,CSe(s,!1)),Ml(r,2)),ci(t.baseOptions,0,1,r)}function dze(t){try{const s=t.H.length;if(s===1)throw Error(t.H[0].message);if(s>1)throw Error("Encountered multiple errors: "+t.H.map(r=>r.message).join(", "))}finally{t.H=[]}}function da(t,s){t.C=Math.max(t.C,s)}function Cme(t,s){t.B=new Lp,Ef(t.B,2,"PassThroughCalculator"),Hc(t.B,"free_memory"),Do(t.B,"free_memory_unused_out"),ad(s,"free_memory"),Qx(s,t.B)}function zA(t,s){Hc(t.B,s),Do(t.B,s+"_unused_out")}function Mme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var mwe=class{constructor(t){this.g=t,this.H=[],this.C=0,this.g.setAutoRenderToScreen(!1)}l(t,s=!0){var r,n,a,o,l,i;if(s){const c=t.baseOptions||{};if((r=t.baseOptions)!=null&&r.modelAssetBuffer&&((n=t.baseOptions)!=null&&n.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((a=Yo(this.baseOptions,ude,1))!=null&&a.g()||(o=Yo(this.baseOptions,ude,1))!=null&&o.l()||(l=t.baseOptions)!=null&&l.modelAssetBuffer||(i=t.baseOptions)!=null&&i.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,p){let f=Yo(u.baseOptions,tze,3);if(!f){var g=f=new tze,v=new Z7e;I8(g,4,Gie,v)}"delegate"in p&&(p.delegate==="GPU"?(p=f,g=new Y2s,I8(p,2,Gie,g)):(p=f,g=new Z7e,I8(p,4,Gie,g))),ci(u.baseOptions,0,3,f)}(this,c),c.modelAssetPath)return fetch(c.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${c.modelAssetPath} (${u.status})`)}).then(u=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(u),!0,!1,!1),Fye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)Fye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:g,value:v}=await u.read();if(g)break;p.push(v),f+=v.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(f),f=0;for(const g of p)u.set(g,f),f+=g.length;return u}(c.modelAssetBuffer).then(u=>{Fye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=Q2s(s)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,s){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.Ja(),this.g.setGraph(t,s),this.B=void 0,dze(this)}finishProcessing(){this.g.finishProcessing(),dze(this)}close(){this.B=void 0,this.g.closeGraph()}};function cw(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}mwe.prototype.close=mwe.prototype.close;class kjs{constructor(s,r,n,a){this.g=s,this.h=r,this.m=n,this.l=a}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function uze(t,s,r){const n=t.g;if(r=cw(n.createShader(r),"Failed to create WebGL shader"),n.shaderSource(r,s),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${n.getShaderInfoLog(r)}`);return n.attachShader(t.h,r),r}function hze(t,s){const r=t.g,n=cw(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=cw(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,a),r.enableVertexAttribArray(t.O),r.vertexAttribPointer(t.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const o=cw(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(t.L),r.vertexAttribPointer(t.L,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(s?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new kjs(r,n,a,o)}function u3e(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function Sjs(t,s,r,n){return u3e(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=hze(t,!0)),r=t.u):(t.A||(t.A=hze(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function dlt(t,s,r){return u3e(t,s),t=cw(s.createTexture(),"Failed to create texture"),s.bindTexture(s.TEXTURE_2D,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,r??s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,r??s.LINEAR),s.bindTexture(s.TEXTURE_2D,null),t}function ult(t,s,r){u3e(t,s),t.B||(t.B=cw(s.createFramebuffer(),"Failed to create framebuffe.")),s.bindFramebuffer(s.FRAMEBUFFER,t.B),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0)}function Cjs(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var hlt=class{H(){return` precision mediump float; varying vec2 vTex; uniform sampler2D inputTexture; void main() { gl_FragColor = texture2D(inputTexture, vTex); } `}m(){const t=this.g;if(this.h=cw(t.createProgram(),"Failed to create WebGL program"),this.X=uze(this,` attribute vec2 aVertex; attribute vec2 aTex; varying vec2 vTex; void main(void) { gl_Position = vec4(aVertex, 0.0, 1.0); vTex = aTex; }`,t.VERTEX_SHADER),this.W=uze(this,this.H(),t.FRAGMENT_SHADER),t.linkProgram(this.h),!t.getProgramParameter(this.h,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(this.h)}`);this.O=t.getAttribLocation(this.h,"aVertex"),this.L=t.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const t=this.g;t.deleteProgram(this.h),t.deleteShader(this.X),t.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function Zv(t,s){switch(s){case 0:return t.g.find(r=>r instanceof Uint8Array);case 1:return t.g.find(r=>r instanceof Float32Array);case 2:return t.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${s}`)}}function pwe(t){var s=Zv(t,1);if(!s){if(s=Zv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=BA(t);var r=h3e(t);if(ult(r,n,mlt(t)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(t.width*t.height*4),n.readPixels(0,0,t.width,t.height,n.RGBA,n.FLOAT,r);for(let a=0,o=0;aMath.round(255*r))),t.g.push(s)),s;var t,s}ia(){return pwe(this)}N(){return mlt(this)}clone(){const t=[];for(const s of this.g){let r;if(s instanceof Uint8Array)r=new Uint8Array(s);else if(s instanceof Float32Array)r=new Float32Array(s);else{if(!(s instanceof WebGLTexture))throw Error(`Type is not supported: ${s}`);{const n=BA(this),a=h3e(this);n.activeTexture(n.TEXTURE1),r=dlt(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=plt(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),ult(a,n,r),Sjs(a,n,!1,()=>{flt(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),fwe(this)}),Cjs(a),fwe(this)}}t.push(r)}return new Hu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&BA(this).deleteTexture(Zv(this,2)),mze=-1}};Hu.prototype.close=Hu.prototype.close,Hu.prototype.clone=Hu.prototype.clone,Hu.prototype.getAsWebGLTexture=Hu.prototype.N,Hu.prototype.getAsFloat32Array=Hu.prototype.ia,Hu.prototype.getAsUint8Array=Hu.prototype.ja,Hu.prototype.hasWebGLTexture=Hu.prototype.R,Hu.prototype.hasFloat32Array=Hu.prototype.ka,Hu.prototype.hasUint8Array=Hu.prototype.Fa;var mze=250;function gy(...t){return t.map(([s,r])=>({start:s,end:r}))}const Mjs=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((pze=class{constructor(t,s){this.l=!0,this.i=t,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",s!==void 0?this.i.canvas=s:llt()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(t){const s=await(await fetch(t)).arrayBuffer();t=!(t.endsWith(".pbtxt")||t.endsWith(".textproto")),this.setGraph(new Uint8Array(s),t)}setGraphFromString(t){this.setGraph(new TextEncoder().encode(t),!1)}setGraph(t,s){const r=t.length,n=this.i._malloc(r);this.i.HEAPU8.set(t,n),s?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(t,s,r,n,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Fa(this,n||"input_audio",o=>{Fa(this,a=a||"audio_header",l=>{this.i._configureAudio(o,l,t,s??0,r)})})}setAutoResizeCanvas(t){this.l=t}setAutoRenderToScreen(t){this.i._setAutoRenderToScreen(t)}setGpuBufferVerticalFlip(t){this.i.gpuOriginForWebTexturesIsBottomLeft=t}ca(t){Uy(this,"__graph_config__",s=>{t(s)}),Fa(this,"__graph_config__",s=>{this.i._getGraphConfig(s,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(t){this.i.errorListener=t}attachEmptyPacketListener(t,s){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[t]=s}addAudioToStream(t,s,r){this.addAudioToStreamWithShape(t,0,0,s,r)}addAudioToStreamWithShape(t,s,r,n,a){const o=4*t.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(t,this.g/4),Fa(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){Fa(this,s,n=>{const[a,o]=lze(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){Fa(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){Fa(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){Fa(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){Fa(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){Fa(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){Fa(this,s,n=>{Fa(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){Fa(this,s,n=>{cze(this,Object.keys(t),a=>{cze(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){Fa(this,r,a=>{Fa(this,s,o=>{const l=this.i._malloc(t.length);this.i.HEAPU8.set(t,l),this.i._addProtoToInputStream(l,t.length,o,a,n),this.i._free(l)})})}addEmptyPacketToStream(t,s){Fa(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateBoolVector(t.length);if(!a)throw Error("Unable to allocate new bool vector on heap.");for(const o of t)this.i._addBoolVectorEntry(a,o);this.i._addBoolVectorToInputStream(a,n,r)})}addDoubleVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateDoubleVector(t.length);if(!a)throw Error("Unable to allocate new double vector on heap.");for(const o of t)this.i._addDoubleVectorEntry(a,o);this.i._addDoubleVectorToInputStream(a,n,r)})}addFloatVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateFloatVector(t.length);if(!a)throw Error("Unable to allocate new float vector on heap.");for(const o of t)this.i._addFloatVectorEntry(a,o);this.i._addFloatVectorToInputStream(a,n,r)})}addIntVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateIntVector(t.length);if(!a)throw Error("Unable to allocate new int vector on heap.");for(const o of t)this.i._addIntVectorEntry(a,o);this.i._addIntVectorToInputStream(a,n,r)})}addUintVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateUintVector(t.length);if(!a)throw Error("Unable to allocate new unsigned int vector on heap.");for(const o of t)this.i._addUintVectorEntry(a,o);this.i._addUintVectorToInputStream(a,n,r)})}addStringVectorToStream(t,s,r){Fa(this,s,n=>{const a=this.i._allocateStringVector(t.length);if(!a)throw Error("Unable to allocate new string vector on heap.");for(const o of t)Fa(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){Fa(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){Fa(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){Fa(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){Fa(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){Fa(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){Fa(this,s,r=>{Fa(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){Fa(this,r,n=>{Fa(this,s,a=>{const o=this.i._malloc(t.length);this.i.HEAPU8.set(t,o),this.i._addProtoToInputSidePacket(o,t.length,a,n),this.i._free(o)})})}addBoolVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const a of t)this.i._addBoolVectorEntry(n,a);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const a of t)this.i._addDoubleVectorEntry(n,a);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const a of t)this.i._addFloatVectorEntry(n,a);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const a of t)this.i._addIntVectorEntry(n,a);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const a of t)this.i._addUintVectorEntry(n,a);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(t,s){Fa(this,s,r=>{const n=this.i._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const a of t)Fa(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){Uy(this,t,s),Fa(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){Vb(this,t,s),Fa(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){Uy(this,t,s),Fa(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){Vb(this,t,s),Fa(this,t,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(t,s,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),Uy(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),Fa(this,t,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends pze{get ga(){return this.i}pa(t,s,r){Fa(this,s,n=>{const[a,o]=lze(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){Uy(this,t,s),Fa(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){Vb(this,t,s),Fa(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var pze,yy=class extends Mjs{};async function Uo(t,s,r){return async function(n,a,o,l){return Njs(n,a,o,l)}(t,r.canvas??(llt()?void 0:document.createElement("canvas")),s,r)}function xlt(t,s,r,n){if(t.U){const o=new Rot;if(r!=null&&r.regionOfInterest){if(!t.oa)throw Error("This task doesn't support region-of-interest.");var a=r.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(a.left<0||a.top<0||a.right>1||a.bottom>1)throw Error("Expected RectF values to be in [0,1].");Wa(o,1,(a.left+a.right)/2),Wa(o,2,(a.top+a.bottom)/2),Wa(o,4,a.right-a.left),Wa(o,3,a.bottom-a.top)}else Wa(o,1,.5),Wa(o,2,.5),Wa(o,4,1),Wa(o,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(Wa(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=clt(s);r=Pd(o,3)*i/l,a=Pd(o,4)*l/i,Wa(o,4,r),Wa(o,3,a)}}t.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",t.U,n)}t.g.pa(s,t.X,n??performance.now()),t.finishProcessing()}function vy(t,s,r){var n;if((n=t.baseOptions)!=null&&n.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");xlt(t,s,r,t.C+1)}function X0(t,s,r,n){var a;if(!((a=t.baseOptions)!=null&&a.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");xlt(t,s,r,n)}function $A(t,s,r,n){var a=s.data;const o=s.width,l=o*(s=s.height);if((a instanceof Uint8Array||a instanceof Float32Array)&&a.length!==l)throw Error("Unsupported channel count: "+a.length/l);return t=new Hu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var Pf=class extends mwe{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new hlt}l(t,s=!0){if("runningMode"in t&&Ml(this.baseOptions,2,yO(!!t.runningMode&&t.runningMode!=="IMAGE")),t.canvas!==void 0&&this.g.i.canvas!==t.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(t,s)}close(){this.P.close(),super.close()}};Pf.prototype.close=Pf.prototype.close;var sx=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},ci(t=this.h=new kme,0,1,s=new kd),Wa(this.h,2,.5),Wa(this.h,3,.3)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Wa(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Wa(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},vy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},X0(this,t,r,s),this.j}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect_in"),nl(t,"detections");const s=new Df;Y0(s,cjs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect_in"),Do(r,"DETECTIONS:detections"),r.o(s),Qx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Lot(o),this.j.detections.push(ilt(n));da(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};sx.prototype.detectForVideo=sx.prototype.G,sx.prototype.detect=sx.prototype.F,sx.prototype.setOptions=sx.prototype.o,sx.createFromModelPath=async function(t,s){return Uo(sx,t,{baseOptions:{modelAssetPath:s}})},sx.createFromModelBuffer=function(t,s){return Uo(sx,t,{baseOptions:{modelAssetBuffer:s}})},sx.createFromOptions=function(t,s){return Uo(sx,t,s)};var m3e=gy([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),p3e=gy([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),f3e=gy([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),glt=gy([474,475],[475,476],[476,477],[477,474]),x3e=gy([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),g3e=gy([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),ylt=gy([469,470],[470,471],[471,472],[472,469]),y3e=gy([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),vlt=[...m3e,...p3e,...f3e,...x3e,...g3e,...y3e],blt=gy([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function fze(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var dd=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,ci(t=this.h=new qot,0,1,s=new kd),this.A=new $ot,ci(this.h,0,3,this.A),this.u=new kme,ci(this.h,0,2,this.u),U1(this.u,4,1),Wa(this.u,2,.5),Wa(this.A,2,.5),Wa(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return"numFaces"in t&&U1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Wa(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Wa(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Wa(this.A,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in t&&(this.outputFacialTransformationMatrixes=!!t.outputFacialTransformationMatrixes),this.l(t)}F(t,s){return fze(this),vy(this,t,s),this.j}G(t,s,r){return fze(this),X0(this,t,r,s),this.j}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect"),nl(t,"face_landmarks");const s=new Df;Y0(s,ujs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Qx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=OR(o),this.j.faceLandmarks.push(Sme(n));da(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{da(this,n)}),this.outputFaceBlendshapes&&(nl(t,"blendshapes"),Do(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=Nme(o),this.j.faceBlendshapes.push(d3e(n.g()??[]));da(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{da(this,n)})),this.outputFacialTransformationMatrixes&&(nl(t,"face_geometry"),Do(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Yo(n=djs(o),tjs,2))&&this.j.facialTransformationMatrixes.push({rows:Nx(n,1)??0??0,columns:Nx(n,2)??0??0,data:R4(n,3,h0,O4()).slice()??[]});da(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{da(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};dd.prototype.detectForVideo=dd.prototype.G,dd.prototype.detect=dd.prototype.F,dd.prototype.setOptions=dd.prototype.o,dd.createFromModelPath=function(t,s){return Uo(dd,t,{baseOptions:{modelAssetPath:s}})},dd.createFromModelBuffer=function(t,s){return Uo(dd,t,{baseOptions:{modelAssetBuffer:s}})},dd.createFromOptions=function(t,s){return Uo(dd,t,s)},dd.FACE_LANDMARKS_LIPS=m3e,dd.FACE_LANDMARKS_LEFT_EYE=p3e,dd.FACE_LANDMARKS_LEFT_EYEBROW=f3e,dd.FACE_LANDMARKS_LEFT_IRIS=glt,dd.FACE_LANDMARKS_RIGHT_EYE=x3e,dd.FACE_LANDMARKS_RIGHT_EYEBROW=g3e,dd.FACE_LANDMARKS_RIGHT_IRIS=ylt,dd.FACE_LANDMARKS_FACE_OVAL=y3e,dd.FACE_LANDMARKS_CONTOURS=vlt,dd.FACE_LANDMARKS_TESSELATION=blt;var v3e=gy([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function xze(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function gze(t){return t.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:t.gestures,landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handedness:t.handedness,handednesses:t.handedness}}function yze(t,s=!0){const r=[];for(const a of t){var n=Nme(a);t=[];for(const o of n.g())n=s&&Nx(o,1)!=null?Nx(o,1)??0:-1,t.push({score:Pd(o,2)??0,index:n,categoryName:Ih(td(o,3))??""??"",displayName:Ih(td(o,4))??""??""});r.push(t)}return r}var Gp=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ci(t=this.j=new Hot,0,1,s=new kd),this.u=new i3e,ci(this.j,0,2,this.u),this.D=new a3e,ci(this.u,0,3,this.D),this.A=new Vot,ci(this.u,0,2,this.A),this.h=new hjs,ci(this.j,0,3,this.h),Wa(this.A,2,.5),Wa(this.u,4,.5),Wa(this.D,2,.5)}get baseOptions(){return Yo(this.j,kd,1)}set baseOptions(t){ci(this.j,0,1,t)}o(t){var a,o,l,i;if(U1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Wa(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Wa(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Wa(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new q5,r=s,n=hwe(t.cannedGesturesClassifierOptions,(a=Yo(this.h,q5,3))==null?void 0:a.l());ci(r,0,2,n),ci(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Yo(this.h,q5,3))==null||o.g());return t.customGesturesClassifierOptions?(ci(r=s=new q5,0,2,n=hwe(t.customGesturesClassifierOptions,(l=Yo(this.h,q5,4))==null?void 0:l.l())),ci(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Yo(this.h,q5,4))==null||i.g()),this.l(t)}Ha(t,s){return xze(this),vy(this,t,s),gze(this)}Ia(t,s,r){return xze(this),X0(this,t,r,s),gze(this)}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect"),nl(t,"hand_gestures"),nl(t,"hand_landmarks"),nl(t,"world_hand_landmarks"),nl(t,"handedness");const s=new Df;Y0(s,mjs,this.j);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"HAND_GESTURES:hand_gestures"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Qx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=OR(o);const l=[];for(const i of q1(n,Oot,1))l.push({x:Pd(i,1)??0,y:Pd(i,2)??0,z:Pd(i,3)??0,visibility:Pd(i,4)??0});this.landmarks.push(l)}da(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{da(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=yT(o);const l=[];for(const i of q1(n,Dot,1))l.push({x:Pd(i,1)??0,y:Pd(i,2)??0,z:Pd(i,3)??0,visibility:Pd(i,4)??0});this.worldLandmarks.push(l)}da(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{da(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...yze(n,!1)),da(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{da(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...yze(n)),da(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function vze(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Gp.prototype.recognizeForVideo=Gp.prototype.Ia,Gp.prototype.recognize=Gp.prototype.Ha,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetPath:s}})},Gp.createFromModelBuffer=function(t,s){return Uo(Gp,t,{baseOptions:{modelAssetBuffer:s}})},Gp.createFromOptions=function(t,s){return Uo(Gp,t,s)},Gp.HAND_CONNECTIONS=v3e;var Wp=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ci(t=this.h=new i3e,0,1,s=new kd),this.u=new a3e,ci(this.h,0,3,this.u),this.j=new Vot,ci(this.h,0,2,this.j),U1(this.j,3,1),Wa(this.j,2,.5),Wa(this.u,2,.5),Wa(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return"numHands"in t&&U1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Wa(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Wa(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Wa(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],vy(this,t,s),vze(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],X0(this,t,r,s),vze(this)}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect"),nl(t,"hand_landmarks"),nl(t,"world_hand_landmarks"),nl(t,"handedness");const s=new Df;Y0(s,pjs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"LANDMARKS:hand_landmarks"),Do(r,"WORLD_LANDMARKS:world_hand_landmarks"),Do(r,"HANDEDNESS:handedness"),r.o(s),Qx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=OR(o),this.landmarks.push(Sme(n));da(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{da(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=yT(o),this.worldLandmarks.push(D8(n));da(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{da(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=Nme(c);const u=[];for(const p of n.g())u.push({score:Pd(p,2)??0,index:Nx(p,1)??0??-1,categoryName:Ih(td(p,3))??""??"",displayName:Ih(td(p,4))??""??""});i.push(u)}l.call(o,...i),da(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Wp.prototype.detectForVideo=Wp.prototype.G,Wp.prototype.detect=Wp.prototype.F,Wp.prototype.setOptions=Wp.prototype.o,Wp.createFromModelPath=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetPath:s}})},Wp.createFromModelBuffer=function(t,s){return Uo(Wp,t,{baseOptions:{modelAssetBuffer:s}})},Wp.createFromOptions=function(t,s){return Uo(Wp,t,s)},Wp.HAND_CONNECTIONS=v3e;var _lt=gy([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function bze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function _ze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{Mme(t)}}function p9(t,s){t=OR(t),s.push(Sme(t))}var Ic=class extends Pf{constructor(t,s){super(new yy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,ci(t=this.j=new Yot,0,1,s=new kd),this.I=new a3e,ci(this.j,0,2,this.I),this.W=new fjs,ci(this.j,0,3,this.W),this.u=new kme,ci(this.j,0,4,this.u),this.O=new $ot,ci(this.j,0,5,this.O),this.A=new Kot,ci(this.j,0,6,this.A),this.M=new Zot,ci(this.j,0,7,this.M),Wa(this.u,2,.5),Wa(this.u,3,.3),Wa(this.O,2,.5),Wa(this.A,2,.5),Wa(this.A,3,.3),Wa(this.M,2,.5),Wa(this.I,2,.5)}get baseOptions(){return Yo(this.j,kd,1)}set baseOptions(t){ci(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Wa(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Wa(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Wa(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Wa(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Wa(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Wa(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Wa(this.I,2,t.minHandLandmarksConfidence??.5),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.D=typeof s=="function"?s:r,bze(this),vy(this,t,n),_ze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,bze(this),X0(this,t,a,s),_ze(this)}m(){var t=new Of;ad(t,"input_frames_image"),nl(t,"pose_landmarks"),nl(t,"pose_world_landmarks"),nl(t,"face_landmarks"),nl(t,"left_hand_landmarks"),nl(t,"left_hand_world_landmarks"),nl(t,"right_hand_landmarks"),nl(t,"right_hand_world_landmarks");const s=new Df,r=new H7e;Ef(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))Ml(a,2,hme(o,0,vO));else{if(!(typeof o=="string"||o instanceof A0||kSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");o_(a,2,CSe(o,!1),p3())}}(r,this.j.g());const n=new Lp;Ef(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),$Se(n,8,H7e,r),Hc(n,"IMAGE:input_frames_image"),Do(n,"POSE_LANDMARKS:pose_landmarks"),Do(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Do(n,"FACE_LANDMARKS:face_landmarks"),Do(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Do(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Do(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Do(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Qx(t,n),Cme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{p9(a,this.h.poseLandmarks),da(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{da(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=yT(a),l.push(D8(a)),da(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{da(this,a)}),this.outputPoseSegmentationMasks&&(Do(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),zA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[$A(this,a,!0,!this.D)],da(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],da(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{p9(a,this.h.faceLandmarks),da(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{da(this,a)}),this.outputFaceBlendshapes&&(nl(t,"extra_blendshapes"),Do(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=Nme(a),l.push(d3e(a.g()??[]))),da(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{da(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{p9(a,this.h.leftHandLandmarks),da(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{da(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=yT(a),l.push(D8(a)),da(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{da(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{p9(a,this.h.rightHandLandmarks),da(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{da(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=yT(a),l.push(D8(a)),da(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{da(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Ic.prototype.detectForVideo=Ic.prototype.G,Ic.prototype.detect=Ic.prototype.F,Ic.prototype.setOptions=Ic.prototype.o,Ic.createFromModelPath=function(t,s){return Uo(Ic,t,{baseOptions:{modelAssetPath:s}})},Ic.createFromModelBuffer=function(t,s){return Uo(Ic,t,{baseOptions:{modelAssetBuffer:s}})},Ic.createFromOptions=function(t,s){return Uo(Ic,t,s)},Ic.HAND_CONNECTIONS=v3e,Ic.POSE_CONNECTIONS=_lt,Ic.FACE_LANDMARKS_LIPS=m3e,Ic.FACE_LANDMARKS_LEFT_EYE=p3e,Ic.FACE_LANDMARKS_LEFT_EYEBROW=f3e,Ic.FACE_LANDMARKS_LEFT_IRIS=glt,Ic.FACE_LANDMARKS_RIGHT_EYE=x3e,Ic.FACE_LANDMARKS_RIGHT_EYEBROW=g3e,Ic.FACE_LANDMARKS_RIGHT_IRIS=ylt,Ic.FACE_LANDMARKS_FACE_OVAL=y3e,Ic.FACE_LANDMARKS_CONTOURS=vlt,Ic.FACE_LANDMARKS_TESSELATION=blt;var rx=class extends Pf{constructor(t,s){super(new yy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},ci(t=this.h=new Qot,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return ci(this.h,0,2,hwe(t,Yo(this.h,r3e,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},vy(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},X0(this,t,r,s),this.j}m(){var t=new Of;ad(t,"input_image"),ad(t,"norm_rect"),nl(t,"classifications");const s=new Df;Y0(s,xjs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Hc(r,"IMAGE:input_image"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"CLASSIFICATIONS:classifications"),r.o(s),Qx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=wjs(njs(n)),da(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};rx.prototype.classifyForVideo=rx.prototype.ta,rx.prototype.classify=rx.prototype.sa,rx.prototype.setOptions=rx.prototype.o,rx.createFromModelPath=function(t,s){return Uo(rx,t,{baseOptions:{modelAssetPath:s}})},rx.createFromModelBuffer=function(t,s){return Uo(rx,t,{baseOptions:{modelAssetBuffer:s}})},rx.createFromOptions=function(t,s){return Uo(rx,t,s)};var Kp=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!0),this.h=new Xot,this.embeddings={embeddings:[]},ci(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){var s=this.h,r=Yo(this.h,eze,2);return r=r?r.clone():new eze,t.l2Normalize!==void 0?Ml(r,1,yO(t.l2Normalize)):"l2Normalize"in t&&Ml(r,1),t.quantize!==void 0?Ml(r,2,yO(t.quantize)):"quantize"in t&&Ml(r,2),ci(s,0,2,r),this.l(t)}za(t,s){return vy(this,t,s),this.embeddings}Aa(t,s,r){return X0(this,t,r,s),this.embeddings}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect"),nl(t,"embeddings_out");const s=new Df;Y0(s,gjs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"EMBEDDINGS:embeddings_out"),r.o(s),Qx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=ojs(n),this.embeddings=function(o){return{embeddings:q1(o,ijs,1).map(l=>{var u,p;const i={headIndex:Nx(l,3)??0??-1,headName:Ih(td(l,4))??""??""};var c=l.v;return Zit(c,0|c[Ea],J7e,Iye(l,1))!==void 0?(l=R4(l=Yo(l,J7e,Iye(l,1),void 0),1,h0,O4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((p=(u=Yo(l,ajs,Iye(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??c),i}),timestampMs:alt(td(o,2,void 0,void 0,ade)??Vit)}}(n),da(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=ize(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=ize(aze(t.quantizedEmbedding),aze(s.quantizedEmbedding))}return t},Kp.prototype.embedForVideo=Kp.prototype.Aa,Kp.prototype.embed=Kp.prototype.za,Kp.prototype.setOptions=Kp.prototype.o,Kp.createFromModelPath=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetPath:s}})},Kp.createFromModelBuffer=function(t,s){return Uo(Kp,t,{baseOptions:{modelAssetBuffer:s}})},Kp.createFromOptions=function(t,s){return Uo(Kp,t,s)};var xwe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};function Tjs(t){var r,n;const s=function(a){return q1(a,Lp,1)}(t.ca()).filter(a=>(Ih(td(a,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(t.u=[],s.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");s.length===1&&(((n=(r=Yo(s[0],Df,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=Ih(td(a,1))??""})}function wze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function jze(t){try{const s=new xwe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{Mme(t)}}xwe.prototype.close=xwe.prototype.close;var gm=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new c3e,this.A=new Jot,ci(this.h,0,3,this.A),ci(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Ml(this.h,2,IR(t.displayNamesLocale)):"displayNamesLocale"in t&&Ml(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){Tjs(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,wze(this),vy(this,t,n),jze(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,wze(this),X0(this,t,a,s),jze(this)}Da(){return this.u}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect");const s=new Df;Y0(s,tlt,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),r.o(s),Qx(t,r),Cme(this,t),this.outputConfidenceMasks&&(nl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),zA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>$A(this,o,!0,!this.j)),da(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],da(this,n)})),this.outputCategoryMask&&(nl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),zA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=$A(this,n,!1,!this.j),da(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,da(this,n)})),nl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,da(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};gm.prototype.getLabels=gm.prototype.Da,gm.prototype.segmentForVideo=gm.prototype.La,gm.prototype.segment=gm.prototype.segment,gm.prototype.setOptions=gm.prototype.o,gm.createFromModelPath=function(t,s){return Uo(gm,t,{baseOptions:{modelAssetPath:s}})},gm.createFromModelBuffer=function(t,s){return Uo(gm,t,{baseOptions:{modelAssetBuffer:s}})},gm.createFromOptions=function(t,s){return Uo(gm,t,s)};var gwe=class{constructor(t,s,r){this.confidenceMasks=t,this.categoryMask=s,this.qualityScores=r}close(){var t,s;(t=this.confidenceMasks)==null||t.forEach(r=>{r.close()}),(s=this.categoryMask)==null||s.close()}};gwe.prototype.close=gwe.prototype.close;var Vy=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new c3e,this.u=new Jot,ci(this.h,0,3,this.u),ci(t=this.h,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}segment(t,s,r,n){const a=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,n=new slt,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new Rye;o_(o,3,yO(!0),!1),o_(o,1,UI(s.keypoint.x),0),o_(o,2,UI(s.keypoint.y),0),I8(n,1,uwe,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new vjs;for(o of s.scribble)o_(s=new Rye,3,yO(!0),!1),o_(s,1,UI(o.x),0),o_(s,2,UI(o.y),0),$Se(i,1,Rye,s);I8(n,2,uwe,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),vy(this,t,a);e:{try{const i=new gwe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{Mme(this)}l=void 0}return l}m(){var t=new Of;ad(t,"image_in"),ad(t,"roi_in"),ad(t,"norm_rect_in");const s=new Df;Y0(s,tlt,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Hc(r,"IMAGE:image_in"),Hc(r,"ROI:roi_in"),Hc(r,"NORM_RECT:norm_rect_in"),r.o(s),Qx(t,r),Cme(this,t),this.outputConfidenceMasks&&(nl(t,"confidence_masks"),Do(r,"CONFIDENCE_MASKS:confidence_masks"),zA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>$A(this,o,!0,!this.j)),da(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],da(this,n)})),this.outputCategoryMask&&(nl(t,"category_mask"),Do(r,"CATEGORY_MASK:category_mask"),zA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=$A(this,n,!1,!this.j),da(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,da(this,n)})),nl(t,"quality_scores"),Do(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,da(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Vy.prototype.segment=Vy.prototype.segment,Vy.prototype.setOptions=Vy.prototype.o,Vy.createFromModelPath=function(t,s){return Uo(Vy,t,{baseOptions:{modelAssetPath:s}})},Vy.createFromModelBuffer=function(t,s){return Uo(Vy,t,{baseOptions:{modelAssetBuffer:s}})},Vy.createFromOptions=function(t,s){return Uo(Vy,t,s)};var nx=class extends Pf{constructor(t,s){super(new yy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},ci(t=this.h=new rlt,0,1,s=new kd)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?Ml(this.h,2,IR(t.displayNamesLocale)):"displayNamesLocale"in t&&Ml(this.h,2),t.maxResults!==void 0?U1(this.h,3,t.maxResults):"maxResults"in t&&Ml(this.h,3),t.scoreThreshold!==void 0?Wa(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&Ml(this.h,4),t.categoryAllowlist!==void 0?ode(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&Ml(this.h,5),t.categoryDenylist!==void 0?ode(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&Ml(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},vy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},X0(this,t,r,s),this.j}m(){var t=new Of;ad(t,"input_frame_gpu"),ad(t,"norm_rect"),nl(t,"detections");const s=new Df;Y0(s,bjs,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Hc(r,"IMAGE:input_frame_gpu"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"DETECTIONS:detections"),r.o(s),Qx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Lot(o),this.j.detections.push(ilt(n));da(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{da(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};nx.prototype.detectForVideo=nx.prototype.G,nx.prototype.detect=nx.prototype.F,nx.prototype.setOptions=nx.prototype.o,nx.createFromModelPath=async function(t,s){return Uo(nx,t,{baseOptions:{modelAssetPath:s}})},nx.createFromModelBuffer=function(t,s){return Uo(nx,t,{baseOptions:{modelAssetBuffer:s}})},nx.createFromOptions=function(t,s){return Uo(nx,t,s)};var ywe=class{constructor(t,s,r){this.landmarks=t,this.worldLandmarks=s,this.segmentationMasks=r}close(){var t;(t=this.segmentationMasks)==null||t.forEach(s=>{s.close()})}};function Nze(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function kze(t){try{const s=new ywe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{Mme(t)}}ywe.prototype.close=ywe.prototype.close;var Zp=class extends Pf{constructor(t,s){super(new yy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,ci(t=this.h=new nlt,0,1,s=new kd),this.A=new Zot,ci(this.h,0,3,this.A),this.j=new Kot,ci(this.h,0,2,this.j),U1(this.j,4,1),Wa(this.j,2,.5),Wa(this.A,2,.5),Wa(this.h,4,.5)}get baseOptions(){return Yo(this.h,kd,1)}set baseOptions(t){ci(this.h,0,1,t)}o(t){return"numPoses"in t&&U1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Wa(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Wa(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Wa(this.A,2,t.minPosePresenceConfidence??.5),"outputSegmentationMasks"in t&&(this.outputSegmentationMasks=t.outputSegmentationMasks??!1),this.l(t)}F(t,s,r){const n=typeof s!="function"?s:{};return this.u=typeof s=="function"?s:r,Nze(this),vy(this,t,n),kze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,Nze(this),X0(this,t,a,s),kze(this)}m(){var t=new Of;ad(t,"image_in"),ad(t,"norm_rect"),nl(t,"normalized_landmarks"),nl(t,"world_landmarks"),nl(t,"segmentation_masks");const s=new Df;Y0(s,_js,this.h);const r=new Lp;Ef(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Hc(r,"IMAGE:image_in"),Hc(r,"NORM_RECT:norm_rect"),Do(r,"NORM_LANDMARKS:normalized_landmarks"),Do(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Qx(t,r),Cme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=OR(o),this.landmarks.push(Sme(n));da(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],da(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=yT(o),this.worldLandmarks.push(D8(n));da(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],da(this,n)}),this.outputSegmentationMasks&&(Do(r,"SEGMENTATION_MASK:segmentation_masks"),zA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>$A(this,o,!0,!this.u)),da(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],da(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Zp.prototype.detectForVideo=Zp.prototype.G,Zp.prototype.detect=Zp.prototype.F,Zp.prototype.setOptions=Zp.prototype.o,Zp.createFromModelPath=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetPath:s}})},Zp.createFromModelBuffer=function(t,s){return Uo(Zp,t,{baseOptions:{modelAssetBuffer:s}})},Zp.createFromOptions=function(t,s){return Uo(Zp,t,s)},Zp.POSE_CONNECTIONS=_lt;let F4=null,VI=null;async function Ajs(){return F4||VI||(VI=(async()=>{const t=await eM.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return F4=await gm.createFromOptions(t,{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite",delegate:"GPU"},runningMode:"VIDEO",outputCategoryMask:!1,outputConfidenceMasks:!0}),F4})(),VI)}function Ejs(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[c+p]);const g=Math.min(f,r-1)-Math.max(p+1,0)+1;o[c+u]=i/g}}for(let l=0;l=0&&(i-=o[u*r+l]);const f=Math.min(p,n-1)-Math.max(u+1,0)+1;s[c*r+l]=i/f}}}function Pjs(){F4&&(F4.close(),F4=null,VI=null)}function Ijs(t,s){const r=N.useRef(null),n=N.useRef(null),a=N.useRef(null),o=N.useRef(null),l=N.useRef(0),i=N.useRef(0),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,v]=N.useState(null),_=s.type!=="none"&&t!==null;return N.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const w=new Image;w.crossOrigin="anonymous",w.src=s.imageUrl,w.onload=()=>{o.current=w}}else o.current=null},[s.type,s.imageUrl]),N.useEffect(()=>{if(!_||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const w=document.createElement("video");return w.srcObject=t,w.muted=!0,w.playsInline=!0,w.autoplay=!0,w.play().catch(()=>{}),a.current=w,()=>{w.srcObject=null,a.current=null}},[_,t]),N.useEffect(()=>{if(!_){u(null),v(null);return}let w=!1;return(async()=>{f(!0),v(null);try{const k=await Ajs();if(w)return;f(!1);const S=a.current;if(!S||(await new Promise(xe=>{if(S.videoWidth>0)return xe();S.onloadedmetadata=()=>xe(),setTimeout(xe,2e3)}),w))return;const M=S.videoWidth||640,L=S.videoHeight||480,P=r.current;if(!P)return;P.width=M,P.height=L;const O=P.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const $=n.current;$.width=M,$.height=L;const U=$.getContext("2d",{willReadFrequently:!0}),B=document.createElement("canvas");B.width=M,B.height=L;const V=B.getContext("2d"),X=P.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(xe=>X.addTrack(xe)),w||u(X);const ee=s.blurRadius??15,Q=s.mirror??!1,ce=new Float32Array(M*L),ne=new Float32Array(M*L),re=new Float32Array(M*L);let oe=!1;const fe=4,ge=.6,ue=()=>{if(w||!a.current)return;const xe=performance.now();if(xe-i.current<30){l.current=requestAnimationFrame(ue);return}i.current=xe;const _e=a.current;if(_e.readyState<2){l.current=requestAnimationFrame(ue);return}try{const Me=k.segmentForVideo(_e,xe).confidenceMasks;if(Me&&Me.length>0){ne.fill(0);for(let pe=1;peLe?(pt=pe.height*Le,Qe=(pe.width-pt)/2):(ye=pe.width/Le,Te=(pe.height-ye)/2),O.drawImage(pe,Qe,Te,pt,ye,0,0,M,L)}U.clearRect(0,0,M,L),U.drawImage(_e,0,0,M,L);const Ie=U.getImageData(0,0,M,L),ke=Ie.data;for(let pe=0;pe{w=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[_,s.type,s.blurRadius,s.imageUrl,t]),N.useEffect(()=>()=>{Pjs()},[]),{canvasRef:r,compositedStream:c,isLoading:p,isActive:_,error:g}}function Tme({maxDurationSeconds:t=300,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=N.useRef(null),i=N.useRef(null),c=N.useRef(null),[u,p]=N.useState(null),f=N.useRef([]),g=N.useRef(null),v=N.useRef(null),_=N.useRef(null),w=N.useRef(null),j=DE(),[k,S]=N.useState("camera"),M=N.useRef(null),L=N.useRef(null),P=N.useRef(null),O=N.useRef(null),$=N.useRef(null),[U,B]=N.useState(!0),[V,X]=N.useState(!0),[Y,ee]=N.useState(null),[Q,ce]=N.useState(!1),[ne,re]=N.useState(!1),[oe,fe]=N.useState(null),[ge,ue]=N.useState(null),[xe,_e]=N.useState(0),[$e,Me]=N.useState("user"),[Ie,ke]=N.useState(0),[pe,we]=N.useState(!1),[Le,Qe]=N.useState(!0),[Te,pt]=N.useState(null),[ye,qe]=N.useState(!1),[at,tt]=N.useState(null),Ae=N.useRef(null),[rt,He]=N.useState(()=>{try{const ur=localStorage.getItem("video-bg-config");if(ur)return JSON.parse(ur)}catch{}return{type:"none"}});N.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(rt))}catch{}},[rt]);const{canvasRef:ct,compositedStream:Ue,isLoading:Ze,isActive:Je}=Ijs(u,rt),Ge=N.useRef(r);Ge.current=r;const et=N.useCallback(ur=>{B(ur)},[]),it=N.useRef(U),Dt=N.useCallback(()=>{P.current&&(cancelAnimationFrame(P.current),P.current=null),M.current&&(M.current.getTracks().forEach(ur=>ur.stop()),M.current=null),O.current&&(O.current.getTracks().forEach(ur=>ur.stop()),O.current=null),$.current&&($.current.srcObject=null,$.current=null)},[]),Vt=N.useCallback(async()=>{var ur;try{const Jr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});M.current=Jr;let Gr=null;try{Gr=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:320},height:{ideal:240}},audio:{echoCancellation:!0,noiseSuppression:!0}})}catch{console.warn("[VideoRecorder] No webcam for PiP overlay")}let mn=null;if(!Gr)try{mn=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Yr=Jr.getVideoTracks()[0],bi=Yr.getSettings(),ft=bi.width||1920,or=bi.height||1080,Vn=document.createElement("canvas");Vn.width=ft,Vn.height=or,L.current=Vn;const Sr=Vn.getContext("2d");let jr=null;Gr&&(jr=document.createElement("video"),jr.srcObject=Gr,jr.muted=!0,jr.playsInline=!0,jr.autoplay=!0,await jr.play(),$.current=jr);const ea=document.createElement("video");ea.srcObject=Jr,ea.muted=!0,ea.playsInline=!0,ea.autoplay=!0,await ea.play();const La=()=>{if(Sr.drawImage(ea,0,0,ft,or),jr&&jr.readyState>=2){const Be=Math.round(ft*.2),Ye=Math.round(Be*(jr.videoHeight/jr.videoWidth||.75)),bt=ft-Be-20,gt=or-Ye-20,Ft=12;Sr.save(),Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+Be-Ft,gt),Sr.quadraticCurveTo(bt+Be,gt,bt+Be,gt+Ft),Sr.lineTo(bt+Be,gt+Ye-Ft),Sr.quadraticCurveTo(bt+Be,gt+Ye,bt+Be-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.clip(),Sr.translate(bt+Be,gt),Sr.scale(-1,1),Sr.drawImage(jr,0,0,Be,Ye),Sr.restore(),Sr.strokeStyle="rgba(255,255,255,0.6)",Sr.lineWidth=2,Sr.beginPath(),Sr.moveTo(bt+Ft,gt),Sr.lineTo(bt+Be-Ft,gt),Sr.quadraticCurveTo(bt+Be,gt,bt+Be,gt+Ft),Sr.lineTo(bt+Be,gt+Ye-Ft),Sr.quadraticCurveTo(bt+Be,gt+Ye,bt+Be-Ft,gt+Ye),Sr.lineTo(bt+Ft,gt+Ye),Sr.quadraticCurveTo(bt,gt+Ye,bt,gt+Ye-Ft),Sr.lineTo(bt,gt+Ft),Sr.quadraticCurveTo(bt,gt,bt+Ft,gt),Sr.closePath(),Sr.stroke()}P.current=requestAnimationFrame(La)};La();const Ii=Vn.captureStream(30),Fo=[],$t=Jr.getAudioTracks();if($t.length&&Fo.push(...$t),Gr){const Be=Gr.getAudioTracks();Be.length&&Fo.push(...Be)}else mn&&Fo.push(...mn.getAudioTracks());const Se=new MediaStream([...Ii.getVideoTracks(),...Fo]);return O.current=Se,Yr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),Dt()},Se}catch(Jr){return console.error("[VideoRecorder] Screen capture error:",Jr),Jr.name!=="NotAllowedError"&&((ur=Ge.current)==null||ur.call(Ge,"Failed to start screen capture: "+(Jr.message||"Unknown error"))),null}},[Dt]),hs=N.useCallback(async()=>{var Jr,Gr;X(!0),pt(null);const ur=j&&U;console.log("[VideoRecorder] initCamera start",{isMobile:j,usePortraitMode:U,shouldBePortrait:ur,facingMode:$e});try{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Camera not available in this browser or context. Try opening in a new tab.");c.current&&(console.log("[VideoRecorder] stopping existing stream"),c.current.getTracks().forEach(or=>or.stop()));const mn=j&&ur?{facingMode:{ideal:$e},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:$e},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",mn);const Yr=await navigator.mediaDevices.getUserMedia({video:mn,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Yr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");c.current=Yr,p(Yr),ee(!0);const ft=Yr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",ft.width,"x",ft.height),l.current){const or=l.current;or.srcObject=Yr,or.muted=!0,or.playsInline=!0,or.autoplay=!0,or.setAttribute("muted",""),or.setAttribute("playsinline",""),or.setAttribute("autoplay","");try{(Jr=or.load)==null||Jr.call(or)}catch(Sr){console.warn("[VideoRecorder] videoEl.load failed",Sr)}const Vn=async()=>{try{return await or.play(),console.log("[VideoRecorder] preview play ok"),qe(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:or.readyState,videoWidth:or.videoWidth,videoHeight:or.videoHeight})},300),!0}catch(Sr){return console.warn("[VideoRecorder] preview play blocked",Sr),qe(!0),!1}};await new Promise(Sr=>{let jr=!1;const ea=()=>{jr||(jr=!0,Sr())},La=()=>{Vn().finally(ea)};or.onloadedmetadata=La,or.onloadeddata=La,setTimeout(ea,1500)})}try{v.current=new AudioContext;const or=v.current.createMediaStreamSource(Yr);_.current=v.current.createAnalyser(),_.current.fftSize=256,or.connect(_.current);const Vn=()=>{if(_.current){const Sr=new Uint8Array(_.current.frequencyBinCount);_.current.getByteFrequencyData(Sr);const jr=Sr.reduce((ea,La)=>ea+La)/Sr.length;ke(Math.min(100,jr/128*100))}w.current=requestAnimationFrame(Vn)};Vn()}catch(or){console.warn("Audio context not available:",or)}}catch(mn){console.error("Camera initialization error:",mn),ee(!1);let Yr="Failed to access camera or microphone.";mn.name==="NotAllowedError"?Yr="Camera permission denied. Please allow camera access in your browser settings.":mn.name==="NotFoundError"?Yr="No camera found. Please connect a camera and try again.":mn.name==="NotReadableError"?Yr="Camera is in use by another application. Please close other apps using the camera.":mn.message&&(Yr=mn.message),pt(Yr),(Gr=Ge.current)==null||Gr.call(Ge,Yr)}finally{X(!1)}},[$e,j,U]);N.useEffect(()=>{it.current!==U&&Y&&!Q&&!ge&&(it.current=U,hs())},[U,Y,Q,ge,hs]),N.useEffect(()=>(hs(),()=>{c.current&&c.current.getTracks().forEach(ur=>ur.stop()),g.current&&clearInterval(g.current),w.current&&cancelAnimationFrame(w.current),v.current&&v.current.close(),Ae.current&&clearInterval(Ae.current),ge&&URL.revokeObjectURL(ge),Dt()}),[hs,ge]),N.useEffect(()=>{if(V||Y!==!0||ge)return;const ur=c.current,Jr=l.current;!ur||!Jr||Je||(Jr.srcObject!==ur&&(Jr.srcObject=ur,Jr.muted=!0,Jr.playsInline=!0,Jr.autoplay=!0,Jr.setAttribute("muted",""),Jr.setAttribute("playsinline",""),Jr.setAttribute("autoplay","")),Jr.play().then(()=>qe(!1)).catch(Gr=>{qe(!0),console.warn("Live preview play blocked on mount:",Gr)}))},[Y,V,ge,Je]),N.useEffect(()=>{n==null||n(Q)},[Q,n]);const As=N.useCallback(async()=>{if(ge)return;const ur=l.current;if(ur)try{await ur.play(),qe(!1)}catch(Jr){qe(!0),console.warn("Live preview still blocked (needs user gesture):",Jr)}},[ge]),Ms=N.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),g.current&&(clearInterval(g.current),g.current=null),Dt(),ce(!1),re(!1)},[Dt]),cs=N.useCallback(async()=>{let ur=null;if(k==="screen"){if(ur=await Vt(),!ur)return}else ur=Je&&Ue?Ue:c.current;if(!ur)return;As(),f.current=[],_e(0);const Gr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Yr=>MediaRecorder.isTypeSupported(Yr)),mn=new MediaRecorder(ur,Gr?{mimeType:Gr,videoBitsPerSecond:k==="screen"?4e6:25e5}:{videoBitsPerSecond:k==="screen"?4e6:25e5});mn.ondataavailable=Yr=>{Yr.data.size>0&&f.current.push(Yr.data)},mn.onstop=()=>{var or;const Yr=mn.mimeType||Gr||((or=f.current[0])==null?void 0:or.type)||"video/webm",bi=new Blob(f.current,{type:Yr});fe(bi);const ft=URL.createObjectURL(bi);ue(ft)},i.current=mn,mn.start(100),ce(!0),g.current=setInterval(()=>{_e(Yr=>Yr>=t-1?(Ms(),t):Yr+1)},1e3)},[As,t,Ms,Je,Ue,k,Vt]),er=N.useCallback(()=>{Ae.current&&(clearInterval(Ae.current),Ae.current=null),tt(3);let ur=3;Ae.current=setInterval(()=>{ur-=1,ur<=0?(Ae.current&&clearInterval(Ae.current),Ae.current=null,tt(null),cs()):tt(ur)},1e3)},[cs]),xt=N.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),re(!0),g.current&&clearInterval(g.current))},[]),Ps=N.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),re(!1),g.current=setInterval(()=>{_e(ur=>ur>=t-1?(Ms(),t):ur+1)},1e3))},[t,Ms]),mr=N.useCallback(()=>{ge&&URL.revokeObjectURL(ge),fe(null),ue(null),_e(0),we(!1),Qe(!0),l.current&&c.current&&!Je&&(l.current.srcObject=c.current,l.current.muted=!0,As())},[As,ge,Je]),Tr=N.useCallback(()=>{Me(ur=>ur==="user"?"environment":"user")},[]),Dr=N.useCallback(()=>{oe&&s(oe,xe)},[oe,xe,s]),xn=N.useCallback(()=>{l.current&&ge&&(pe?l.current.pause():(Qe(!1),l.current.muted=!1,l.current.play()),we(!pe))},[ge,pe]);N.useEffect(()=>{if(!ge)return;const ur=l.current;if(!ur)return;Qe(!1),ur.pause(),ur.removeAttribute("src"),ur.srcObject=null,ur.load(),ur.src=ge,ur.currentTime=0,ur.playsInline=!0,ur.muted=!1,ur.onended=()=>we(!1);const Jr=()=>{var Yr;const Gr=ur.error,mn=Gr?`Recorded video failed to play (code ${Gr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Gr),(Yr=Ge.current)==null||Yr.call(Ge,mn)};return ur.addEventListener("error",Jr),ur.load(),()=>{ur.removeEventListener("error",Jr)}},[ge]);const Si=ur=>{const Jr=Math.floor(ur/60),Gr=ur%60;return`${Jr}:${Gr.toString().padStart(2,"0")}`},Ia=k==="screen"?"aspect-video":j&&U?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ia,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(bs,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):Y===!1?e.jsx("div",{className:It("flex items-center justify-center bg-black rounded-lg",Ia,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Cl,{className:"h-12 w-12 mx-auto mb-4 text-destructive"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Camera Access Required"}),e.jsx("p",{className:"text-gray-400 mb-4 text-sm",children:Te||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>hs(),variant:"secondary",className:"w-full",children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Try Again"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-3",children:"💡 Tip: If you're viewing this in an embedded preview, try opening the app in a new browser tab for full camera access."})]})]})}):e.jsxs("div",{className:It("flex flex-col gap-2",a),children:[!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:k==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("camera"),children:[e.jsx(ff,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:k==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>S("screen"),children:[e.jsx(fS,{className:"h-4 w-4"}),"Screen"]})]}),k==="camera"&&!Q&&!ge&&e.jsx(Gws,{value:rt,onChange:He,isLoading:Ze,disabled:Q}),k==="camera"&&j&&!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(xS,{className:It("h-4 w-4",U?"text-muted-foreground":"text-primary")}),e.jsx(be,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(qr,{id:"orientation-toggle",checked:U,onCheckedChange:et}),e.jsx(be,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(_0,{className:It("h-4 w-4",U?"text-primary":"text-muted-foreground")})]}),k==="screen"&&!Q&&!ge&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 px-4 bg-muted/50 rounded-lg text-sm text-muted-foreground",children:[e.jsx(fS,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Press record to share your screen. Your webcam will appear as a small overlay."})]}),e.jsxs("div",{className:It("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{As()},children:[e.jsx("video",{ref:l,src:ge??void 0,className:It("w-full bg-black",U&&!ge?"object-contain":"object-cover",Ia,!ge&&$e==="user"!==(rt.mirror??!1)&&"scale-x-[-1]",Je&&!ge&&"hidden"),playsInline:!0,controls:!!ge,muted:ge?Le:!0,autoPlay:!ge},ge??"live"),Je&&!ge&&e.jsx("canvas",{ref:ct,className:It("w-full bg-black",U?"object-contain":"object-cover",Ia,$e==="user"!==(rt.mirror??!1)&&"scale-x-[-1]")}),Je&&Ze&&!ge&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60 z-20",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(bs,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ge&&ye&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:e.jsx(K,{type:"button",variant:"secondary",onClick:()=>void As(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ge&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),at!==null&&!ge&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:at},at),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),Q&&e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx("div",{className:It("w-3 h-3 rounded-full",ne?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[Si(xe)," / ",Si(t)]})]}),Q&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Bi,{value:xe/t*100,className:"h-1 rounded-none"})}),!ge&&e.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[e.jsx(TL,{className:"h-4 w-4 text-white"}),e.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${Ie}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ge?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:mr,children:[e.jsx(Wo,{className:"h-5 w-5 mr-2"}),"Re-record"]}),e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:xn,children:pe?e.jsx(Rm,{className:"h-5 w-5"}):e.jsx(il,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Dr,children:[e.jsx(ba,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[k==="camera"?e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:Tr,disabled:Q||at!==null,children:e.jsx(g1,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!Q&&at===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:k==="screen"?cs:er,children:k==="screen"?e.jsx(fS,{className:"h-6 w-6"}):e.jsx(Cn,{className:"h-6 w-6"})}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:ne?Ps:xt,children:ne?e.jsx(il,{className:"h-5 w-5"}):e.jsx(Rm,{className:"h-5 w-5"})}),e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:Ms,children:e.jsx(w0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const wlt="teleprompter_settings",zye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function Ljs(){try{const t=localStorage.getItem(wlt);return t?{...zye,...JSON.parse(t)}:zye}catch{return zye}}function Djs(t){try{localStorage.setItem(wlt,JSON.stringify(t))}catch{}}function jlt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=N.useRef(null),c=N.useRef(null),u=N.useRef(0),p=N.useRef(0),[f,g]=N.useState(Ljs),{scrollSpeed:v,fontSize:_,lineHeight:w,opacity:j,position:k,isMirrored:S}=f,M=N.useCallback((Y,ee)=>{g(Q=>{const ce={...Q,[Y]:ee};return Djs(ce),ce})},[]),[L,P]=N.useState(!1),[O,$]=N.useState(null),U=N.useCallback(Y=>{if(!i.current)return;u.current===0&&(u.current=Y);const ee=Y-u.current;u.current=Y,p.current+=v*ee/1e3;const Q=Math.floor(p.current);Q>0&&(i.current.scrollTop+=Q,p.current-=Q);const{scrollTop:ce,scrollHeight:ne,clientHeight:re}=i.current;if(ce+re>=ne){P(!1);return}c.current=requestAnimationFrame(U)},[v]);N.useEffect(()=>(L?(u.current=0,p.current=0,c.current=requestAnimationFrame(U)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[L,U]),N.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){$(3);let Y=3;const ee=setInterval(()=>{Y-=1,Y<=0?(clearInterval(ee),$(null),o==null||o(),P(!0)):$(Y)},1e3);return()=>clearInterval(ee)}else setTimeout(()=>P(!0),100);else n||(P(!1),$(null))},[n,s,a,o]);const B=N.useCallback(()=>{i.current&&(i.current.scrollTop=0),P(!1)},[]),V=N.useCallback(()=>{P(Y=>!Y)},[]);if(!s)return e.jsx("div",{className:It("absolute top-4 right-4 pointer-events-auto z-10",l),children:e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const X={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:It("absolute inset-0 pointer-events-none",l),children:[O!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:O},O),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:It("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",X[k],O!==null&&"opacity-30"),style:{opacity:O!==null?.3:j},children:e.jsxs("div",{ref:i,className:It("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${_}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(Qo,{className:"h-4 w-4"})})}),e.jsx(Ro,{className:"w-72",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:v})]}),e.jsx(Yg,{value:[v],onValueChange:([Y])=>M("scrollSpeed",Y),min:1,max:100,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_,"px"]})]}),e.jsx(Yg,{value:[_],onValueChange:([Y])=>M("fontSize",Y),min:16,max:48,step:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(Yg,{value:[w*10],onValueChange:([Y])=>M("lineHeight",Y/10),min:12,max:24,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(j*100),"%"]})]}),e.jsx(Yg,{value:[j*100],onValueChange:([Y])=>M("opacity",Y/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:k==="top"?"default":"outline",size:"sm",onClick:()=>M("position","top"),children:e.jsx(xf,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="center"?"default":"outline",size:"sm",onClick:()=>M("position","center"),children:e.jsx(y0,{className:"h-4 w-4"})}),e.jsx(K,{variant:k==="bottom"?"default":"outline",size:"sm",onClick:()=>M("position","bottom"),children:e.jsx(oo,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs",children:"Mirror Mode"}),e.jsx(qr,{checked:S,onCheckedChange:Y=>M("isMirrored",Y)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:L?e.jsx(Rm,{className:"h-4 w-4"}):e.jsx(il,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:B,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(g1,{className:"h-4 w-4"})}),e.jsxs(K,{variant:"secondary",size:"sm",onClick:r,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[e.jsx(kp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function Ojs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ha(),[o,l]=N.useState(""),[i,c]=N.useState(null),[u,p]=N.useState("levelup"),{data:f,isLoading:g}=v_s(),{data:v,isLoading:_}=b_s(),{data:w,isLoading:j}=__s(),k=w_s(),S=N.useMemo(()=>v?v.filter($=>{const U=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),B=!i||$.category_id===i;return U&&B}):[],[v,o,i]),M=N.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),L=$=>{t({title:$.title,text:$.script_text})},P=async $=>{try{await k.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},O=g||_||j;return e.jsxs("div",{className:It("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),e.jsxs(_a,{value:u,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[e.jsxs(fa,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(ns,{value:"levelup",children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(ns,{value:"my-scripts",children:[e.jsx(Sx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(ws,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(st,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map($=>e.jsx(st,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>c($.id),children:$.name},$.id))]}),e.jsx(Ki,{className:"flex-1 max-h-[50vh]",children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(wn,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map($=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>L($),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(st,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U=>{U.stopPropagation(),P($)},children:e.jsx(Sx,{className:"h-4 w-4"})}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]}),e.jsxs(ws,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Ki,{className:"flex-1 max-h-[50vh]",children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sx,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No saved scripts"}),e.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):e.jsx("div",{className:"space-y-2",children:M.map($=>e.jsxs(Ee,{className:It("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>L($),children:[e.jsx(Pt,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(st,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function Rjs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=N.useState(()=>{const i=iT(t);return new Set([i.category])}),l=i=>{o(c=>{const u=new Set(c);return u.has(i)?u.delete(i):u.add(i),u})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(bs,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:sLt.map(i=>{const c=rLt(i.id),u=a.has(i.id),p=c.some(f=>f.id===t);return e.jsxs(vf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(bf,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:i.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.length,")"]}),p&&!u&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),e.jsx(oo,{className:It("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(_f,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:c.map(f=>{const g=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:It("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",g?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[g&&e.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:e.jsx(ba,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"opacity-70 shrink-0",children:f.icon}),e.jsx("span",{className:"text-sm font-medium truncate",children:f.name})]})]},f.id)})})})]},i.id)})}),r&&t!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',iT(t).headerText(r),'"']})]})}function Nlt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=N.useState(r.page_template||"default"),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState(r.page_template||"default"),[v,_]=N.useState([]),[w,j]=N.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[k,S]=N.useState(!1),[M,L]=N.useState(!1),P=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";N.useEffect(()=>{t&&v.length===0&&O()},[t]);const O=async()=>{L(!0);try{const{data:ce,error:ne}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ne)throw ne;const re=(ce||[]).map(oe=>({id:oe.id,name:[oe.first_name,oe.last_name].filter(Boolean).join(" ")||"Unnamed",email:oe.email||null}));_(re)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{L(!1)}},$=async ce=>{j(ce),S(!1),c(!0);try{const{error:ne}=await H.from("agent_videos").update({contact_id:(ce==null?void 0:ce.id)||null,recipient_name:(ce==null?void 0:ce.name)||null}).eq("id",r.id);if(ne)throw ne;me.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ne){console.error("Failed to update contact:",ne),me.error("Failed to update contact")}finally{c(!1)}},U=async ce=>{l(ce),c(!0);try{const{error:ne}=await H.from("agent_videos").update({page_template:ce}).eq("id",r.id);if(ne)throw ne;g(ce),me.success("Template saved!"),a==null||a()}catch(ne){console.error("Failed to save template:",ne),me.error("Failed to save template"),l(f)}finally{c(!1)}},B=(w==null?void 0:w.name)||null,V=()=>{const ce=r.title||"Video Message",ne=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},X=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const ce=V(),ne=`Watch: ${r.title||"Video Message"} ${P}`;try{const re=new Blob([ce],{type:"text/html"}),oe=new Blob([ne],{type:"text/plain"}),fe=new ClipboardItem({"text/html":re,"text/plain":oe});await navigator.clipboard.write([fe]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ne+` `+ce),me.success("Copied! Paste into your email.")}},Y=async()=>{await navigator.clipboard.writeText(P),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},ee=()=>{const ne=iT(o).headerText(B),re=o==="default"?`Check out this video: ${P}`:`${ne} Check out this special video: ${P}`;window.open(`sms:?body=${encodeURIComponent(re)}`,"_self")},Q=()=>{const ce=iT(o),ne=ce.headerText(B),re=o==="default"?r.title||"Video Message":ne,oe=`${ce.subText} Watch the video: ${P}`,fe=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${fe}?subject=${encodeURIComponent(re)}&body=${encodeURIComponent(oe)}`,"_self")};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Wr,{children:"Choose a themed page template and share your video"})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($o,{open:k,onOpenChange:S,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":k,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search contacts..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:M?"Loading...":"No contacts found."}),e.jsx($x,{children:v.map(ce=>e.jsxs(bp,{value:ce.name,onSelect:()=>$(ce),children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",(w==null?void 0:w.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),w&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Mr,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',iT(o).headerText(w.name),'"']})]}),e.jsx(Rjs,{selectedTemplate:o,onSelect:U,contactName:B,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:P,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:Y,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ba,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(yi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:X,children:[e.jsx(vl,{className:"h-4 w-4"}),"Copy with Thumbnail (for Gmail)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste into Gmail to embed a clickable video thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:ee,children:[e.jsx(so,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Q,children:[e.jsx(lr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(Un,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function Fjs(){var tt;const t=nr(),[s]=uc(),{toast:r}=Ha(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=iit(),{data:u}=Wm(),p=L3(),f=C_s(),[g,v]=N.useState("record"),[_,w]=N.useState(""),[j,k]=N.useState(!1),[S,M]=N.useState(!1),[L,P]=N.useState(!1),[O,$]=N.useState(null),[U,B]=N.useState(0),[V,X]=N.useState(0),[Y,ee]=N.useState(null),[Q,ce]=N.useState(null),[ne,re]=N.useState(n||""),[oe,fe]=N.useState(""),[ge,ue]=N.useState(""),[xe,_e]=N.useState(null),[$e,Me]=N.useState(null),[Ie,ke]=N.useState(null),[pe,we]=N.useState(!1),Le=N.useCallback(async(Ae,rt)=>{$(Ae),v("uploading");try{const{videoId:He,uploadUrl:ct}=await SR(oe||"Quick Video Touch");ee(He);const{apiKey:Ue}=await CR(He),Ze=new XMLHttpRequest;Ze.upload.onprogress=it=>{it.lengthComputable&&B(it.loaded/it.total*100)},await new Promise((it,Dt)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?it():Dt(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>Dt(new Error("Upload failed")),Ze.open("PUT",ct),Ze.setRequestHeader("AccessKey",Ue),Ze.send(Ae)}),v("processing");let Je=0;const Ge=Date.now(),et=90*1e3;for(;Je<4;){if(await new Promise(Dt=>setTimeout(Dt,3e3)),Date.now()-Ge>et){const Dt=Ae.size/1048576,Vt=`https://iframe.mediadelivery.net/play/${He}/${He}`;await p.mutateAsync({bunny_video_id:He,playback_url:Vt,file_size_mb:Dt,title:oe||"Quick Video Touch",notes:ge||void 0,contact_id:ne&&ne!=="none"?ne:void 0,status:"processing",touch_type:"video_touch"}),r({title:"Video saved — still processing",description:'Your video has been saved and will appear in your library with a "processing" badge. It will be ready to share once encoding completes (usually within a few minutes).',duration:8e3}),t("/mission-control/video-library");return}const it=await AA(He);if(Je=it.status,X(it.encodeProgress||0),Je===4)ce({playbackUrl:it.directPlayUrl,thumbnailUrl:it.thumbnailUrl,previewUrl:it.previewUrl||null,duration:it.length||rt,fileSizeMb:(it.storageSize||Ae.size)/(1024*1024)});else if(Je===5||Je===6)throw new Error("Video processing failed")}v("details")}catch(He){console.error("Upload error:",He),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),v("record")}},[oe,r]),Qe=async()=>{if(!(!Y||!Q))try{const Ae=ne&&ne!=="none"?ne:null,rt=await p.mutateAsync({bunny_video_id:Y,contact_id:Ae,playback_url:Q.playbackUrl,thumbnail_url:Q.thumbnailUrl,preview_url:Q.previewUrl,duration_seconds:Q.duration,file_size_mb:Q.fileSizeMb,title:oe||"Quick Video Touch",notes:ge,task_id:a||null,status:"ready"});_e(rt.id),Me(rt.share_token||null),Ae&&await f.mutateAsync({contactId:Ae,videoId:rt.id,notes:ge}),r({title:"Video saved successfully!"}),v("share")}catch(Ae){console.error("Save video error:",Ae),r({title:"Failed to save video",description:(Ae==null?void 0:Ae.message)||"Please try again.",variant:"destructive"})}},Te=(Ae,rt)=>{navigator.clipboard.writeText(rt),ke(Ae),setTimeout(()=>ke(null),2e3),r({title:"Copied to clipboard!"})},pt=()=>$e?`https://video.relevelup.com/${$e}`:(Q==null?void 0:Q.playbackUrl)||"",ye=()=>{const Ae=u==null?void 0:u.find(Ze=>Ze.id===ne),rt=Ae?`${Ae.first_name}`:"",He=(Ae==null?void 0:Ae.phone)||"",ct=(Ae==null?void 0:Ae.email)||"",Ue=pt();return{text:`Hey${rt?` ${rt}`:""}! I recorded a quick video for you: ${Ue}`,link:Ue,contactPhone:He,contactEmail:ct}},qe=()=>{const{text:Ae,contactPhone:rt}=ye(),He=rt?`sms:${rt}?body=${encodeURIComponent(Ae)}`:`sms:?body=${encodeURIComponent(Ae)}`;window.open(He,"_self")},at=()=>{const{link:Ae,contactEmail:rt}=ye(),He="Check out this video",ct=`I recorded a quick video for you: ${Ae}`,Ue=rt?`mailto:${rt}?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`:`mailto:?subject=${encodeURIComponent(He)}&body=${encodeURIComponent(ct)}`;window.open(Ue,"_self")};return o?e.jsx(Ts,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"QuickVid"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>t("/mission-control/video-library"),className:"gap-1.5",children:[e.jsx(wn,{className:"h-4 w-4"}),"Video Library"]}),c&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]})]}),g==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(Tme,{maxDurationSeconds:300,onRecordingComplete:Le,onRecordingStateChange:P,className:"w-full",teleprompterContent:j&&_&&e.jsx(jlt,{text:_,isVisible:j,onToggleVisibility:()=>k(!1),isRecording:L,startCountdown:!0})}),!j&&_&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>k(!0),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Pr,{placeholder:"Type or paste your script here...",value:_,onChange:Ae=>w(Ae.target.value),rows:6}),e.jsxs(lE,{open:S,onOpenChange:M,children:[e.jsx(fNe,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(S3,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(cE,{className:"p-4 border-b",children:e.jsx(dE,{children:"Select a Script"})}),e.jsx(Ojs,{onSelectScript:Ae=>{w(Ae.text),M(!1),k(!0)},className:"h-[calc(100vh-80px)]"})]})]}),_&&e.jsx(K,{className:"w-full",onClick:()=>k(!0),children:"Use Script"})]})]})]}),g==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(di,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-pulse"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Uploading Video..."}),e.jsx(Bi,{value:U,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.toFixed(0),"%"]})]})}),g==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(bs,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),e.jsx(Bi,{value:V,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[V.toFixed(0),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:`This usually takes 30-60 seconds. If it takes longer, we'll auto-save your video and you can find it in your Video Library — look for the "processing" badge.`})]})}),g==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:oe,onChange:Ae=>fe(Ae.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Attach to Contact (Optional)"}),e.jsxs(Ks,{value:ne,onValueChange:re,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"No contact - use anywhere"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Bo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Ae=>e.jsx(Mt,{value:Ae.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-4 w-4"}),Ae.first_name," ",Ae.last_name]})},Ae.id))]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Pr,{value:ge,onChange:Ae=>ue(Ae.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:Qe,disabled:p.isPending,children:[p.isPending&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),g==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(ba,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:qe,children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:at,children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Te("link",ye().link),children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ie==="link"&&e.jsx(ba,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>we(!0),children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{v("record"),$(null),ee(null),ce(null)},children:"Record Another"})]})]})]}),xe&&$e&&e.jsx(Nlt,{open:pe,onOpenChange:we,video:{id:xe,share_token:$e,title:oe||null,contact_id:ne||null,thumbnail_url:(Q==null?void 0:Q.thumbnailUrl)||null},contactName:((tt=u==null?void 0:u.find(Ae=>Ae.id===ne))==null?void 0:tt.first_name)||null})]})}):e.jsx(Ts,{title:"QuickVid",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(Yu,{className:"h-16 w-16 text-destructive mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Storage Limit Reached"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You've reached your video storage limit. Delete videos from your library to record more."}),e.jsx(K,{onClick:()=>t("/mission-control/video-library"),children:"Open Video Library"})]})})}function zjs({open:t,onOpenChange:s}){const{data:r}=Wm(),{data:n}=rme(),a=L3(),o=N.useRef(null),[l,i]=N.useState(null),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState(!1),[j,k]=N.useState(0),[S,M]=N.useState("idle"),L=(n==null?void 0:n.total_storage_mb)||0,O=((n==null?void 0:n.max_storage_mb)||1024)-L,$=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;if(!Y.type.startsWith("video/")){me.error("Please select a video file");return}const ee=Y.size/(1024*1024);if(ee>500){me.error("Video file must be less than 500MB");return}if(ee>O){me.error(`Not enough storage. You have ${O.toFixed(1)} MB remaining.`);return}i(Y),c||u(Y.name.replace(/\.[^/.]+$/,""))},U=async()=>{if(!l){me.error("Please select a video file");return}w(!0),k(0),M("creating");try{const{data:X,error:Y}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(Y)throw new Error(Y.message);const{videoId:ee,libraryId:Q}=X;M("uploading");const{data:ce,error:ne}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ee,isAgentVideo:!0}});if(ne)throw new Error(ne.message);await new Promise((fe,ge)=>{const ue=new XMLHttpRequest;ue.upload.addEventListener("progress",xe=>{if(xe.lengthComputable){const _e=Math.round(xe.loaded/xe.total*100);k(_e)}}),ue.addEventListener("load",()=>{ue.status>=200&&ue.status<300?fe():ge(new Error(`Upload failed with status ${ue.status}`))}),ue.addEventListener("error",()=>ge(new Error("Upload failed"))),ue.open("PUT",ce.uploadUrl),ue.setRequestHeader("AccessKey",ce.apiKey),ue.send(l)}),M("processing");const re=l.size/(1024*1024),oe=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;await a.mutateAsync({bunny_video_id:ee,playback_url:oe,file_size_mb:re,title:c||l.name,notes:p||void 0,contact_id:g||void 0,status:"processing",touch_type:"video_upload"}),me.success("Video uploaded successfully! Processing may take a few minutes."),B()}catch(X){console.error("Upload error:",X),me.error(X instanceof Error?X.message:"Failed to upload video")}finally{w(!1),M("idle")}},B=()=>{_||(i(null),u(""),f(""),v(""),k(0),M("idle"),s(!1))},V=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${j}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(xs,{open:t,onOpenChange:B,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Upload Video"}),e.jsx(Wr,{children:"Upload a video file from your device to your video library."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Cn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!_&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:X=>{X.stopPropagation(),i(null)},children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var X;return(X=o.current)==null?void 0:X.click()},children:[e.jsx(di,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:$,disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:c,onChange:X=>u(X.target.value),placeholder:"Enter video title",disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Associate with Contact (optional)"}),e.jsxs(Ks,{value:g||"__none__",onValueChange:X=>v(X==="__none__"?"":X),disabled:_,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a contact"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(X=>e.jsxs(Mt,{value:X.id,children:[X.first_name," ",X.last_name||""]},X.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Pr,{id:"notes",value:p,onChange:X=>f(X.target.value),placeholder:"Add any notes about this video",rows:2,disabled:_})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Bi,{value:S==="uploading"?j:S==="processing"?100:10})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:B,disabled:_,children:"Cancel"}),e.jsx(K,{onClick:U,disabled:!l||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function Bjs(t){return mt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function $js(){const{user:t}=Os();return mt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await H.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function qjs(){const{user:t}=Os();return mt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await H.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Ujs(){const{user:t}=Os(),s=Xt();return Lt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await H.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function Vjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function Hjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function Gjs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=N.useState([]),[c,u]=N.useState(null),[p,f]=N.useState(!1),[g,v]=N.useState(!1),[_,w]=N.useState(""),[j,k]=N.useState(""),[S,M]=N.useState(""),[L,P]=N.useState(!1),O=Ujs(),$=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",U=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",B=r.title||"Video Message";N.useEffect(()=>{t&&l.length===0&&V()},[t]),N.useEffect(()=>{if(t&&(k(`I recorded a video for you — ${B}`),M("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),w(""),r.contact_id)){const ne=l.find(re=>re.id===r.contact_id);ne&&(u(ne),w(ne.email||""))}},[t,r.contact_id,l]);const V=async()=>{v(!0);try{const{data:ne,error:re}=await H.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(re)throw re;i(ne||[])}catch{console.error("Failed to fetch contacts")}finally{v(!1)}},X=ne=>{u(ne),f(!1),w(ne.email||""),M(`Hey ${ne.first_name}! I recorded a quick video just for you. Click below to watch it:`),k(`I recorded a video for you — ${B}`)},Y=()=>{u(null),w(""),M("Hey! I recorded a quick video just for you. Click below to watch it:")},ee=ne=>`${ne.first_name} ${ne.last_name||""}`.trim(),Q=ne=>{const re=S.split(/\n\n+/).map(ge=>`

${ge.replace(/\n/g,"
")}

`).join(""),oe=ne?Hjs(ne):$,fe=ne?``:"";return`
${re}

▶ Watch Video

${fe}
`},ce=async()=>{if(!_){me.error("Please enter a recipient email");return}if(!$){me.error("Video does not have a share link");return}P(!0);try{let ne;try{const ge=c?ee(c):_.split("@")[0];ne=(await O.mutateAsync({video_id:r.id,recipient_email:_,recipient_name:ge,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(ge){console.warn("Failed to create tracking record, sending without tracking:",ge)}const re=Q(ne),{data:oe,error:fe}=await H.functions.invoke("gmail-send",{body:{to:_,subject:j,body:re,contactId:(c==null?void 0:c.id)||null}});if(fe)throw fe;if(!(oe!=null&&oe.success))throw new Error((oe==null?void 0:oe.error)||"Failed to send");me.success("Video email sent!"),s(!1),o==null||o()}catch(ne){console.error("Gmail send error:",ne),me.error("Failed to send: "+(ne instanceof Error?ne.message:"Unknown error"))}finally{P(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5 text-red-500"}),"Send Video via Gmail"]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:n})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs($o,{open:p,onOpenChange:f,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[c?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"}),ee(c),c.email&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",c.email,")"]})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search contacts..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:g?"Loading...":"No contacts found."}),e.jsx($x,{children:l.filter(ne=>ne.email).map(ne=>e.jsxs(bp,{value:`${ne.first_name} ${ne.last_name||""} ${ne.email||""}`,onSelect:()=>X(ne),children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",(c==null?void 0:c.id)===ne.id?"opacity-100":"opacity-0")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ee(ne)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne.email})]})]},ne.id))})]})]})})]}),c&&e.jsx(K,{variant:"ghost",size:"icon",onClick:Y,className:"shrink-0",children:e.jsx(Mr,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(ze,{id:"video-to",value:_,onChange:ne=>w(ne.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-subject",children:"Subject"}),e.jsx(ze,{id:"video-subject",value:j,onChange:ne=>k(ne.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Pr,{id:"video-message",value:S,onChange:ne=>M(ne.target.value),rows:4,className:"resize-y"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[U?e.jsx("img",{src:U,alt:B,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(il,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 rounded-full bg-white/80 flex items-center justify-center shadow",children:e.jsx(il,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:L,children:"Cancel"}),e.jsxs(K,{onClick:ce,disabled:L||!_||!j,className:"gap-2",children:[L?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"}),L?"Sending...":"Send Video Email"]})]})]})]})})}const Wjs=()=>{const{user:t}=Os();return mt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function Kjs({recipient:t}){return t.watched_at?e.jsxs(st,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(il,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(st,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(Nh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(st,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(Dn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(st,{variant:"outline",className:"text-[10px]",children:[e.jsx($n,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function Zjs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=Bjs(r);return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(yo,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(vs,{className:"h-12 w-full"},i))}):a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recipients tracked for this video yet."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"text-center p-2 rounded-lg bg-muted/50",children:[e.jsx("div",{className:"text-lg font-bold",children:a.length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Sent"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-amber-50",children:[e.jsx("div",{className:"text-lg font-bold text-amber-700",children:a.filter(l=>l.opened_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Opened"})]}),e.jsxs("div",{className:"text-center p-2 rounded-lg bg-blue-50",children:[e.jsx("div",{className:"text-lg font-bold text-blue-700",children:a.filter(l=>l.clicked_at).length}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Clicked"})]})]}),e.jsx(Ki,{className:"h-[400px]",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Recipient"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Sent"}),e.jsx(St,{children:"Last Activity"})]})}),e.jsx(Bn,{children:a.map(l=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.recipient_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.recipient_email})]})}),e.jsx(dt,{children:e.jsx(Kjs,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:ms(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Vc(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function Yjs(){const{data:t,isLoading:s}=$js(),{data:r=[],isLoading:n}=qjs(),[a,o]=N.useState(null),l=s||n,i=r.reduce((c,u)=>{const p=u.agent_videos,f=(p==null?void 0:p.id)||u.video_id;return c[f]||(c[f]={videoId:f,title:(p==null?void 0:p.title)||"Untitled",thumbnailUrl:p==null?void 0:p.thumbnail_url,recipients:[]}),c[f].recipients.push(u),c},{});return l?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((c,u)=>e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(vs,{className:"h-8 w-16"})})]},u))})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx($n,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(Dn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(Nh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(gr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(c=>{const u=c.recipients.filter(f=>f.opened_at).length,p=c.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:c.videoId,title:c.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:c.thumbnailUrl?e.jsx("img",{src:c.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const g=f.currentTarget;g.style.display="none",g.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:c.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx($n,{className:"h-3 w-3"})," ",c.recipients.length]}),e.jsxs("span",{className:"text-xs text-amber-600 flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(Nh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Jo,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(Zjs,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Qjs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=N.useState(!1),[l,i]=N.useState(!1),c=n&&t&&!a,u=s&&!l;return!u&&!c?e.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[u&&e.jsx("img",{src:s,alt:r,loading:"lazy",className:`w-full h-full object-cover absolute inset-0 transition-opacity duration-200 ${c?"opacity-0":"opacity-100"}`,onError:()=>i(!0)}),c&&e.jsx("img",{src:t,alt:r,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function Xjs({video:t,previewSrc:s,thumbnailSrc:r,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:c,onEmbedToCrm:u,onShareWithTemplate:p,onSendViaGmail:f,isGmailConnected:g,getContactName:v,getShareUrl:_,copyToClipboard:w,formatDuration:j}){const[k,S]=N.useState(!1);return e.jsxs(Ee,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(Qjs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:k}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(il,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:j(t.duration_seconds)}),t.status!=="ready"&&e.jsx(st,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Wi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:v(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(Dn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),g&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(lr,{className:"h-3 w-3"}),"Send via Gmail"]}),e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(Wi,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:v(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),e.jsx("span",{children:ms(new Date(t.created_at),"MMM d, yyyy")})]}),(t.view_count??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[e.jsx(Dn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M=>M.stopPropagation(),children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",className:"bg-popover",children:[e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),n()},children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(xw,{}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),p()},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),w(_(t),"Share link")},children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),i()},children:[e.jsx(rS,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),c()},children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),u()},children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),g&&t.share_token&&e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),o()},children:[e.jsx(za,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(xw,{}),t.contact_id&&e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),l()},children:[e.jsx(Wi,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Aa,{onClick:M=>{M.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Jjs(){var it,Dt;const t=nr(),{data:s,isLoading:r,refetch:n}=j_s(),{data:a}=rme(),{data:o}=Wm(),l=S_s(),i=k_s(),{isGmailConnected:c,gmailEmail:u}=Zx(),{data:p}=Ux(),{data:f=[],isLoading:g}=Wjs(),[v,_]=N.useState("my"),[w,j]=N.useState(""),[k,S]=N.useState(null),[M,L]=N.useState(!1),[P,O]=N.useState(!1),[$,U]=N.useState(!1),[B,V]=N.useState(!1),[X,Y]=N.useState(!1),[ee,Q]=N.useState(""),[ce,ne]=N.useState(!1),[re,oe]=N.useState(!1),[fe,ge]=N.useState(!1),[ue,xe]=N.useState(!1),[_e,$e]=N.useState(""),[Me,Ie]=N.useState({}),ke=Vt=>{if(!Vt)return"Unassigned";const hs=o==null?void 0:o.find(As=>As.id===Vt);return hs?`${hs.first_name} ${hs.last_name||""}`.trim():"Unknown"},pe=Vt=>{if(!Vt)return"0:00";const hs=Math.floor(Vt/60),As=Vt%60;return`${hs}:${As.toString().padStart(2,"0")}`},we=s==null?void 0:s.filter(Vt=>{if(!w)return!0;const hs=ke(Vt.contact_id).toLowerCase(),As=(Vt.title||"").toLowerCase(),Ms=(Vt.notes||"").toLowerCase();return hs.includes(w.toLowerCase())||As.includes(w.toLowerCase())||Ms.includes(w.toLowerCase())}),[Le,Qe]=N.useState(!1);N.useEffect(()=>{if(Le)return;(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Ms=>Ms.status==="processing"&&Ms.bunny_video_id);if(!hs.length)return;let As=!1;for(const Ms of hs)try{const{data:cs,error:er}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:Ms.bunny_video_id,isAgentVideo:!0}});if(er||!cs)continue;cs.status===4&&(await H.from("agent_videos").update({status:"ready",playback_url:cs.directPlayUrl,thumbnail_url:cs.thumbnailUrl,preview_url:cs.previewUrl,duration_seconds:cs.length||Ms.duration_seconds,updated_at:new Date().toISOString()}).eq("id",Ms.id),As=!0)}catch(cs){console.warn("Reconcile check failed for video",Ms.id,cs)}Qe(!0),As&&n()})()},[s,Le,n]),N.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(xt=>(xt==null?void 0:xt.bunny_video_id)&&!Me[xt.id]);if(!hs.length)return;const As=hs.map(xt=>xt.bunny_video_id),{data:Ms,error:cs}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:As,isAgentVideo:!0}});if(cs)throw cs;const er=(Ms==null?void 0:Ms.assets)||{};Ie(xt=>{const Ps={...xt};for(const mr of hs)er[mr.bunny_video_id]&&(Ps[mr.id]={previewUrl:er[mr.bunny_video_id].previewUrl,thumbnailUrl:er[mr.bunny_video_id].thumbnailUrl});return Ps})})().catch(hs=>console.warn("Failed to load signed Bunny asset URLs",hs))},[s,Me]);const Te=(a==null?void 0:a.total_storage_mb)||0,pt=(a==null?void 0:a.max_storage_mb)||1024,ye=Te/pt*100,qe=ye>=80,at=ye>=100,tt=async(Vt,hs)=>{await navigator.clipboard.writeText(Vt),me.success(`${hs} copied to clipboard`)},Ae=Vt=>Vt.share_token?`https://video.relevelup.com/${Vt.share_token}`:Vt.playback_url||"",rt=Vt=>{const hs=Ae(Vt),As=o==null?void 0:o.find(mr=>mr.id===Vt.contact_id),Ms=ke(Vt.contact_id),cs=Ms!=="Unassigned"?Ms.split(" ")[0]:"",er=(As==null?void 0:As.phone)||"",xt=`Hey${cs?` ${cs}`:""}! I recorded a quick video message for you. Check it out: ${hs}`,Ps=er?`sms:${er}?body=${encodeURIComponent(xt)}`:`sms:?body=${encodeURIComponent(xt)}`;window.open(Ps,"_self")},He=Vt=>{const hs=o==null?void 0:o.find(Ps=>Ps.id===Vt.contact_id),As=(hs==null?void 0:hs.email)||"",Ms=Ae(Vt),cs="Check out this video",er=`I recorded a quick video for you: ${Ms}`,xt=As?`mailto:${As}?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`:`mailto:?subject=${encodeURIComponent(cs)}&body=${encodeURIComponent(er)}`;window.open(xt,"_self")},ct=Vt=>{var cs;const hs=Ae(Vt),As=Vt.title||"Video Message",Ms=Vt.share_token?`https://video.relevelup.com/thumb/${Vt.share_token}`:((cs=Me[Vt.id])==null?void 0:cs.thumbnailUrl)||Vt.thumbnail_url||"";return``},Ue=async Vt=>{if(!Vt.thumbnail_url&&!Vt.share_token){me.error("Video thumbnail not available yet");return}const hs=ct(Vt),As=Ae(Vt),Ms=`Watch: ${Vt.title||"Video Message"} ${As}`;try{const cs=new Blob([hs],{type:"text/html"}),er=new Blob([Ms],{type:"text/plain"}),xt=new ClipboardItem({"text/html":cs,"text/plain":er});await navigator.clipboard.write([xt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(Ms+` `+hs),me.success("Copied! Paste into your email.")}},Ze=async Vt=>{try{me.loading("Preparing download...",{id:"download"});const{data:hs,error:As}=await H.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Vt.bunny_video_id,isAgentVideo:!0}});if(As||!(hs!=null&&hs.downloadUrl))throw new Error((As==null?void 0:As.message)||"Failed to get download URL");const cs=`${((Vt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,er=await fetch(hs.downloadUrl);if(!er.ok)throw new Error("Failed to fetch video file");const xt=await er.blob(),Ps=URL.createObjectURL(xt),mr=document.createElement("a");mr.href=Ps,mr.download=cs,mr.rel="noreferrer",document.body.appendChild(mr),mr.click(),mr.remove(),URL.revokeObjectURL(Ps),me.success("Download started",{id:"download"})}catch(hs){console.error("Download error:",hs),me.error("Could not force download (your browser may block it).",{id:"download"})}},Je=async Vt=>{S(Vt),ne(!0),Q(""),Y(!0);try{const{data:hs,error:As}=await H.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Vt.bunny_video_id,title:Vt.title,isAgentVideo:!0,shareToken:Vt.share_token}});if(As||!(hs!=null&&hs.html))throw new Error("Failed to generate CRM embed code");Q(hs.html)}catch(hs){console.error("CRM embed error:",hs),me.error("Failed to generate CRM embed code"),Y(!1)}finally{ne(!1)}},Ge=Vt=>{S(Vt),L(!0)},et=async()=>{if(k)try{await l.mutateAsync({id:k.id,bunnyVideoId:k.bunny_video_id,hardDelete:!0}),O(!1),S(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(Ts,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>_("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${v==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((it=p.team)==null?void 0:it.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>_("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${v==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>_("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${v==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(yo,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),v==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>U(!0),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),v==="team"?e.jsx(eNs,{videos:f,isLoading:g,searchTerm:w,setSearchTerm:j}):v==="analytics"?e.jsx(Yjs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:qe?"border-amber-500":at?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_L,{className:`h-5 w-5 ${at?"text-destructive":qe?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Te.toFixed(1)," MB / ",pt>=1024?`${(pt/1024).toFixed(0)} GB`:`${pt} MB`]})]}),e.jsx(Bi,{value:Math.min(ye,100),className:`h-2 ${at?"[&>div]:bg-destructive":qe?"[&>div]:bg-amber-500":""}`})]}),qe&&!at&&e.jsxs(st,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Cl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),at&&e.jsxs(st,{variant:"destructive",children:[e.jsx(Cl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),at&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:Vt=>j(Vt.target.value),className:"pl-10"})]}),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(we==null?void 0:we.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:we==null?void 0:we.map(Vt=>{var hs,As;return e.jsx(Xjs,{video:Vt,previewSrc:(hs=Me[Vt.id])==null?void 0:hs.previewUrl,thumbnailSrc:(As=Me[Vt.id])==null?void 0:As.thumbnailUrl,onOpen:()=>Ge(Vt),onDelete:()=>{S(Vt),O(!0)},onRename:()=>{S(Vt),$e(Vt.title||""),xe(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Vt.contact_id}`),onGetEmbedCode:()=>{S(Vt),V(!0)},onCopyEmailHtml:()=>Ue(Vt),onEmbedToCrm:()=>Je(Vt),onShareWithTemplate:()=>{S(Vt),oe(!0)},onSendViaGmail:()=>{S(Vt),ge(!0)},isGmailConnected:c,getContactName:ke,getShareUrl:Ae,copyToClipboard:tt,formatDuration:pe},Vt.id)})}),e.jsx(xs,{open:M,onOpenChange:L,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsx(_s,{children:(k==null?void 0:k.title)||"Video Preview"}),e.jsx(Wr,{children:(k==null?void 0:k.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wi,{className:"h-3 w-3"}),ke(k.contact_id)]})})]}),k&&e.jsxs("div",{className:"space-y-4",children:[k.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(bs,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(!1),n()},children:[e.jsx(Wo,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:k.playback_url?(()=>{let Vt=k.playback_url;return Vt.includes("iframe.mediadelivery.net/play/")&&(Vt=Vt.replace("/play/","/embed/"),Vt+=(Vt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Vt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Vt,title:k.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:k.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:k.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>me.error("Video preview failed to load")},k.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(Cn,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>rt(k),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(K,{variant:"outline",onClick:()=>He(k),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>tt(Ae(k),"Share link"),children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ue(k),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ze(k),children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),Je(k)},children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),oe(!0)},children:[e.jsx(Bl,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(k==null?void 0:k.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{L(!1),ge(!0)},children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{L(!1),O(!0)},children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(xs,{open:P,onOpenChange:O,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Delete Video"}),e.jsx(Wr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:et,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(zjs,{open:$,onOpenChange:U}),e.jsx(xs,{open:B,onOpenChange:V,children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Embed Video"}),e.jsx(Wr,{children:"Copy this code to embed the video on your website."})]}),k&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Embed Code"}),e.jsx(Pr,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{className:"flex-1",onClick:()=>{const Vt=``;tt(Vt,"Embed code")},children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this code into your website's HTML where you want the video to appear. The video will automatically resize to fit its container."})]})]})}),k&&e.jsx(Nlt,{open:re,onOpenChange:oe,video:k,contactName:ke(k.contact_id)}),k&&e.jsx(Gjs,{open:fe,onOpenChange:ge,video:k,gmailEmail:u,signedThumbnailUrl:(Dt=Me[k.id])==null?void 0:Dt.thumbnailUrl}),e.jsx(xs,{open:ue,onOpenChange:xe,children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Rename Video"}),e.jsx(Wr,{children:"Enter a new title for this video."})]}),e.jsx(ze,{value:_e,onChange:Vt=>$e(Vt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Vt=>{Vt.key==="Enter"&&_e.trim()&&i.mutate({id:k.id,title:_e.trim()},{onSuccess:()=>{me.success("Video renamed"),xe(!1)}})}}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>xe(!1),children:"Cancel"}),e.jsx(K,{disabled:!_e.trim()||i.isPending,onClick:()=>{i.mutate({id:k.id,title:_e.trim()},{onSuccess:()=>{me.success("Video renamed"),xe(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(xs,{open:X,onOpenChange:Y,children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(en,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Wr,{children:"Copy this HTML code and paste it into your CRM's email editor. It uses a simple image + link format that works in all CRM email programs."})]}),ce?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):ee?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"CRM Email HTML"}),e.jsx(Pr,{readOnly:!0,rows:12,value:ee,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{tt(ee,"CRM embed code")},children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy CRM Embed Code"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this into your CRM's email HTML editor. The recipient will see the video thumbnail and can click to watch. Works with Follow Up Boss, KvCORE, BoomTown, Sierra, and more."})]}):null]})})]})]})})}function eNs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=N.useMemo(()=>{if(!r)return t;const i=r.toLowerCase();return t.filter(c=>(c.title||"").toLowerCase().includes(i)||(c.owner_name||"").toLowerCase().includes(i)||(c.recipient_name||"").toLowerCase().includes(i))},[t,r]),o=N.useMemo(()=>{const i=new Map;return a.forEach(c=>{const u=i.get(c.owner_user_id);u?u.videos.push(c):i.set(c.owner_user_id,{name:c.owner_name,avatar:c.owner_avatar_url,videos:[c]})}),Array.from(i.entries())},[a]),l=i=>{if(!i)return"0:00";const c=Math.floor(i/60),u=i%60;return`${c}:${u.toString().padStart(2,"0")}`};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,c])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(kn,{className:"h-7 w-7",children:[e.jsx(Ua,{src:c.avatar||""}),e.jsx(Sn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(st,{variant:"secondary",className:"text-xs",children:c.videos.length})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.videos.map(u=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[u.thumbnail_url?e.jsx("img",{src:u.thumbnail_url,alt:u.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:p=>{p.target.style.display="none"}}):e.jsx(Cn,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wi,{className:"h-3 w-3"}),u.recipient_name]}),u.view_count!=null&&u.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const tNs=()=>{const{user:t}=Os();return mt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},Sze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function sNs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=tNs(),[a,o]=N.useState(""),[l,i]=N.useState("all"),c=N.useMemo(()=>{if(!r)return new Map;const _=new Map;let w=0;return r.forEach(j=>{_.has(j.owner_user_id)||(_.set(j.owner_user_id,{name:j.owner_name||"Unknown",avatar:j.owner_avatar_url,color:Sze[w%Sze.length]}),w++)}),_},[r]),u=N.useMemo(()=>Array.from(c.entries()).map(([_,w])=>({id:_,...w})),[c]),p=N.useMemo(()=>{if(!r)return[];let _=r;if(l!=="all"&&(_=_.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();_=_.filter(j=>{var k,S,M,L;return j.deal_name.toLowerCase().includes(w)||((k=j.contact_name)==null?void 0:k.toLowerCase().includes(w))||((S=j.property_address)==null?void 0:S.toLowerCase().includes(w))||((M=j.city)==null?void 0:M.toLowerCase().includes(w))||((L=j.owner_name)==null?void 0:L.toLowerCase().includes(w))})}return _},[r,a,l]),f=N.useMemo(()=>{const _=new Map;return p.forEach(w=>{const j=w.stage_name||"Unknown";_.has(j)||_.set(j,{name:j,color:w.stage_color,icon:w.stage_icon,deals:[],totalValue:0});const k=_.get(j);k.deals.push(w),k.totalValue+=w.sale_price||0}),Array.from(_.values())},[p]),g=_=>_>=1e6?`$${(_/1e6).toFixed(1)}M`:_>=1e3?`$${(_/1e3).toFixed(0)}K`:`$${_.toFixed(0)}`,v=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):null;return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals...",value:a,onChange:_=>o(_.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"All Members"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Members"}),u.map(_=>e.jsx(Mt,{value:_.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:_.color}}),_.name]})},_.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(_=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:_.color}}),_.name.split(" ")[0]]},_.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(_=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(vs,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(vs,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(vs,{className:"h-24 w-full rounded-lg"})]},_))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(_=>{const w=_.icon&&M2e[_.icon]||wd;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:_.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:_.color?`${_.color}20`:void 0},children:e.jsx(w,{className:"h-3.5 w-3.5",style:{color:_.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:_.name})]}),e.jsx(st,{variant:"secondary",className:"text-xs px-2",children:_.deals.length})]}),_.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:g(_.totalValue)})]}),e.jsx(Ki,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:_.deals.map(j=>{const k=c.get(j.owner_user_id);return e.jsx(rNs,{deal:j,ownerColor:(k==null?void 0:k.color)||"#888",ownerName:(k==null?void 0:k.name)||"Unknown",ownerAvatar:(k==null?void 0:k.avatar)||null,formatPrice:v},j.id)})})})]},_.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function rNs({deal:t,ownerColor:s,ownerName:r,ownerAvatar:n,formatPrice:a}){const o={buyer:{label:"Buyer",className:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",className:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",className:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",className:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",className:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},l=t.deal_type?o[t.deal_type]:null;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 space-y-2 transition-all hover:shadow-sm",style:{borderLeftWidth:4,borderLeftColor:s},children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(kn,{className:"h-4 w-4",children:[e.jsx(Ua,{src:n||""}),e.jsx(Sn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(st,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",l.className),children:l.label})]}),t.contact_name&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.contact_name}),(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(dn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.sale_price&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(hl,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function nNs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:It("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(hr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(Xo,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary text-primary-foreground rounded-full w-4 h-4 flex items-center justify-center",children:o})]})}),n?e.jsxs(Ki,{className:"flex-1 p-2",children:[e.jsx("div",{className:"space-y-1",children:t.map(l=>{const i=s.has(l.id);return e.jsxs("button",{onClick:()=>r(l.id),className:It("w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left transition-colors",i?"bg-primary/10 hover:bg-primary/15":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"relative",children:[e.jsxs(kn,{className:"h-7 w-7",children:[e.jsx(Ua,{src:l.avatar_url||""}),e.jsx(Sn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),e.jsx("span",{className:It("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(qr,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick:c=>c.stopPropagation()})]},l.id)})}),t.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[t.slice(0,5).map(l=>{const i=s.has(l.id);return e.jsx("button",{onClick:()=>r(l.id),className:"relative",title:l.name,children:e.jsxs(kn,{className:It("h-7 w-7 transition-all",i?"ring-2 ring-offset-1 ring-offset-background":"opacity-50"),style:i?{"--tw-ring-color":l.color}:{},children:[e.jsx(Ua,{src:l.avatar_url||""}),e.jsx(Sn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]})},l.id)}),t.length>5&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",t.length-5]})]})]})}const Cze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function aNs(){const t=ri(),{data:s}=Ux(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=mt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await H.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:c,error:u}=await H.from("profiles").select("id, name, avatar_url").in("id",i);if(u)throw u;return(c||[]).map((p,f)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:Cze[f%Cze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function iNs(t){return mt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await H.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function klt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=N.useState(!1),l=t.find(c=>c.id===s),i=c=>{c.id!==s&&r(c.id,c.name),o(!1)};return e.jsxs(ou,{open:a,onOpenChange:o,children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:c=>c.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(oa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Bd,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&M2e[c.icon]||wd,p=c.id===s;return e.jsxs(Aa,{onClick:()=>i(c),className:It("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${c.color}20`},children:e.jsx(u,{className:"h-3 w-3",style:{color:c.color}})}),e.jsx("span",{className:"flex-1",children:c.name}),p&&e.jsx(ba,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const oNs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},lNs={low:{color:"bg-slate-100 text-slate-600",dot:"bg-slate-400"},medium:{color:"bg-amber-100 text-amber-700",dot:"bg-amber-500"},high:{color:"bg-orange-100 text-orange-700",dot:"bg-orange-500"},urgent:{color:"bg-red-100 text-red-700",dot:"bg-red-500"}};function Slt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,M;const c=DE(),u=oNs[t.deal_type],p=lNs[t.priority],f=N.useMemo(()=>t.target_close_date?cy(Rl(t.target_close_date),new Date):null,[t.target_close_date]),g=f!==null&&f<0,v=f!==null&&f<=7&&f>=0,_=N.useMemo(()=>{var O;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const L=((O=t.listing)==null?void 0:O.created_at)||t.listing_date;if(!L)return null;const P=t.contract_date?Rl(t.contract_date):new Date;return cy(P,Rl(L))},[t]),w=l&&!t.scorecard_transaction_id,j=!!t.scorecard_transaction_id,k=L=>L?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L):null;return e.jsx(Ee,{className:It("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",g&&"border-red-200 bg-red-50/30",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(kn,{className:"h-4 w-4",children:[e.jsx(Ua,{src:i.avatar_url||""}),e.jsx(Sn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(st,{variant:"outline",className:It("text-[10px] px-1.5 py-0 shrink-0",u.color),children:u.label})]}),t.contact&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(kn,{className:"h-5 w-5",children:e.jsxs(Sn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(M=t.contact.last_name)==null?void 0:M[0]]})}),e.jsxs("span",{className:"truncate",children:[t.contact.first_name," ",t.contact.last_name]})]}),t.listing&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(ml,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(vo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),j&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(sa,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),_!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(uL,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:It("font-medium",_>90?"text-red-600":_>60?"text-amber-600":"text-muted-foreground"),children:[_," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(dn,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property_address||`${t.city}, ${t.state}`})]}),t.expected_price&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(hl,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:k(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",k(t.expected_commission)," GCI"]}),(()=>{const L=bx(t);return L!==null&&L!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",k(L)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:It("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:It("w-1.5 h-1.5 rounded-full",p.dot)}),e.jsx("span",{className:"capitalize",children:t.priority})]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.probability,"%"]})]}),o&&c&&n&&a?e.jsx(klt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(L,P)=>a(t.id,L,P)}):t.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-[10px]",g&&"text-red-600",v&&!g&&"text-amber-600",!g&&!v&&"text-muted-foreground"),children:[g?e.jsx(Cl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),e.jsx("span",{children:g?`${Math.abs(f)}d overdue`:v?`${f}d left`:ms(Rl(t.target_close_date),"MMM d")})]}):null]})]})})}function cNs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const p=N.useRef(null),f=s.reduce((j,k)=>j+(k.expected_price||0),0),g=s.reduce((j,k)=>j+(k.expected_commission||0),0),v=s.reduce((j,k)=>j+(bx(k)||0),0),_=j=>j>=1e6?`$${(j/1e6).toFixed(1)}M`:j>=1e3?`$${(j/1e3).toFixed(0)}K`:`$${j.toFixed(0)}`,w=t.icon&&M2e[t.icon]||wd;return e.jsxs("div",{ref:p,className:It("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:j=>o(j,t.id),onDrop:j=>l(j,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(w,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(st,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:_(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[_(g)," GCI"]}),v>0&&v!==g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[_(v)," Net"]})]})]})]}),e.jsx(Ki,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(j=>e.jsx("div",{draggable:!0,onDragStart:k=>{k.dataTransfer.effectAllowed="move",a(j.id,t.id)},children:e.jsx(Slt,{deal:j,onClick:()=>r(j),isWonStage:c,ownerInfo:(u==null?void 0:u(j))||null})},j.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function dNs({stats:t,isLoading:s}){const r=a=>a>=1e6?`$${(a/1e6).toFixed(1)}M`:a>=1e3?`$${(a/1e3).toFixed(0)}K`:`$${a.toLocaleString()}`,n=[{label:"Active Deals",value:(t==null?void 0:t.activeDeals)||0,icon:zm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:FL,color:"text-indigo-500",bgColor:"bg-indigo-500/10",tooltip:"GCI adjusted by each deal's win probability"},{label:"Weighted Net",value:r((t==null?void 0:t.weightedNet)||0),icon:YL,color:"text-teal-500",bgColor:"bg-teal-500/10",tooltip:"Net to Agent adjusted by each deal's win probability"},{label:"YTD Closed Net",value:r((t==null?void 0:t.ytdWonNet)||0),icon:dL,color:"text-green-500",bgColor:"bg-green-500/10",subtitle:`${(t==null?void 0:t.ytdWonDeals)||0} deals`,tooltip:"Net commission from deals closed this year"},{label:"Projected Annual",value:r((t==null?void 0:t.projectedAnnualNet)||0),icon:Jo,color:"text-amber-500",bgColor:"bg-amber-500/10",tooltip:"YTD Closed Net + Weighted Active Net"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4,5].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(G1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:It("h-5 w-5",a.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),e.jsx("p",{className:"text-xl font-bold",children:a.value}),"subtitle"in a&&a.subtitle&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a.subtitle})]})]})})},a.label);return"tooltip"in a&&a.tooltip?e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:o}),e.jsx(ec,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function uNs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Os(),[a,o]=N.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(st,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(vf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(bf,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(st,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(oo,{className:It("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(_f,{children:e.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Enable Client Portal"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),e.jsx(qr,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(ANe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(nle,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Eh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:It("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[e.jsx(nle,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ru,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Public"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Shareable link"})]})]})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(Oo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(be,{htmlFor:"require_onboarding",className:"text-sm font-medium cursor-pointer",children:"Require client onboarding before portal access"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Client confirms contact details + preferences before viewing portal. Info is saved to your contacts."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(be,{htmlFor:"allow_spouse",className:"text-sm cursor-pointer",children:"Allow client to add spouse/partner during onboarding"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Invite Details"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(ze,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(ze,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(ze,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Ks,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"email",children:"Email"}),e.jsxs(Mt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const hNs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],mNs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function pNs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=nme(),{data:o}=Wm(),{data:l}=gQe(),i=Iue(),c=yit(),u=vit(),p=_Se(),[f,g]=N.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!1),[M,L]=N.useState({first_name:"",last_name:"",email:"",phone:""}),P=(l==null?void 0:l.filter(ee=>((r==null?void 0:r.listing_id)===ee.id,!0)))||[],[O,$]=N.useState({deal_name:"",deal_type:"buyer",stage_id:"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""});N.useEffect(()=>{var ee,Q,ce,ne,re,oe,fe,ge;t&&(r?($({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((ee=r.expected_price)==null?void 0:ee.toString())||"",commission_percentage:((Q=r.commission_percentage)==null?void 0:Q.toString())||"3",brokerage_split_pct:((ce=r.brokerage_split_pct)==null?void 0:ce.toString())||"",team_split_pct:((ne=r.team_split_pct)==null?void 0:ne.toString())||"",referral_fee_pct:((re=r.referral_fee_pct)==null?void 0:re.toString())||"",franchise_fee_pct:((oe=r.franchise_fee_pct)==null?void 0:oe.toString())||"",transaction_fee:((fe=r.transaction_fee)==null?void 0:fe.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Rl(r.target_close_date):void 0,contract_date:r.contract_date?Rl(r.contract_date):void 0,listing_date:r.listing_date?Rl(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&_(`${r.contact.first_name} ${r.contact.last_name}`)):($({deal_name:"",deal_type:"buyer",stage_id:n||((ge=a==null?void 0:a[0])==null?void 0:ge.id)||"",contact_id:"",listing_id:"",property_address:"",city:"",state:"",zip_code:"",expected_price:"",commission_percentage:"3",brokerage_split_pct:"",team_split_pct:"",referral_fee_pct:"",franchise_fee_pct:"",transaction_fee:"",commission_calc_method:"standard",target_close_date:void 0,contract_date:void 0,listing_date:void 0,priority:"medium",probability:"50",notes:""}),_(""),g({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const U=o==null?void 0:o.filter(ee=>{var ce,ne,re;const Q=v.toLowerCase();return((ce=ee.first_name)==null?void 0:ce.toLowerCase().includes(Q))||((ne=ee.last_name)==null?void 0:ne.toLowerCase().includes(Q))||((re=ee.email)==null?void 0:re.toLowerCase().includes(Q))}).slice(0,5),B=()=>{const ee=parseFloat(O.expected_price)||0,Q=parseFloat(O.commission_percentage)||0;return ee*(Q/100)},V=()=>{const ee=B();if(!ee)return null;const Q=parseFloat(O.brokerage_split_pct)||0,ce=parseFloat(O.team_split_pct)||0,ne=parseFloat(O.referral_fee_pct)||0,re=parseFloat(O.franchise_fee_pct)||0,oe=parseFloat(O.transaction_fee)||0;if(O.commission_calc_method==="referral_first"){let ge=ee;ne&&(ge-=ee*ne/100);let ue=ge;return Q&&(ue-=ge*Q/100),ce&&(ue-=ee*ce/100),re&&(ue-=ee*re/100),oe&&(ue-=oe),Math.max(0,ue)}let fe=ee;return Q&&(fe=fe*((100-Q)/100)),ce&&(fe=fe*((100-ce)/100)),ne&&(fe=fe-ee*ne/100),re&&(fe=fe-ee*re/100),oe&&(fe=fe-oe),Math.max(0,fe)},X=async ee=>{var Q,ce,ne;if(ee.preventDefault(),!O.deal_name.trim()){me.error("Please enter a deal name");return}try{const re={deal_name:O.deal_name,deal_type:O.deal_type,stage_id:O.stage_id||null,contact_id:O.contact_id||null,listing_id:O.listing_id||null,property_address:O.property_address||null,city:O.city||null,state:O.state||null,zip_code:O.zip_code||null,expected_price:O.expected_price?parseFloat(O.expected_price):null,expected_commission:B()||null,commission_percentage:O.commission_percentage?parseFloat(O.commission_percentage):3,brokerage_split_pct:O.brokerage_split_pct?parseFloat(O.brokerage_split_pct):null,team_split_pct:O.team_split_pct?parseFloat(O.team_split_pct):null,referral_fee_pct:O.referral_fee_pct?parseFloat(O.referral_fee_pct):null,franchise_fee_pct:O.franchise_fee_pct?parseFloat(O.franchise_fee_pct):null,transaction_fee:O.transaction_fee?parseFloat(O.transaction_fee):null,commission_calc_method:O.commission_calc_method,target_close_date:((Q=O.target_close_date)==null?void 0:Q.toISOString().split("T")[0])||null,contract_date:((ce=O.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ne=O.listing_date)==null?void 0:ne.toISOString().split("T")[0])||null,priority:O.priority,probability:parseInt(O.probability)||50,notes:O.notes||null};if(r)await u.mutateAsync({id:r.id,...re}),me.success("Deal updated successfully");else{const oe=await c.mutateAsync(re);if(me.success("Deal created successfully"),f.portal_enabled&&(oe!=null&&oe.id))try{await p.mutateAsync({deal_id:oe.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),me.success("Client portal created!")}catch{me.error("Deal created, but portal setup failed")}}s(!1)}catch{me.error("Failed to save deal")}},Y=c.isPending||u.isPending;return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Wr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:X,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(be,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(ze,{id:"deal_name",value:O.deal_name,onChange:ee=>$(Q=>({...Q,deal_name:ee.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Deal Type"}),e.jsxs(Ks,{value:O.deal_type,onValueChange:ee=>$(Q=>({...Q,deal_type:ee})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:hNs.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Stage"}),e.jsxs(Ks,{value:O.stage_id||"none",onValueChange:ee=>$(Q=>({...Q,stage_id:ee==="none"?"":ee})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select stage"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:ee.color}}),ee.name]})},ee.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:v,onChange:ee=>{_(ee.target.value),j(!0),S(!1),ee.target.value||$(Q=>({...Q,contact_id:""}))},onFocus:()=>j(!0),placeholder:"Search contacts...",className:"pl-9"}),w&&v&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[U&&U.length>0?U.map(ee=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{$(Q=>({...Q,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name}`),j(!1)},children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[ee.first_name," ",ee.last_name]}),ee.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:ee.email})]},ee.id)):e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"No contacts found"}),e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2 border-t text-primary font-medium",onClick:()=>{const ee=v.trim().split(/\s+/);L({first_name:ee[0]||"",last_name:ee.slice(1).join(" ")||"",email:"",phone:""}),S(!0),j(!1)},children:[e.jsx(El,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',v.trim(),'"']})]})]})]}),k&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(El,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>S(!1),children:"Cancel"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{placeholder:"First name *",value:M.first_name,onChange:ee=>L(Q=>({...Q,first_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Last name",value:M.last_name,onChange:ee=>L(Q=>({...Q,last_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Email",type:"email",value:M.email,onChange:ee=>L(Q=>({...Q,email:ee.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Phone",type:"tel",value:M.phone,onChange:ee=>L(Q=>({...Q,phone:ee.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!M.first_name.trim()||i.isPending,onClick:async()=>{try{const ee=await i.mutateAsync({first_name:M.first_name.trim(),last_name:M.last_name.trim()||null,email:M.email.trim()||null,phone:M.phone.trim()||null});ee&&($(Q=>({...Q,contact_id:ee.id})),_(`${ee.first_name} ${ee.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(El,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),P.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx(ml,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(Ks,{value:O.listing_id||"none",onValueChange:ee=>{const Q=ee==="none"?"":ee,ce=P.find(ne=>ne.id===Q);$(ce?ne=>{var re;return{...ne,listing_id:Q,deal_type:"seller",property_address:ce.property_address||ne.property_address,city:ce.city||ne.city,state:ce.state||ne.state,expected_price:((re=ce.price)==null?void 0:re.toString())||ne.expected_price}}:ne=>({...ne,listing_id:Q}))},children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"None"}),P.map(ee=>e.jsx(Mt,{value:ee.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:ee.property_address||`${ee.city}, ${ee.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(ee.price/1e3).toFixed(0),"K"]})]})},ee.id))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes will sync automatically between the deal and listing."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Property Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(be,{htmlFor:"property_address",children:"Address"}),e.jsx(ze,{id:"property_address",value:O.property_address,onChange:ee=>$(Q=>({...Q,property_address:ee.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:O.city,onChange:ee=>$(Q=>({...Q,city:ee.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:O.state,onChange:ee=>$(Q=>({...Q,state:ee.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(ze,{id:"zip_code",value:O.zip_code,onChange:ee=>$(Q=>({...Q,zip_code:ee.target.value}))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"expected_price",children:"Expected Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(ze,{id:"expected_price",type:"number",value:O.expected_price,onChange:ee=>$(Q=>({...Q,expected_price:ee.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"commission_percentage",type:"number",step:"0.1",value:O.commission_percentage,onChange:ee=>$(Q=>({...Q,commission_percentage:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Expected GCI"}),e.jsx(ze,{value:B()?`$${B().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-muted/50",children:[e.jsx(be,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Ks,{value:O.commission_calc_method,onValueChange:ee=>$(Q=>({...Q,commission_calc_method:ee})),children:[e.jsx(Gs,{className:"h-7 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(Mt,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),O.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.brokerage_split_pct,onChange:ee=>$(Q=>({...Q,brokerage_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"30"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to brokerage"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.team_split_pct,onChange:ee=>$(Q=>({...Q,team_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to team lead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.referral_fee_pct,onChange:ee=>$(Q=>({...Q,referral_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:O.franchise_fee_pct,onChange:ee=>$(Q=>({...Q,franchise_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Transaction Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"$"}),e.jsx(ze,{type:"number",step:"1",min:"0",value:O.transaction_fee,onChange:ee=>$(Q=>({...Q,transaction_fee:ee.target.value})),className:"pl-7 h-8 text-sm",placeholder:"500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flat fee deducted"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Net to Agent"}),e.jsx(ze,{value:V()?`$${Math.round(V()).toLocaleString()}`:"-",disabled:!0,className:"bg-muted h-8 text-sm font-semibold"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Target Close Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.target_close_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.target_close_date?ms(O.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:O.target_close_date,onSelect:ee=>$(Q=>({...Q,target_close_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Contract Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.contract_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.contract_date?ms(O.contract_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:O.contract_date,onSelect:ee=>$(Q=>({...Q,contract_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(O.deal_type==="seller"||O.deal_type==="dual")&&!O.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(be,{children:"Listing Date (for Days on Market)"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O.listing_date&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O.listing_date?ms(O.listing_date,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:O.listing_date,onSelect:ee=>$(Q=>({...Q,listing_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Priority"}),e.jsxs(Ks,{value:O.priority,onValueChange:ee=>$(Q=>({...Q,priority:ee})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:mNs.map(ee=>e.jsx(Mt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"0",max:"100",value:O.probability,onChange:ee=>$(Q=>({...Q,probability:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Pr,{id:"notes",value:O.notes,onChange:ee=>$(Q=>({...Q,notes:ee.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(uNs,{formData:f,onChange:g}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:Y,children:[Y&&e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function fNs({dealId:t}){const s=ri(),r=Xt(),[n,a]=N.useState(""),[o,l]=N.useState(!1),{data:i=[]}=mt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:_,error:w}=await H.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(w)throw w;return _},enabled:!!t}),{data:c=[]}=mt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:_,error:w}=await H.from("deal_tags").select("tag").eq("owner_user_id",s);if(w)throw w;return[...new Set(_.map(k=>k.tag))].sort()},enabled:!!s}),u=Lt({mutationFn:async _=>{if(!s)throw new Error("Not authenticated");const{error:w}=await H.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:_.trim()});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Lt({mutationFn:async _=>{const{error:w}=await H.from("deal_tags").delete().eq("id",_);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const _=n.trim();_&&(i.some(w=>w.tag.toLowerCase()===_.toLowerCase())||u.mutate(_))},g=i.map(_=>_.tag.toLowerCase()),v=c.filter(_=>_.toLowerCase().includes(n.toLowerCase())&&!g.includes(_.toLowerCase())).slice(0,5);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[i.map(_=>e.jsxs(st,{variant:"secondary",className:"gap-1 text-xs",children:[_.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(_.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Mr,{className:"h-3 w-3"})})]},_.id)),!o&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground px-2 py-0.5 rounded border border-dashed border-border hover:border-primary transition-colors",children:[e.jsx(qs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(ze,{value:n,onChange:_=>a(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),f()),_.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag and press Enter...",className:"h-7 text-xs",autoFocus:!0,onBlur:()=>{n.trim()||l(!1)}}),n&&v.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded shadow-lg max-h-32 overflow-y-auto",children:v.map(_=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:w=>{w.preventDefault(),u.mutate(_)},children:_},_))})]})]})}function xNs(t){return mt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function gNs(){const t=ri(),s=Xt();return Lt({mutationFn:async({dealId:r,file:n})=>{if(!t)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${t}/${r}/${crypto.randomUUID()}.${a}`,{error:l}=await H.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:c}=await H.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(c)throw c;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function yNs(){const t=Xt();return Lt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await H.storage.from("deal-files").remove([r]);const{error:a}=await H.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function vNs(){const t=Xt();return Lt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await H.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function bNs(t){const{data:s,error:r}=await H.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const Mze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function _Ns({open:t,onOpenChange:s}){const{data:r,isLoading:n}=I_s(),a=L_s(),o=D_s(),l=O_s(),[i,c]=N.useState(!1),[u,p]=N.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,g]=N.useState(""),v=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),g(""),c(!1),me.success("Question added")}catch{me.error("Failed to add question")}},_=async S=>{try{await l.mutateAsync(S),me.success("Question removed")}catch{me.error("Failed to remove question")}},w=async(S,M)=>{try{await o.mutateAsync({id:S,is_required:M})}catch{me.error("Failed to update question")}},j=()=>{f.trim()&&(p(S=>({...S,options:[...S.options,f.trim()]})),g(""))},k=S=>{p(M=>({...M,options:M.options.filter((L,P)=>P!==S)}))};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(Ki,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3 pr-2",children:[n&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var M;return e.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"secondary",className:"text-xs",children:Mze[S.field_type]||S.field_type}),S.is_required&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((M=S.options)==null?void 0:M.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",S.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(qr,{checked:S.is_required,onCheckedChange:L=>w(S.id,L),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>_(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Question"}),e.jsx(ze,{value:u.question_text,onChange:S=>p(M=>({...M,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(Mze).map(([S,M])=>e.jsx("button",{type:"button",onClick:()=>p(L=>({...L,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:M},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>k(M),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]},M)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:f,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),j()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:j,disabled:!f.trim(),className:"h-8",children:e.jsx(qs,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:u.is_required,onCheckedChange:S=>p(M=>({...M,is_required:S}))}),e.jsx(be,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>c(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:v,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(bs,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),e.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?e.jsx("div",{}):e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function wNs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=N.useState(""),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:_,error:w}=await H.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(w)throw w;return _},enabled:i||!!n}),f=N.useMemo(()=>!n||!u?null:u.find(_=>_.id===n),[n,u]),g=N.useMemo(()=>!u||!r?[]:u.filter(_=>{var w;return((w=_.client_email)==null?void 0:w.toLowerCase())===r.toLowerCase()&&_.id!==t}),[u,r,t]),v=N.useMemo(()=>{if(!u||!o.trim())return[];const _=o.toLowerCase();return u.filter(w=>{var k,S,M,L;const j=w.deal_pipeline;return((k=w.client_name)==null?void 0:k.toLowerCase().includes(_))||((S=w.client_email)==null?void 0:S.toLowerCase().includes(_))||((M=j==null?void 0:j.deal_name)==null?void 0:M.toLowerCase().includes(_))||((L=j==null?void 0:j.property_address)==null?void 0:L.toLowerCase().includes(_))})},[u,o]);if(n){const _=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Linked Portal"}),e.jsxs("div",{className:"flex items-center gap-2 bg-primary/5 border border-primary/20 rounded-lg p-3",children:[e.jsx(ml,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(_==null?void 0:_.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(_==null?void 0:_.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(_==null?void 0:_.property_address)||"No address"]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(jS,{className:"h-3 w-3 mr-1"}),"Unlink"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Client will see both transactions in a tabbed view on one portal link."})]})}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>c(!i),children:[e.jsx(ml,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&g.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground font-medium",children:"✨ Suggested match (same client email)"}),g.map(_=>{const w=_.deal_pipeline;return e.jsxs("button",{onClick:()=>a(_.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w==null?void 0:w.property_address})]}),e.jsx(ml,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},_.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:o,onChange:_=>l(_.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),v.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:v.map(_=>{const w=_.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(_.id),c(!1),l("")},className:"w-full flex items-center gap-2 border rounded-lg p-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:_.client_email})]})]},_.id)})}),o&&v.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function b3e({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=N.useState(!1),[c,u]=N.useState([]),[p,f]=N.useState(!1),[g,v]=N.useState("");N.useEffect(()=>{!l||!t||(f(!0),H.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:w})=>{u(w||[]),f(!1)}))},[l,t]);const _=c.filter(w=>!g||(w.title||w.recipient_name||"").toLowerCase().includes(g.toLowerCase()));return e.jsxs(xs,{open:l,onOpenChange:i,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(yu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(fs,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:g,onChange:w=>v(w.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(vs,{className:"h-16 w-full"}),e.jsx(vs,{className:"h-16 w-full"})]}):_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:c.length===0?"No videos in your library yet":"No videos match your search"}):_.map(w=>e.jsxs("button",{onClick:()=>{s(w.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:j=>{const k=j.currentTarget.parentElement;if(k){j.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",k.appendChild(S)}}}):e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:w.title||w.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.duration_seconds?`${Math.round(w.duration_seconds)}s`:"",w.created_at?` · ${new Date(w.created_at).toLocaleDateString()}`:""]})]})]},w.id))})]})]})}function _3e({contactId:t,onVideoReady:s}){const[r,n]=N.useState(!1),[a,o]=N.useState("record"),[l,i]=N.useState(0),[c,u]=N.useState(0),p=L3(),f=()=>{o("record"),i(0),u(0)},g=_=>{!_&&(a==="uploading"||a==="processing")||(n(_),_||f())},v=N.useCallback(async(_,w)=>{o("uploading");try{const j="Card Video",{videoId:k,libraryId:S}=await SR(j),{uploadUrl:M,apiKey:L}=await CR(k),P=new XMLHttpRequest;P.upload.onprogress=Y=>{Y.lengthComputable&&i(Y.loaded/Y.total*100)},await new Promise((Y,ee)=>{P.onload=()=>P.status>=200&&P.status<300?Y():ee(new Error("Upload failed")),P.onerror=()=>ee(new Error("Upload failed")),P.open("PUT",M),P.setRequestHeader("AccessKey",L),P.send(_)}),o("processing");let O=0;const $=Date.now(),U=9e4,B=`https://iframe.mediadelivery.net/embed/${S}/${k}`;for(;O<4;){if(await new Promise(ee=>setTimeout(ee,3e3)),Date.now()-$>U){const ee=_.size/1048576;await p.mutateAsync({bunny_video_id:k,playback_url:`https://iframe.mediadelivery.net/play/${S}/${k}`,file_size_mb:ee,title:j,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(B),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const Y=await AA(k);if(O=Y.status,u(Y.encodeProgress||0),O===5||O===6)throw new Error("Video processing failed")}const V=await AA(k),X=(V.storageSize||_.size)/(1024*1024);await p.mutateAsync({bunny_video_id:k,contact_id:t||void 0,playback_url:V.directPlayUrl||B,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||w,file_size_mb:X,title:j,status:"ready",touch_type:"video"}),s(B),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(j){console.error("Recording upload error:",j),me.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(xs,{open:r,onOpenChange:g,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(fs,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(Tme,{maxDurationSeconds:300,onRecordingComplete:v,onError:_=>me.error(_)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(bs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Bi,{value:l,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(bs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Bi,{value:c,className:"w-64"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(c),"%"]})]}),a==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(gi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}const jNs=t=>`portal-settings-draft:${t}`;function Clt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=MR(),[o,l]=N.useState(!1),i=N.useMemo(()=>jNs(r.id),[r.id]),[c,u]=N.useState(!1),[p,f]=N.useState(r.next_step_text||""),[g,v]=N.useState(r.next_step_video_url||""),[_,w]=N.useState(r.inspection_date||""),[j,k]=N.useState(r.appraisal_date||""),[S,M]=N.useState(r.welcome_message||""),[L,P]=N.useState(r.review_url||""),[O,$]=N.useState(r.show_post_close_tips),[U,B]=N.useState(r.notify_client),[V,X]=N.useState(r.require_onboarding),[Y,ee]=N.useState(r.allow_spouse),[Q,ce]=N.useState(r.visibility),[ne,re]=N.useState(r.stage_mapping||[]),[oe,fe]=N.useState(null),[ge,ue]=N.useState(r.linked_portal_id||null),xe=()=>{f(r.next_step_text||""),v(r.next_step_video_url||""),w(r.inspection_date||""),k(r.appraisal_date||""),M(r.welcome_message||""),P(r.review_url||""),$(r.show_post_close_tips),B(r.notify_client),X(r.require_onboarding),ee(r.allow_spouse),ce(r.visibility),re(r.stage_mapping||[]),ue(r.linked_portal_id||null)};N.useEffect(()=>{u(!1);const we=localStorage.getItem(i);if(we)try{const Le=JSON.parse(we);f(Le.nextStepText||""),v(Le.nextStepVideo||""),w(Le.inspectionDate||""),k(Le.appraisalDate||""),M(Le.welcomeMessage||""),P(Le.reviewUrl||""),$(!!Le.showPostClose),B(!!Le.notifyClient),X(!!Le.requireOnboarding),ee(!!Le.allowSpouse),ce(Le.visibility||r.visibility),re(Le.stageMapping||[]),ue(Le.linkedPortalId??null),u(!0);return}catch{localStorage.removeItem(i)}xe(),u(!0)},[i,r]),N.useEffect(()=>{if(!c)return;const we={nextStepText:p,nextStepVideo:g,inspectionDate:_,appraisalDate:j,welcomeMessage:S,reviewUrl:L,showPostClose:O,notifyClient:U,requireOnboarding:V,allowSpouse:Y,visibility:Q,stageMapping:ne,linkedPortalId:ge};p!==(r.next_step_text||"")||g!==(r.next_step_video_url||"")||_!==(r.inspection_date||"")||j!==(r.appraisal_date||"")||S!==(r.welcome_message||"")||L!==(r.review_url||"")||O!==r.show_post_close_tips||U!==r.notify_client||V!==r.require_onboarding||Y!==r.allow_spouse||Q!==r.visibility||JSON.stringify(ne)!==JSON.stringify(r.stage_mapping||[])||ge!==(r.linked_portal_id||null)?localStorage.setItem(i,JSON.stringify(we)):localStorage.removeItem(i)},[p,g,_,j,S,L,O,U,V,Y,Q,ne,ge,i,c,r]);const _e=()=>{localStorage.removeItem(i),xe()},$e=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:p||null,next_step_video_url:g||null,inspection_date:_||null,appraisal_date:j||null,welcome_message:S||null,review_url:L||null,show_post_close_tips:O,notify_client:U,require_onboarding:V,allow_spouse:Y,visibility:Q,stage_mapping:ne.length>0?ne:null,linked_portal_id:ge});const we=r.linked_portal_id;ge&&ge!==we&&await H.from("client_portals").update({linked_portal_id:r.id}).eq("id",ge),!ge&&we&&await H.from("client_portals").update({linked_portal_id:null}).eq("id",we),localStorage.removeItem(i),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},Me=()=>{re([...ne,{label:""}])},Ie=we=>{re(ne.filter((Le,Qe)=>Qe!==we)),oe===we&&fe(null)},ke=(we,Le,Qe)=>{const Te=[...ne];Te[we]={...Te[we],[Le]:Qe},re(Te)},pe=()=>{const Le=pNe(null).map(Qe=>({label:Qe.label,description:Qe.description,stageId:void 0}));re(Le)};return e.jsxs(e.Fragment,{children:[e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(js,{children:e.jsx(_s,{children:"Portal Settings"})}),e.jsxs(_a,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(fa,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(ns,{value:"general",children:"General"}),e.jsx(ns,{value:"timeline",children:"Timeline"}),e.jsx(ns,{value:"content",children:"Content"})]}),e.jsxs(Ki,{className:"flex-1 mt-4",children:[e.jsxs(ws,{value:"general",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Visibility"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),e.jsx("div",{className:"flex gap-1",children:["private","public"].map(we=>e.jsx("button",{onClick:()=>ce(we),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Q===we?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:we.charAt(0).toUpperCase()+we.slice(1)},we))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Require Onboarding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),e.jsx(qr,{checked:V,onCheckedChange:X})]}),V&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),e.jsx(qr,{checked:Y,onCheckedChange:ee})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Post-Close Celebration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),e.jsx(qr,{checked:O,onCheckedChange:$})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Notify Client on Updates"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email client when you post portal updates"})]}),e.jsx(qr,{checked:U,onCheckedChange:B})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(wNs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ge,onLink:ue})}),e.jsx("div",{children:e.jsx(ze,{type:"date",value:_,onChange:we=>w(we.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(ze,{type:"date",value:j,onChange:we=>k(we.target.value),className:"mt-1"})]})]}),e.jsx(ws,{value:"timeline",className:"space-y-4 mt-0 px-1",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client-Facing Stages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:pe,className:"text-xs",children:"Auto-map"})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground bg-muted/50 rounded-md p-2",children:'💡 These labels are what clients see. Click "More" on any stage to customize its description and add a video link. Internal pipeline stages are automatically translated to friendly names.'}),ne.length===0&&e.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),e.jsx(K,{variant:"outline",size:"sm",onClick:pe,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ne.map((we,Le)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(ze,{value:we.label,onChange:Qe=>ke(Le,"label",Qe.target.value),placeholder:`Stage ${Le+1} label`,className:"flex-1 h-9 text-sm"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-primary",onClick:()=>fe(oe===Le?null:Le),children:oe===Le?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>Ie(Le),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),oe===Le&&e.jsxs("div",{className:"ml-6 space-y-2 pl-2 border-l-2 border-primary/15 pb-2",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:we.description||"",onChange:Qe=>ke(Le,"description",Qe.target.value),placeholder:"e.g. Now it's time to start actively looking at homes",className:"mt-0.5 w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[50px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Video"}),we.video_url?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:we.video_url.length>40?we.video_url.slice(0,40)+"...":we.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>ke(Le,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(_3e,{onVideoReady:Qe=>ke(Le,"video_url",Qe)}),e.jsx(b3e,{userId:n,onSelect:Qe=>ke(Le,"video_url",Qe),triggerSize:"sm",triggerClassName:"gap-1.5 shrink-0 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const Qe=prompt("Paste a YouTube or Loom URL:");Qe&&ke(Le,"video_url",Qe)},children:[e.jsx(Bo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Le))}),ne.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:Me,className:"mt-2 text-xs w-full",children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(ws,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:S,onChange:we=>M(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Welcome! Here's everything you need for your transaction."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:p,onChange:we=>f(we.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"We're waiting on the inspection report..."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(ze,{value:g,onChange:we=>v(we.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Review URL"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Shown after deal closes"}),e.jsx(ze,{value:L,onChange:we=>P(we.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"ghost",onClick:_e,children:"Reset Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:$e,disabled:a.isPending,children:[a.isPending?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Uc,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})]})}),e.jsx(_Ns,{open:o,onOpenChange:l})]})}const NNs=t=>`portal-update-draft:${t}`;function Mlt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const o=N.useMemo(()=>NNs(r),[r]),[l,i]=N.useState(""),[c,u]=N.useState(""),[p,f]=N.useState(""),[g,v]=N.useState(!1),[_,w]=N.useState(a??!1),[j,k]=N.useState(!1),S=oit();N.useEffect(()=>{k(!1);const P=localStorage.getItem(o);if(P)try{const O=JSON.parse(P);i(O.title||""),u(O.content||""),f(O.videoUrl||""),v(!!O.isStageChange),w(typeof O.sendNotification=="boolean"?O.sendNotification:a??!1),k(!0);return}catch{localStorage.removeItem(o)}i(""),u(""),f(""),v(!1),w(a??!1),k(!0)},[o,a]),N.useEffect(()=>{if(!j)return;const P={title:l,content:c,videoUrl:p,isStageChange:g,sendNotification:_};l.trim()||c.trim()||p.trim()||g||_!==(a??!1)?localStorage.setItem(o,JSON.stringify(P)):localStorage.removeItem(o)},[l,c,p,g,_,j,o,a]);const M=()=>{localStorage.removeItem(o),i(""),u(""),f(""),v(!1),w(a??!1)},L=async()=>{if(l.trim())try{if(await S.mutateAsync({portal_id:r,title:l.trim(),content:c.trim()||void 0,video_url:p.trim()||void 0,is_stage_change:g}),_&&n)try{const P=k1(n);await H.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:l.trim(),update_content:c.trim()||null,portal_url:P}}),me.success("Update posted & client notified")}catch(P){console.error("Notification failed:",P),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");M(),s(!1)}catch{me.error("Failed to post update")}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Title *"}),e.jsx(ze,{value:l,onChange:P=>i(P.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:c,onChange:P=>u(P.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(ze,{value:p,onChange:P=>f(P.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(Cn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>v(!g),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${g?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>w(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(Lm,{className:"h-3 w-3"}):e.jsx(i1,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",onClick:M,children:"Clear Draft"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Close"}),e.jsxs(K,{onClick:L,disabled:!l.trim()||S.isPending,children:[S.isPending?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($n,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})]})})}function Tlt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=MR(),{isGmailConnected:o,gmailEmail:l}=Zx(),[i,c]=N.useState(r.client_name||""),[u,p]=N.useState(r.client_email||""),[f,g]=N.useState(!1),[v,_]=N.useState(!1),w=k1(r.slug),j=i.split(" ")[0]||"there",k=`Your Transaction Portal – ${n}`,S=`Hi ${j}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,M=()=>{navigator.clipboard.writeText(w),_(!0),setTimeout(()=>_(!1),2e3),me.success("Portal link copied!")},L=async()=>{if(!u.trim()){me.error("Please enter the client email");return}g(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:O}=await H.functions.invoke("gmail-send",{body:{to:u,subject:k,body:S.replace(/\n/g,"
")}});if(O)throw O;me.success(`Invite sent to ${u}`),s(!1)}catch(O){me.error(O.message||"Failed to send invite")}finally{g(!1)}},P=()=>{const O=encodeURIComponent(k),$=encodeURIComponent(S);window.open(`mailto:${u}?subject=${O}&body=${$}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(ze,{value:i,onChange:O=>c(O.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(ze,{type:"email",value:u,onChange:O=>p(O.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(K,{variant:"outline",size:"icon",onClick:M,className:"shrink-0",children:v?e.jsx(ba,{className:"h-4 w-4 text-emerald-600"}):e.jsx(yi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:L,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:P,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:M,className:"w-full text-muted-foreground",children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function kNs({deal:t}){const{isAdmin:s,user:r}=Os(),{data:n,isLoading:a}=T_s(t.id),o=_Se(),l=MR(),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState(!1),w=`portal-management-ui:${t.id}`;if(N.useEffect(()=>{const O=sessionStorage.getItem(w);if(O)try{const $=JSON.parse(O);p(!!$.settingsOpen),g(!!$.composerOpen),_(!!$.inviteOpen)}catch{sessionStorage.removeItem(w)}},[w]),N.useEffect(()=>{u||f||v?sessionStorage.setItem(w,JSON.stringify({settingsOpen:u,composerOpen:f,inviteOpen:v})):sessionStorage.removeItem(w)},[u,f,v,w]),a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(bs,{className:"h-3 w-3 animate-spin ml-auto"})]})});const j=async()=>{var O,$;c(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((O=t.contact)==null?void 0:O.email)||void 0,client_phone:(($=t.contact)==null?void 0:$.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{c(!1)}},k=async O=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:O}),me.success(O?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},S=()=>{if(!n)return;const O=k1(n.slug);navigator.clipboard.writeText(O),me.success("Portal link copied!")},M=()=>{if(!n)return;const O=k1(n.slug);window.open(O,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Create a beautiful portal so your client can track their deal progress in real-time."}),e.jsxs(K,{onClick:j,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(fn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const L=k1(n.slug),P=(r==null?void 0:r.id)||"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(st,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:k})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:L})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(yi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:M,className:"text-xs flex-1 min-w-0",children:[e.jsx(en,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx($n,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(GM,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(Qo,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(Clt,{open:u,onOpenChange:p,portal:n,dealOwnerId:P}),e.jsx(Mlt,{open:f,onOpenChange:g,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(Tlt,{open:v,onOpenChange:_,portal:n,dealName:t.deal_name})]})}const SNs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function CNs(t){return mt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await H.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function MNs(){const t=Xt();return Lt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await H.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?me.error("This contact is already linked to this deal"):me.error("Failed to link contact")}})}function TNs(){const t=Xt();return Lt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await H.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact removed from deal")},onError:()=>{me.error("Failed to remove contact")}})}function ANs({dealId:t,primaryContactId:s}){const r=nr(),{data:n,isLoading:a}=CNs(t),{data:o}=Wm(),l=MNs(),i=TNs(),[c,u]=N.useState(!1),[p,f]=N.useState(""),[g,v]=N.useState("Client"),_=new Set((n==null?void 0:n.map(M=>M.contact_id))||[]);s&&_.add(s);const w=o==null?void 0:o.filter(M=>{var P,O,$;if(_.has(M.id))return!1;if(!p.trim())return!0;const L=p.toLowerCase();return((P=M.first_name)==null?void 0:P.toLowerCase().includes(L))||((O=M.last_name)==null?void 0:O.toLowerCase().includes(L))||(($=M.email)==null?void 0:$.toLowerCase().includes(L))}).slice(0,8),j=M=>{l.mutate({dealId:t,contactId:M,role:g}),u(!1),f("")},k=M=>{i.mutate({id:M,dealId:t})},S={Client:"bg-primary/10 text-primary","Co-Buyer":"bg-blue-500/10 text-blue-600","Co-Seller":"bg-emerald-500/10 text-emerald-600",Spouse:"bg-pink-500/10 text-pink-600",Lender:"bg-amber-500/10 text-amber-600","Title Company":"bg-purple-500/10 text-purple-600",Inspector:"bg-orange-500/10 text-orange-600",Appraiser:"bg-cyan-500/10 text-cyan-600",Attorney:"bg-slate-500/10 text-slate-600",Contractor:"bg-lime-500/10 text-lime-600",Other:"bg-muted text-muted-foreground"};return!(n!=null&&n.length)&&!c?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(Ro,{className:"w-80 p-3",align:"start",children:e.jsx(Tze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:v,filteredContacts:w,onAdd:j})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})}),e.jsx(Ro,{className:"w-80 p-3",align:"end",children:e.jsx(Tze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:v,filteredContacts:w,onAdd:j})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(M=>{var L,P,O,$,U,B,V,X;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(kn,{className:"h-7 w-7",children:e.jsxs(Sn,{className:"text-[10px] bg-primary/10 text-primary",children:[(P=(L=M.contact)==null?void 0:L.first_name)==null?void 0:P[0],($=(O=M.contact)==null?void 0:O.last_name)==null?void 0:$[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${M.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(U=M.contact)==null?void 0:U.first_name," ",(B=M.contact)==null?void 0:B.last_name]})}),e.jsx(st,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[M.role]||S.Other}`,children:M.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=M.contact)==null?void 0:V.phone)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`tel:${M.contact.phone}`,children:e.jsx(Mn,{className:"h-3 w-3"})})}),((X=M.contact)==null?void 0:X.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${M.contact.email}`,children:e.jsx(lr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>k(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]},M.id)})})]})}function Tze({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Ks,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"h-8 text-sm",children:e.jsx(Ys,{placeholder:"Role"})}),e.jsx(Ws,{children:SNs.map(l=>e.jsx(Mt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ze,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Ki,{className:"max-h-40",children:a&&a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(l=>e.jsxs("button",{onClick:()=>o(l.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-accent transition-colors",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[l.first_name," ",l.last_name]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[l.phone,l.email].filter(Boolean).join(" · ")||"No contact info"})]},l.id))}):e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:t?"No contacts found":"Type to search"})})]})}const ENs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},PNs={note:so,call:Mn,email:lr,meeting:hn,stage_change:en,task_completed:sa,document:dn,system:un};function INs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var ke,pe;const{data:l,isLoading:i}=jws((t==null?void 0:t.id)||""),{data:c,isLoading:u}=kws((t==null?void 0:t.id)||""),p=Nws(),f=Cws(),g=Sws(),v=wws(),{data:_,isLoading:w}=xNs((t==null?void 0:t.id)||""),j=gNs(),k=yNs(),S=vNs(),M=N.useRef(null),[L,P]=N.useState(""),[O,$]=N.useState(""),[U,B]=N.useState(!1),[V,X]=N.useState(!1);if(!t)return null;const Y=ENs[t.deal_type],ee=(()=>{var Qe;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const we=((Qe=t.listing)==null?void 0:Qe.created_at)||t.listing_date;if(!we)return null;const Le=t.contract_date?Rl(t.contract_date):new Date;return cy(Le,Rl(we))})(),Q=we=>we?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(we):"-",ce=async()=>{if(L.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:L}),P(""),me.success("Note added")}catch{me.error("Failed to add note")}},ne=async()=>{if(O.trim())try{await f.mutateAsync({deal_id:t.id,title:O,sort_order:((c==null?void 0:c.length)||0)+1}),$(""),me.success("Task added")}catch{me.error("Failed to add task")}},re=async(we,Le)=>{try{await g.mutateAsync({id:we,is_completed:Le,deal_id:t.id})}catch{me.error("Failed to update task")}},oe=async()=>{try{await v.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},fe=(c==null?void 0:c.filter(we=>we.is_completed).length)||0,ge=(c==null?void 0:c.length)||0,ue=(_==null?void 0:_.length)||0,xe=we=>we<1024?`${we} B`:we<1024*1024?`${(we/1024).toFixed(1)} KB`:`${(we/(1024*1024)).toFixed(1)} MB`,_e=we=>we?we.startsWith("image/")?vl:we.includes("pdf")?wn:FM:FM,$e=async we=>{const Le=we.target.files;if(!(!Le||!t)){X(!0);try{for(const Qe of Array.from(Le)){if(Qe.size>20*1024*1024){me.error(`${Qe.name} exceeds 20MB limit`);continue}await j.mutateAsync({dealId:t.id,file:Qe})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{X(!1),M.current&&(M.current.value="")}}},Me=async(we,Le)=>{if(t)try{await k.mutateAsync({fileId:we,storagePath:Le,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Ie=async(we,Le)=>{try{const Qe=await bNs(we),Te=document.createElement("a");Te.href=Qe,Te.download=Le,Te.target="_blank",document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(lE,{open:s,onOpenChange:r,children:e.jsxs(S3,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(cE,{className:"p-6 pb-4 border-b shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(st,{variant:"outline",className:It("text-xs",Y.color),children:Y.label}),e.jsxs(st,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(dE,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(fNs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(md,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>B(!0),children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})}),e.jsx(Ki,{className:"flex-1",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.contact&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(kn,{className:"h-10 w-10",children:e.jsxs(Sn,{className:"bg-primary/10 text-primary",children:[(ke=t.contact.first_name)==null?void 0:ke[0],(pe=t.contact.last_name)==null?void 0:pe[0]]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"font-medium",children:[t.contact.first_name," ",t.contact.last_name]}),t.contact.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.contact.email})]}),e.jsxs("div",{className:"flex gap-2",children:[t.contact.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`tel:${t.contact.phone}`,children:e.jsx(Mn,{className:"h-4 w-4"})})}),t.contact.email&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,children:e.jsx("a",{href:`mailto:${t.contact.email}`,children:e.jsx(lr,{className:"h-4 w-4"})})})]})]}),e.jsx(ANs,{dealId:t.id,primaryContactId:t.contact_id}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(t.property_address||t.city)&&e.jsxs("div",{className:"col-span-2 flex items-start gap-2 text-sm",children:[e.jsx(dn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.property_address||"Address TBD"}),e.jsx("p",{className:"text-muted-foreground",children:[t.city,t.state,t.zip_code].filter(Boolean).join(", ")})]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),e.jsx("p",{className:"text-lg font-bold",children:Q(t.expected_price)})]}),e.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),e.jsx("p",{className:"text-lg font-bold text-emerald-600",children:Q(t.expected_commission)})]}),(t.brokerage_split_pct||t.team_split_pct||t.referral_fee_pct||t.franchise_fee_pct||t.transaction_fee)&&e.jsxs("div",{className:"col-span-2 bg-muted/30 rounded-lg p-3 space-y-1.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Commission Splits"}),t.brokerage_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Brokerage Split"}),e.jsxs("span",{children:[t.brokerage_split_pct,"%",t.expected_commission?` (${Q(t.expected_commission*t.brokerage_split_pct/100)})`:""]})]}),t.team_split_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Team Split"}),e.jsxs("span",{children:[t.team_split_pct,"%"]})]}),t.referral_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Referral Fee"}),e.jsxs("span",{children:[t.referral_fee_pct,"%"]})]}),t.franchise_fee_pct!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Franchise Fee"}),e.jsxs("span",{children:[t.franchise_fee_pct,"%"]})]}),t.transaction_fee!=null&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Transaction Fee"}),e.jsx("span",{children:Q(t.transaction_fee)})]}),t.net_commission!=null&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"border-t pt-1.5 mt-1.5",children:e.jsxs("div",{className:"flex justify-between text-sm font-semibold",children:[e.jsx("span",{children:"Net to Agent"}),e.jsx("span",{className:"text-emerald-600",children:Q(t.net_commission)})]})})})]}),o&&!t.scorecard_transaction_id&&a&&e.jsxs(K,{onClick:()=>a(t),className:"w-full bg-green-600 hover:bg-green-700",children:[e.jsx(vo,{className:"h-4 w-4 mr-2"}),"Add to Scorecard"]}),t.scorecard_transaction_id&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[e.jsx(sa,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),ee!==null&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),e.jsxs("p",{className:It("text-lg font-bold",ee>90?"text-red-600":ee>60?"text-amber-600":"text-foreground"),children:[ee," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ms(Rl(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(hl,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[t.probability,"% probability"]})]})]}),t.notes&&e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium mb-1",children:"Notes"}),e.jsx("p",{className:"text-muted-foreground",children:t.notes})]}),e.jsx(kNs,{deal:t}),e.jsxs(_a,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(fa,{className:"w-full grid grid-cols-3",children:[e.jsxs(ns,{value:"tasks",className:"gap-1",children:[e.jsx(sa,{className:"h-4 w-4"}),"Tasks ",ge>0&&`(${fe}/${ge})`]}),e.jsxs(ns,{value:"files",className:"gap-1",children:[e.jsx(gS,{className:"h-4 w-4"}),"Files ",ue>0&&`(${ue})`]}),e.jsxs(ns,{value:"activity",className:"gap-1",children:[e.jsx(un,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(ws,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add a new task...",value:O,onChange:we=>$(we.target.value),onKeyDown:we=>we.key==="Enter"&&ne()}),e.jsx(K,{onClick:ne,disabled:!O.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(we=>e.jsxs("div",{className:It("flex items-center gap-3 p-3 rounded-lg border transition-colors",we.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Oo,{checked:we.is_completed,onCheckedChange:Le=>re(we.id,!!Le)}),e.jsx("span",{className:It("flex-1 text-sm",we.is_completed&&"line-through text-muted-foreground"),children:we.title}),we.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(new Date(we.due_date),"MMM d")})]},we.id)),(c==null?void 0:c.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),e.jsxs(ws,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:M,className:"hidden",multiple:!0,onChange:$e,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var we;return(we=M.current)==null?void 0:we.click()},disabled:V,children:[V?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(di,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[_==null?void 0:_.map(we=>{const Le=_e(we.file_type);return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:e.jsx(Le,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:we.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[xe(we.file_size)," · ",ms(new Date(we.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G1,{children:e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${we.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:we.id,visible:!we.visible_on_portal,dealId:t.id}),children:we.visible_on_portal?e.jsx(Dn,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})})}),e.jsx(ec,{side:"top",children:we.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ie(we.storage_path,we.file_name),children:e.jsx(vi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Me(we.id,we.storage_path),children:e.jsx(Mr,{className:"h-4 w-4"})})]})]},we.id)}),(_==null?void 0:_.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs(ws,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Pr,{placeholder:"Add a note...",value:L,onChange:we=>P(we.target.value),rows:2}),e.jsxs(K,{onClick:ce,disabled:!L.trim(),size:"sm",className:"w-full",children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(we=>{const Le=PNs[we.activity_type]||un;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(Le,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:we.title}),we.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:we.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Vc(new Date(we.created_at),{addSuffix:!0})})]})]},we.id)}),(l==null?void 0:l.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),e.jsx(Mc,{open:U,onOpenChange:B,children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Deal?"}),e.jsxs(ic,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function LNs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=Lue(),o=vit(),{data:l}=mE(),{data:i}=Gx(),[c,u]=N.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ms(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});N.useEffect(()=>{if(r&&t){const g=r.deal_type==="seller"?"seller":"buyer",v=r.expected_price||0,_=r.commission_percentage||3,w=r.expected_commission||v*_/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:g,close_date:r.actual_close_date||r.target_close_date||ms(new Date,"yyyy-MM-dd"),sale_price:v,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async g=>{if(g.preventDefault(),!!r)try{const v=await a.mutateAsync({property_address:c.property_address,city:c.city||null,state:c.state||null,zip:c.zip||null,transaction_type:c.transaction_type,close_date:c.close_date,sale_price:c.sale_price,commission_amount:c.commission_amount||null,brokerage_split_pct:r.brokerage_split_pct||null,team_split_pct:r.team_split_pct||null,franchise_fee_pct:r.franchise_fee_pct||null,referral_fee_pct:r.referral_fee_pct||null,transaction_fee:r.transaction_fee||null,lead_source_id:c.lead_source_id||null,client_type_id:c.client_type_id||null,contact_id:r.contact_id||null,notes:c.notes||null,is_win:!0});await o.mutateAsync({id:r.id,scorecard_transaction_id:v.id,actual_close_date:c.close_date}),me.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(v){console.error("Error syncing to scorecard:",v),me.error("Failed to add to scorecard")}},f=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(g);return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(vo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(_s,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Wr,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(ze,{id:"property_address",value:c.property_address,onChange:g=>u(v=>({...v,property_address:g.target.value})),placeholder:"123 Main St",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:c.city,onChange:g=>u(v=>({...v,city:g.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:c.state,onChange:g=>u(v=>({...v,state:g.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"zip",children:"Zip"}),e.jsx(ze,{id:"zip",value:c.zip,onChange:g=>u(v=>({...v,zip:g.target.value})),placeholder:"75001"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Transaction Type *"}),e.jsxs(Ks,{value:c.transaction_type,onValueChange:g=>u(v=>({...v,transaction_type:g})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(ze,{id:"close_date",type:"date",value:c.close_date,onChange:g=>u(v=>({...v,close_date:g.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(hl,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(ze,{id:"sale_price",type:"number",value:c.sale_price||"",onChange:g=>u(v=>({...v,sale_price:Number(g.target.value)})),placeholder:"450000",required:!0,min:0}),c.sale_price>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.sale_price)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(yS,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(ze,{id:"commission_amount",type:"number",value:c.commission_amount||"",onChange:g=>u(v=>({...v,commission_amount:Number(g.target.value)})),placeholder:"13500",min:0}),c.commission_amount>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:f(c.commission_amount)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Lead Source"}),e.jsxs(Ks,{value:c.lead_source_id,onValueChange:g=>u(v=>({...v,lead_source_id:g})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select source"})}),e.jsx(Ws,{children:l==null?void 0:l.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Client Type"}),e.jsxs(Ks,{value:c.client_type_id,onValueChange:g=>u(v=>({...v,client_type_id:g})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select type"})}),e.jsx(Ws,{children:i==null?void 0:i.map(g=>e.jsx(Mt,{value:g.id,children:g.name},g.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"notes",children:"Notes"}),e.jsx(Pr,{id:"notes",value:c.notes,onChange:g=>u(v=>({...v,notes:g.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(Un,{className:"gap-2 sm:gap-0 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Skip for now"}),e.jsx(K,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":e.jsxs(e.Fragment,{children:["Add to Scorecard",e.jsx(Sa,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const DNs={buyer:{label:"Buyer",color:"bg-blue-500/10 text-blue-600 border-blue-200"},seller:{label:"Seller",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200"},dual:{label:"Dual",color:"bg-purple-500/10 text-purple-600 border-purple-200"},referral:{label:"Referral",color:"bg-orange-500/10 text-orange-600 border-orange-200"},lease:{label:"Lease",color:"bg-cyan-500/10 text-cyan-600 border-cyan-200"}},Aze={urgent:0,high:1,medium:2,low:3};function ONs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=N.useState("target_close_date"),[l,i]=N.useState("asc"),c=v=>{a===v?i(_=>_==="asc"?"desc":"asc"):(o(v),i("asc"))},u=N.useMemo(()=>[...t].sort((v,_)=>{var j,k;let w=0;switch(a){case"deal_name":w=v.deal_name.localeCompare(_.deal_name);break;case"stage":{const S=((j=s.find(L=>L.id===v.stage_id))==null?void 0:j.sort_order)||0,M=((k=s.find(L=>L.id===_.stage_id))==null?void 0:k.sort_order)||0;w=S-M;break}case"expected_price":w=(v.expected_price||0)-(_.expected_price||0);break;case"expected_commission":w=(v.expected_commission||0)-(_.expected_commission||0);break;case"target_close_date":{const S=v.target_close_date?Rl(v.target_close_date).getTime():1/0,M=_.target_close_date?Rl(_.target_close_date).getTime():1/0;w=S-M;break}case"priority":w=Aze[v.priority]-Aze[_.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),p=v=>v?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(v):"—",f=v=>v?s.find(_=>_.id===v):null,g=({field:v,children:_})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(v),children:[_,a===v?l==="asc"?e.jsx(Su,{className:"ml-2 h-4 w-4"}):e.jsx(Kh,{className:"ml-2 h-4 w-4"}):e.jsx(_d,{className:"ml-2 h-4 w-4 opacity-50"})]});return t.length===0?e.jsx("div",{className:"text-center py-16",children:e.jsx("p",{className:"text-muted-foreground",children:"No deals to display"})}):e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{className:"bg-muted/50",children:[e.jsx(St,{className:"w-[250px]",children:e.jsx(g,{field:"deal_name",children:"Deal Name"})}),e.jsx(St,{className:"w-[150px]",children:e.jsx(g,{field:"stage",children:"Stage"})}),e.jsx(St,{className:"w-[100px]",children:"Type"}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_price",children:"Price"})}),e.jsx(St,{className:"w-[120px]",children:e.jsx(g,{field:"expected_commission",children:"GCI"})}),e.jsx(St,{className:"w-[130px]",children:e.jsx(g,{field:"target_close_date",children:"Close Date"})}),e.jsx(St,{className:"w-[100px]",children:e.jsx(g,{field:"priority",children:"Priority"})})]})}),e.jsx(Bn,{children:u.map(v=>{f(v.stage_id);const _=DNs[v.deal_type],w=v.target_close_date?cy(Rl(v.target_close_date),new Date):null,j=w!==null&&w<0,k=w!==null&&w<=7&&w>=0;return e.jsxs(Cs,{className:It("cursor-pointer hover:bg-muted/50 transition-colors",j&&"bg-red-50/50"),onClick:()=>r(v),children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:v.deal_name}),v.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[v.contact.first_name," ",v.contact.last_name]})]})}),e.jsx(dt,{onClick:S=>S.stopPropagation(),children:e.jsx(klt,{stages:s,currentStageId:v.stage_id||"",onStageSelect:(S,M)=>n(v.id,S,M)})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:It("text-xs",_.color),children:_.label})}),e.jsx(dt,{children:e.jsx("span",{className:"font-medium",children:p(v.expected_price)})}),e.jsx(dt,{children:e.jsx("span",{className:"text-emerald-600",children:p(v.expected_commission)})}),e.jsx(dt,{children:v.target_close_date?e.jsxs("div",{className:It("flex items-center gap-1 text-sm",j&&"text-red-600",k&&!j&&"text-amber-600"),children:[j&&e.jsx(Cl,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ms(Rl(v.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:It("text-xs capitalize",v.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",v.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",v.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",v.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:v.priority})})]},v.id)})})]})})}function RNs(){const t=ri();return mt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function FNs(t){const s=ri();return mt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await H.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function zNs(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function BNs(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function $Ns(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function w3e(){const t=Xt();return Lt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await H.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function qNs(){const t=Xt();return Lt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await H.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function UNs(t){const s=ri();return mt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=H.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function VNs(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function HNs(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function GNs(){const t=ri(),s=Xt();return Lt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await H.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),c=a.filter(f=>!i.has(f.title)).map((f,g)=>({owner_user_id:t,deal_id:r,stage_id:n,title:f.title,description:f.description,priority:f.priority,due_date:f.default_due_offset_days?new Date(Date.now()+f.default_due_offset_days*864e5).toISOString().split("T")[0]:null,sort_order:g,status:"todo"}));if(c.length===0)return[];const{data:u,error:p}=await H.from("deal_tasks").insert(c).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const WNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function KNs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=FNs(t?r:void 0),p=qNs(),f=GNs(),[g,v]=N.useState(new Set),[_,w]=N.useState(!1),j=(c||[]).filter(L=>L.status!=="done");N.useEffect(()=>{j.length>0&&v(new Set(j.map(L=>L.id)))},[c]);const k=L=>{v(P=>{const O=new Set(P);return O.has(L)?O.delete(L):O.add(L),O})},S=async()=>{w(!0);try{const L=Array.from(g);L.length>0&&await p.mutateAsync(L),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{w(!1)}},M=async()=>{w(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(L){console.error("Stage move (skip) failed:",L),me.error((L==null?void 0:L.message)||"Failed to move deal. Please try again.")}finally{w(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[480px]",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Move Deal"}),e.jsxs(Wr,{children:["Moving ",e.jsx("span",{className:"font-medium text-foreground",children:n})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx(st,{variant:"outline",className:"text-sm",children:a}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(st,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:j.length})," incomplete task",j.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Ki,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:j.map(L=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Oo,{checked:g.has(L.id),onCheckedChange:()=>k(L.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[WNs[L.priority]," ",L.title]}),L.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:L.stage.color+"20",color:L.stage.color},children:L.stage.name})]},L.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{g.size===j.length?v(new Set):v(new Set(j.map(L=>L.id)))},children:g.size===j.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:M,disabled:_,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:S,disabled:_,children:[_&&e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}),g.size>0?`Complete ${g.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(sa,{className:"h-8 w-8 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"All tasks completed! Ready to move."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:S,disabled:_,children:[_&&e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function ZNs(){const t=ri();return mt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function YNs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=_Se(),u=MR(),p=A_s(),f=E_s(),[g,v]=N.useState(!1),_=!!(n!=null&&n.archived_at),w=async()=>{v(!0);try{await c.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),me.success("Portal enabled!")}catch{me.error("Failed to create portal")}finally{v(!1)}},j=async P=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:P}),me.success(P?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},k=()=>{n&&(navigator.clipboard.writeText(k1(n.slug)),me.success("Link copied!"))},S=()=>{n&&window.open(k1(n.slug),"_blank")},M=async()=>{if(n)try{await p.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},L=async()=>{if(n)try{await f.mutateAsync(n.id),me.success("Portal restored")}catch{me.error("Failed to restore portal")}};return n?_?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(st,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:L,className:"text-xs gap-1",children:[e.jsx(rL,{className:"h-3.5 w-3.5"}),"Restore"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(st,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:k,title:"Copy link",children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:S,title:"Preview",children:e.jsx(en,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,s),title:"Invite client",children:e.jsx($n,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n),title:"Post update",children:e.jsx(GM,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:e.jsx(Qo,{className:"h-3.5 w-3.5"})}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(xx,{className:"h-3.5 w-3.5"})})}),e.jsx(Bd,{align:"end",children:e.jsxs(Aa,{onClick:M,children:[e.jsx(IM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(qr,{checked:n.is_enabled,onCheckedChange:j,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:w,disabled:g,className:"shrink-0 ml-4",children:[g?e.jsx(bs,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(fn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function QNs(){const{data:t,isLoading:s}=ame(),{data:r,isLoading:n}=ZNs(),[a,o]=N.useState(""),[l,i]=N.useState("all"),c=P_s(),[u,p]=N.useState(null),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(null),k=ri(),S=s||n,M=new Map;r==null||r.forEach(V=>M.set(V.deal_id,V));const P=[...(t||[]).filter(V=>{var ce,ne,re,oe,fe;const X=M.get(V.id),Y=a.toLowerCase(),ee=!Y||V.deal_name.toLowerCase().includes(Y)||((ne=(ce=V.contact)==null?void 0:ce.first_name)==null?void 0:ne.toLowerCase().includes(Y))||((oe=(re=V.contact)==null?void 0:re.last_name)==null?void 0:oe.toLowerCase().includes(Y))||((fe=X==null?void 0:X.client_name)==null?void 0:fe.toLowerCase().includes(Y));let Q=!0;return l==="active"?Q=!!(X!=null&&X.is_enabled)&&!(X!=null&&X.archived_at):l==="disabled"?Q=!!X&&!X.is_enabled&&!X.archived_at:l==="archived"?Q=!!(X!=null&&X.archived_at):l==="none"?Q=!X:l==="all"&&(Q=!(X!=null&&X.archived_at)||!X),ee&&Q})].sort((V,X)=>{const Y=M.get(V.id),ee=M.get(X.id);if(Y!=null&&Y.archived_at&&!(ee!=null&&ee.archived_at))return 1;if(!(Y!=null&&Y.archived_at)&&(ee!=null&&ee.archived_at)||Y&&!ee)return-1;if(!Y&&ee)return 1;if(Y&&ee){if(Y.is_enabled&&!ee.is_enabled)return-1;if(!Y.is_enabled&&ee.is_enabled)return 1}return 0}),O=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,$=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,U=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,B=async()=>{if(w)try{await c.mutateAsync({id:w.id,dealId:w.deal_id}),me.success("Portal permanently deleted"),j(null)}catch{me.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(fn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[O," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",O-$," disabled",U>0&&` · ${U} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals or clients...",value:a,onChange:V=>o(V.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Ki,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[P.map(V=>{const X=M.get(V.id)||null,Y=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(YNs,{dealId:V.id,dealName:V.deal_name,contactName:Y,portal:X,onSettingsOpen:p,onComposerOpen:ee=>g(ee),onInviteOpen:(ee,Q)=>_({portal:ee,dealName:Q}),onDeleteConfirm:j},V.id)}),P.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(fn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-medium",children:"No matching deals"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try adjusting your search or filters"})]})]})})]}),u&&e.jsx(Clt,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:k||""}),f&&e.jsx(Mlt,{open:!!f,onOpenChange:V=>!V&&g(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),v&&e.jsx(Tlt,{open:!!v,onOpenChange:V=>!V&&_(null),portal:v.portal,dealName:v.dealName}),e.jsx(Mc,{open:!!w,onOpenChange:V=>!V&&j(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Permanently delete this portal?"}),e.jsx(ic,{children:"This will permanently remove the portal and all its updates. The client will no longer be able to access their portal page. This action cannot be undone."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class XNs extends N.Component{constructor(s){super(s),this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("DealPipeline error:",s,r)}render(){return this.state.hasError?e.jsx(Ts,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}const _I="deal-pipeline-detail-sheet";function JNs(){var Ms;const t=DE(),{data:s,isLoading:r}=nme(),{data:n,isLoading:a,refetch:o}=ame(),{data:l,isLoading:i}=Mws(),c=git(),u=_ws(),[p,f]=N.useState("board"),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(null),[S,M]=N.useState(null),[L,P]=N.useState(null),[O,$]=N.useState(null),[U,B]=N.useState(!1),[V,X]=N.useState(null),[Y,ee]=N.useState(""),[Q,ce]=N.useState("all"),[ne,re]=N.useState(!1),[oe,fe]=N.useState(!1),[ge,ue]=N.useState(new Set),xe=N.useRef(!1),[_e,$e]=N.useState(null),{data:Me}=Ux(),{isTeamLeader:Ie,teamMembers:ke}=aNs(),pe=N.useMemo(()=>Array.from(ge),[ge]),{data:we}=iNs(pe),Le=N.useMemo(()=>{const cs=new Map;return ke.forEach(er=>cs.set(er.id,{name:er.name,avatar_url:er.avatar_url,color:er.color})),cs},[ke]),Qe=N.useCallback(cs=>cs.owner_user_id&&Le.get(cs.owner_user_id)||null,[Le]),Te=N.useCallback(cs=>{ue(er=>{const xt=new Set(er);return xt.has(cs)?xt.delete(cs):xt.add(cs),xt})},[]);N.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[pt,ye]=uc(),qe=N.useRef(!1);N.useEffect(()=>{const cs=pt.get("deal");if(cs&&n&&n.length>0&&!qe.current){const er=n.find(xt=>xt.id===cs);er&&(qe.current=!0,k(er),w(!0),pt.delete("deal"),ye(pt,{replace:!0}))}},[n,pt]);const at=N.useMemo(()=>{if(!we||!s)return[];const cs=new Map(s.map(er=>[er.name,er.id]));return we.map(er=>{const xt=er._stage_name&&cs.get(er._stage_name)||null;return{...er,stage_id:xt||er.stage_id}})},[we,s]),tt=N.useMemo(()=>[...n||[],...at],[n,at]);N.useEffect(()=>{if(xe.current||tt.length===0)return;xe.current=!0;const cs=sessionStorage.getItem(_I);if(cs)try{const er=JSON.parse(cs);if(!er.open||!er.dealId)return;const xt=tt.find(Ps=>Ps.id===er.dealId);xt&&(k(xt),w(!0))}catch{sessionStorage.removeItem(_I)}},[tt]),N.useEffect(()=>{_&&(j!=null&&j.id)?sessionStorage.setItem(_I,JSON.stringify({dealId:j.id,open:!0})):sessionStorage.removeItem(_I)},[_,j==null?void 0:j.id]);const Ae=tt.filter(cs=>{var mr,Tr,Dr,xn,Si,Ia;const er=Y.toLowerCase(),xt=!er||cs.deal_name.toLowerCase().includes(er)||((Tr=(mr=cs.contact)==null?void 0:mr.first_name)==null?void 0:Tr.toLowerCase().includes(er))||((xn=(Dr=cs.contact)==null?void 0:Dr.last_name)==null?void 0:xn.toLowerCase().includes(er))||((Si=cs.property_address)==null?void 0:Si.toLowerCase().includes(er))||((Ia=cs.city)==null?void 0:Ia.toLowerCase().includes(er)),Ps=Q==="all"||cs.deal_type===Q;return xt&&Ps}),rt=N.useMemo(()=>{if(!s)return l||null;const cs=new Set(s.filter(Dr=>Dr.is_won_stage).map(Dr=>Dr.id)),er=new Set(s.filter(Dr=>Dr.is_lost_stage).map(Dr=>Dr.id)),xt=tt.filter(Dr=>Dr.stage_id&&!cs.has(Dr.stage_id)&&!er.has(Dr.stage_id)),Ps=tt.filter(Dr=>Dr.stage_id&&cs.has(Dr.stage_id)),mr=new Date().getFullYear(),Tr=Ps.filter(Dr=>Dr.actual_close_date?new Date(Dr.actual_close_date).getFullYear()===mr:!0);return{totalDeals:tt.length,activeDeals:xt.length,wonDeals:Ps.length,pipelineValue:xt.reduce((Dr,xn)=>Dr+(xn.expected_price||0),0),expectedCommission:xt.reduce((Dr,xn)=>Dr+(xn.expected_commission||0),0),expectedNetToAgent:xt.reduce((Dr,xn)=>Dr+(bx(xn)||0),0),wonValue:Ps.reduce((Dr,xn)=>Dr+(xn.expected_price||0),0),weightedGCI:xt.reduce((Dr,xn)=>Dr+(xn.expected_commission||0)*((xn.probability??50)/100),0),weightedNet:xt.reduce((Dr,xn)=>Dr+(bx(xn)||0)*((xn.probability??50)/100),0),ytdWonDeals:Tr.length,ytdWonGCI:Tr.reduce((Dr,xn)=>Dr+(xn.expected_commission||0),0),ytdWonNet:Tr.reduce((Dr,xn)=>Dr+(bx(xn)||0),0),projectedAnnualNet:Tr.reduce((Dr,xn)=>Dr+(bx(xn)||0),0)+xt.reduce((Dr,xn)=>Dr+(bx(xn)||0)*((xn.probability??50)/100),0)}},[tt,s,l]),He=cs=>{k(cs),w(!0)},ct=cs=>{M(cs||null),k(null),v(!0)},Ue=cs=>{k(cs),w(!1),v(!0)},Ze=cs=>{w(cs),cs||sessionStorage.removeItem(_I)},Je=(cs,er)=>{P(cs)},Ge=(cs,er)=>{cs.preventDefault(),cs.dataTransfer.dropEffect="move",$(er)},et=async(cs,er)=>{if(cs.preventDefault(),$(null),!L)return;const xt=n==null?void 0:n.find(Tr=>Tr.id===L),Ps=s==null?void 0:s.find(Tr=>Tr.id===er),mr=s==null?void 0:s.find(Tr=>Tr.id===(xt==null?void 0:xt.stage_id));if(!xt||!Ps||xt.stage_id===er){P(null);return}$e({dealId:L,dealName:xt.deal_name,fromStageName:(mr==null?void 0:mr.name)||"Unknown",toStageName:Ps.name,toStageId:er,isWonStage:Ps.is_won_stage,deal:xt}),P(null)},it=async()=>{if(!_e)return;const{dealId:cs,toStageId:er,toStageName:xt,isWonStage:Ps,deal:mr}=_e;if(await u.mutateAsync({dealId:cs,stageId:er,stageName:xt}),me.success(`Moved to ${xt}`),Ps&&!mr.scorecard_transaction_id){const Tr={...mr,stage_id:er};X(Tr),B(!0)}},Dt=N.useCallback(async(cs,er,xt)=>{const Ps=n==null?void 0:n.find(Dr=>Dr.id===cs),mr=s==null?void 0:s.find(Dr=>Dr.id===er),Tr=s==null?void 0:s.find(Dr=>Dr.id===(Ps==null?void 0:Ps.stage_id));!Ps||!mr||Ps.stage_id===er||$e({dealId:cs,dealName:Ps.deal_name,fromStageName:(Tr==null?void 0:Tr.name)||"Unknown",toStageName:xt,toStageId:er,isWonStage:mr.is_won_stage,deal:Ps})},[n,s]),Vt=cs=>Ae.filter(er=>er.stage_id===cs),hs=r||a,As=t?"list":p;return e.jsxs(Ts,{children:[e.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[e.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:e.jsx(Wo,{className:"h-4 w-4"})}),!t&&e.jsx(G1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>f("board"),className:"px-3 gap-1.5",children:[e.jsx(Cp,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(ec,{children:"Kanban board view"})]}),e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>f("list"),className:"px-3 gap-1.5",children:[e.jsx(rh,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(ec,{children:"Grouped list view"})]}),e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>f("table"),className:"px-3 gap-1.5",children:[e.jsx(ZM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(ec,{children:"Sortable table view"})]}),e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(fn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(ec,{children:"Client portal management"})]})]})}),Me&&!Ie&&e.jsxs(K,{variant:"outline",onClick:()=>re(!0),children:[e.jsx(hr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),As!=="portals"&&e.jsx(dNs,{stats:rt,isLoading:i}),As!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search deals, contacts, addresses...",value:Y,onChange:cs=>ee(cs.target.value),className:"pl-9 pr-8"}),Y&&e.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Mr,{className:"h-4 w-4"})})]}),e.jsxs(Ks,{value:Q,onValueChange:ce,children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Ys,{placeholder:"All Types"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"dual",children:"Dual"}),e.jsx(Mt,{value:"referral",children:"Referral"}),e.jsx(Mt,{value:"lease",children:"Lease"})]})]}),(Y||Q!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Ae.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ie&&!t&&ke.length>0&&e.jsx(nNs,{members:ke,enabledMembers:ge,onToggleMember:Te,isOpen:oe,onToggleOpen:()=>fe(cs=>!cs)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:hs?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(cs=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(vs,{className:"h-full rounded-xl"})},cs))}):As==="board"?e.jsxs(Ki,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[e.jsx("div",{className:"flex gap-4 h-full pb-4",children:s==null?void 0:s.map(cs=>e.jsx(cNs,{stage:cs,deals:Vt(cs.id),onDealClick:He,onAddDeal:ct,onDragStart:Je,onDragOver:Ge,onDrop:et,isDragOver:O===cs.id,isWonStage:cs.is_won_stage,getOwnerInfo:Qe},cs.id))}),e.jsx(xue,{orientation:"horizontal"})]}):As==="table"?e.jsx(Ki,{className:"h-full",children:e.jsx(ONs,{deals:Ae,stages:s||[],onDealClick:He,onStageChange:Dt})}):As==="portals"?e.jsx(QNs,{}):e.jsx(Ki,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(cs=>{const er=Vt(cs.id);return er.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:cs.color}}),e.jsx("h3",{className:"font-semibold",children:cs.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",er.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:er.map(xt=>e.jsx(Slt,{deal:xt,onClick:()=>He(xt),stages:s,onStageChange:Dt,showStagePicker:!0,isWonStage:cs.is_won_stage,ownerInfo:Qe(xt)},xt.id))})]},cs.id)}),(n==null?void 0:n.length)===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(Cp,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),e.jsxs(K,{onClick:()=>ct(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&Ae.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(sn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{ee(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(pNs,{open:g,onOpenChange:v,deal:j,defaultStageId:S}),e.jsx(INs,{deal:j,open:_,onOpenChange:Ze,onEdit:Ue,isWonStage:j?(Ms=s==null?void 0:s.find(cs=>cs.id===j.stage_id))==null?void 0:Ms.is_won_stage:!1,onAddToScorecard:cs=>{X(cs),B(!0),w(!1)}}),e.jsx(LNs,{open:U,onOpenChange:B,deal:V,onComplete:()=>{o(),X(null)}}),_e&&e.jsx(KNs,{open:!!_e,onOpenChange:cs=>{cs||$e(null)},dealId:_e.dealId,dealName:_e.dealName,fromStageName:_e.fromStageName,toStageName:_e.toStageName,toStageId:_e.toStageId,onConfirm:it}),e.jsx(sNs,{open:ne,onOpenChange:re})]})}function eks(){return e.jsx(XNs,{children:e.jsx(JNs,{})})}function Alt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var ee;const o=zNs(),l=BNs(),{data:i}=ame(),c=ri(),{data:u}=mt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:Q,error:ce}=await H.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",c).order("first_name").limit(500);if(ce)throw ce;return Q},enabled:!!c&&t}),[p,f]=N.useState(""),[g,v]=N.useState(""),[_,w]=N.useState("none"),[j,k]=N.useState("none"),[S,M]=N.useState("medium"),[L,P]=N.useState("todo"),[O,$]=N.useState(),[U,B]=N.useState(!1),[V,X]=N.useState(!1);N.useEffect(()=>{r?(f(r.title),v(r.description||""),w(r.deal_id||"none"),k(r.contact_id||"none"),M(r.priority),P(r.status),$(r.due_date?Nm(r.due_date):void 0)):(f(""),v(""),w(n||"none"),k("none"),M("medium"),P("todo"),$(void 0))},[r,t,n]);const Y=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const Q={title:p.trim(),description:g.trim()||null,deal_id:_==="none"?null:_,contact_id:j==="none"?null:j,stage_id:a||null,priority:S,status:L,due_date:O?ms(O,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...Q}),me.success("Task updated")):(await o.mutateAsync(Q),me.success("Task created")),s(!1)}catch{me.error("Failed to save task")}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[480px]",children:[e.jsx(js,{children:e.jsx(_s,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title *"}),e.jsx(ze,{value:p,onChange:Q=>f(Q.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:g,onChange:Q=>v(Q.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Priority"}),e.jsxs(Ks,{value:S,onValueChange:Q=>M(Q),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:L,onValueChange:Q=>P(Q),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"todo",children:"To Do"}),e.jsx(Mt,{value:"in_progress",children:"In Progress"}),e.jsx(Mt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date"}),e.jsxs($o,{children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:It("w-full justify-start text-left font-normal",!O&&"text-muted-foreground"),children:[e.jsx(hn,{className:"mr-2 h-4 w-4"}),O?ms(O,"PPP"):"Pick a date"]})}),e.jsx(Ro,{className:"w-auto p-0",align:"start",children:e.jsx(jf,{mode:"single",selected:O,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Link to Deal"}),e.jsxs($o,{open:U,onOpenChange:B,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Ca,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),_!=="none"?((ee=i==null?void 0:i.find(Q=>Q.id===_))==null?void 0:ee.deal_name)||"Select deal":"No Deal"]}),e.jsx(Cx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search deals..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:"No deals found."}),e.jsxs($x,{children:[e.jsxs(bp,{value:"no-deal",onSelect:()=>{w("none"),B(!1)},children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",_==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Q=>e.jsxs(bp,{value:Q.deal_name,onSelect:()=>{w(Q.id),B(!1)},children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",_===Q.id?"opacity-100":"opacity-0")}),Q.deal_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Link to Contact"}),e.jsxs($o,{open:V,onOpenChange:X,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(Wi,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?(()=>{const Q=u==null?void 0:u.find(ce=>ce.id===j);return Q?`${Q.first_name} ${Q.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(Cx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Rx,{children:[e.jsx(Fx,{placeholder:"Search contacts..."}),e.jsxs(zx,{children:[e.jsx(Bx,{children:"No contacts found."}),e.jsxs($x,{children:[e.jsxs(bp,{value:"no-contact",onSelect:()=>{k("none"),X(!1)},children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Q=>e.jsxs(bp,{value:`${Q.first_name} ${Q.last_name}`,onSelect:()=>{k(Q.id),X(!1)},children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",j===Q.id?"opacity-100":"opacity-0")}),Q.first_name," ",Q.last_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const tks={urgent:{label:"Urgent",color:"bg-red-500/10 text-red-600 border-red-200",dot:"🔴"},high:{label:"High",color:"bg-orange-500/10 text-orange-600 border-orange-200",dot:"🟠"},medium:{label:"Medium",color:"bg-amber-500/10 text-amber-600 border-amber-200",dot:"🟡"},low:{label:"Low",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200",dot:"🟢"}};function sks({tasks:t}){const s=w3e(),r=$Ns(),n=nr(),[a,o]=N.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{me.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),me.success("Task deleted")}catch{me.error("Failed to delete task")}};if(t.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(sa,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:"No tasks found"}),e.jsx("p",{className:"text-muted-foreground/60 text-sm",children:"Create a new task to get started"})]});const c=new Map,u=[];return t.forEach(p=>{if(p.deal){const f=c.get(p.deal.id)||{dealName:p.deal.deal_name,tasks:[]};f.tasks.push(p),c.set(p.deal.id,f)}else u.push(p)}),e.jsxs("div",{className:"space-y-4",children:[u.length>0&&e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 px-4 py-2 border-b",children:e.jsx("h3",{className:"font-medium text-sm text-muted-foreground",children:"General Tasks"})}),u.map(p=>e.jsx(Eze,{task:p,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:f=>n(`/mission-control/pipeline?deal=${f}`)},p.id))]}),Array.from(c.entries()).map(([p,f])=>e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>n(`/mission-control/pipeline?deal=${p}`),className:"w-full bg-muted/30 px-4 py-2 border-b flex items-center gap-2 hover:bg-muted/50 transition-colors text-left",children:[e.jsx(Ca,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(st,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(g=>g.status==="done").length,"/",f.tasks.length]}),e.jsx(oa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(g=>e.jsx(Eze,{task:g,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:v=>n(`/mission-control/pipeline?deal=${v}`)},g.id))]},p)),a&&e.jsx(Alt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function Eze({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&k0(Nm(t.due_date))&&!_u(Nm(t.due_date)),i=!o&&t.due_date&&_u(Nm(t.due_date)),c=tks[t.priority];return e.jsxs("div",{className:It("flex items-center gap-3 px-4 py-3 border-b last:border-b-0 group hover:bg-muted/30 transition-colors",o&&"opacity-60"),children:[e.jsx("button",{onClick:()=>s(t),className:"shrink-0",children:o?e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}):e.jsx(wd,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium truncate",o&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Wi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(st,{variant:"outline",className:It("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:It("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-3 w-3"}),ms(Nm(t.due_date),"MMM d")]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>n(t),className:"p-1 hover:bg-muted rounded",children:e.jsx(md,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx("button",{onClick:()=>r(t.id),className:"p-1 hover:bg-destructive/10 rounded",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const rks=[{status:"todo",label:"To Do",icon:wd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:pp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:sa,color:"border-t-emerald-500"}],nks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function aks({tasks:t}){const s=w3e(),r=N.useMemo(()=>{const o={todo:[],in_progress:[],done:[]};return t.forEach(l=>o[l.status].push(l)),o},[t]),n=(o,l)=>{o.dataTransfer.setData("taskId",l)},a=async(o,l)=>{o.preventDefault();const i=o.dataTransfer.getData("taskId");if(!i)return;const c=t.find(u=>u.id===i);if(!(!c||c.status===l))try{await s.mutateAsync({id:i,status:l})}catch{me.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:rks.map(o=>e.jsxs("div",{className:It("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(st,{variant:"secondary",className:"ml-auto text-xs",children:r[o.status].length})]}),e.jsxs("div",{className:"p-2 space-y-2 min-h-[200px]",children:[r[o.status].map(l=>e.jsx(iks,{task:l,onDragStart:n},l.id)),r[o.status].length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"Drag tasks here"})]})]},o.status))})}function iks({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&k0(Nm(t.due_date))&&!_u(Nm(t.due_date)),a=!r&&t.due_date&&_u(Nm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:It("bg-background border rounded-lg p-3 cursor-grab active:cursor-grabbing shadow-sm hover:shadow-md transition-shadow",n&&"border-destructive/50"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs mt-0.5",children:nks[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:It("text-sm font-medium",r&&"line-through text-muted-foreground"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[t.deal&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Ca,{className:"h-2.5 w-2.5"}),t.deal.deal_name]}),t.contact&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-0.5",children:[e.jsx(Wi,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:It("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(un,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ms(Nm(t.due_date),"MMM d")]}),t.stage&&e.jsx("span",{className:"inline-block text-[10px] px-1.5 py-0.5 rounded-full font-medium mt-1.5",style:{backgroundColor:t.stage.color+"20",color:t.stage.color},children:t.stage.name})]})]})})}const Pze={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function oks({tasks:t}){const[s,r]=N.useState(new Date),n=w3e(),a=zc(s),o=dx(s),l=Xh(a),i=uue(o),c=B4t({start:l,end:i}),u=N.useMemo(()=>{const g=new Map;return t.forEach(v=>{if(!v.due_date)return;const _=v.due_date,w=g.get(_)||[];w.push(v),g.set(_,w)}),g},[t]),p=N.useMemo(()=>t.filter(g=>!g.due_date),[t]),f=async g=>{const v=g.status==="done"?"todo":"done";try{await n.mutateAsync({id:g.id,status:v})}catch{me.error("Failed to update task")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(N4(s,1)),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ms(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Bm(s,1)),children:e.jsx(oa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(g=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:g},g))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:c.map(g=>{const v=ms(g,"yyyy-MM-dd"),_=u.get(v)||[],w=mue(g,s),j=_u(g);return e.jsxs("div",{className:It("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",j&&"bg-primary/5"),children:[e.jsx("div",{className:It("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",j&&"text-primary font-bold"),children:ms(g,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[_.slice(0,3).map(k=>e.jsxs("button",{onClick:()=>f(k),className:It("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",k.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[k.status==="done"?e.jsx(sa,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(wd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[Pze[k.priority]," ",k.title]})]},k.id)),_.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",_.length-3," more"]})]})]},v)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(g=>e.jsxs("button",{onClick:()=>f(g),className:It("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",g.status==="done"&&"opacity-50 line-through"),children:[g.status==="done"?e.jsx(sa,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(wd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[Pze[g.priority]," ",g.title]}),g.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",g.deal.deal_name]})]},g.id))})]})]})}const lks={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function cks({open:t,onOpenChange:s,stages:r}){var k;const[n,a]=N.useState(((k=r[0])==null?void 0:k.id)||""),{data:o,isLoading:l}=UNs(n||void 0),i=VNs(),c=HNs(),[u,p]=N.useState(""),[f,g]=N.useState("medium"),[v,_]=N.useState(""),w=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:v?parseInt(v):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),_(""),me.success("Template added")}catch{me.error("Failed to add template")}},j=async S=>{try{await c.mutateAsync(S),me.success("Template deleted")}catch{me.error("Failed to delete template")}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[560px]",children:[e.jsx(js,{children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(gL,{className:"h-5 w-5"}),"Task Templates by Stage"]})}),e.jsx("p",{className:"text-sm text-muted-foreground -mt-2",children:"Create default tasks that auto-populate when a deal enters a stage."}),e.jsxs("div",{children:[e.jsx(be,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:It("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===S.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:S.name},S.id))})]}),e.jsx(Ki,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border rounded-lg group",children:[e.jsx("span",{className:"text-xs",children:lks[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(st,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>j(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Task title...",value:u,onChange:S=>p(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(Ks,{value:f,onValueChange:S=>g(S),children:[e.jsx(Gs,{className:"w-[100px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"low",children:"🟢 Low"}),e.jsx(Mt,{value:"medium",children:"🟡 Med"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(ze,{type:"number",placeholder:"e.g., 7",value:v,onChange:S=>_(S.target.value)})]}),e.jsxs(K,{onClick:w,disabled:!u.trim()||i.isPending,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function dks(){const{data:t,isLoading:s}=RNs(),{data:r}=nme(),[n,a]=N.useState("list"),[o,l]=N.useState(""),[i,c]=N.useState("active"),[u,p]=N.useState("all"),[f,g]=N.useState("all"),[v,_]=N.useState(!1),[w,j]=N.useState(!1),k=N.useMemo(()=>{if(!t)return[];const L=new Map;return t.forEach(P=>{P.deal&&L.set(P.deal.id,P.deal.deal_name)}),Array.from(L,([P,O])=>({id:P,name:O}))},[t]),S=N.useMemo(()=>t?t.filter(L=>{var V,X,Y,ee;const P=o.toLowerCase(),O=!P||L.title.toLowerCase().includes(P)||((X=(V=L.deal)==null?void 0:V.deal_name)==null?void 0:X.toLowerCase().includes(P))||`${((Y=L.contact)==null?void 0:Y.first_name)||""} ${((ee=L.contact)==null?void 0:ee.last_name)||""}`.toLowerCase().includes(P),$=i==="all"||i==="active"&&L.status!=="done"||i==="todo"&&L.status==="todo"||i==="in_progress"&&L.status==="in_progress"||i==="done"&&L.status==="done"||i==="overdue"&&L.status!=="done"&&L.due_date&&k0(Nm(L.due_date))&&!_u(Nm(L.due_date)),U=u==="all"||L.priority===u,B=f==="all"||f==="no_deal"&&!L.deal_id||L.deal_id===f;return O&&$&&U&&B}):[],[t,o,i,u,f]),M=N.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const L=t.filter(P=>P.status!=="done");return{total:L.length,overdue:L.filter(P=>P.due_date&&k0(Nm(P.due_date))&&!_u(Nm(P.due_date))).length,dueToday:L.filter(P=>P.due_date&&_u(Nm(P.due_date))).length,dueThisWeek:L.filter(P=>P.due_date&&O3t(Nm(P.due_date))).length,completed:t.filter(P=>P.status==="done").length}},[t]);return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[e.jsx(ey,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>_(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>c("active"),className:`p-3 rounded-lg border text-left transition-colors ${i==="active"?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-xs font-medium",children:[e.jsx(rh,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.total})]}),e.jsxs("button",{onClick:()=>c("overdue"),className:`p-3 rounded-lg border text-left transition-colors ${i==="overdue"?"border-destructive bg-destructive/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive text-xs font-medium",children:[e.jsx(Yu,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:M.overdue})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueToday})]}),e.jsxs("button",{onClick:()=>{c("active")},className:"p-3 rounded-lg border text-left hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600 text-xs font-medium",children:[e.jsx(Od,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.dueThisWeek})]}),e.jsxs("button",{onClick:()=>c("done"),className:`p-3 rounded-lg border text-left transition-colors ${i==="done"?"border-emerald-500 bg-emerald-500/5":"hover:bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-medium",children:[e.jsx(sa,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:M.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search tasks...",value:o,onChange:L=>l(L.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:u,onValueChange:p,children:[e.jsx(Gs,{className:"w-[130px]",children:e.jsx(Ys,{placeholder:"Priority"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Priorities"}),e.jsx(Mt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(Mt,{value:"high",children:"🟠 High"}),e.jsx(Mt,{value:"medium",children:"🟡 Medium"}),e.jsx(Mt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Ys,{placeholder:"Deal"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Deals"}),e.jsx(Mt,{value:"no_deal",children:"No Deal"}),k.map(L=>e.jsx(Mt,{value:L.id,children:L.name},L.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(rh,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("kanban"),className:`p-1.5 rounded-md transition-colors ${n==="kanban"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(f0,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>a("calendar"),className:`p-1.5 rounded-md transition-colors ${n==="calendar"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Od,{className:"h-4 w-4"})})]})]}),s?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full"})}):e.jsxs(e.Fragment,{children:[n==="list"&&e.jsx(sks,{tasks:S}),n==="kanban"&&e.jsx(aks,{tasks:S}),n==="calendar"&&e.jsx(oks,{tasks:S})]}),e.jsx(Alt,{open:v,onOpenChange:_}),e.jsx(cks,{open:w,onOpenChange:j,stages:r||[]})]})})}const vwe=[{value:"video_intro",label:"Video Intro",icon:Cn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:ML,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Fm,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:ml,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:nd,description:"Links to your social profiles"}],uks=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],hks={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function Elt({cardId:t}){const{data:s,isLoading:r}=Dkt(t),n=Okt(),a=Rkt(),o=Fkt(),[l,i]=N.useState(!1),[c,u]=N.useState(""),[p,f]=N.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(vs,{className:"h-16 w-full"}),e.jsx(vs,{className:"h-16 w-full"})]});const g=()=>{c&&n.mutate({card_id:t,block_type:c,sort_order:(s==null?void 0:s.length)||0,config:hks[c]||{}},{onSuccess:()=>{i(!1),u("")}})},v=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},_=(S,M)=>{if(!s)return;const L=s.findIndex($=>$.id===S.id),P=M==="up"?L-1:L+1;if(P<0||P>=s.length)return;const O=s[P];a.mutate({id:S.id,sort_order:O.sort_order}),a.mutate({id:O.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},j=(S,M)=>{a.mutate({id:S.id,config:M},{onSuccess:()=>f(null)})},k=S=>vwe.find(M=>M.value===S);return e.jsxs("div",{className:"space-y-3",children:[!s||s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),e.jsxs(K,{size:"sm",onClick:()=>i(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,M)=>{const L=k(S.block_type),P=(L==null?void 0:L.icon)||Fm;return e.jsx(Ee,{className:S.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(P,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(L==null?void 0:L.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:mks(S)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"up"),disabled:M===0,children:e.jsx(Su,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S,"down"),disabled:M===s.length-1,children:e.jsx(Kh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(S),children:S.is_visible?e.jsx(Dn,{className:"h-3 w-3"}):e.jsx(kp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:vwe.map(S=>{const M=S.icon;return e.jsxs("button",{onClick:()=>u(S.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${c===S.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[e.jsx(M,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:S.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.description})]})]},S.value)})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:g,disabled:!c||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(pks,{block:p,onSave:S=>j(p,S),onClose:()=>f(null)})]})}function mks(t){var r;const s=t.config;switch(t.block_type){case"video_intro":return s.video_url?"Video configured":"No video set";case"testimonials":{const n=((r=s.testimonials)==null?void 0:r.length)||0;return`${n} testimonial${n!==1?"s":""}`}case"specialties":{const n=s.tags||[];return n.length?n.slice(0,3).join(", ")+(n.length>3?"...":""):"No tags"}case"custom_links":{const n=s.links||[];return`${n.length} link${n.length!==1?"s":""}`}case"social_media":{const n=s.platforms||[];return n.length?n.map(a=>a.platform).join(", "):"No platforms"}default:return""}}function pks({block:t,onSave:s,onClose:r}){const[n,a]=N.useState(t.config),o=vwe.find(l=>l.value===t.block_type);return e.jsx(xs,{open:!0,onOpenChange:r,children:e.jsxs(fs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(fks,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(xks,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(gks,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(yks,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(vks,{config:n,onChange:a}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function fks({config:t,onChange:s,cardId:r}){var v,_;const[n,a]=N.useState(""),[o,l]=N.useState((v=t.video_url)!=null&&v.includes("youtube")||(_=t.video_url)!=null&&_.includes("youtu.be")?"youtube":"library"),{data:i}=mt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await H.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:j}=await H.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(j)throw j;return w||[]},enabled:!!i}),p=(c==null?void 0:c.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,g=w=>{var M;const j=(M=w.playback_url)==null?void 0:M.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${j?j[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(_a,{value:o,onValueChange:l,children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ns,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(ns,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(ws,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(Ki,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(vs,{className:"h-14 w-full"}),e.jsx(vs,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(c==null?void 0:c.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(w=>e.jsxs("button",{onClick:()=>g(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:j=>{var k;j.currentTarget.style.display="none",(k=j.currentTarget.nextElementSibling)==null||k.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${w.thumbnail_url?"hidden":""}`,children:e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),f===w.bunny_video_id&&e.jsx(ba,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx(ws,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(be,{children:"YouTube URL"}),e.jsx(ze,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function xks({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:e.jsx(Nr,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Client name",value:l.name,onChange:c=>n(i,"name",c.target.value)}),e.jsx(ze,{placeholder:"Role/title (optional)",value:l.role||"",onChange:c=>n(i,"role",c.target.value)}),e.jsx("textarea",{className:"w-full min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm",placeholder:"Their testimonial quote...",value:l.quote,onChange:c=>n(i,"quote",c.target.value)})]})},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function gks({config:t,onChange:s}){const r=t.tags||[],[n,a]=N.useState(""),o=i=>{s({...t,tags:r.includes(i)?r.filter(c=>c!==i):[...r,i]})},l=()=>{n.trim()&&!r.includes(n.trim())&&(s({...t,tags:[...r,n.trim()]}),a(""))};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:uks.map(i=>e.jsx("button",{onClick:()=>o(i),className:`px-3 py-1.5 text-xs rounded-full border transition-colors ${r.includes(i)?"bg-primary text-primary-foreground border-primary":"bg-muted border-border hover:bg-muted/80"}`,children:i},i))})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),r.length>0&&e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs text-muted-foreground mb-1 block",children:["Selected (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:[i,e.jsx("button",{onClick:()=>o(i),className:"hover:text-destructive",children:"×"})]},i))})]})]})}function yks({config:t,onChange:s}){const r=t.links||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,links:u})},a=()=>s({...t,links:[...r,{label:"",url:""}]}),o=l=>s({...t,links:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-3",children:[r.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{placeholder:"Button label",value:l.label,onChange:c=>n(i,"label",c.target.value)}),e.jsx(ze,{placeholder:"https://...",value:l.url,onChange:c=>n(i,"url",c.target.value)})]}),r.length>1&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:e.jsx(Nr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const Ize=[{value:"instagram",label:"Instagram"},{value:"facebook",label:"Facebook"},{value:"linkedin",label:"LinkedIn"},{value:"twitter",label:"X (Twitter)"},{value:"youtube",label:"YouTube"},{value:"tiktok",label:"TikTok"},{value:"zillow",label:"Zillow"},{value:"realtor",label:"Realtor.com"},{value:"spotify",label:"Spotify"},{value:"apple_music",label:"Apple Music"}];function vks({config:t,onChange:s}){const r=t.platforms||[],n=c=>{r.find(u=>u.platform===c)||s({...t,platforms:[...r,{platform:c,url:""}]})},a=(c,u)=>{const p=[...r];p[c]={...p[c],url:u},s({...t,platforms:p})},o=c=>{s({...t,platforms:r.filter((u,p)=>p!==c)})},l=Ize.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=Uve[c],p=Ize.find(f=>f.value===c);return{label:(p==null?void 0:p.label)||c,color:(u==null?void 0:u.color)||"#666",iconPath:u==null?void 0:u.icon}};return e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map((c,u)=>{const p=i(c.platform);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&e.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:e.jsx("path",{d:p.iconPath})})}),e.jsx("div",{className:"flex-1",children:e.jsx(ze,{placeholder:`Your ${p.label} profile URL`,value:c.url,onChange:f=>a(u,f.target.value)})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(u),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>{const u=Uve[c.value];return e.jsxs("button",{onClick:()=>n(c.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-full border border-border bg-muted hover:bg-muted/80 transition-colors",children:[(u==null?void 0:u.icon)&&e.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:u.color,children:e.jsx("path",{d:u.icon})}),c.label]},c.value)})})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var bks=Object.defineProperty,hde=Object.getOwnPropertySymbols,Plt=Object.prototype.hasOwnProperty,Ilt=Object.prototype.propertyIsEnumerable,Lze=(t,s,r)=>s in t?bks(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,bwe=(t,s)=>{for(var r in s||(s={}))Plt.call(s,r)&&Lze(t,r,s[r]);if(hde)for(var r of hde(s))Ilt.call(s,r)&&Lze(t,r,s[r]);return t},_we=(t,s)=>{var r={};for(var n in t)Plt.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&hde)for(var n of hde(t))s.indexOf(n)<0&&Ilt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var g3;(t=>{const s=class xo{constructor(c,u,p,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cxo.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let _=0;_7)throw new RangeError("Invalid value");let _,w;for(_=p;;_++){const M=xo.getNumDataCodewords(_,u)*8,L=l.getTotalBits(c,_);if(L<=M){w=L;break}if(_>=f)throw new RangeError("Data too long")}for(const M of[xo.Ecc.MEDIUM,xo.Ecc.QUARTILE,xo.Ecc.HIGH])v&&w<=xo.getNumDataCodewords(_,M)*8&&(u=M);let j=[];for(const M of c){r(M.mode.modeBits,4,j),r(M.numChars,M.mode.numCharCountBits(_),j);for(const L of M.getData())j.push(L)}a(j.length==w);const k=xo.getNumDataCodewords(_,u)*8;a(j.length<=k),r(0,Math.min(4,k-j.length),j),r(0,(8-j.length%8)%8,j),a(j.length%8==0);for(let M=236;j.lengthS[L>>>3]|=M<<7-(L&7)),new xo(_,u,S,g)}getModule(c,u){return 0<=c&&c>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(f,g));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(f,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(f,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(f,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let p=0;p<12;p++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;a(u>>>18==0);for(let p=0;p<18;p++){const f=n(u,p),g=this.size-11+p%3,v=Math.floor(p/3);this.setFunctionModule(g,v,f),this.setFunctionModule(v,g,f)}}drawFinderPattern(c,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(p)),v=c+f,_=u+p;0<=v&&v{(M!=w-g||P>=_)&&S.push(L[M])});return a(S.length==v),S}drawCodewords(c){if(c.length!=Math.floor(xo.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f>>3],7-(u&7)),u++)}}a(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&c++):(this.finderPenaltyAddHistory(_,w),v||(c+=this.finderPenaltyCountPatterns(w)*xo.PENALTY_N3),v=this.modules[g][j],_=1);c+=this.finderPenaltyTerminateAndCount(v,_,w)*xo.PENALTY_N3}for(let g=0;g5&&c++):(this.finderPenaltyAddHistory(_,w),v||(c+=this.finderPenaltyCountPatterns(w)*xo.PENALTY_N3),v=this.modules[j][g],_=1);c+=this.finderPenaltyTerminateAndCount(v,_,w)*xo.PENALTY_N3}for(let g=0;gv+(_?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),c+=f*xo.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let p=[6];for(let f=this.size-7;p.lengthxo.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const p=Math.floor(c/7)+2;u-=(25*p-10)*p-55,c>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(xo.getNumRawDataModules(c)/8)-xo.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*xo.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let f=0;f0);for(const f of c){const g=f^p.shift();p.push(0),u.forEach((v,_)=>p[_]^=xo.reedSolomonMultiply(v,g))}return p}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(u>>>f&1)*c;return a(p>>>8==0),p}finderPenaltyCountPatterns(c){const u=c[1];a(u<=this.size*3);const p=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(p&&c[0]>=u*4&&c[6]>=u?1:0)+(p&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,p){return c&&(this.finderPenaltyAddHistory(u,p),u=0),u+=this.size,this.finderPenaltyAddHistory(u,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=s;function r(i,c,u){if(c<0||c>31||i>>>c)throw new RangeError("Value out of range");for(let p=c-1;p>=0;p--)u.push(i>>>p&1)}function n(i,c){return(i>>>c&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class ud{constructor(c,u,p){if(this.mode=c,this.numChars=u,this.bitData=p,u<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(c){let u=[];for(const p of c)r(p,8,u);return new ud(ud.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!ud.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let p=0;p=1<{(s=>{const r=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(t.QrCode||(t.QrCode={}))})(g3||(g3={}));(t=>{(s=>{const r=class{constructor(a,o){this.modeBits=a,this.numBitsCharCount=o}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(t.QrSegment||(t.QrSegment={}))})(g3||(g3={}));var SM=g3;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var _ks={L:SM.QrCode.Ecc.LOW,M:SM.QrCode.Ecc.MEDIUM,Q:SM.QrCode.Ecc.QUARTILE,H:SM.QrCode.Ecc.HIGH},Llt=128,Dlt="L",Olt="#FFFFFF",Rlt="#000000",Flt=!1,zlt=1,wks=4,jks=0,Nks=.1;function Blt(t,s=0){const r=[];return t.forEach(function(n,a){let o=null;n.forEach(function(l,i){if(!l&&o!==null){r.push(`M${o+s} ${a+s}h${i-o}v1H${o+s}z`),o=null;return}if(i===n.length-1){if(!l)return;o===null?r.push(`M${i+s},${a+s} h1v1H${i+s}z`):r.push(`M${o+s},${a+s} h${i+1-o}v1H${o+s}z`);return}l&&o===null&&(o=i)})}),r.join("")}function $lt(t,s){return t.slice().map((r,n)=>n=s.y+s.h?r:r.map((a,o)=>o=s.x+s.w?a:!1))}function kks(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Nks),l=a/s,i=(n.width||o)*l,c=(n.height||o)*l,u=n.x==null?t.length/2-i/2:n.x*l,p=n.y==null?t.length/2-c/2:n.y*l,f=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let _=Math.floor(u),w=Math.floor(p),j=Math.ceil(i+u-_),k=Math.ceil(c+p-w);g={x:_,y:w,w:j,h:k}}const v=n.crossOrigin;return{x:u,y:p,h:c,w:i,excavation:g,opacity:f,crossOrigin:v}}function Sks(t,s){return s!=null?Math.max(Math.floor(s),0):t?wks:jks}function qlt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let c=ht.useMemo(()=>{const _=(Array.isArray(t)?t:[t]).reduce((w,j)=>(w.push(...SM.QrSegment.makeSegments(j)),w),[]);return SM.QrCode.encodeSegments(_,_ks[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:g}=ht.useMemo(()=>{let v=c.getModules();const _=Sks(n,a),w=v.length+_*2,j=kks(v,l,_,o);return{cells:v,margin:_,numCells:w,calculatedImageSettings:j}},[c,l,o,n,a]);return{qrcode:c,margin:p,cells:u,numCells:f,calculatedImageSettings:g}}var Cks=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Mks=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Llt,level:l=Dlt,bgColor:i=Olt,fgColor:c=Rlt,includeMargin:u=Flt,minVersion:p=zlt,boostLevel:f,marginSize:g,imageSettings:v}=n,w=_we(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=w,k=_we(w,["style"]),S=v==null?void 0:v.src,M=ht.useRef(null),L=ht.useRef(null),P=ht.useCallback(Q=>{M.current=Q,typeof r=="function"?r(Q):r&&(r.current=Q)},[r]),[O,$]=ht.useState(!1),{margin:U,cells:B,numCells:V,calculatedImageSettings:X}=qlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:g,imageSettings:v,size:o});ht.useEffect(()=>{if(M.current!=null){const Q=M.current,ce=Q.getContext("2d");if(!ce)return;let ne=B;const re=L.current,oe=X!=null&&re!==null&&re.complete&&re.naturalHeight!==0&&re.naturalWidth!==0;oe&&X.excavation!=null&&(ne=$lt(B,X.excavation));const fe=window.devicePixelRatio||1;Q.height=Q.width=o*fe;const ge=o/V*fe;ce.scale(ge,ge),ce.fillStyle=i,ce.fillRect(0,0,V,V),ce.fillStyle=c,Cks?ce.fill(new Path2D(Blt(ne,U))):B.forEach(function(ue,xe){ue.forEach(function(_e,$e){_e&&ce.fillRect($e+U,xe+U,1,1)})}),X&&(ce.globalAlpha=X.opacity),oe&&ce.drawImage(re,X.x+U,X.y+U,X.w,X.h)}}),ht.useEffect(()=>{$(!1)},[S]);const Y=bwe({height:o,width:o},j);let ee=null;return S!=null&&(ee=ht.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{$(!0)},ref:L,crossOrigin:X==null?void 0:X.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",bwe({style:Y,height:o,width:o,ref:P,role:"img"},k)),ee)});Mks.displayName="QRCodeCanvas";var RR=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Llt,level:l=Dlt,bgColor:i=Olt,fgColor:c=Rlt,includeMargin:u=Flt,minVersion:p=zlt,boostLevel:f,title:g,marginSize:v,imageSettings:_}=n,w=_we(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:k,numCells:S,calculatedImageSettings:M}=qlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:v,imageSettings:_,size:o});let L=k,P=null;_!=null&&M!=null&&(M.excavation!=null&&(L=$lt(k,M.excavation)),P=ht.createElement("image",{href:_.src,height:M.h,width:M.w,x:M.x+j,y:M.y+j,preserveAspectRatio:"none",opacity:M.opacity,crossOrigin:M.crossOrigin}));const O=Blt(L,j);return ht.createElement("svg",bwe({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!g&&ht.createElement("title",null,g),ht.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:c,d:O,shapeRendering:"crispEdges"}),P)});RR.displayName="QRCodeSVG";function Tks({slug:t,agentName:s}){const r=N.useRef(null),n=`https://cards.relevelup.com/${t}`,a=N.useCallback(()=>{var f;const o=(f=r.current)==null?void 0:f.querySelector("svg");if(!o)return;const l=document.createElement("canvas"),i=1024;l.width=i,l.height=i;const c=l.getContext("2d");if(!c)return;const u=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{c.fillStyle="#ffffff",c.fillRect(0,0,i,i),c.drawImage(p,0,0,i,i);const g=document.createElement("a");g.download=`${t}-qr-code.png`,g.href=l.toDataURL("image/png"),g.click(),me.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(u)))},[t]);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-sm font-medium",children:"QR Code"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{ref:r,className:"bg-white p-3 rounded-lg border shadow-sm shrink-0",children:e.jsx(RR,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Download this QR code to use on business cards, flyers, signs, or any print materials. Scanning it opens your digital card instantly."}),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[e.jsx(vi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function Bye(t){return{is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56,bold_theme_colors:t.bold_theme_colors||null,display_email:t.display_email||""}}function Aks(){const{user:t}=Os(),{data:s,isLoading:r}=Pkt(t==null?void 0:t.id),n=DE(),[a,o]=N.useState(null),l=N.useMemo(()=>a||(s?Bye(s):null),[a,s]);if(r)return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(vs,{className:"h-8 w-48"}),e.jsx(vs,{className:"h-32 w-full"}),e.jsx(vs,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Ts,{children:e.jsx(Pks,{userId:t==null?void 0:t.id})});const i=l||Bye(s),c=u=>{o(p=>{const f=p||Bye(s);return typeof u=="function"?u(f):u})};return e.jsx(Ts,{children:e.jsxs("div",{className:"flex gap-6 items-start",children:[e.jsxs("div",{className:`${n?"w-full":"flex-1 min-w-0"} max-w-2xl p-4 space-y-6 animate-fade-in`,children:[e.jsx(Iks,{card:s}),e.jsx(Rks,{card:s,form:i,setForm:c})]}),!n&&e.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&e.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:e.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[e.jsx(xS,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium",children:"Live Preview"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(Eks,{card:s,form:i})})]})})]})})}function Eks({card:t,form:s}){const{data:r}=mt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await H.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=N.useMemo(()=>({...t,is_published:s.is_published,theme:s.theme,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,custom_cta_url:t.custom_cta_url,show_photo:s.show_photo,show_bio:s.show_bio,show_video:t.show_video,show_credentials:s.show_credentials,show_social_links:s.show_social_links,show_save_contact:s.show_save_contact,show_leave_review:s.show_leave_review,show_refer_friend:s.show_refer_friend,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,display_email:s.display_email||null,social_links:t.social_links||[],profile:{name:(r==null?void 0:r.name)||null,email:s.display_email||(r==null?void 0:r.email)||null,phone:(r==null?void 0:r.phone)||null,brokerage_id:(r==null?void 0:r.brokerage_id)||null},brokerage_name:s.brokerage_display_name||null,avatar_url:(r==null?void 0:r.avatar_url)||null}),[t,s,r]);return e.jsx("div",{className:"transform scale-[0.85] origin-top",children:e.jsx(jje,{card:n})})}function Pks({userId:t}){var c;const[s,r]=N.useState(""),n=wWe(),{data:a}=mt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await H.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((c=a==null?void 0:a.name)==null?void 0:c.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!t)return;const u=(s.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!u){me.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>me.success("Your digital card has been created!")})},i=[{icon:ru,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Yh,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Au,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Bl,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/90 via-primary to-primary/80 p-8 md:p-12 mb-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm text-sm font-medium mb-4",children:[e.jsx(fn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(Pt,{className:"text-center pb-2",children:[e.jsx(Rt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(gr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-medium",children:"Your Card URL"}),e.jsxs("div",{className:"flex items-center gap-0 mt-1.5",children:[e.jsx("span",{className:"inline-flex items-center px-3 h-10 rounded-l-md border border-r-0 bg-muted text-sm text-muted-foreground whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function Iks({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),me.success("Card link copied!")};return e.jsx("div",{className:"rounded-xl border bg-card p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-xl font-bold",children:"My Digital Card"}),e.jsx(st,{variant:t.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:t.is_published?"Live":"Draft"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ru,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",t.slug]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[e.jsx(yi,{className:"h-3.5 w-3.5"})," Copy Link"]}),e.jsx(K,{size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function Lks({userId:t}){const s=Xt(),r=N.useRef(null),[n,a]=N.useState(!1),[o,l]=N.useState(""),{data:i,isLoading:c}=mt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:X}=await H.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let Y=(X==null?void 0:X.avatar_url)||null;if(!Y){const{data:ee}=await H.storage.from("avatars").list(`${t}`);if(ee&&ee.length>0){const{data:Q}=H.storage.from("avatars").getPublicUrl(`${t}/${ee[0].name}`);Y=`${Q.publicUrl}?t=${Date.now()}`,await H.from("profiles").update({avatar_url:Y}).eq("id",t)}}return{...X,avatar_url:Y}}}),[u,p]=N.useState(null),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(!1),k=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",M=v??(i==null?void 0:i.email)??"",L=i==null?void 0:i.avatar_url,P=((i==null?void 0:i.name)||"A").split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),O=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Lt({mutationFn:async X=>{const{error:Y}=await H.from("profiles").update(X).eq("id",t);if(Y)throw Y},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Profile updated!")},onError:()=>me.error("Failed to update profile")}),U=()=>{const X={};if(u!==null&&u!==(i==null?void 0:i.name)&&(X.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(X.phone=f||null),v!==null&&v!==(i==null?void 0:i.email)&&(X.email=v),Object.keys(X).length===0){me.info("No changes to save");return}$.mutate(X)},B=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;if(!Y.type.startsWith("image/")){me.error("Please select an image file");return}const ee=new FileReader;ee.onloadend=()=>{l(ee.result),a(!0)},ee.readAsDataURL(Y),X.target.value=""},V=async X=>{j(!0);try{const{data:Y}=await H.storage.from("avatars").list(`${t}`);Y&&Y.length>0&&await H.storage.from("avatars").remove(Y.map(re=>`${t}/${re.name}`));const ee=`${t}/avatar.jpg`,{error:Q}=await H.storage.from("avatars").upload(ee,X,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:ce}=H.storage.from("avatars").getPublicUrl(ee),ne=ce.publicUrl+"?t="+Date.now();await H.from("profiles").update({avatar_url:ne}).eq("id",t),s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Photo updated!")}catch{me.error("Failed to upload photo")}finally{j(!1)}};return c?e.jsx(vs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:O?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(be,{className:"text-sm font-semibold",children:"Profile Info"}),O&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(Cl,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var X;return(X=r.current)==null?void 0:X.click()},children:[e.jsxs(kn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Ua,{src:L||void 0,alt:k}),e.jsx(Sn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:P})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ff,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:B})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":L?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(ze,{value:k,onChange:X=>p(X.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(ze,{value:S,onChange:X=>g(X.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(ze,{value:M,onChange:X=>_(X.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(Lke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function Dks({form:t,setForm:s,userId:r}){const[n,a]=N.useState(null),[o,l]=N.useState(t.brokerage_logo_url?"logo":"name"),[i,c]=N.useState(t.team_logo_url?"logo":"name"),u=v=>{l(v),s(v==="name"?_=>({..._,brokerage_logo_url:""}):_=>({..._,brokerage_display_name:""}))},p=v=>{c(v),s(v==="name"?_=>({..._,team_logo_url:""}):_=>({..._,team_name:""}))},f=async(v,_)=>{var j;const w=(j=v.target.files)==null?void 0:j[0];if(w){if(!w.type.startsWith("image/")){me.error("Please select an image file");return}a(_);try{const k=w.name.split(".").pop()||"png",M=`${r}/${_==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${k}`,{error:L}=await H.storage.from("card-logos").upload(M,w,{upsert:!0});if(L)throw L;const{data:P}=H.storage.from("card-logos").getPublicUrl(M),O=P.publicUrl+"?t="+Date.now();s(_==="brokerage_logo_url"?$=>({...$,[_]:O,brokerage_display_name:""}):$=>({...$,[_]:O,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{a(null),v.target.value=""}}},g=v=>{s(_=>({..._,[v]:""}))};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-semibold",children:"Brokerage & Team Branding"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose either a name or a logo for each — not both."})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>u("logo"),children:"Use Logo"})]}),o==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(ze,{value:t.brokerage_display_name,onChange:v=>s(_=>({..._,brokerage_display_name:v.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.brokerage_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>g("brokerage_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(ff,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":t.brokerage_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:v=>f(v,"brokerage_logo_url"),disabled:n!==null})]})]}),t.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.brokerage_logo_size||56,"px"]})]}),e.jsx(Yg,{value:[t.brokerage_logo_size||56],onValueChange:([v])=>s(_=>({..._,brokerage_logo_size:v})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),e.jsx(K,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(ze,{value:t.team_name,onChange:v=>s(_=>({..._,team_name:v.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Team Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.team_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.team_logo_url,alt:"Team logo",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>g("team_logo_url"),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}):null,e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(ff,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":t.team_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:v=>f(v,"team_logo_url"),disabled:n!==null})]})]}),t.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.team_logo_size||56,"px"]})]}),e.jsx(Yg,{value:[t.team_logo_size||56],onValueChange:([v])=>s(_=>({..._,team_logo_size:v})),min:24,max:120,step:4})]})]})]})]})})}function Oks({form:t,setForm:s}){const r={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=t.bold_theme_colors||r,a=(i,c)=>{s(u=>({...u,bold_theme_colors:{...r,...u.bold_theme_colors,[i]:c}}))},o=()=>{s(i=>({...i,bold_theme_colors:null}))},l=[{key:"accent",label:"Accent Color",desc:"Page background, icons, highlights"},{key:"dark",label:"Dark Color",desc:"Header background, action buttons, social icons"},{key:"button",label:"CTA Button Color",desc:"Main call-to-action button"}];return e.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Bl,{className:"h-4 w-4"})," Brand Colors"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),e.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:c,desc:u})=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"relative shrink-0",children:[e.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),e.jsx("div",{className:"h-10 w-10 rounded-lg border-2 border-border cursor-pointer shadow-sm hover:scale-105 transition-transform",style:{backgroundColor:n[i]}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:c}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(ze,{value:n[i],onChange:p=>{const f=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(f)&&a(i,f)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),e.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function Rks({card:t,form:s,setForm:r}){var w;const n=jWe(),a=Xt(),{data:o}=NWe(t.id),[l,i]=N.useState(t.slug),[c,u]=N.useState(!1),[p,f]=N.useState("idle"),g=N.useRef(JSON.stringify(s)),v=N.useRef(null);N.useEffect(()=>{const j=JSON.stringify(s);if(j!==g.current)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{g.current=j,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{v.current&&clearTimeout(v.current)}},[s]);const _=async()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!j){me.error("Please enter a valid URL");return}if(j===t.slug){me.info("No changes to save");return}u(!0);try{const{data:k}=await H.from("agent_cards").select("id").eq("slug",j).neq("id",t.id).maybeSingle();if(k){me.error("This URL is already taken. Try another one.");return}const{error:S}=await H.from("agent_cards").update({slug:j}).eq("id",t.id);if(S)throw S;i(j),a.invalidateQueries({queryKey:["agent-card"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_a,{defaultValue:"content",children:[e.jsxs(fa,{className:"w-full h-11 p-1",children:[e.jsxs(ns,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Mx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(ns,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Dn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(ns,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Yh,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(ns,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(p1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(ns,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Tx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(ws,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(Lks,{userId:t.user_id}),e.jsx(Dks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-sm font-semibold",children:"Card Status"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),e.jsx(qr,{checked:s.is_published,onCheckedChange:j=>r(k=>({...k,is_published:j}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:l,onChange:j=>i(j.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:_,disabled:c||l===t.slug,className:"shrink-0",children:c?"Saving...":"Update"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(ze,{value:s.display_email,onChange:j=>r(k=>({...k,display_email:j.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(Ks,{value:s.theme,onValueChange:j=>r(k=>({...k,theme:j})),children:[e.jsx(Gs,{className:"h-11",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(Mt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(Oks,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(ze,{value:s.title,onChange:j=>r(k=>({...k,title:j.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(ze,{value:s.positioning_statement,onChange:j=>r(k=>({...k,positioning_statement:j.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Pr,{value:s.bio,onChange:j=>r(k=>({...k,bio:j.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(ze,{value:s.review_snippet,onChange:j=>r(k=>({...k,review_snippet:j.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(ze,{value:s.review_source_url,onChange:j=>r(k=>({...k,review_source_url:j.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(ze,{value:s.booking_url,onChange:j=>r(k=>({...k,booking_url:j.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(ze,{value:s.custom_cta_label,onChange:j=>r(k=>({...k,custom_cta_label:j.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(ws,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:j,label:k,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{className:"text-sm font-medium",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(qr,{checked:s[j],onCheckedChange:M=>r(L=>({...L,[j]:M}))})]},j))})})}),e.jsx(ws,{value:"blocks",className:"mt-4",children:e.jsx(Elt,{cardId:t.id})}),e.jsx(ws,{value:"analytics",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Views",value:(o==null?void 0:o.views)??0,icon:Dn,color:"text-blue-600 bg-blue-100 dark:text-blue-400 dark:bg-blue-900/30"},{label:"Clicks",value:(o==null?void 0:o.clicks)??0,icon:Tx,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:El,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(j=>e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${j.color}`,children:e.jsx(j.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:j.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:j.value})]})},j.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(j=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:j.name}),j.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:j.phone})]}),j.intent&&e.jsx(st,{variant:"secondary",className:"text-xs",children:j.intent})]},j.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Tx,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"font-medium text-muted-foreground",children:"No analytics data yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Share your card link to start tracking"})]})})]})}),e.jsx(ws,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(Tks,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function Fks(){const t=Xt(),[s,r]=N.useState(""),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState(null),[w,j]=N.useState(null),[k,S]=N.useState(0),{data:M,isLoading:L}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Q)throw Q;return ee}}),P=Lt({mutationFn:async ee=>{const{data:Q,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:ee}});if(ce)throw ce;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),me.success("BoldTrail connected successfully!")},onError:ee=>{me.error(ee.message||"Failed to connect BoldTrail")}}),O=Lt({mutationFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(Q)throw Q;return ee},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("BoldTrail disconnected")},onError:()=>me.error("Failed to disconnect")}),$=Lt({mutationFn:async ee=>{const{data:Q,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:ee}});if(ce)throw ce;if(Q!=null&&Q.error)throw new Error(Q.error);return Q},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),me.success("Sync direction saved")},onError:ee=>{me.error(ee.message||"Failed to save sync direction")}}),U=Lt({mutationFn:async()=>{const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(Q)throw Q;if(ee!=null&&ee.error)throw new Error(ee.error);return ee},onSuccess:ee=>{_(null),c(ee),a(!0)},onError:ee=>{me.error(ee.message||"Failed to generate sync preview")}}),B=Lt({mutationFn:async()=>{j("Initializing sync..."),S(5);const{data:ee,error:Q}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:Y}});if(Q)throw Q;if(ee!=null&&ee.error)throw new Error(ee.error);const ce=ee;let ne=ce.sync_log_id,re=ce.next_phase,oe=ce.next_offset;const fe=ce.push_total||0,ge=ce.pull_total||0,ue=fe+ge;let xe=0,_e=0;for(;re!=="finalize";){re==="push"?(j(`Pushing contacts to BoldTrail... (${xe}/${fe})`),S(ue>0?xe/ue*100:0)):re==="pull"&&(j(`Pulling contacts from BoldTrail... (${_e}/${ge})`),S(ue>0?(fe+_e)/ue*100:0));const{data:Ie,error:ke}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:re,offset:oe,sync_log_id:ne,sync_direction:Y}});if(ke)throw ke;if(Ie!=null&&Ie.error)throw new Error(Ie.error);const pe=Ie;xe+=pe.chunk_pushed||0,_e+=pe.chunk_pulled||0,pe.progress&&j(pe.progress),re==="pull"&&ge>0?S(Math.min(95,_e/ge*100)):re==="push"&&fe>0&&S(Math.min(95,xe/fe*100)),re=pe.next_phase,oe=pe.next_offset}j("Finalizing sync..."),S(95);const{data:$e,error:Me}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ne,sync_direction:Y}});if(Me)throw Me;return S(100),$e},onSuccess:ee=>{j(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${ee.contacts_pushed||0}, pulled ${ee.contacts_pulled||0}, skipped ${ee.contacts_skipped||0} duplicates.`)},onError:ee=>{j(null),S(0),me.error(ee.message||"Sync failed")}}),V=M==null?void 0:M.connected,X=(M==null?void 0:M.sync_direction)||"bidirectional",Y=v??X;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:e.jsx(_d,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(pp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(gr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Two-way contact sync with duplicate prevention"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Preview what will sync before executing"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Syncs name, email, phone, address, notes, and lead source"})]}),V?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx("div",{className:"rounded-lg border p-3 space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"BoldTrail Connected"}),(M==null?void 0:M.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(M.last_sync_at).toLocaleString(),M.last_sync_status&&e.jsx(st,{variant:M.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:M.last_sync_status})]}),(M==null?void 0:M.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[M.boldtrail_contact_count," contacts in BoldTrail"]}),(M==null?void 0:M.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.last_sync_message})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect BoldTrail?"}),e.jsx(ic,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>O.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(Q_e,{value:X,onChange:ee=>$.mutate(ee)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||B.isPending,variant:"outline",className:"gap-2",children:[U.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(Dn,{className:"h-4 w-4"}),"Preview Sync"]})})]}):e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:ee=>r(ee.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>P.mutate(s),disabled:!s||s.length<10||P.isPending,children:[P.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find your API token in BoldTrail → Lead Engine → Lead Dropbox → My API Tokens. Generate a ",e.jsx("strong",{children:"Contacts"})," scope token."]})]})]})})]}),e.jsx(xs,{open:n,onOpenChange:ee=>{B.isPending||a(ee)},children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_d,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Wr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const ee=Y==="pull_only"?0:i.to_push,Q=Y==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Q_e,{value:Y,onChange:_,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Y==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:ee}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Su,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${Y==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Kh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),B.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:k||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:w||"Sync in progress..."})]}),ee>0&&e.jsxs(vf,{open:u,onOpenChange:p,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Su,{className:"h-3 w-3 text-emerald-600"}),ee," contacts to push to BoldTrail"]}),e.jsx(oo,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(_f,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((ce,ne)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ne)),i.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_push-20," more"]})]})})]}),Q>0&&e.jsxs(vf,{open:f,onOpenChange:g,children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kh,{className:"h-3 w-3 text-blue-600"}),Q," contacts to pull from BoldTrail"]}),e.jsx(oo,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(_f,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((ce,ne)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:ce.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:ce.email})]},ne)),i.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",i.to_pull-20," more"]})]})})]}),ee===0&&Q===0&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),disabled:B.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>B.mutate(),disabled:B.isPending||ee===0&&Q===0,className:"gap-2",children:[B.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(_d,{className:"h-4 w-4"}),B.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(js,{className:"p-6 pb-0",children:e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(_d,{className:"h-5 w-5 text-emerald-600"}),"How BoldTrail Sync Works"]})}),e.jsx("div",{className:"px-6 pb-6",children:e.jsx("video",{src:"/videos/BoldTrailIntegration.mp4",controls:!0,autoPlay:!0,className:"w-full rounded-lg",controlsList:"nodownload"})})]})})]})}function Ult(){const t=nr(),[s,r]=N.useState(""),[n,a]=N.useState(""),[o,l]=N.useState("Test from ReLevelUp"),[i,c]=N.useState(!1),{data:u,isLoading:p}=mt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:v}}=await H.auth.getSession();if(!v)throw new Error("Not authenticated");return(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){me.error("Please fill in From and To email addresses");return}c(!0);try{const{data:{session:v}}=await H.auth.getSession();if(!v)throw new Error("Not authenticated");const w=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${v.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

This is a test email sent via Amazon SES from the ReLevelUp platform.

If you received this, SES is configured correctly! 🎉

"})})).json();w.success?me.success(`Test email sent! Message ID: ${w.messageId}`):me.error(w.error||"Failed to send test email")}catch(v){me.error(v.message||"Failed to send test email")}finally{c(!1)}},g=(u==null?void 0:u.configured)===!0;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx(lr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(gr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(st,{variant:g?"default":"secondary",children:p?"Checking...":g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cl,{className:"h-3 w-3"})," Not Configured"]})})]})}),g&&e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"From Email"}),e.jsx(ze,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:v=>a(v.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"To Email"}),e.jsx(ze,{placeholder:"your@email.com",value:s,onChange:v=>r(v.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Subject"}),e.jsx(ze,{value:o,onChange:v=>l(v.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx($n,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Ph,{className:"h-4 w-4 mr-2"})," Launch Campaign Composer"]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Region:"})," ",u==null?void 0:u.region]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Domain:"})," send.relevelup.com (verified)"]})]})]}),!g&&!p&&e.jsx(Oe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}function zks(){var _,w,j,k;const{user:t}=Os(),s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(""),[l,i]=N.useState(""),{data:c}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(M)throw M;return S}}),{data:u}=mt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:M}=await H.from("profiles").select("email, name").eq("id",t.id).single();if(M)throw M;return S}}),p=((_=c==null?void 0:c.reply_to_email)==null?void 0:_.trim())||((w=u==null?void 0:u.email)==null?void 0:w.trim())||"",f=((j=c==null?void 0:c.display_name)==null?void 0:j.trim())||((k=u==null?void 0:u.name)==null?void 0:k.trim())||"";N.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const g=Lt({mutationFn:async()=>{if(!t||!a.trim())throw new Error("Please enter a reply-to email");const S={reply_to_email:a.trim(),display_name:l.trim()||null,updated_at:new Date().toISOString()};if(c){const{error:M}=await H.from("mass_email_settings").update(S).eq("user_id",t.id);if(M)throw M}else{const{error:M}=await H.from("mass_email_settings").insert({user_id:t.id,...S});if(M)throw M}},onSuccess:()=>{s.invalidateQueries({queryKey:["mass-email-settings",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-ready",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["mass-email-settings-check",t==null?void 0:t.id]}),me.success("Reply-to email saved!"),n(!1)},onError:S=>me.error(S.message)}),v=!!p;return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-orange-500/10 flex items-center justify-center",children:e.jsx($n,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Mass Email",v?e.jsxs(st,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(gi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(gr,{children:"Set the email address where replies from your campaigns will be sent. If you haven't customized it yet, we'll use your profile email."})]})]})}),e.jsx(Oe,{className:"space-y-3",children:v&&!r?e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:f||"No display name"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>n(!0),children:[e.jsx(za,{className:"h-3 w-3 mr-1"})," Edit"]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Display Name"}),e.jsx(ze,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:S=>i(S.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How your name appears in the recipient's inbox"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(ze,{type:"email",placeholder:"your@email.com",value:a,onChange:S=>o(S.target.value)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",onClick:()=>g.mutate(),disabled:g.isPending||!a.trim(),children:[e.jsx(Uc,{className:"h-4 w-4 mr-1"})," Save"]}),r&&e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{n(!1),o(p),i(f)},children:[e.jsx(Mr,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function Bks(){const{isAdmin:t}=Os(),s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),{data:c,isLoading:u}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:L,error:P}=await H.from("gmail_integrations").select("*").maybeSingle();if(P)throw P;return L}}),{data:p}=mt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:L}}=await H.auth.getUser();if(!L)return[];const{data:P,error:O}=await H.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(O)throw O;return P}}),f=async()=>{n(!0);try{const{data:L,error:P}=await H.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(P)throw P;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Gmail OAuth error:",L),me.error("Failed to start Gmail connection"),n(!1)}},g=async()=>{o(!0);try{const{data:L,error:P}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(P)throw P;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),me.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},v=async()=>{i(!0);try{const{data:L,error:P}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(P)throw P;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),me.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},_=Lt({mutationFn:async L=>{const{error:P}=await H.from("gmail_integrations").delete().eq("id",L);if(P)throw P},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),w=Lt({mutationFn:async L=>{const{error:P}=await H.from("social_accounts").delete().eq("id",L);if(P)throw P},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),j=!!(c!=null&&c.is_active),k=(p==null?void 0:p.filter(L=>L.platform==="facebook"))||[],S=(p==null?void 0:p.filter(L=>L.platform==="instagram"))||[],M=(p==null?void 0:p.filter(L=>L.platform==="linkedin"))||[];return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),e.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:e.jsx(lr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Gmail",j&&e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(gr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),j?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Gmail?"}),e.jsx(ic,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>_.mutate(c.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:f,disabled:r||u,children:[r?e.jsx(Wo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Sa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(Cu,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?k.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Eh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[k.length>0&&e.jsx("div",{className:"space-y-2",children:k.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:L.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Cu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Facebook?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>w.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:e.jsx(Tu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Eh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:L.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Tu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",L.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Instagram?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>w.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:g,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:e.jsx(Mp,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?M.length>0?e.jsx(st,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(st,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Eh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(gr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-8 w-8",children:[e.jsx(Ua,{src:L.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect LinkedIn?"}),e.jsx(ic,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>w.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}),e.jsxs(K,{onClick:v,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(Fks,{}),e.jsx(zks,{}),t&&e.jsx(Ult,{})]})})}function $ks(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your Gmail account...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Gmail connected successfully!"),me.success("Gmail connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Gmail OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Gmail"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(bs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(jc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function qks(){const t=nr();return N.useEffect(()=>{const s=setTimeout(()=>{t("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(s)},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function Uks(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing your connection...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:v}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(v)throw v;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(bs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(jc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const Vlt=new Date().getFullYear(),Vks=Array.from({length:5},(t,s)=>Vlt-s);function Hks(){const[t,s]=N.useState(Vlt),r=nr(),{data:n,isLoading:a}=N8t();return a?e.jsx(Ts,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(vs,{className:"h-24"},o))}),e.jsx(vs,{className:"h-96"})]})}):e.jsx(Ts,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),e.jsxs(Ks,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Vks.map(o=>e.jsx(Mt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(yo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agents with Scorecards"}),e.jsx(gr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(yo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Email"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:n.map(o=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:o.name}),e.jsx(dt,{className:"text-muted-foreground",children:o.email}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r(`/admin/scorecard/${o.id}`),children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Hlt=new Date().getFullYear(),Gks=Array.from({length:10},(t,s)=>Hlt-s);function Dze(){var _;const{userId:t}=lo(),s=nr(),n=dc().pathname.startsWith("/mission-control"),[a,o]=N.useState(Hlt),{data:l,isLoading:i}=mt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:j}=await H.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return w},enabled:!!t}),{data:c,isLoading:u}=zNe(a,t),{yearStats:p,lifetimeStats:f,showCommission:g}=MQe(a,t),{data:v}=CQe(a,t);return i?e.jsx(Ts,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(vs,{className:"h-24"},w))})]})}):e.jsx(Ts,{title:`${l==null?void 0:l.name}'s Scorecard`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s(n?"/mission-control/scorecard":"/admin/scorecard"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:l==null?void 0:l.name}),e.jsx("p",{className:"text-muted-foreground",children:l==null?void 0:l.email})]})]}),e.jsxs(Ks,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Gks.map(w=>e.jsx(Mt,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(dn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Xl(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(tc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((_=p.topLeadSource)==null?void 0:_.name)||"-"})]})})]}),v&&e.jsx(cit,{goals:v,stats:p,year:a,showCommission:g}),e.jsxs(_a,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"transactions",children:"Transactions"}),e.jsx(ns,{value:"charts",children:"Charts"}),e.jsxs(ns,{value:"map",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ws,{value:"transactions",children:e.jsx(wSe,{transactions:c||[],showCommission:g,isLoading:u})}),e.jsx(ws,{value:"charts",children:e.jsx(jSe,{stats:p,year:a})}),e.jsx(ws,{value:"map",children:e.jsx(NSe,{transactions:c||[],isLoading:u})})]})]})})}function Wks(){const t=Xt(),[s,r]=N.useState(""),[n,a]=N.useState("all");sYe();const{data:o,refetch:l}=mt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:L}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(L==null?void 0:L.enabled)??!1}}),{data:i,isLoading:c}=mt({queryKey:["admin-listings"],queryFn:async()=>{const{data:L,error:P}=await H.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(P)throw P;return L}}),{data:u}=mt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:L}=await H.from("listings").select("id, is_approved, status"),{data:P}=await H.from("listing_shares").select("id"),{data:O}=await H.from("listing_views").select("id");return{total:(L==null?void 0:L.length)||0,pending:(L==null?void 0:L.filter($=>!$.is_approved).length)||0,active:(L==null?void 0:L.filter($=>$.status==="active").length)||0,totalShares:(P==null?void 0:P.length)||0,totalViews:(O==null?void 0:O.length)||0}}}),p=async(L,P,O="submit_url")=>{try{const{data:{session:$}}=await H.auth.getSession();if(!$)return;const{data:U,error:B}=await H.functions.invoke("google-indexing",{body:{action:O,listing_id:L,listing_slug:P}});if(B)throw B;if((U==null?void 0:U.configured)===!1)return;U!=null&&U.success&&me.success("Submitted to Google for indexing")}catch($){console.error("Google indexing submission failed:",$)}},f=Lt({mutationFn:async()=>{const{data:{session:L}}=await H.auth.getSession();if(!L)throw new Error("Not authenticated");const{data:P,error:O}=await H.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(O)throw O;return P},onSuccess:L=>{if((L==null?void 0:L.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(L==null?void 0:L.succeeded)||0} URLs to Google (${(L==null?void 0:L.failed)||0} failed)`)},onError:L=>{me.error("Failed to submit to Google"),console.error(L)}}),g=Lt({mutationFn:async({id:L,approved:P,slug:O})=>{const{error:$}=await H.from("listings").update({is_approved:P}).eq("id",L);if($)throw $;return{id:L,approved:P,slug:O}},onSuccess:L=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(L.approved?"Listing approved":"Listing unapproved"),L.approved?p(L.id,L.slug||null,"submit_url"):p(L.id,L.slug||null,"remove_url")}}),v=Lt({mutationFn:async({id:L,featured:P})=>{const{error:O}=await H.from("listings").update({is_featured:P}).eq("id",L);if(O)throw O},onSuccess:(L,{featured:P})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(P?"Listing featured":"Listing unfeatured")}}),_=Lt({mutationFn:async L=>{const{error:P}=await H.from("listings").delete().eq("id",L);if(P)throw P},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),w=Lt({mutationFn:async L=>{const{error:P}=await H.from("feature_flags").update({enabled:L}).eq("key","listing_exchange_enabled");if(P)throw P},onSuccess:()=>{l(),me.success("Feature flag updated")}}),j=o??!1,k=i==null?void 0:i.filter(L=>{var $,U,B,V;const P=(($=L.city)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((B=(U=L.agent)==null?void 0:U.name)==null?void 0:B.toLowerCase().includes(s.toLowerCase()))||((V=L.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),O=n==="all"||n==="pending"&&!L.is_approved||n==="approved"&&L.is_approved;return P&&O}),S=L=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(L),M=L=>{const P={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return P[L]||P.active};return e.jsx(Ts,{title:"Listing Exchange Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(ru,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(qr,{checked:j,onCheckedChange:L=>w.mutate(L)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.active)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.pending)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dn,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(nd,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by city, address, or agent...",value:s,onChange:L=>r(L.target.value),className:"pl-9"})]}),e.jsx(_a,{value:n,onValueChange:L=>a(L),children:e.jsxs(fa,{children:[e.jsx(ns,{value:"all",children:"All"}),e.jsx(ns,{value:"pending",children:"Pending"}),e.jsx(ns,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{children:["Listings (",(k==null?void 0:k.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Property"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Price"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-center",children:"Approved"}),e.jsx(St,{className:"text-center",children:"Featured"}),e.jsx(St,{children:"Views"}),e.jsx(St,{children:"Shares"}),e.jsx(St,{children:"Date"}),e.jsx(St,{})]})}),e.jsx(Bn,{children:c?e.jsx(Cs,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(k==null?void 0:k.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):k==null?void 0:k.map(L=>{var P,O,$,U,B;return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(O=(P=L.photos)==null?void 0:P[0])!=null&&O.photo_url?e.jsx("img",{src:L.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(Ca,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.property_address||`${L.city}, ${L.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($=L.property_type)==null?void 0:$.replace("_"," ")})]})]})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm",children:((U=L.agent)==null?void 0:U.name)||"Unknown"})}),e.jsx(dt,{className:"font-medium",children:S(L.price)}),e.jsx(dt,{children:e.jsx(st,{variant:"outline",className:M(L.status),children:(B=L.status)==null?void 0:B.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_approved??!1,onCheckedChange:V=>g.mutate({id:L.id,approved:V,slug:L.slug})})}),e.jsx(dt,{className:"text-center",children:e.jsx(qr,{checked:L.is_featured??!1,onCheckedChange:V=>v.mutate({id:L.id,featured:V})})}),e.jsx(dt,{children:L.view_count||0}),e.jsx(dt,{children:L.share_count||0}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(xx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Aa,{onClick:()=>window.open(`/mission-control/listings/${L.id}`,"_blank"),children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Aa,{onClick:()=>v.mutate({id:L.id,featured:!L.is_featured}),children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),L.is_featured?"Unfeature":"Feature"]}),e.jsxs(Aa,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&_.mutate(L.id)},children:[e.jsx(Mr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},L.id)})})]})})})]})]})})}const Kks=()=>{var f,g;const[t,s]=N.useState(""),[r,n]=N.useState(null),{data:a,isLoading:o}=mt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:v,error:_}=await H.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(_)throw _;const w=(v==null?void 0:v.map(S=>S.user_id))||[],{data:j}=await H.from("profiles").select("id, name, email").in("id",w);return v==null?void 0:v.map(S=>({...S,profiles:(j==null?void 0:j.find(M=>M.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(v=>{var w,j,k,S,M;const _=t.toLowerCase();return((j=(w=v.profiles)==null?void 0:w.name)==null?void 0:j.toLowerCase().includes(_))||((S=(k=v.profiles)==null?void 0:k.email)==null?void 0:S.toLowerCase().includes(_))||((M=v.review_text)==null?void 0:M.toLowerCase().includes(_))}),i=a!=null&&a.length?(a.reduce((v,_)=>v+_.rating,0)/a.length).toFixed(1):"0.0",c=a==null?void 0:a.reduce((v,_)=>(v[_.rating]=(v[_.rating]||0)+1,v),{}),u=(a==null?void 0:a.filter(v=>v.posted_to_google).length)||0,p=v=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(_=>e.jsx(Jn,{className:It("h-4 w-4",v>=_?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},_))});return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Total Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Average Rating"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Jn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"5-Star Reviews"}),e.jsx(Rt,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(Pt,{className:"pb-2",children:[e.jsx(gr,{children:"Posted to Google"}),e.jsxs(Rt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(en,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or review...",value:t,onChange:v=>s(v.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Member"}),e.jsx(St,{children:"Rating"}),e.jsx(St,{className:"hidden md:table-cell",children:"Review"}),e.jsx(St,{children:"Google"}),e.jsx(St,{children:"Date"})]})}),e.jsx(Bn,{children:o?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(v=>{var _,w;return e.jsxs(Cs,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(v),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_=v.profiles)==null?void 0:_.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=v.profiles)==null?void 0:w.email})]})}),e.jsx(dt,{children:p(v.rating)}),e.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:v.review_text||"-"})}),e.jsx(dt,{children:v.posted_to_google?e.jsx(st,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(st,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ms(new Date(v.created_at),"MMM d, yyyy")})]},v.id)})})]})})}),e.jsx(xs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(js,{children:e.jsx(_s,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((g=r.profiles)==null?void 0:g.email)&&e.jsxs("a",{href:`mailto:${r.profiles.email}`,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-primary",children:[e.jsx(lr,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(hn,{className:"h-4 w-4"}),ms(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(st,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(en,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(st,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Zks=[{value:"0",label:"Sunday"},{value:"1",label:"Monday"},{value:"2",label:"Tuesday"},{value:"3",label:"Wednesday"},{value:"4",label:"Thursday"},{value:"5",label:"Friday"},{value:"6",label:"Saturday"}],Yks=Array.from({length:24},(t,s)=>({value:String(s),label:s===0?"12:00 AM":s<12?`${s}:00 AM`:s===12?"12:00 PM":`${s-12}:00 PM`}));function Qks(){const t=Xt(),{user:s}=Os(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(!1),{data:c,isLoading:u}=mt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_settings").select("*").single();if(B)throw B;return U}}),{data:p,isLoading:f}=mt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:U,error:B}=await H.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(B)throw B;return U}}),{data:g}=mt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:U,error:B}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(B)throw B;return U||0}}),{data:v,refetch:_}=mt({queryKey:["digest-queue-status"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,X,Y]=await Promise.all([H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",U.toISOString()),H.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",U.toISOString())]);return{pending:B.count||0,processing:V.count||0,sent:X.count||0,failed:Y.count||0,total:(B.count||0)+(V.count||0)+(X.count||0)+(Y.count||0)}},refetchInterval:5e3});N.useEffect(()=>{if(v&&(v.pending>0||v.processing>0)){const U=setInterval(()=>{_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(U)}},[v,_,t]);const{data:w=0}=mt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const{count:B,error:V}=await H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString());if(V)throw V;return B||0}}),j=Lt({mutationFn:async U=>{const{error:B}=await H.from("weekly_digest_settings").update(U).eq("id",c==null?void 0:c.id);if(B)throw B},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:U=>{me.error("Failed to update settings: "+U.message)}}),k=async()=>{n(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(B)throw B;U.queued?me.success(`${U.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):U.sent!==void 0&&me.success(`Digest sent! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(U){me.error("Failed to send digest: "+U.message)}finally{n(!1)}},S=async()=>{var U,B,V,X,Y,ee;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:Q,error:ce}=await H.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ne=Q==null?void 0:Q.resendId,re=Q==null?void 0:Q.resendDetails,oe=re==null?void 0:re.status,fe=((U=re==null?void 0:re.body)==null?void 0:U.status)||((V=(B=re==null?void 0:re.body)==null?void 0:B.data)==null?void 0:V.status),ge=((Y=(X=re==null?void 0:re.body)==null?void 0:X.error)==null?void 0:Y.message)||((ee=re==null?void 0:re.body)==null?void 0:ee.message);me.success(ne?`Preview accepted by email provider (id: ${ne})${oe?`, status check: ${oe}`:""}${fe?`, provider: ${fe}`:""}${ge?` (${ge})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(Q){me.error("Failed to send preview: "+Q.message)}finally{o(!1)}},M=async()=>{i(!0);try{const{data:U,error:B}=await H.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(B)throw B;U.queued===0||U.sent===0&&U.failed===0&&!U.queued?me.info("No failed emails to retry"):U.queued?me.success(`${U.queued} emails queued for retry!`):me.success(`Retry complete! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(U){me.error("Failed to retry: "+U.message)}finally{i(!1)}},L=v!=null&&v.total?Math.round((v.sent+v.failed)/v.total*100):0,P=((v==null?void 0:v.pending)||0)>0||((v==null?void 0:v.processing)||0)>0,{data:O}=mt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var ee,Q;const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,X,Y]=await Promise.all([H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",U.toISOString()),H.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:B.count||0,totalFailed:V.count||0,agentOsEngaged:X.count||0,lastSent:((Q=(ee=Y.data)==null?void 0:ee[0])==null?void 0:Q.sent_at)||null}},refetchInterval:P?5e3:!1}),$={totalSent:(O==null?void 0:O.totalSent)||0,totalFailed:(O==null?void 0:O.totalFailed)||0,lastSent:O==null?void 0:O.lastSent,agentOsEngaged:(O==null?void 0:O.agentOsEngaged)||0};return u?e.jsx(Ts,{title:"Weekly Digest",description:"Manage automated weekly email digests",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-32 bg-muted rounded-lg"}),e.jsx("div",{className:"h-64 bg-muted rounded-lg"})]})}):e.jsx(Ts,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(_a,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(ns,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(yo,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(ws,{value:"settings",className:"space-y-6",children:[P&&v&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(bs,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[v.sent.toLocaleString()," sent, ",v.pending.toLocaleString()," pending",v.failed>0&&`, ${v.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[L,"%"]})]}),e.jsx(Bi,{value:L,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(v.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(hr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:g}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(sa,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx(jc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(un,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?ms(new Date($.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(gr,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(qr,{checked:c==null?void 0:c.is_enabled,onCheckedChange:U=>j.mutate({is_enabled:U})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Cron Frequency"}),e.jsxs(Ks,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:U=>j.mutate({cron_frequency:U}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(Mt,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(c==null?void 0:c.cron_frequency)==="hourly"?"Cron runs every hour; digest sends when day & hour match.":"Cron runs once daily at the selected hour (UTC)."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Day of Week"}),e.jsxs(Ks,{value:String(c==null?void 0:c.send_day),onValueChange:U=>j.mutate({send_day:parseInt(U)}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Zks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Time (UTC)"}),e.jsxs(Ks,{value:String(c==null?void 0:c.send_hour),onValueChange:U=>j.mutate({send_hour:parseInt(U)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Yks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(Dn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:k,disabled:r,className:"flex-1",children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(K,{onClick:M,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Wo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(gr,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"New Resources"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:U=>j.mutate({include_new_resources:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Community Highlights"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:U=>j.mutate({include_community_posts:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Agent OS Stats"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:U=>j.mutate({include_agent_os_stats:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Upcoming Events"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:U=>j.mutate({include_upcoming_events:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(be,{children:"Goals Progress"})]}),e.jsx(qr,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:U=>j.mutate({include_goals_progress:U})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Custom Introduction"}),e.jsx(gr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Pr,{placeholder:"Here's what's new this week to help you grow your business...",value:(c==null?void 0:c.custom_intro_text)||"",onChange:U=>j.mutate({custom_intro_text:U.target.value||null}),rows:3})})]})]}),e.jsx(ws,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(gr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(U=>e.jsx("div",{className:"h-12 bg-muted rounded"},U))}):p&&p.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Email"}),e.jsx(St,{children:"Sent At"}),e.jsx(St,{children:"Status"}),e.jsx(St,{children:"Resources"}),e.jsx(St,{children:"Agent OS"})]})}),e.jsx(Bn,{children:p.map(U=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:U.email_sent_to}),e.jsx(dt,{children:ms(new Date(U.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(st,{variant:U.delivery_status==="sent"?"default":"destructive",children:U.delivery_status})}),e.jsx(dt,{children:U.resources_count}),e.jsx(dt,{children:U.has_agent_os_activity?e.jsx(st,{variant:"secondary",children:"Active"}):e.jsx(st,{variant:"outline",children:"Not Started"})})]},U.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(lr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No digests sent yet"}),e.jsx("p",{className:"text-sm",children:"Send your first digest to see delivery stats"})]})})]})})]})})}const Xks={first_event:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",streak_3:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",streak_5:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",events_5:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",events_10:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",events_25:"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"};function Jks(){var xe,_e,$e;const t=Xt(),[s,r]=N.useState(""),[n,a]=N.useState(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(!0),[w,j]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(null),{data:P,isLoading:O}=mt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Me,error:Ie}=await H.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ie)throw Ie;const ke=(Me==null?void 0:Me.map(Le=>Le.user_id))||[],{data:pe}=await H.from("profiles").select("id, name, email").in("id",ke),we=new Map((pe==null?void 0:pe.map(Le=>[Le.id,{name:Le.name,email:Le.email}]))||[]);return Me==null?void 0:Me.map(Le=>({...Le,profile:we.get(Le.user_id)||null}))}}),{data:$}=mt({queryKey:["all-profiles-for-points",P],queryFn:async()=>{const Ie=[];let ke=0;for(;;){const{data:pe,error:we}=await H.from("profiles").select("id, name, email").order("name").range(ke,ke+1e3-1);if(we)throw we;if(Ie.push(...pe),!pe||pe.length<1e3)break;ke+=1e3}return Ie}}),B=(($==null?void 0:$.filter(Me=>!(P!=null&&P.some(Ie=>Ie.user_id===Me.id))))||[]).filter(Me=>{var ke,pe;if(!k)return!0;const Ie=k.toLowerCase();return((ke=Me.name)==null?void 0:ke.toLowerCase().includes(Ie))||((pe=Me.email)==null?void 0:pe.toLowerCase().includes(Ie))}),{data:V,isLoading:X}=mt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Me,error:Ie}=await H.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ie)throw Ie;return Me},enabled:!!(n!=null&&n.user_id)&&i}),{data:Y}=mt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Me,error:Ie}=await H.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ie)throw Ie;return Me},enabled:!!(n!=null&&n.user_id)}),ee=Lt({mutationFn:async({userId:Me,points:Ie,reason:ke})=>{const{error:pe}=await H.from("agent_points").insert({user_id:Me,points:Ie,reason:ke});if(pe)throw pe;const{data:we}=await H.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Me).maybeSingle(),Le=((we==null?void 0:we.total_points)||0)+Ie,Qe=((we==null?void 0:we.spendable_points)||0)+Ie,{error:Te}=await H.from("agent_attendance_stats").upsert({user_id:Me,total_points:Math.max(0,Le),spendable_points:Math.max(0,Qe),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Te)throw Te},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),g(""),me.success(v?"Points awarded successfully!":"Points deducted successfully!")},onError:Me=>{console.error("Error modifying points:",Me),me.error("Failed to modify points")}}),Q=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const Me=parseInt(u);if(isNaN(Me)||Me<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:n.user_id,points:v?Me:-Me,reason:f})},ce=()=>{if(!M||!u||!f){me.error("Please fill in all fields");return}const Me=parseInt(u);if(isNaN(Me)||Me<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:M.id,points:Me,reason:f},{onSuccess:()=>{j(!1),L(null),S("")}})},ne=(Me,Ie)=>{a(Me),_(Ie),l(!0)},re=Me=>{a(Me),c(!0)},oe=P==null?void 0:P.filter(Me=>{var we,Le,Qe,Te;const Ie=((Le=(we=Me.profile)==null?void 0:we.name)==null?void 0:Le.toLowerCase())||"",ke=((Te=(Qe=Me.profile)==null?void 0:Qe.email)==null?void 0:Te.toLowerCase())||"",pe=s.toLowerCase();return Ie.includes(pe)||ke.includes(pe)}),fe=(P==null?void 0:P.reduce((Me,Ie)=>Me+Ie.total_points,0))||0,ge=(P==null?void 0:P.length)||0,ue=ge>0?Math.round(fe/ge):0;return O?e.jsx(Ts,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Me=>e.jsx(vs,{className:"h-24"},Me))}),e.jsx(vs,{className:"h-96"})]})}):e.jsx(Ts,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ge}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(vo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:fe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jo,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ue}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:s,onChange:Me=>r(Me.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>j(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Agent Leaderboard"}),e.jsx(gr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!oe||oe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-12",children:"#"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Total Points"}),e.jsx(St,{className:"text-center",children:"Spendable"}),e.jsx(St,{className:"text-center",children:"Events"}),e.jsx(St,{className:"text-center",children:"Streak"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:oe.map((Me,Ie)=>{var ke,pe,we,Le;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:Ie<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ie===0?"bg-yellow-100 text-yellow-700":Ie===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ie+1}):e.jsx("span",{className:"text-muted-foreground",children:Ie+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{children:((pe=(ke=Me.profile)==null?void 0:ke.name)==null?void 0:pe.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((we=Me.profile)==null?void 0:we.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(Le=Me.profile)==null?void 0:Le.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Me.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(So,{className:"h-3 w-3 mr-1"}),Me.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3 text-muted-foreground"}),Me.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(sh,{className:"h-3 w-3 text-orange-500"}),Me.current_streak]})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ne(Me,!0),title:"Award points",children:e.jsx(qs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ne(Me,!1),title:"Deduct points",children:e.jsx(y0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Me),title:"View history",children:e.jsx($M,{className:"h-4 w-4"})})]})})]},Me.user_id)})})]})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:v?"Award Points":"Deduct Points"}),e.jsxs(Wr,{children:[v?"Award":"Deduct"," points ",v?"to":"from"," ",((xe=n==null?void 0:n.profile)==null?void 0:xe.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"points",children:"Points Amount"}),e.jsx(ze,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Me=>p(Me.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"reason",children:"Reason"}),e.jsx(Pr,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Me=>g(Me.target.value)})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:ee.isPending,className:v?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:ee.isPending?"Saving...":v?"Award Points":"Deduct Points"})]})]})}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(js,{children:[e.jsxs(_s,{children:["Point History: ",(_e=n==null?void 0:n.profile)==null?void 0:_e.name]}),e.jsx(Wr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(_a,{defaultValue:"history",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsx(ns,{value:"history",children:"Point History"}),e.jsx(ns,{value:"badges",children:"Badges"})]}),e.jsx(ws,{value:"history",className:"mt-4",children:X?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Me=>e.jsx(vs,{className:"h-12"},Me))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx($M,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No point history yet"})]}):e.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:V.map(Me=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:Me.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ms(new Date(Me.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(st,{variant:Me.points>=0?"default":"destructive",className:Me.points>=0?"bg-green-100 text-green-800":"",children:[Me.points>=0?"+":"",Me.points]})]},Me.id))})}),e.jsx(ws,{value:"badges",className:"mt-4",children:!Y||Y.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(tc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Y.map(Me=>e.jsxs("div",{className:`p-3 rounded-lg ${Xks[Me.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Me.badge_name})]}),Me.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Me.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ms(new Date(Me.earned_at),"MMM d, yyyy")]})]},Me.id))})})]})]})}),e.jsx(xs,{open:w,onOpenChange:Me=>{j(Me),Me||(L(null),S(""),p(""),g(""))},children:e.jsxs(fs,{className:"max-w-md",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Award Points to New Agent"}),e.jsx(Wr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:M?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(kn,{className:"h-10 w-10",children:e.jsx(Sn,{children:(($e=M.name)==null?void 0:$e.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:M.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:M.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>L(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(ze,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Me=>p(Me.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Pr,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Me=>g(Me.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:k,onChange:Me=>S(Me.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:B.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(hr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:k?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Me=>{var Ie;return e.jsxs("button",{onClick:()=>L(Me),className:"w-full flex items-center gap-3 p-3 hover:bg-muted/50 transition-colors border-b last:border-b-0 text-left",children:[e.jsx(kn,{className:"h-8 w-8",children:e.jsx(Sn,{children:((Ie=Me.name)==null?void 0:Ie.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Me.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.email})]})]},Me.id)})})]})}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),M&&e.jsxs(K,{onClick:ce,disabled:ee.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function e4s(){const{data:t,isLoading:s}=Ekt(),[r,n]=N.useState(null),[a,o]=N.useState(!1),[l,i]=N.useState(""),[c,u]=N.useState("all"),[p,f]=N.useState("newest"),[g,v]=N.useState("table"),_=N.useMemo(()=>(t==null?void 0:t.map(M=>M.user_id))||[],[t]),w=N.useMemo(()=>(t==null?void 0:t.map(M=>M.id))||[],[t]),{data:j}=mt({queryKey:["card-profiles-lookup",_],queryFn:async()=>{if(_.length===0)return{};const{data:M}=await H.from("profiles").select("id, name, email").in("id",_),L={};return M==null||M.forEach(P=>{L[P.id]={name:P.name||"",email:P.email||""}}),L},enabled:_.length>0}),{data:k}=mt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const M={};w.forEach(O=>{M[O]={views:0,leads:0}});const{data:L}=await H.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");L==null||L.forEach(O=>{M[O.card_id]&&M[O.card_id].views++});const{data:P}=await H.from("agent_card_leads").select("card_id").in("card_id",w);return P==null||P.forEach(O=>{M[O.card_id]&&M[O.card_id].leads++}),M},enabled:w.length>0}),S=N.useMemo(()=>{if(!t)return[];let M=[...t];if(c==="live"?M=M.filter(L=>L.is_published):c==="draft"&&(M=M.filter(L=>!L.is_published)),l.trim()){const L=l.toLowerCase();M=M.filter(P=>{var $,U;const O=j==null?void 0:j[P.user_id];return P.slug.toLowerCase().includes(L)||(($=O==null?void 0:O.name)==null?void 0:$.toLowerCase().includes(L))||((U=O==null?void 0:O.email)==null?void 0:U.toLowerCase().includes(L))})}return p==="newest"?M.sort((L,P)=>new Date(P.created_at).getTime()-new Date(L.created_at).getTime()):p==="oldest"?M.sort((L,P)=>new Date(L.created_at).getTime()-new Date(P.created_at).getTime()):p==="name"?M.sort((L,P)=>{var O,$;return(((O=j==null?void 0:j[L.user_id])==null?void 0:O.name)||"").localeCompare((($=j==null?void 0:j[P.user_id])==null?void 0:$.name)||"")}):p==="slug"?M.sort((L,P)=>L.slug.localeCompare(P.slug)):p==="views_desc"?M.sort((L,P)=>{var O,$;return(((O=k==null?void 0:k[P.id])==null?void 0:O.views)||0)-((($=k==null?void 0:k[L.id])==null?void 0:$.views)||0)}):p==="views_asc"?M.sort((L,P)=>{var O,$;return(((O=k==null?void 0:k[L.id])==null?void 0:O.views)||0)-((($=k==null?void 0:k[P.id])==null?void 0:$.views)||0)}):p==="leads_desc"?M.sort((L,P)=>{var O,$;return(((O=k==null?void 0:k[P.id])==null?void 0:O.leads)||0)-((($=k==null?void 0:k[L.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&M.sort((L,P)=>{var O,$;return(((O=k==null?void 0:k[L.id])==null?void 0:O.leads)||0)-((($=k==null?void 0:k[P.id])==null?void 0:$.leads)||0)}),M},[t,c,l,p,j]);return e.jsxs(Ts,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, or slug...",value:l,onChange:M=>i(M.target.value),className:"pl-9"})]}),e.jsxs(Ks,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-full sm:w-36",children:e.jsx(Ys,{placeholder:"Status"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Status"}),e.jsx(Mt,{value:"live",children:"Live"}),e.jsx(Mt,{value:"draft",children:"Draft"})]})]}),e.jsxs(Ks,{value:p,onValueChange:f,children:[e.jsx(Gs,{className:"w-full sm:w-44",children:e.jsx(Ys,{placeholder:"Sort by"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"newest",children:"Newest First"}),e.jsx(Mt,{value:"oldest",children:"Oldest First"}),e.jsx(Mt,{value:"name",children:"Name A–Z"}),e.jsx(Mt,{value:"slug",children:"Slug A–Z"}),e.jsx(Mt,{value:"views_desc",children:"Most Views"}),e.jsx(Mt,{value:"views_asc",children:"Fewest Views"}),e.jsx(Mt,{value:"leads_desc",children:"Most Leads"}),e.jsx(Mt,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(K,{variant:g==="table"?"default":"ghost",size:"sm",onClick:()=>v("table"),className:"rounded-r-none",children:e.jsx(ZM,{className:"h-4 w-4"})}),e.jsx(K,{variant:g==="grid"?"default":"ghost",size:"sm",onClick:()=>v("grid"),className:"rounded-l-none",children:e.jsx(Cp,{className:"h-4 w-4"})})]})]}),!s&&t&&t.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",S.length," of ",t.length," cards"]}),s?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(M=>e.jsx(vs,{className:"h-48"},M))}):S.length>0?g==="table"?e.jsx(t4s,{cards:S,cardProfiles:j,cardStats:k,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(M=>e.jsx(s4s,{card:M,onEdit:()=>n(M),stats:k==null?void 0:k[M.id]},M.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(sn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(r4s,{open:a,onOpenChange:o}),r&&e.jsx(n4s,{card:r,open:!!r,onOpenChange:M=>!M&&n(null)})]})}function t4s({cards:t,cardProfiles:s,cardStats:r,onEdit:n,sortBy:a,setSortBy:o}){const l=c=>{a===`${c}_desc`?o(`${c}_asc`):o(`${c}_desc`)},i=({field:c})=>a===`${c}_desc`?e.jsx(Kh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(Su,{className:"h-3 w-3"}):e.jsx(_d,{className:"h-3 w-3 opacity-40"});return e.jsx(Ee,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"text-left p-3 font-medium",children:e.jsxs("button",{onClick:()=>{o(a==="name"?"newest":"name")},className:"flex items-center gap-1 hover:text-foreground text-muted-foreground",children:["Agent ",a==="name"&&e.jsx(Su,{className:"h-3 w-3"})]})}),e.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),e.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",e.jsx(i,{field:"views"})]})}),e.jsx("th",{className:"text-right p-3 font-medium",children:e.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",e.jsx(i,{field:"leads"})]})}),e.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(c=>{const u=s==null?void 0:s[c.user_id],p=r==null?void 0:r[c.id],f=`https://cards.relevelup.com/${c.slug}`;return e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:(u==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u==null?void 0:u.email)||""})]})}),e.jsx("td",{className:"p-3 hidden md:table-cell",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",c.slug]})}),e.jsx("td",{className:"p-3 text-center",children:e.jsx(st,{variant:c.is_published?"default":"secondary",className:"text-xs",children:c.is_published?"Live":"Draft"})}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),e.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>n(c),className:"h-8 w-8 p-0",children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(f),me.success("Link copied!")},children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:e.jsx(en,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function s4s({card:t,onEdit:s,stats:r}){const[n,a]=N.useState(null);N.useEffect(()=>{(async()=>{const{data:c}=await H.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await H.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(c==null?void 0:c.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),me.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(Sn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(st,{variant:t.is_published?"default":"secondary",children:t.is_published?"Live":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.views)??0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx(za,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(yi,{className:"h-3 w-3"})}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:e.jsx(en,{className:"h-3 w-3"})})})]})]})})}function r4s({open:t,onOpenChange:s}){const[r,n]=N.useState(""),[a,o]=N.useState(""),[l,i]=N.useState(""),[c,u]=N.useState(!1),p=wWe(),f=l.trim(),{data:g}=mt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let S=H.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(S=S.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:M}=await S;return M||[]},enabled:t}),[v,_]=N.useState(null),w=(g==null?void 0:g.find(S=>S.id===r))||v,j=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},k=S=>{var L;n(S),u(!1);const M=g==null?void 0:g.find(P=>P.id===S);M&&(_(M),o(((L=M.name)==null?void 0:L.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create Agent Card"}),e.jsx(Wr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Agent"}),e.jsxs($o,{open:c,onOpenChange:u,children:[e.jsx(qo,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(Cx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ro,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Rx,{shouldFilter:!1,children:[e.jsx(Fx,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(zx,{children:[e.jsx(Bx,{children:"No agents found."}),e.jsx($x,{children:(g||[]).map(S=>e.jsxs(bp,{value:S.id,onSelect:k,children:[e.jsx(ba,{className:It("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"URL Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"/card/"}),e.jsx(ze,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:j,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function n4s({card:t,open:s,onOpenChange:r}){const n=jWe(),{data:a}=NWe(t.id),o=Xt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),[p,f]=N.useState(!1),[g,v]=N.useState(""),[_,w]=N.useState(t.slug),[j,k]=N.useState(!1),[S,M]=N.useState({is_published:t.is_published,theme:t.theme,title:t.title||"",positioning_statement:t.positioning_statement||"",bio:t.bio||"",review_snippet:t.review_snippet||"",review_source_url:t.review_source_url||"",booking_url:t.booking_url||"",custom_cta_label:t.custom_cta_label||"",custom_cta_url:t.custom_cta_url||"",show_photo:t.show_photo,show_bio:t.show_bio,show_credentials:t.show_credentials,show_social_links:t.show_social_links,show_save_contact:t.show_save_contact,show_leave_review:t.show_leave_review,show_refer_friend:t.show_refer_friend,brokerage_display_name:t.brokerage_display_name||"",brokerage_logo_url:t.brokerage_logo_url||"",brokerage_logo_size:t.brokerage_logo_size||56,team_name:t.team_name||"",team_logo_url:t.team_logo_url||"",team_logo_size:t.team_logo_size||56});N.useEffect(()=>{s&&(async()=>{try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:X}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${X.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const L=B=>{var Y;const V=(Y=B.target.files)==null?void 0:Y[0];if(!V)return;if(!V.type.startsWith("image/")){me.error("Please select an image file");return}if(V.size>5*1024*1024){me.error("Image must be under 5MB");return}const X=new FileReader;X.onloadend=()=>{v(X.result),f(!0)},X.readAsDataURL(V),B.target.value=""},P=async B=>{u(!0);try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await H.storage.from("avatars").remove(V.map(ce=>`${t.user_id}/${ce.name}`));const X=`${t.user_id}/avatar.jpg`,{error:Y}=await H.storage.from("avatars").upload(X,B,{upsert:!0,contentType:"image/jpeg"});if(Y)throw Y;const{data:ee}=H.storage.from("avatars").getPublicUrl(X),Q=`${ee.publicUrl}?t=${Date.now()}`;i(Q),await H.from("profiles").update({avatar_url:Q}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),me.success("Photo updated!")}catch(V){me.error(V.message||"Upload failed")}finally{u(!1)}},O=async()=>{const B=_.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!B){me.error("Please enter a valid URL");return}if(B===t.slug){me.info("No changes to save");return}k(!0);try{const{data:V}=await H.from("agent_cards").select("id").eq("slug",B).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:X}=await H.from("agent_cards").update({slug:B}).eq("id",t.id);if(X)throw X;w(B),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{k(!1)}},$=async(B,V)=>{var Y;const X=(Y=B.target.files)==null?void 0:Y[0];if(X){if(!X.type.startsWith("image/")){me.error("Please select an image file");return}try{const ee=X.name.split(".").pop()||"png",Q=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${Q}.${ee}`,{error:ne}=await H.storage.from("card-logos").upload(ce,X,{upsert:!0});if(ne)throw ne;const{data:re}=H.storage.from("card-logos").getPublicUrl(ce),oe=re.publicUrl+"?t="+Date.now();M(V==="brokerage_logo_url"?fe=>({...fe,[V]:oe,brokerage_display_name:""}):fe=>({...fe,[V]:oe,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{B.target.value=""}}},U=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(xs,{open:s,onOpenChange:r,children:e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Agent Card"}),e.jsxs(Wr,{children:["/card/",t.slug]})]}),e.jsxs(_a,{defaultValue:"content",children:[e.jsxs(fa,{className:"w-full",children:[e.jsx(ns,{value:"content",className:"flex-1",children:"Content"}),e.jsx(ns,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(ns,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(ns,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(ws,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Published"}),e.jsx(qr,{checked:S.is_published,onCheckedChange:B=>M(V=>({...V,is_published:B}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(kn,{className:"h-16 w-16",children:[e.jsx(Ua,{src:l||void 0}),e.jsx(Sn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:L,disabled:c}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:c,children:e.jsx("span",{children:c?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(ze,{value:_,onChange:B=>w(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:O,disabled:j||_===t.slug,className:"shrink-0",children:j?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Theme"}),e.jsxs(Ks,{value:S.theme,onValueChange:B=>M(V=>({...V,theme:B})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(Mt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(Mt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(Mt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Title / Tagline"}),e.jsx(ze,{value:S.title,onChange:B=>M(V=>({...V,title:B.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Positioning Statement"}),e.jsx(ze,{value:S.positioning_statement,onChange:B=>M(V=>({...V,positioning_statement:B.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Bio"}),e.jsx(Pr,{value:S.bio,onChange:B=>M(V=>({...V,bio:B.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review Snippet"}),e.jsx(ze,{value:S.review_snippet,onChange:B=>M(V=>({...V,review_snippet:B.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Review Source URL"}),e.jsx(ze,{value:S.review_source_url,onChange:B=>M(V=>({...V,review_source_url:B.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(ze,{value:S.booking_url,onChange:B=>M(V=>({...V,booking_url:B.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Custom CTA Label (optional)"}),e.jsx(ze,{value:S.custom_cta_label,onChange:B=>M(V=>({...V,custom_cta_label:B.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Custom CTA URL (optional)"}),e.jsx(ze,{value:S.custom_cta_url,onChange:B=>M(V=>({...V,custom_cta_url:B.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{value:S.brokerage_display_name,onChange:B=>M(V=>({...V,brokerage_display_name:B.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!S.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${S.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),S.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>$(B,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(Yg,{value:[S.brokerage_logo_size||56],onValueChange:([B])=>M(V=>({...V,brokerage_logo_size:B})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(be,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{value:S.team_name,onChange:B=>M(V=>({...V,team_name:B.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!S.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[S.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:S.team_logo_url,alt:"Team logo",style:{height:`${S.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>M(B=>({...B,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),S.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>$(B,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(Yg,{value:[S.team_logo_size||56],onValueChange:([B])=>M(V=>({...V,team_logo_size:B})),min:24,max:120,step:4})]})]})]})]}),e.jsx(ws,{value:"sections",className:"space-y-4 mt-4",children:[{key:"show_photo",label:"Show Photo",hint:"Photo is pulled from the agent's profile."},{key:"show_bio",label:"Show Bio"},{key:"show_credentials",label:"Show Credentials"},{key:"show_social_links",label:"Show Social Links"},{key:"show_save_contact",label:"Save Contact Button"},{key:"show_leave_review",label:"Leave Review Button"},{key:"show_refer_friend",label:"Refer a Friend Button"}].map(({key:B,label:V,hint:X})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(be,{children:V}),X&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[X," ",B==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(qr,{checked:S[B],onCheckedChange:Y=>M(ee=>({...ee,[B]:Y}))})]},B))}),e.jsx(ws,{value:"blocks",className:"mt-4",children:e.jsx(Elt,{cardId:t.id})}),e.jsx(ws,{value:"analytics",className:"mt-4",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(B=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:B.name}),B.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",B.phone]}),B.intent&&e.jsx(st,{variant:"secondary",className:"ml-2 text-xs",children:B.intent})]},B.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:U,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(Lke,{open:p,onClose:()=>f(!1),imageSrc:g,onCropComplete:P,aspectRatio:1})]})}const vT={pending_payment:"Pending Payment",order_submitted:"Order Submitted",awaiting_proof_approval:"Awaiting Proof Approval",proof_approved:"Proof Approved",processing:"Processing",in_production:"In Production",shipped:"Shipped",completed:"Completed",cancelled:"Cancelled",refunded:"Refunded"},j3e={pending_payment:"bg-yellow-100 text-yellow-800",order_submitted:"bg-blue-100 text-blue-800",awaiting_proof_approval:"bg-orange-100 text-orange-800",proof_approved:"bg-green-100 text-green-800",processing:"bg-purple-100 text-purple-800",in_production:"bg-indigo-100 text-indigo-800",shipped:"bg-cyan-100 text-cyan-800",completed:"bg-green-200 text-green-900",cancelled:"bg-red-100 text-red-800",refunded:"bg-gray-100 text-gray-800"};function N3e(t=!0){return mt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=H.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function a4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category created successfully")},onError:s=>{me.error("Failed to create category: "+s.message)}})}function i4s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category updated successfully")},onError:s=>{me.error("Failed to update category: "+s.message)}})}function o4s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category deleted successfully")},onError:s=>{me.error("Failed to delete category: "+s.message)}})}function Glt(t,s=!0){return mt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function l4s(t){return mt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function c4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product created successfully")},onError:s=>{me.error("Failed to create product: "+s.message)}})}function d4s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),me.success("Product updated successfully")},onError:s=>{me.error("Failed to update product: "+s.message)}})}function u4s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product deleted successfully")},onError:s=>{me.error("Failed to delete product: "+s.message)}})}function h4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function m4s(){const t=Xt();return Lt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Image deleted successfully")},onError:s=>{me.error("Failed to delete image: "+s.message)}})}function p4s(){const t=Xt();return Lt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await H.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Primary image updated")},onError:s=>{me.error("Failed to set primary image: "+s.message)}})}function f4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),me.success("Variant added successfully")}})}function x4s(){const t=Xt();return Lt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await H.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Variant deleted successfully")}})}function g4s(){const t=Xt();return Lt({mutationFn:async({productId:s,videoUrl:r})=>{await H.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await H.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),me.success("Video updated successfully")}})}function y4s(t){const{isAdmin:s}=Os();return mt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(c=>c.user_id))],{data:l}=await H.from("profiles").select("id, name, email").in("id",o),i=new Map((l==null?void 0:l.map(c=>[c.id,c]))||[]);return n.map(c=>({...c,user:i.get(c.user_id)}))}return n}})}function v4s(){const{user:t}=Os();return mt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function b4s(t){return mt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await H.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function _4s(){const t=Xt(),{user:s}=Os();return Lt({mutationFn:async({orderId:r,status:n,notes:a,trackingNumber:o,trackingUrl:l,previousStatus:i})=>{const c={status:n};o!==void 0&&(c.tracking_number=o),l!==void 0&&(c.tracking_url=l);const{error:u}=await H.from("marketplace_orders").update(c).eq("id",r);if(u)throw u;const{error:p}=await H.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(g){console.error("Failed to send notification email:",g)}},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Order status updated")},onError:r=>{me.error("Failed to update order: "+r.message)}})}function w4s(){const t=Xt();return Lt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await H.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await H.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await H.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof uploaded & customer notified")}})}function j4s(){const t=Xt();return Lt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await H.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof approved")}})}function N4s(){const t=Xt();return Lt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await H.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof rejected - please upload a new proof")}})}function k4s(){const{data:t,isLoading:s}=N3e(!1),r=a4s(),n=i4s(),a=o4s(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),f=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),c(null)},g=w=>{c(w),p({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},v=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},_=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(vs,{className:"h-12 w-full"},w))})})]}):e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Categories"}),e.jsxs(xs,{open:o,onOpenChange:w=>{l(w),w||f()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:u.name,onChange:w=>p({...u,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",value:u.description,onChange:w=>p({...u,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"image_url",children:"Image URL"}),e.jsx(ze,{id:"image_url",value:u.image_url,onChange:w=>p({...u,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:u.sort_order,onChange:w=>p({...u,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:u.is_active,onCheckedChange:w=>p({...u,is_active:w})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{children:"Sort Order"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(w=>e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:w.name}),e.jsx(dt,{className:"max-w-xs truncate",children:w.description}),e.jsx(dt,{children:w.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>g(w),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(w.id),disabled:a.isPending,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function S4s(){var ue,xe;const{data:t,isLoading:s}=Glt(void 0,!1),{data:r}=N3e(!1),n=c4s(),a=d4s(),o=u4s(),l=h4s(),i=m4s(),c=p4s(),u=f4s(),p=x4s(),f=g4s(),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState(!1),[S,M]=N.useState(null),[L,P]=N.useState(null),[O,$]=N.useState(!1),[U,B]=N.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,X]=N.useState({name:"",price_adjustment:0}),[Y,ee]=N.useState(""),Q=()=>{B({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),M(null)},ce=_e=>{M(_e),B({name:_e.name,description:_e.description||"",base_price:Number(_e.base_price),shipping_fee:Number(_e.shipping_fee),category_id:_e.category_id||"",allow_artwork_upload:_e.allow_artwork_upload,requires_proof_approval:_e.requires_proof_approval,is_active:_e.is_active,sort_order:_e.sort_order}),v(!0)},ne=async _e=>{_e.preventDefault();const $e={...U,category_id:U.category_id||null};S?await a.mutateAsync({id:S.id,...$e}):await n.mutateAsync($e),v(!1),Q()},re=async _e=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(_e)},oe=async _e=>{if(!L||!_e.target.files||_e.target.files.length===0)return;$(!0);const $e=_e.target.files[0],Me=$e.name.split(".").pop(),Ie=`products/${L.id}/${Date.now()}.${Me}`;try{const{error:ke}=await H.storage.from("marketplace").upload(Ie,$e);if(ke)throw ke;const{data:{publicUrl:pe}}=H.storage.from("marketplace").getPublicUrl(Ie);await l.mutateAsync({product_id:L.id,image_url:pe,is_primary:!L.images||L.images.length===0}),me.success("Image uploaded successfully")}catch(ke){me.error("Failed to upload image: "+ke.message)}finally{$(!1)}},fe=async _e=>{_e.preventDefault(),L&&(await u.mutateAsync({product_id:L.id,name:V.name,price_adjustment:V.price_adjustment}),X({name:"",price_adjustment:0}))},ge=async()=>{!L||!Y||(await f.mutateAsync({productId:L.id,videoUrl:Y}),ee(""))};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(_e=>e.jsx(vs,{className:"h-64 w-full"},_e))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Products"}),e.jsxs(xs,{open:g,onOpenChange:_e=>{v(_e),_e||Q()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:S?"Edit Product":"Add Product"})}),e.jsxs("form",{onSubmit:ne,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"name",children:"Product Name"}),e.jsx(ze,{id:"name",value:U.name,onChange:_e=>B({...U,name:_e.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"category",children:"Category"}),e.jsxs(Ks,{value:U.category_id,onValueChange:_e=>B({...U,category_id:_e}),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsx(Ws,{children:r==null?void 0:r.map(_e=>e.jsx(Mt,{value:_e.id,children:_e.name},_e.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"description",children:"Description"}),e.jsx(Pr,{id:"description",value:U.description,onChange:_e=>B({...U,description:_e.target.value}),rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(ze,{id:"base_price",type:"number",step:"0.01",min:"0",value:U.base_price,onChange:_e=>B({...U,base_price:parseFloat(_e.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(ze,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:U.shipping_fee,onChange:_e=>B({...U,shipping_fee:parseFloat(_e.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:U.sort_order,onChange:_e=>B({...U,sort_order:parseInt(_e.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"allow_artwork_upload",checked:U.allow_artwork_upload,onCheckedChange:_e=>B({...U,allow_artwork_upload:_e})}),e.jsx(be,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"requires_proof_approval",checked:U.requires_proof_approval,onCheckedChange:_e=>B({...U,requires_proof_approval:_e})}),e.jsx(be,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"is_active",checked:U.is_active,onCheckedChange:_e=>B({...U,is_active:_e})}),e.jsx(be,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(_e=>{var $e,Me;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[_e.images&&_e.images.length>0?e.jsx("img",{src:(($e=_e.images.find(Ie=>Ie.is_primary))==null?void 0:$e.image_url)||_e.images[0].image_url,alt:_e.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"No image"}),!_e.is_active&&e.jsx(st,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:_e.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Me=_e.category)==null?void 0:Me.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(_e.base_price).toFixed(2)]}),Number(_e.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(_e.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[_e.allow_artwork_upload&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),_e.requires_proof_approval&&e.jsx(st,{variant:"outline",className:"text-xs",children:"Proof Required"}),_e.variants&&_e.variants.length>0&&e.jsxs(st,{variant:"outline",className:"text-xs",children:[_e.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ce(_e),children:[e.jsx(za,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{P(_e),w(!0)},children:[e.jsx(u1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{P(_e),k(!0)},children:[e.jsx(Fm,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(_e.id),children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]})]})]},_e.id)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),e.jsx(xs,{open:_,onOpenChange:w,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Manage Images - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ue=L==null?void 0:L.images)==null?void 0:ue.map(_e=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:_e.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),_e.is_primary&&e.jsx(st,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!_e.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var $e;await c.mutateAsync({imageId:_e.id,productId:L.id}),P({...L,images:($e=L.images)==null?void 0:$e.map(Me=>({...Me,is_primary:Me.id===_e.id}))})},disabled:c.isPending,title:"Set as primary",children:e.jsx(Jn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var Me;await i.mutateAsync({id:_e.id,productId:L.id});const $e=t==null?void 0:t.find(Ie=>Ie.id===L.id);$e&&P({...$e,images:(Me=$e.images)==null?void 0:Me.filter(Ie=>Ie.id!==_e.id)})},disabled:i.isPending,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},_e.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:oe,className:"hidden",id:"image-upload",disabled:O}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(u1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:O?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(be,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(ze,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:Y,onChange:_e=>ee(_e.target.value)}),e.jsxs(K,{onClick:ge,disabled:!Y,children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(L==null?void 0:L.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",L.video.video_url]})]})]})]})}),e.jsx(xs,{open:j,onOpenChange:k,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:["Manage Variants - ",L==null?void 0:L.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:fe,className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:_e=>X({...V,name:_e.target.value}),required:!0}),e.jsx(ze,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:_e=>X({...V,price_adjustment:parseFloat(_e.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(xe=L==null?void 0:L.variants)==null?void 0:xe.map(_e=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:_e.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(_e.price_adjustment)>=0?"+":"","$",Number(_e.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:_e.id,productId:L.id}),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},_e.id)),(!(L!=null&&L.variants)||L.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const C4s=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function M4s(){var w,j,k;const{data:t,isLoading:s}=y4s(),r=_4s(),n=w4s(),[a,o]=N.useState(null),[l,i]=N.useState(!1),[c,u]=N.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=N.useState(!1),g=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},v=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:c.status,notes:c.notes,trackingNumber:c.trackingNumber,trackingUrl:c.trackingUrl,previousStatus:a.status}),i(!1))},_=async(S,M)=>{if(!a||!S.target.files||S.target.files.length===0)return;f(!0);const L=S.target.files[0],P=L.name.split(".").pop(),O=`proofs/${a.id}/${M}/${Date.now()}.${P}`;try{const{error:$}=await H.storage.from("marketplace").upload(O,L);if($)throw $;const{data:{publicUrl:U}}=H.storage.from("marketplace").getPublicUrl(O);await n.mutateAsync({itemId:M,proofUrl:U,orderId:a.id}),me.success("Proof uploaded successfully")}catch($){me.error("Failed to upload proof: "+$.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(vs,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Order #"}),e.jsx(St,{children:"Customer"}),e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Total"}),e.jsx(St,{children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:t.map(S=>{var M,L;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-mono",children:S.order_number}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((M=S.user)==null?void 0:M.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(L=S.user)==null?void 0:L.email})]})}),e.jsx(dt,{children:ms(new Date(S.created_at),"MMM d, yyyy")}),e.jsxs(dt,{className:"font-bold",children:["$",Number(S.total).toFixed(2)]}),e.jsx(dt,{children:e.jsx(st,{className:j3e[S.status],children:vT[S.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(S),children:[e.jsx(Dn,{className:"h-4 w-4 mr-1"}),"View"]})})]},S.id)})})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(j=a.user)==null?void 0:j.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(k=a.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(st,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:M=>_(M,S.id),className:"hidden",id:`proof-${S.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${S.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(di,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},S.id))})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Status"}),e.jsxs(Ks,{value:c.status,onValueChange:S=>u({...c,status:S}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:C4s.map(S=>e.jsx(Mt,{value:S,children:vT[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Tracking Number"}),e.jsx(ze,{value:c.trackingNumber,onChange:S=>u({...c,trackingNumber:S.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Tracking URL"}),e.jsx(ze,{value:c.trackingUrl,onChange:S=>u({...c,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Notes (optional)"}),e.jsx(Pr,{value:c.notes,onChange:S=>u({...c,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:v,disabled:r.isPending,className:"w-full",children:[e.jsx(Al,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(st,{variant:"outline",children:vT[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ms(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function T4s(){const[t,s]=N.useState("products"),r=nr();return e.jsx(Ts,{title:"Marketplace Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),e.jsxs(K,{variant:"outline",onClick:()=>r("/marketplace"),children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(_a,{value:t,onValueChange:s,children:[e.jsxs(fa,{className:"grid w-full grid-cols-3",children:[e.jsxs(ns,{value:"products",className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"Products"]}),e.jsxs(ns,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(ns,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(ws,{value:"products",children:e.jsx(S4s,{})}),e.jsx(ws,{value:"categories",children:e.jsx(k4s,{})}),e.jsx(ws,{value:"orders",children:e.jsx(M4s,{})})]})]})})}function Wlt(){return mt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function A4s(t){return mt({queryKey:["reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function E4s(t){return mt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=H.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function P4s(t){return mt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function I4s(){return mt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await H.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await H.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function L4s(t){return mt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await H.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function D4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["homereel-credits"]})}})}function O4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function R4s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function F4s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function z4s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function B4s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function $4s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function q4s(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function $ye(t,s){const r=q4s(t);if(r)try{const{data:n,error:a}=await H.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),me.error("Failed to download file");return}const o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=s||r.path.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("Download error:",n),me.error("Failed to download file")}else try{const a=await(await fetch(t)).blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=s||t.split("/").pop()||"download",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),100)}catch(n){console.error("External download error:",n),me.error("Failed to download file")}}function Klt(){return mt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await H.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function U4s(){const t=Xt();return Lt({mutationFn:async({id:s,points:r,is_active:n})=>{const a={points:r};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await H.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function V4s(){const{user:t}=Os(),[s,r]=N.useState("items"),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(null),[w,j]=N.useState(!1),[k,S]=N.useState(null),[M,L]=N.useState(""),[P,O]=N.useState(""),[$,U]=N.useState(null),[B,V]=N.useState(""),[X,Y]=N.useState("file"),[ee,Q]=N.useState(""),[ce,ne]=N.useState(""),[re,oe]=N.useState(""),[fe,ge]=N.useState(!0),[ue,xe]=N.useState(null),[_e,$e]=N.useState(!1),[Me,Ie]=N.useState(!1),ke=N.useRef(null),pe=N.useRef(null),{data:we,isLoading:Le}=Wlt(),{data:Qe,isLoading:Te}=A4s(),{data:pt,isLoading:ye}=I4s(),{data:qe,isLoading:at}=Klt(),tt=O4s(),Ae=R4s(),rt=F4s(),He=z4s(),ct=B4s(),Ue=$4s(),Ze=U4s(),[Je,Ge]=N.useState({}),et=xt=>{xt?(l(xt),c(xt.name),p(xt.description||""),g(xt.icon||"")):(l(null),c(""),p(""),g("")),a(!0)},it=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Ae.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),me.success("Category updated successfully")):(await tt.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((we==null?void 0:we.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(xt){console.error("Error saving category:",xt),me.error("Failed to save category")}},Dt=async()=>{if(v)try{await rt.mutateAsync(v),me.success("Category deleted successfully"),_(null)}catch(xt){console.error("Error deleting category:",xt),me.error("Failed to delete category")}},Vt=xt=>{var Ps;xt?(S(xt),L(xt.name),O(xt.description||""),U(xt.category_id),V(xt.points_cost.toString()),Y(xt.item_type),Q(xt.file_url||""),ne(xt.preview_image_url||""),oe(((Ps=xt.max_quantity)==null?void 0:Ps.toString())||""),ge(xt.is_active)):(S(null),L(""),O(""),U(null),V(""),Y("file"),Q(""),ne(""),oe(""),ge(!0)),j(!0)},hs=async(xt,Ps)=>{Ps==="file"?$e(!0):Ie(!0);try{const mr=xt.name.split(".").pop(),Tr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${mr}`,Dr=`${Ps==="file"?"items":"previews"}/${Tr}`,{error:xn}=await H.storage.from("reward-store").upload(Dr,xt);if(xn)throw xn;const{data:{publicUrl:Si}}=H.storage.from("reward-store").getPublicUrl(Dr);Ps==="file"?Q(Si):ne(Si),me.success("File uploaded successfully")}catch(mr){console.error("Error uploading file:",mr),me.error("Failed to upload file")}finally{Ps==="file"?$e(!1):Ie(!1)}},As=async()=>{if(!M.trim()){me.error("Please enter an item name");return}if(!B||parseInt(B)<0){me.error("Please enter a valid points cost");return}try{const xt={name:M,description:P||null,category_id:$,points_cost:parseInt(B),item_type:X,file_url:ee||null,preview_image_url:ce||null,max_quantity:re?parseInt(re):null,current_quantity:re?parseInt(re):null,is_active:fe,created_by:t==null?void 0:t.id};k?(await ct.mutateAsync({id:k.id,...xt,current_quantity:k.max_quantity!==(re?parseInt(re):null)?re?parseInt(re):null:k.current_quantity}),me.success("Item updated successfully")):(await He.mutateAsync(xt),me.success("Item created successfully")),j(!1)}catch(xt){console.error("Error saving item:",xt),me.error("Failed to save item")}},Ms=async()=>{if(ue)try{await Ue.mutateAsync(ue),me.success("Item deleted successfully"),xe(null)}catch(xt){console.error("Error deleting item:",xt),me.error("Failed to delete item")}},cs=async(xt,Ps)=>{const mr=Je[xt];if(mr===void 0||mr===Ps.toString())return;const Tr=parseInt(mr);if(isNaN(Tr)||Tr<0){me.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:xt,points:Tr}),me.success("Points updated successfully"),Ge(Dr=>{const xn={...Dr};return delete xn[xt],xn})}catch(Dr){console.error("Error updating points:",Dr),me.error("Failed to update points")}};return Le||Te||ye||at?e.jsx(Ts,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-8 w-64"}),e.jsx(vs,{className:"h-96"})]})}):e.jsxs(Ts,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Al,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Qe==null?void 0:Qe.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(Qe==null?void 0:Qe.filter(xt=>xt.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Om,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(we==null?void 0:we.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Jn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[Qe&&Qe.length>0?Math.round(Qe.reduce((xt,Ps)=>xt+Ps.points_cost,0)/Qe.length):0," pts"]})]})})]}),e.jsxs(_a,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"items",children:"Items"}),e.jsx(ns,{value:"categories",children:"Categories"}),e.jsx(ns,{value:"purchases",children:"Purchases"}),e.jsx(ns,{value:"point-settings",children:"Point Settings"})]}),e.jsx(ws,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Store Items"}),e.jsx(gr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Vt(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!Qe||Qe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No items yet. Add your first reward item!"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Item"}),e.jsx(St,{children:"Category"}),e.jsx(St,{className:"text-center",children:"Cost"}),e.jsx(St,{className:"text-center",children:"Type"}),e.jsx(St,{className:"text-center",children:"Quantity"}),e.jsx(St,{className:"text-center",children:"Status"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:Qe.map(xt=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[xt.preview_image_url?e.jsx("img",{src:xt.preview_image_url,alt:xt.name,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:e.jsx(So,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:xt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:xt.description||"No description"})]})]})}),e.jsx(dt,{children:xt.category?e.jsx(st,{variant:"outline",children:xt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[xt.item_type==="file"?e.jsx(wn,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Bo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:xt.item_type})]})}),e.jsx(dt,{className:"text-center",children:xt.max_quantity!==null?e.jsxs("span",{className:xt.current_quantity===0?"text-red-500":"",children:[xt.current_quantity,"/",xt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(st,{variant:xt.is_active?"default":"secondary",children:xt.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Vt(xt),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>xe(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(ws,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Categories"}),e.jsx(gr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>et(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!we||we.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Om,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Name"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center",children:"Items"}),e.jsx(St,{className:"text-right",children:"Actions"})]})}),e.jsx(Bn,{children:we.map(xt=>e.jsxs(Cs,{children:[e.jsxs(dt,{className:"font-medium",children:[xt.icon&&e.jsx("span",{className:"mr-2",children:xt.icon}),xt.name]}),e.jsx(dt,{className:"text-muted-foreground",children:xt.description||"—"}),e.jsx(dt,{className:"text-center",children:(Qe==null?void 0:Qe.filter(Ps=>Ps.category_id===xt.id).length)||0}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>et(xt),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(xt.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},xt.id))})]})})]})}),e.jsx(ws,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(vp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(gr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!pt||pt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(vp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Date"}),e.jsx(St,{children:"Agent"}),e.jsx(St,{children:"Item"}),e.jsx(St,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Bn,{children:pt.map(xt=>{var Ps,mr,Tr,Dr;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"text-muted-foreground",children:ms(new Date(xt.purchased_at),"MMM d, yyyy 'at' h:mm a")}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Ps=xt.user)==null?void 0:Ps.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((mr=xt.user)==null?void 0:mr.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(Tr=xt.item)!=null&&Tr.preview_image_url?e.jsx("img",{src:xt.item.preview_image_url,alt:xt.item.name,className:"h-8 w-8 rounded object-cover"}):e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:e.jsx(So,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Dr=xt.item)==null?void 0:Dr.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),xt.points_spent]})})]},xt.id)})})]})})]})})]})]}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:o?"Edit Category":"Add Category"}),e.jsx(Wr,{children:o?"Update the category details":"Create a new category for your store items"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryName",children:"Name"}),e.jsx(ze,{id:"categoryName",value:i,onChange:xt=>c(xt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Pr,{id:"categoryDescription",value:u,onChange:xt=>p(xt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(ze,{id:"categoryIcon",value:f,onChange:xt=>g(xt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:it,disabled:tt.isPending||Ae.isPending,children:tt.isPending||Ae.isPending?"Saving...":"Save"})]})]})}),e.jsx(xs,{open:w,onOpenChange:j,children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:k?"Edit Item":"Add Item"}),e.jsx(Wr,{children:k?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemName",children:"Name *"}),e.jsx(ze,{id:"itemName",value:M,onChange:xt=>L(xt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Pr,{id:"itemDescription",value:P,onChange:xt=>O(xt.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Ks,{value:$||"none",onValueChange:xt=>U(xt==="none"?null:xt),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select category"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No category"}),we==null?void 0:we.map(xt=>e.jsxs(Mt,{value:xt.id,children:[xt.icon&&`${xt.icon} `,xt.name]},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(ze,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:xt=>V(xt.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemType",children:"Type"}),e.jsxs(Ks,{value:X,onValueChange:Y,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"file",children:"File Download"}),e.jsx(Mt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(ze,{id:"itemMaxQuantity",type:"number",min:"1",value:re,onChange:xt=>oe(xt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:ee,onChange:xt=>Q(xt.target.value),placeholder:X==="file"?"Upload a file or paste URL":"Paste external link"}),X==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=ke.current)==null?void 0:xt.click()},disabled:_e,children:e.jsx(di,{className:"h-4 w-4"})}),e.jsx("input",{ref:ke,type:"file",className:"hidden",onChange:xt=>{var mr;const Ps=(mr=xt.target.files)==null?void 0:mr[0];Ps&&hs(Ps,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:ce,onChange:xt=>ne(xt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var xt;return(xt=pe.current)==null?void 0:xt.click()},disabled:Me,children:e.jsx(vl,{className:"h-4 w-4"})}),e.jsx("input",{ref:pe,type:"file",accept:"image/*",className:"hidden",onChange:xt=>{var mr;const Ps=(mr=xt.target.files)==null?void 0:mr[0];Ps&&hs(Ps,"preview")}})]}),ce&&e.jsx("img",{src:ce,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{id:"itemIsActive",checked:fe,onCheckedChange:ge}),e.jsx(be,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:As,disabled:He.isPending||ct.isPending,children:He.isPending||ct.isPending?"Saving...":"Save"})]})]})}),e.jsx(Mc,{open:!!v,onOpenChange:()=>_(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Category"}),e.jsx(ic,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:Dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(Mc,{open:!!ue,onOpenChange:()=>xe(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Item"}),e.jsx(ic,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:Ms,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Point Reward Settings"}),e.jsx(gr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!qe||qe.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Qo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Action"}),e.jsx(St,{children:"Description"}),e.jsx(St,{className:"text-center w-32",children:"Points"}),e.jsx(St,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Bn,{children:qe.map(xt=>e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:xt.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:xt.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(ze,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Je[xt.id]??xt.points.toString(),onChange:Ps=>Ge(mr=>({...mr,[xt.id]:Ps.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Je[xt.id]===void 0||Je[xt.id]===xt.points.toString()||Ze.isPending,onClick:()=>cs(xt.id,xt.points),children:e.jsx(Uc,{className:"h-4 w-4"})})})]},xt.id))})]})})]})]})}const Oze=()=>e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-5 w-5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{width:"100",height:"100",rx:"20",fill:"#7D2AE8"}),e.jsx("path",{d:"M50 20C33.43 20 20 33.43 20 50C20 66.57 33.43 80 50 80C66.57 80 80 66.57 80 50C80 33.43 66.57 20 50 20ZM63.5 63.5C58.3 68.7 50 70.6 43.1 67.6C36.2 64.6 32 57.6 32 50C32 42.4 36.2 35.4 43.1 32.4C50 29.4 58.3 31.3 63.5 36.5L59.3 40.7C55.8 37.2 50.7 35.8 46 37.3C41.3 38.8 37.7 42.8 36.6 47.6C35.5 52.4 37 57.4 40.4 60.8C43.8 64.2 48.8 65.7 53.6 64.6C58.4 63.5 62.4 59.9 63.9 55.2L68.7 56.7C66.9 61.3 65.5 61.5 63.5 63.5Z",fill:"white"})]}),Rze=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function H4s(){const t=Xt(),[s,r]=N.useState(!1),[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=mt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(M)throw M;return S}}),{data:f}=mt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:M}=await H.from("brokerages").select("id, name").order("name");if(M)throw M;return S}}),{data:g}=mt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:M}=await H.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(M)throw M;return S}}),v=async()=>{var S;r(!0);try{const{data:M}=await H.auth.getSession(),L=(S=M==null?void 0:M.session)==null?void 0:S.access_token;if(!L)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),U=await $.json();if(!$.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to get authorization URL");if(U!=null&&U.authUrl){localStorage.setItem("canva_code_verifier",U.codeVerifier),localStorage.setItem("canva_oauth_state",U.state);const B=window.open(U.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!B){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=Y=>{var ee,Q;Y.origin===window.location.origin&&(((ee=Y.data)==null?void 0:ee.type)==="canva-oauth-success"?(window.removeEventListener("message",V),me.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((Q=Y.data)==null?void 0:Q.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(Y.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const X=setInterval(()=>{B.closed&&(clearInterval(X),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(M){console.error("Canva connect error:",M);const L=(M==null?void 0:M.message)||"";L.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(L||"Failed to start Canva connection"),r(!1)}},_=Lt({mutationFn:async S=>{var B;const{data:M}=await H.auth.getSession(),L=(B=M==null?void 0:M.session)==null?void 0:B.access_token;if(!L)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),U=await $.json();if(!$.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),me.success("Canva disconnected")},onError:S=>{me.error(S.message||"Failed to disconnect Canva")}}),w=Lt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").insert({brokerage_id:S.brokerage_id,folder_id:S.folder_id.trim(),folder_name:S.folder_name.trim(),folder_type:S.folder_type,description:S.description.trim()||null,sort_order:(g==null?void 0:g.length)||0});if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder added"),l(!1),c({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>me.error("Failed to add folder")}),j=Lt({mutationFn:async S=>{const{error:M}=await H.from("canva_brokerage_folders").delete().eq("id",S);if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),k=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:e.jsx(Oze,{})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",k&&e.jsx(st,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(st,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(gr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(gi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),k?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Canva?"}),e.jsx(ic,{children:"This will remove the Canva platform integration. Agents who have already connected will not be affected, but new folder sharing will stop."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>_.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",g&&g.length>0&&e.jsx(st,{variant:"secondary",className:"text-xs",children:g.length})]}),n?e.jsx(xf,{className:"h-4 w-4"}):e.jsx(oo,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[g&&g.length>0?g.map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(st,{variant:"outline",className:"text-xs shrink-0",children:((M=Rze.find(P=>P.value===S.folder_type))==null?void 0:M.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(L=S.brokerages)==null?void 0:L.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>j.mutate(S.id),children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]},S.id)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:v,disabled:s||p,children:[s?e.jsx(Wo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(Oze,{})}),"Connect Canva",e.jsx(Sa,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Brokerage Folder Mapping"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Brokerage"}),e.jsxs(Ks,{value:i.brokerage_id,onValueChange:S=>c(M=>({...M,brokerage_id:S})),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a brokerage…"})}),e.jsx(Ws,{children:f==null?void 0:f.map(S=>e.jsx(Mt,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Canva Folder ID"}),e.jsx(ze,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>c(M=>({...M,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Folder Display Name"}),e.jsx(ze,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>c(M=>({...M,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{children:"Folder Type"}),e.jsxs(Ks,{value:i.folder_type,onValueChange:S=>c(M=>({...M,folder_type:S})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:Rze.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(ze,{placeholder:"What's in this folder?",value:i.description,onChange:S=>c(M=>({...M,description:S.target.value}))})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(Wo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function G4s(){return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(ch,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(H4s,{}),e.jsx(Ult,{})]})})}const W4s={new_events:{label:"New Events",icon:"📅"},new_templates:{label:"New Templates",icon:"📄"},new_toolbox:{label:"New Toolbox Resources",icon:"🧰"},new_social_swag:{label:"New Social Swag",icon:"🎨"},new_newsletters:{label:"New Newsletters",icon:"📰"},new_community_posts:{label:"New Community Posts",icon:"💬"}};function wI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function K4s(){var X,Y,ee,Q,ce;const t=Xt(),[s,r]=N.useState("Test Push"),[n,a]=N.useState("Testing web push notification"),[o,l]=N.useState("/community"),[i,c]=N.useState(!1),[u,p]=N.useState(!1),[f,g]=N.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[v,_]=N.useState(null),[w,j]=N.useState(null),{data:k,isLoading:S}=mt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ne,error:re}=await H.from("push_notification_settings").select("*").order("setting_key");if(re)throw re;return ne}}),{data:M,isLoading:L}=mt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ne,error:re}=await H.from("push_subscriptions").select("*",{count:"exact",head:!0});if(re)throw re;return{totalSubscriptions:ne||0}}}),P=Lt({mutationFn:async({settingKey:ne,isEnabled:re})=>{const{error:oe}=await H.from("push_notification_settings").update({is_enabled:re}).eq("setting_key",ne);if(oe)throw oe},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:ne=>{me.error("Failed to update setting: "+ne.message)}}),O=N.useMemo(()=>{var ne,re;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((ne=f.serviceWorker)==null?void 0:ne.activeState)??"unknown"} · sub=${(re=f.subscription)!=null&&re.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);N.useEffect(()=>{let ne=!0;const re=async()=>{var ue,xe,_e,$e,Me,Ie,ke;const fe="serviceWorker"in navigator&&"PushManager"in window,ge={isSupported:fe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ue=navigator.serviceWorker)!=null&&ue.controller)};if(!fe){ne&&g(ge);return}try{const{data:pe,error:we}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(we)throw we;ge.vapidPublicKey=pe==null?void 0:pe.vapidPublicKey;const Qe=(await navigator.serviceWorker.getRegistrations()).find(Te=>{var ye,qe,at;return(((ye=Te.active)==null?void 0:ye.scriptURL)||((qe=Te.waiting)==null?void 0:qe.scriptURL)||((at=Te.installing)==null?void 0:at.scriptURL)||"").includes("/sw.js")});if(Qe){ge.pushWorkerScriptUrl=((xe=Qe.active)==null?void 0:xe.scriptURL)||((_e=Qe.waiting)==null?void 0:_e.scriptURL)||(($e=Qe.installing)==null?void 0:$e.scriptURL),ge.serviceWorker={scope:Qe.scope,activeState:(Me=Qe.active)==null?void 0:Me.state};const Te=await Qe.pushManager.getSubscription();if(Te){const pt=Te.toJSON();ge.subscription={endpoint:pt.endpoint,p256dh:(Ie=pt.keys)==null?void 0:Ie.p256dh,auth:(ke=pt.keys)==null?void 0:ke.auth}}}}catch(pe){ge.error=(pe==null?void 0:pe.message)||String(pe)}ne&&g(ge)};re();const oe=window.setInterval(re,4e3);return()=>{ne=!1,window.clearInterval(oe)}},[]);const $=async()=>{if(typeof Notification>"u"){me.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){me.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),me.success("Triggered a local notification (not push).")}catch(ne){me.error(`Local notification failed: ${(ne==null?void 0:ne.message)||String(ne)}`)}},U=async()=>{c(!0),_(null);try{const{data:ne,error:re}=await H.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(re)throw re;_({sent:ne==null?void 0:ne.sent,failed:ne==null?void 0:ne.failed,expiredCleaned:ne==null?void 0:ne.expiredCleaned,vapidPublicKey:ne==null?void 0:ne.vapidPublicKey}),(ne==null?void 0:ne.sent)>0?me.success(`Test notification sent to ${ne.sent} subscriber(s)`):(ne==null?void 0:ne.failed)>0?me.warning(`Notification failed for ${ne.failed} subscriber(s). ${ne.expired||0} expired subscriptions cleaned up.`):me.info("No active subscriptions to send to")}catch(ne){console.error("Error sending test notification:",ne),_({error:(ne==null?void 0:ne.message)||String(ne)}),me.error("Failed to send test notification: "+(ne.message||"Unknown error"))}finally{c(!1)}},B=async()=>{p(!0),j(null);try{const{data:ne,error:re}=await H.functions.invoke("generate-vapid-keys",{body:{}});if(re)throw re;const oe=ne==null?void 0:ne.publicKey,fe=ne==null?void 0:ne.privateKey;if(!oe||!fe)throw new Error("generate-vapid-keys did not return keys");j({publicKey:oe,privateKey:fe}),me.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ne){console.error("Error generating VAPID keys:",ne),me.error("Failed to generate VAPID keys: "+((ne==null?void 0:ne.message)||"Unknown error"))}finally{p(!1)}},V=Lt({mutationFn:async()=>{const{error:ne}=await H.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ne)throw ne},onSuccess:()=>{me.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ne=>{me.error("Failed to clear subscriptions: "+ne.message)}});return e.jsx(Ts,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(gr,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:L?"...":(M==null?void 0:M.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(gr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:k==null?void 0:k.map(ne=>{const re=W4s[ne.setting_key]||{label:ne.setting_key,icon:"🔔"};return e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:re.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:re.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ne.description})]})]}),e.jsx(qr,{checked:ne.is_enabled,onCheckedChange:oe=>P.mutate({settingKey:ne.setting_key,isEnabled:oe}),disabled:P.isPending})]},ne.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Lm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(gr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:O}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?wI(f.vapidPublicKey):"(not loaded)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["scope: ",(X=f.serviceWorker)!=null&&X.scope?wI(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((Y=f.serviceWorker)==null?void 0:Y.activeState)??"none"]})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["endpoint: ",(ee=f.subscription)!=null&&ee.endpoint?wI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Q=f.subscription)!=null&&Q.p256dh?wI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=f.subscription)!=null&&ce.auth?wI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(ze,{id:"test-title",value:s,onChange:ne=>r(ne.target.value),placeholder:"Enter notification title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Pr,{id:"test-body",value:n,onChange:ne=>a(ne.target.value),placeholder:"Enter notification message",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(ze,{id:"test-url",value:o,onChange:ne=>l(ne.target.value),placeholder:"/community or full URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),e.jsxs(K,{onClick:U,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),v&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),v.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",v.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",v.sent??0," sent, ",v.failed??0," failed, ",v.expiredCleaned??0," expired cleaned"]}),v.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:v.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(gr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),V.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:B,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function Z4s(){const{toast:t}=Ha(),[s,r]=N.useState([]),[n,a]=N.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=N.useState(!0),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=lR("presentation_count","desc"),f=p(s,{name:_=>{var w;return((w=_.name)==null?void 0:w.toLowerCase())||""},presentations:_=>_.presentation_count,views:_=>_.total_views,leads:_=>_.total_leads,cta_clicks:_=>_.total_cta_clicks,conversion:_=>_.total_views>0?_.total_leads/_.total_views*100:0});N.useEffect(()=>{g()},[]);const g=async()=>{try{l(!0);const{data:_,error:w}=await H.rpc("get_admin_presentation_stats");if(w)throw w;if(!_||_.length===0){l(!1);return}const j=_.map(P=>P.owner_user_id),{data:k,error:S}=await H.from("profiles").select("id, name, email, avatar_url").in("id",j);if(S)throw S;const M=new Map((k==null?void 0:k.map(P=>[P.id,P]))||[]),L=_.map(P=>{const O=M.get(P.owner_user_id);return{owner_user_id:P.owner_user_id,name:(O==null?void 0:O.name)||"Unknown",email:(O==null?void 0:O.email)||"",avatar_url:(O==null?void 0:O.avatar_url)||null,presentation_count:Number(P.presentation_count),total_views:Number(P.total_views),total_leads:Number(P.total_leads),total_cta_clicks:Number(P.total_cta_clicks)}});r(L),r(L),a({totalPresentations:L.reduce((P,O)=>P+O.presentation_count,0),totalViews:L.reduce((P,O)=>P+O.total_views,0),totalLeads:L.reduce((P,O)=>P+O.total_leads,0),totalCtaClicks:L.reduce((P,O)=>P+O.total_cta_clicks,0),agentsUsing:L.length})}catch(_){console.error("Error loading presentation stats:",_),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},v=[{label:"Agents Using",value:n.agentsUsing,icon:hr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:ty,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Dn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:El,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Tx,color:"text-rose-600"}];return e.jsx(Ts,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:v.map(_=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:_.label}),e.jsx(_.icon,{className:`h-4 w-4 ${_.color}`})]}),e.jsx(Oe,{children:o?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:_.value.toLocaleString()})})]},_.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((_,w)=>e.jsx(vs,{className:"h-12 w-full"},w))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(bl,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(bl,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(bl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(bl,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(bl,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(bl,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Bn,{children:f.map(_=>{var j,k;const w=_.total_views>0?(_.total_leads/_.total_views*100).toFixed(1):"0.0";return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:_.avatar_url?e.jsx("img",{src:_.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((k=(j=_.name)==null?void 0:j.charAt(0))==null?void 0:k.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:_.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:_.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:_.presentation_count}),e.jsx(dt,{className:"text-center",children:_.total_views.toLocaleString()}),e.jsx(dt,{className:"text-center",children:_.total_leads>0?e.jsx(st,{variant:"secondary",children:_.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:_.total_cta_clicks}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(w)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[w,"%"]})})]},_.owner_user_id)})})]})})]})]})})}function Y4s(){const{toast:t}=Ha(),[s,r]=N.useState([]),[n,a]=N.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=N.useState(!0);N.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await H.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(j=>j.agent_id),{data:g,error:v}=await H.from("profiles").select("id, name, email, avatar_url").in("id",f);if(v)throw v;const _=new Map((g==null?void 0:g.map(j=>[j.id,j]))||[]),w=u.map(j=>{const k=_.get(j.agent_id);return{agent_id:j.agent_id,name:(k==null?void 0:k.name)||"Unknown",email:(k==null?void 0:k.email)||"",avatar_url:(k==null?void 0:k.avatar_url)||null,open_house_count:Number(j.open_house_count),total_visitors:Number(j.total_visitors),total_leads:Number(j.total_leads),active_count:Number(j.active_count)}});w.sort((j,k)=>k.total_visitors-j.total_visitors),r(w),a({totalOpenHouses:w.reduce((j,k)=>j+k.open_house_count,0),totalVisitors:w.reduce((j,k)=>j+k.total_visitors,0),totalLeads:w.reduce((j,k)=>j+k.total_leads,0),activeOpenHouses:w.reduce((j,k)=>j+k.active_count,0),agentsUsing:w.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},c=[{label:"Agents Using",value:n.agentsUsing,icon:hr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:dn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:gi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Dn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:El,color:"text-rose-600"}];return e.jsx(Ts,{title:"Guest Book Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:c.map(u=>e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Rt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:u.value.toLocaleString()})})]},u.label))}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(Jo,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(vs,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Agent"}),e.jsx(St,{className:"text-center",children:"Open Houses"}),e.jsx(St,{className:"text-center",children:"Active"}),e.jsx(St,{className:"text-center",children:"Visitors"}),e.jsx(St,{className:"text-center",children:"Leads"}),e.jsx(St,{className:"text-center",children:"Conversion"})]})}),e.jsx(Bn,{children:s.map(u=>{var f,g;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(Cs,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:u.avatar_url?e.jsx("img",{src:u.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((g=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:g.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:u.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:u.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:u.open_house_count}),e.jsx(dt,{className:"text-center",children:u.active_count>0?e.jsx(st,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(dt,{className:"text-center",children:u.total_leads>0?e.jsx(st,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},u.agent_id)})})]})})]})]})})}function Q4s(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing connection...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Failed to connect: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("Failed to connect: No authorization code");return}try{const{data:f,error:g}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Accounts connected successfully!"),me.success(f.message||"Social accounts connected!");else throw new Error((f==null?void 0:f.error)||"Failed to connect accounts")}catch(f){console.error("Callback error:",f),n("error"),o(f.message||"Failed to complete connection"),me.error(f.message||"Failed to connect accounts")}})()},[t]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(bs,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(jc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Rt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function X4s(){const t=Xt(),[s,r]=N.useState(""),[n,a]=N.useState(""),[o,l]=N.useState([]),i=N.useRef(null),{data:c,isLoading:u}=mt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:j,error:k}=await H.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(k)throw k;return j}}),p={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(j=>j.status==="sent").length)||0,converted:(c==null?void 0:c.filter(j=>j.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(j=>j.status==="converted").length/c.length*100):0},f=Lt({mutationFn:async j=>{const{data:k,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:j}});if(S)throw S;return k},onSuccess:j=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${j.sent} email${j.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:j=>{me.error("Failed to send: "+j.message)}}),g=Lt({mutationFn:async()=>{var M,L;const{data:{user:j}}=await H.auth.getUser();if(!(j!=null&&j.email))throw new Error("Could not get your email");const{data:k,error:S}=await H.functions.invoke("send-prospect-email",{body:{emails:[{email:j.email,first_name:(L=(M=j.user_metadata)==null?void 0:M.name)==null?void 0:L.split(" ")[0]}],test_mode:!0}});if(S)throw S;return k},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:j=>{me.error("Failed to send test: "+j.message)}}),v=()=>{if(!s.trim()){me.error("Please enter an email address");return}if(c==null?void 0:c.find(k=>k.email.toLowerCase()===s.trim().toLowerCase())){me.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},_=j=>{var M;const k=(M=j.target.files)==null?void 0:M[0];if(!k)return;const S=new FileReader;S.onload=L=>{var B,V;const O=((B=L.target)==null?void 0:B.result).split(` `).filter(X=>X.trim()),$=[],U=(V=O[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let X=U;Xce.trim().replace(/"/g,"")),ee=Y[0],Q=Y[1];ee&&ee.includes("@")&&$.push({email:ee,first_name:Q||void 0})}l($),me.success(`${$.length} entries loaded from CSV`)},S.readAsText(k),i.current&&(i.current.value="")},w=()=>{if(o.length===0){me.error("No entries to send");return}const j=new Set((c==null?void 0:c.map(S=>S.email.toLowerCase()))||[]),k=o.filter(S=>!j.has(S.email.toLowerCase()));if(k.length===0){me.error("All emails have already been prospected");return}k.lengthg.mutate(),disabled:g.isPending,className:"gap-2 ml-4 shrink-0",children:[g.isPending?e.jsx(bs,{className:"h-3 w-3 animate-spin"}):e.jsx(lr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(_a,{defaultValue:"single",children:[e.jsxs(fa,{className:"mb-4",children:[e.jsxs(ns,{value:"single",children:[e.jsx($n,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(ns,{value:"bulk",children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(ws,{value:"single",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(ze,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:j=>r(j.target.value),onKeyDown:j=>j.key==="Enter"&&v()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(be,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(ze,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&v()})]}),e.jsxs(K,{onClick:v,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(ws,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:_,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},className:"gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(hr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Mr,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((j,k)=>e.jsxs("div",{className:"text-muted-foreground",children:[j.email,j.first_name?` — ${j.first_name}`:""]},k)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:w,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx($n,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(lr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(gr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((j,k)=>e.jsx(vs,{className:"h-12 w-full"},k))}):c&&c.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:c.map(j=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:j.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ms(new Date(j.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:j.status==="converted"?e.jsxs(st,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(st,{variant:"secondary",className:"gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.converted_at?ms(new Date(j.converted_at),"MMM d, yyyy"):"—"})]},j.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(zm,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No prospects yet. Send your first invite above!"})]})})]})]})})}function Ame(t){const s=Xt(),{toast:r}=Ha(),n=mt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:c,error:u}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return c},enabled:!!t}),a=mt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const c=1e3;let u=[],p=0,f=!0;for(;f;){const{data:g,error:v}=await H.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+c-1);if(v)throw v;u=u.concat(g),f=g.length===c,p+=c}return u},enabled:!!t}),o=Lt({mutationFn:async c=>{const{data:{user:u}}=await H.auth.getUser();if(!u)throw new Error("Not authenticated");const p={first_name:c.first_name||"",last_name:c.last_name||null,email:c.email||null,phone:c.phone||null,current_brokerage:c.current_brokerage||null,license_number:c.license_number||null,experience_years:c.experience_years??null,annual_production:c.annual_production||null,source:c.source||"manual",notes:c.notes||null,stage_id:c.stage_id||null,brokerage_id:t,created_by:u.id,address:c.address||null,city:c.city||null,state:c.state||null,zip_code:c.zip_code||null,last_year_volume:c.last_year_volume||null,last_year_transactions:c.last_year_transactions??null,avg_sale_price:c.avg_sale_price||null,specialties:c.specialties||null,linkedin_url:c.linkedin_url||null,website_url:c.website_url||null,instagram_handle:c.instagram_handle||null,facebook_url:c.facebook_url||null,birthday:c.birthday||null,spouse_name:c.spouse_name||null,interests:c.interests||null,referred_by:c.referred_by||null},{data:f,error:g}=await H.from("recruit_prospects").insert(p).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect added"})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),l=Lt({mutationFn:async({id:c,...u})=>{const{data:p,error:f}=await H.from("recruit_prospects").update({...u,updated_at:new Date().toISOString()}).eq("id",c).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]})},onError:c=>r({title:"Error",description:c.message,variant:"destructive"})}),i=Lt({mutationFn:async c=>{const{error:u}=await H.from("recruit_prospects").delete().eq("id",c);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-prospects",t]}),r({title:"Prospect removed"})}});return{stages:n.data||[],prospects:a.data||[],isLoading:n.isLoading||a.isLoading,addProspect:o,updateProspect:l,deleteProspect:i}}function J4s(t){const s=Xt(),{toast:r}=Ha(),n=mt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await H.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Lt({mutationFn:async o=>{const{data:{user:l}}=await H.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:c}=await H.from("recruit_activities").insert({...o,created_by:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{s.invalidateQueries({queryKey:["recruit-activities",t]}),r({title:"Activity logged"})},onError:o=>r({title:"Error",description:o.message,variant:"destructive"})});return{activities:n.data||[],isLoading:n.isLoading,addActivity:a}}const Fze=(t,s)=>{var r;return{first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",license_number:"",experience_years:"",annual_production:"",source:"manual",notes:"",stage_id:t||((r=s==null?void 0:s[0])==null?void 0:r.id)||"",address:"",city:"",state:"",zip_code:"",last_year_volume:"",last_year_transactions:"",avg_sale_price:"",specialties:"",linkedin_url:"",website_url:"",instagram_handle:"",facebook_url:"",birthday:"",spouse_name:"",interests:"",referred_by:""}};function Zlt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=N.useState(Fze(n,r)),c=p=>f=>i(g=>({...g,[p]:f.target.value})),u=p=>{p.preventDefault(),a({...l,experience_years:l.experience_years?parseInt(l.experience_years):null,last_year_transactions:l.last_year_transactions?parseInt(l.last_year_transactions):null,stage_id:l.stage_id||null}),i(Fze(n,r)),s(!1)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(_a,{defaultValue:"basic",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4",children:[e.jsx(ns,{value:"basic",children:"Basic Info"}),e.jsx(ns,{value:"production",children:"Production"}),e.jsx(ns,{value:"social",children:"Social & Web"}),e.jsx(ns,{value:"personal",children:"Personal"})]}),e.jsxs(ws,{value:"basic",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:c("last_name")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Current Brokerage"}),e.jsx(ze,{value:l.current_brokerage,onChange:c("current_brokerage")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"License #"}),e.jsx(ze,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Experience (years)"}),e.jsx(ze,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Address"}),e.jsx(ze,{placeholder:"Street address",value:l.address,onChange:c("address")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"City"}),e.jsx(ze,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"State"}),e.jsx(ze,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Zip"}),e.jsx(ze,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Pipeline Stage"}),e.jsxs(Ks,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:r.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Referred By"}),e.jsx(ze,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:c("referred_by")})]})]}),e.jsxs(ws,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Annual Production Volume"}),e.jsx(ze,{placeholder:"e.g. $5M, 20 transactions",value:l.annual_production,onChange:c("annual_production")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Last Year Volume"}),e.jsx(ze,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:c("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Year Transactions"}),e.jsx(ze,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:c("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Avg Sale Price"}),e.jsx(ze,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:c("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Specialties / Niche"}),e.jsx(ze,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:c("specialties")})]})]}),e.jsxs(ws,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"LinkedIn URL"}),e.jsx(ze,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:c("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Website URL"}),e.jsx(ze,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Instagram Handle"}),e.jsx(ze,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Facebook URL"}),e.jsx(ze,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:c("facebook_url")})]})]}),e.jsxs(ws,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Birthday"}),e.jsx(ze,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Spouse / Partner Name"}),e.jsx(ze,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Interests / Hobbies"}),e.jsx(ze,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Pr,{value:l.notes,onChange:c("notes"),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:o,children:"Add Prospect"})]})]})]})})}const wwe=[{value:"why_switch",label:"Why Switch Brokerages"},{value:"commission",label:"Commission & Splits"},{value:"culture",label:"Culture & Team"},{value:"follow_up",label:"Follow Up"},{value:"general",label:"General Pitch"}];function eSs(t){return mt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function tSs(t){return mt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function sSs(){const t=Xt(),{toast:s}=Ha();return Lt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function Ylt(){const t=Xt();return Lt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await H.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function Qlt(t){return mt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function rSs(){const t=Xt(),{toast:s}=Ha();return Lt({mutationFn:async r=>{const{data:{user:n}}=await H.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function nSs(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function aSs({prospectId:t,prospectName:s,brokerageId:r}){var B;const{data:n=[],isLoading:a}=tSs(t),{data:o=[]}=Qlt(r),l=sSs(),i=L3(),c=Ylt(),[u,p]=N.useState("idle"),[f,g]=N.useState(0),[v,_]=N.useState(0),[w,j]=N.useState(""),[k,S]=N.useState(""),[M,L]=N.useState(!1),P=((B=o.find(V=>V.id===w))==null?void 0:B.script_text)||"",O=()=>{p("idle"),g(0),_(0),j(""),S("")},$=N.useCallback(async(V,X)=>{p("uploading");try{const Y=`Recruiting: ${s}`,{videoId:ee,libraryId:Q}=await SR(Y),{uploadUrl:ce,apiKey:ne}=await CR(ee),re=new XMLHttpRequest;re.upload.onprogress=Me=>{Me.lengthComputable&&g(Me.loaded/Me.total*100)},await new Promise((Me,Ie)=>{re.onload=()=>re.status>=200&&re.status<300?Me():Ie(new Error("Upload failed")),re.onerror=()=>Ie(new Error("Upload failed")),re.open("PUT",ce),re.setRequestHeader("AccessKey",ne),re.send(V)}),p("processing");let oe=0;const fe=Date.now(),ge=9e4,ue=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;for(;oe<4&&(await new Promise(Ie=>setTimeout(Ie,3e3)),!(Date.now()-fe>ge));){const Me=await AA(ee);if(oe=Me.status,_(Me.encodeProgress||0),oe===5||oe===6)throw new Error("Video processing failed")}const xe=await AA(ee),_e=(xe.storageSize||V.size)/(1024*1024),$e=await i.mutateAsync({bunny_video_id:ee,playback_url:xe.directPlayUrl||ue,thumbnail_url:xe.thumbnailUrl,preview_url:xe.previewUrl||null,duration_seconds:xe.length||X,file_size_mb:_e,title:Y,status:oe>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:$e.id,brokerage_id:r,message:k||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{L(!1),O()},1500)}catch(Y){me.error(Y.message||"Failed to upload video"),p("record")}},[t,s,r,k,i,l]),U=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),me.success("Share link copied"))};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5",children:[e.jsx(Cn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(xs,{open:M,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(L(V),V||O())},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(js,{children:e.jsxs(_s,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(Ks,{value:w,onValueChange:j,children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Ys,{placeholder:"No script — speak freely"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"none",children:"No script"}),o.map(V=>{var X;return e.jsx(Mt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(st,{variant:"outline",className:"text-[9px] ml-1",children:(X=wwe.find(Y=>Y.value===V.category))==null?void 0:X.label})]})},V.id)})]})]}),P&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:P})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Pr,{value:k,onChange:V=>S(V.target.value),placeholder:`Hi ${s.split(" ")[0]}, I'd love to chat about what we're building here...`,rows:3,className:"mt-1"})]}),e.jsxs(K,{onClick:()=>p("record"),className:"w-full",children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(Tme,{maxDurationSeconds:300,onRecordingComplete:$,teleprompterContent:P||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(Bi,{value:f,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(f),"%"]})]}),u==="processing"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Processing video…"}),e.jsx(Bi,{value:v,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(v),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(il,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(V=>{var X,Y;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md border text-sm",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:(X=V.video)!=null&&X.thumbnail_url?e.jsx("img",{src:V.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs truncate",children:((Y=V.video)==null?void 0:Y.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(st,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(Dn,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(st,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx($n,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(st,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(un,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ms(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>U(V.share_token),children:e.jsx(yi,{className:"h-3 w-3"})}),!V.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c.mutate({id:V.id,sent_via:"email"}),children:e.jsx($n,{className:"h-3 w-3"})})]})]},V.id)})})]})}function iSs(t){return mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("recruit_campaign_sends").select("id, prospect_id, subject, email_number, status, sent_at, opened_at, clicked_at, error_message, created_at").eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}const zze=[{value:"call",label:"Phone Call",icon:Mn},{value:"email",label:"Email",icon:lr},{value:"text",label:"Text Message",icon:so},{value:"meeting",label:"Meeting",icon:hn},{value:"note",label:"Note",icon:wn},{value:"campaign_email",label:"Campaign Email",icon:$n}];function Yp({label:t,value:s,icon:r}){return s?e.jsxs("div",{children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r&&e.jsx(r,{className:"h-3 w-3"})," ",t]}),e.jsx("p",{className:"font-medium text-sm",children:s})]}):null}function f9({label:t,url:s,icon:r}){return s?e.jsxs("a",{href:s.startsWith("http")?s:`https://${s}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[e.jsx(r,{className:"h-3.5 w-3.5"})," ",t," ",e.jsx(en,{className:"h-3 w-3 opacity-50"})]}):null}function gc({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:t}),e.jsx(ze,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function Xlt({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=J4s((t==null?void 0:t.id)||null),{data:u=[]}=iSs((t==null?void 0:t.id)||null),[p,f]=N.useState({type:"note",title:"",description:""}),[g,v]=N.useState(!1),[_,w]=N.useState(!1),[j,k]=N.useState({});if(!t)return null;const S=()=>{var Y,ee;k({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((Y=t.experience_years)==null?void 0:Y.toString())||"",notes:t.notes||"",source:t.source||"",address:t.address||"",city:t.city||"",state:t.state||"",zip_code:t.zip_code||"",last_year_volume:t.last_year_volume||"",last_year_transactions:((ee=t.last_year_transactions)==null?void 0:ee.toString())||"",avg_sale_price:t.avg_sale_price||"",specialties:t.specialties||"",annual_production:t.annual_production||"",linkedin_url:t.linkedin_url||"",website_url:t.website_url||"",instagram_handle:t.instagram_handle||"",facebook_url:t.facebook_url||"",birthday:t.birthday||"",spouse_name:t.spouse_name||"",interests:t.interests||"",referred_by:t.referred_by||""}),w(!0)},M=()=>{const Y={id:t.id};for(const[ee,Q]of Object.entries(j))ee==="experience_years"||ee==="last_year_transactions"?Y[ee]=Q?parseInt(Q):null:Y[ee]=Q||null;o(Y),w(!1)},L=()=>w(!1),P=Y=>ee=>k(Q=>({...Q,[Y]:ee})),O=()=>{p.title.trim()&&(c.mutate({prospect_id:t.id,activity_type:p.type,title:p.title,description:p.description||null}),f({type:"note",title:"",description:""}),v(!1))},$=s.find(Y=>Y.id===t.stage_id),U=t.address||t.city||t.state,B=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,V=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,X=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(lE,{open:n,onOpenChange:Y=>{Y||w(!1),a(Y)},children:e.jsx(S3,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Ki,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(cE,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(dE,{className:"text-xl",children:[t.first_name," ",t.last_name]}),$&&e.jsx(st,{variant:"outline",style:{borderColor:$.color,color:$.color},className:"mt-1",children:$.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:L,children:e.jsx(Mr,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:M,children:e.jsx(Uc,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:S,title:"Edit prospect",children:e.jsx(za,{className:"h-4 w-4"})}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete prospect?"}),e.jsx(ic,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>{l(t.id),a(!1)},children:"Delete"})]})]})]})]})]})}),!_&&e.jsxs("div",{className:"space-y-1.5 text-sm",children:[t.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," ",t.email]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," ",t.phone]}),U&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ia,{className:"h-3.5 w-3.5"}),[t.address,t.city,t.state,t.zip_code].filter(Boolean).join(", ")]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(Ks,{value:t.stage_id||"",onValueChange:Y=>o({id:t.id,stage_id:Y}),children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:s.map(Y=>e.jsx(Mt,{value:Y.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Y.color}}),Y.name]})},Y.id))})]})]}),e.jsxs(_a,{defaultValue:"details",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(ns,{value:"details",className:"text-xs",children:"Details"}),e.jsx(ns,{value:"production",className:"text-xs",children:"Production"}),e.jsx(ns,{value:"social",className:"text-xs",children:"Social"}),e.jsx(ns,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(ws,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(gc,{label:"First Name",value:j.first_name,onChange:P("first_name")}),e.jsx(gc,{label:"Last Name",value:j.last_name,onChange:P("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(gc,{label:"Email",value:j.email,onChange:P("email"),type:"email"}),e.jsx(gc,{label:"Phone",value:j.phone,onChange:P("phone")})]}),e.jsx(gc,{label:"Current Brokerage",value:j.current_brokerage,onChange:P("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(gc,{label:"License #",value:j.license_number,onChange:P("license_number")}),e.jsx(gc,{label:"Experience (years)",value:j.experience_years,onChange:P("experience_years"),type:"number"})]}),e.jsx(gc,{label:"Address",value:j.address,onChange:P("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(gc,{label:"City",value:j.city,onChange:P("city")}),e.jsx(gc,{label:"State",value:j.state,onChange:P("state")}),e.jsx(gc,{label:"Zip",value:j.zip_code,onChange:P("zip_code")})]}),e.jsx(gc,{label:"Source",value:j.source,onChange:P("source")}),e.jsx(gc,{label:"Referred By",value:j.referred_by,onChange:P("referred_by")}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Notes"}),e.jsx(Pr,{value:j.notes,onChange:Y=>k(ee=>({...ee,notes:Y.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(ws,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(gc,{label:"Annual Production",value:j.annual_production,onChange:P("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(gc,{label:"Last Year Volume",value:j.last_year_volume,onChange:P("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(gc,{label:"Last Year Transactions",value:j.last_year_transactions,onChange:P("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(gc,{label:"Avg Sale Price",value:j.avg_sale_price,onChange:P("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(gc,{label:"Specialties / Niche",value:j.specialties,onChange:P("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(ws,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(gc,{label:"LinkedIn URL",value:j.linkedin_url,onChange:P("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(gc,{label:"Website URL",value:j.website_url,onChange:P("website_url"),type:"url",placeholder:"https://..."}),e.jsx(gc,{label:"Instagram Handle",value:j.instagram_handle,onChange:P("instagram_handle"),placeholder:"@handle"}),e.jsx(gc,{label:"Facebook URL",value:j.facebook_url,onChange:P("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(ws,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(gc,{label:"Birthday",value:j.birthday,onChange:P("birthday"),type:"date"}),e.jsx(gc,{label:"Spouse / Partner",value:j.spouse_name,onChange:P("spouse_name")}),e.jsx(gc,{label:"Interests / Hobbies",value:j.interests,onChange:P("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ws,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Yp,{label:"License #",value:t.license_number}),e.jsx(Yp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Yp,{label:"Referred By",value:t.referred_by}),e.jsx(Yp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(ws,{value:"production",className:"mt-3",children:B?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Annual Production",value:t.annual_production}),e.jsx(Yp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Yp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Yp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Yp,{label:"Specialties / Niche",value:t.specialties})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No production data added yet"})}),e.jsx(ws,{value:"social",className:"mt-3",children:V?e.jsxs("div",{className:"space-y-2",children:[e.jsx(f9,{label:"LinkedIn",url:t.linkedin_url,icon:Mp}),e.jsx(f9,{label:"Website",url:t.website_url,icon:ru}),t.instagram_handle&&e.jsx(f9,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Tu}),e.jsx(f9,{label:"Facebook",url:t.facebook_url,icon:Cu})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(ws,{value:"personal",className:"mt-3",children:X?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Birthday",value:t.birthday?ms(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:So}),e.jsx(Yp,{label:"Spouse / Partner",value:t.spouse_name,icon:Ya}),e.jsx("div",{className:"col-span-2",children:e.jsx(Yp,{label:"Interests / Hobbies",value:t.interests})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No personal details added yet"})})]})]}),e.jsx(aSs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(al,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Activity Log"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>v(!g),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),g&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(Ks,{value:p.type,onValueChange:Y=>f(ee=>({...ee,type:Y})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:zze.map(Y=>e.jsx(Mt,{value:Y.value,children:Y.label},Y.value))})]}),e.jsx(ze,{placeholder:"Subject / Title",value:p.title,onChange:Y=>f(ee=>({...ee,title:Y.target.value}))}),e.jsx(Pr,{placeholder:"Details (optional)",value:p.description,onChange:Y=>f(ee=>({...ee,description:Y.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>v(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:O,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const Y=[...i.map(ee=>({type:"manual",data:ee,date:ee.created_at})),...u.map(ee=>({type:"campaign_email",data:ee,date:ee.sent_at||ee.created_at}))].sort((ee,Q)=>new Date(Q.date).getTime()-new Date(ee.date).getTime());return Y.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):Y.map(ee=>{if(ee.type==="manual"){const ce=ee.data,ne=zze.find(oe=>oe.value===ce.activity_type),re=(ne==null?void 0:ne.icon)||wn;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center",children:e.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:ce.title}),ce.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:ce.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const Q=ee.data;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx($n,{className:"h-3.5 w-3.5 text-primary"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium",children:["Campaign Email #",Q.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:Q.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[Q.status==="failed"?e.jsx(st,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx($n,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),Q.opened_at?e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(Dn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ms(new Date(Q.opened_at),"MMM d, h:mm a")]}):Q.status!=="failed"?e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,Q.clicked_at&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(Nh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ms(new Date(Q.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ms(new Date(Q.sent_at||Q.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${Q.id}`)})})()})]})]})})})})}const oSs=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes","address","city","state","zip_code","last_year_volume","last_year_transactions","avg_sale_price","linkedin_url","website_url","specialties","referred_by"];function Jlt({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ha(),o=Xt(),l=N.useRef(null),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState({}),[v,_]=N.useState(((V=n[0])==null?void 0:V.id)||""),[w,j]=N.useState(!1),[k,S]=N.useState("upload"),[M,L]=N.useState(0),P=()=>{c([]),p([]),g({}),S("upload"),L(0)},O=X=>{var Q;const Y=(Q=X.target.files)==null?void 0:Q[0];if(!Y)return;const ee=new FileReader;ee.onload=ce=>{var xe;const re=((xe=ce.target)==null?void 0:xe.result).split(/\r?\n/).filter(_e=>_e.trim());if(re.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const oe=$(re[0]);p(oe);const fe={},ge=new Set;oe.forEach((_e,$e)=>{const Me=_e.toLowerCase().replace(/[^a-z0-9]/g,"");let Ie=null;/^firstname$/.test(Me)||Me==="first"?Ie="first_name":/^lastname$/.test(Me)||Me==="last"?Ie="last_name":/^email$/.test(Me)||Me==="emailaddress"?Ie="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Me)?Ie="phone":/officename|currentbrokerage|brokerage|company/.test(Me)?Ie="current_brokerage":/membernumber|licensenumber|license/.test(Me)?Ie="license_number":/experienceyears|yearsexperience/.test(Me)?Ie="experience_years":/^totalvolume$|annualproduction/.test(Me)?Ie="annual_production":/^address$/.test(Me)?Ie="address":/^city$/.test(Me)?Ie="city":/^state$/.test(Me)?Ie="state":/^postalcode$|^zip$|^zipcode$/.test(Me)?Ie="zip_code":/listsidevolume|lastyearvolume/.test(Me)?Ie="last_year_volume":/^totalcount$|lastyeartransactions/.test(Me)?Ie="last_year_transactions":/avgsaleprice|averageprice/.test(Me)?Ie="avg_sale_price":/linkedin/.test(Me)?Ie="linkedin_url":/website/.test(Me)?Ie="website_url":/specialt/.test(Me)?Ie="specialties":/referr/.test(Me)?Ie="referred_by":/^notes$|^note$/.test(Me)&&(Ie="notes"),Ie&&!ge.has(Ie)&&(fe[String($e)]=Ie,ge.add(Ie))}),g(fe);const ue=re.slice(1).map(_e=>{const $e=$(_e),Me={};return oe.forEach((Ie,ke)=>{Me[String(ke)]=$e[ke]||""}),Me});c(ue),S("map")},ee.readAsText(Y)},$=X=>{const Y=[];let ee="",Q=!1;for(const ce of X)ce==='"'?Q=!Q:ce===","&&!Q?(Y.push(ee.trim()),ee=""):ee+=ce;return Y.push(ee.trim()),Y},U=async()=>{j(!0);try{const{data:{user:X}}=await H.auth.getUser();if(!X)throw new Error("Not authenticated");const Y=i.map(Q=>{const ce={brokerage_id:r,created_by:X.id,stage_id:v,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([ne,re])=>{var fe;const oe=(fe=Q[ne])==null?void 0:fe.trim();oe&&(re==="experience_years"||re==="last_year_transactions"?ce[re]=parseInt(oe.replace(/[^0-9.-]/g,""))||null:re==="annual_production"||re==="last_year_volume"||re==="avg_sale_price"?ce[re]=oe.replace(/[^0-9.$,.-]/g,""):ce[re]=oe)}),ce});let ee=0;for(let Q=0;Q{const X=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,Y=new Blob([X],{type:"text/csv"}),ee=URL.createObjectURL(Y),Q=document.createElement("a");Q.href=ee,Q.download="recruit-prospects-template.csv",Q.click(),URL.revokeObjectURL(ee)};return e.jsx(xs,{open:t,onOpenChange:X=>{X||P(),s(X)},children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Import Prospects from CSV"})}),k==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(c1,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:O}),e.jsxs(K,{onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},children:[e.jsx(di,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),k==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(Ks,{value:v,onValueChange:_,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{})}),e.jsx(Ws,{children:n.map(X=>e.jsx(Mt,{value:X.id,children:X.name},X.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[140px]",children:"CSV Column"}),e.jsx(St,{className:"w-[160px]",children:"Map To"}),e.jsx(St,{children:"Preview"})]})}),e.jsx(Bn,{children:u.map((X,Y)=>{var ee;return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium text-xs",children:X}),e.jsx(dt,{children:e.jsxs(Ks,{value:f[String(Y)]||"skip",onValueChange:Q=>g(ce=>({...ce,[String(Y)]:Q==="skip"?"":Q})),children:[e.jsx(Gs,{className:"h-8 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"skip",children:"— Skip —"}),oSs.map(Q=>e.jsx(Mt,{value:Q,children:Q.replace(/_/g," ")},Q))]})]})}),e.jsx(dt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((ee=i[0])==null?void 0:ee[String(Y)])||"—"})]},Y)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Cl,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{P()},children:"Back"}),e.jsx(K,{onClick:U,disabled:w||!Object.values(f).includes("first_name"),children:w?"Importing...":`Import ${i.length} Prospects`})]})]}),k==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(ba,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[M," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{P(),s(!1)},children:"Close"})]})]})})}function ect({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ame(t),[i,c]=N.useState(!1),[u,p]=N.useState(),[f,g]=N.useState(null),[v,_]=N.useState(!1),[w,j]=N.useState(!1),[k,S]=N.useState(null);if(n)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const M=B=>r.filter(V=>V.stage_id===B),L=(B,V)=>{S(V),B.dataTransfer.effectAllowed="move"},P=B=>{B.preventDefault(),B.dataTransfer.dropEffect="move"},O=(B,V)=>{B.preventDefault(),k&&(o.mutate({id:k,stage_id:V}),S(null))},$=B=>{p(B),c(!0)},U=B=>{g(B),_(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(di,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),c(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Ki,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(B=>{const V=M(B.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:P,onDrop:X=>O(X,B.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:B.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:B.name}),e.jsx(st,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(B.id),children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:V.map(X=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:B.color},draggable:!0,onDragStart:Y=>L(Y,X.id),onClick:()=>U(X),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Wi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]})]}),X.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ca,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:X.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(lr,{className:"h-3 w-3 text-muted-foreground"}),X.phone&&e.jsx(Mn,{className:"h-3 w-3 text-muted-foreground"}),X.experience_years!=null&&e.jsxs(st,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[X.experience_years,"yr"]})]})]})]})},X.id))})]},B.id)})}),e.jsx(xue,{orientation:"horizontal"})]}),e.jsx(Zlt,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(Xlt,{prospect:f,stages:s,brokerageId:t,open:v,onOpenChange:_,onUpdate:B=>{o.mutate(B),g(V=>V?{...V,...B}:null)},onDelete:B=>l.mutate(B)}),e.jsx(Jlt,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function mde({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=Ame(t),{user:i}=Os(),c=Xt(),[u,p]=N.useState(!1),[f,g]=N.useState(null),[v,_]=N.useState(!1),[w,j]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState("all"),[P,O]=N.useState("all"),[$,U]=N.useState("all"),[B,V]=N.useState(null),[X,Y]=N.useState("asc"),[ee,Q]=N.useState(new Set),[ce,ne]=N.useState(!1),[re,oe]=N.useState(""),fe=N.useMemo(()=>{const Te=new Set;return r.forEach(pt=>{pt.current_brokerage&&Te.add(pt.current_brokerage)}),Array.from(Te).sort()},[r]),{data:ge=[]}=mt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:Te,error:pt}=await H.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(pt)throw pt;return Te}}),{data:ue=[]}=mt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{let pt=[],ye=0;for(;;){const{data:qe,error:at}=await H.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t).range(ye,ye+1e3-1);if(at)throw at;if(pt=pt.concat(qe??[]),!qe||qe.length<1e3)break;ye+=1e3}return pt}}),xe=N.useMemo(()=>{const Te=new Map;return ue.forEach(pt=>{Te.has(pt.prospect_id)||Te.set(pt.prospect_id,new Set),Te.get(pt.prospect_id).add(pt.campaign_id)}),Te},[ue]),_e=Te=>{B===Te?Y(pt=>pt==="asc"?"desc":"asc"):(V(Te),Y("asc"))},$e=({column:Te})=>B!==Te?e.jsx(_d,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):X==="asc"?e.jsx(Su,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Kh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Me=Te=>s.find(pt=>pt.id===Te),Ie=N.useMemo(()=>{let Te=r.filter(pt=>{var Ae,rt,He;const ye=!k||`${pt.first_name} ${pt.last_name}`.toLowerCase().includes(k.toLowerCase())||((Ae=pt.email)==null?void 0:Ae.toLowerCase().includes(k.toLowerCase()))||((rt=pt.current_brokerage)==null?void 0:rt.toLowerCase().includes(k.toLowerCase())),qe=M==="all"||pt.stage_id===M,at=P==="all"||pt.current_brokerage===P;let tt=!0;return $==="in_campaign"?tt=xe.has(pt.id):$==="not_in_campaign"?tt=!xe.has(pt.id):$!=="all"&&(tt=((He=xe.get(pt.id))==null?void 0:He.has($))??!1),ye&&qe&&at&&tt});return B&&(Te=[...Te].sort((pt,ye)=>{var Ae,rt;let qe=null,at=null;switch(B){case"name":qe=`${pt.first_name} ${pt.last_name||""}`.toLowerCase(),at=`${ye.first_name} ${ye.last_name||""}`.toLowerCase();break;case"stage":qe=((Ae=Me(pt.stage_id))==null?void 0:Ae.sort_order)??999,at=((rt=Me(ye.stage_id))==null?void 0:rt.sort_order)??999;break;case"brokerage":qe=(pt.current_brokerage||"").toLowerCase(),at=(ye.current_brokerage||"").toLowerCase();break;case"experience":qe=pt.experience_years??-1,at=ye.experience_years??-1;break;case"production":qe=(pt.annual_production||"").toLowerCase(),at=(ye.annual_production||"").toLowerCase();break;case"source":qe=(pt.source||"").toLowerCase(),at=(ye.source||"").toLowerCase();break;default:return 0}if(qe===at)return 0;if(qe==null)return 1;if(at==null)return-1;const tt=qe0&&Ie.every(Te=>ee.has(Te.id)),pe=Ie.some(Te=>ee.has(Te.id)),we=()=>{Q(ke?new Set:new Set(Ie.map(Te=>Te.id)))},Le=Te=>{Q(pt=>{const ye=new Set(pt);return ye.has(Te)?ye.delete(Te):ye.add(Te),ye})},Qe=Lt({mutationFn:async()=>{if(!re||!(i!=null&&i.id))throw new Error("Select a campaign");const Te=new Set(ue.filter(qe=>qe.campaign_id===re).map(qe=>qe.prospect_id)),pt=Array.from(ee).filter(qe=>!Te.has(qe)).map(qe=>({prospect_id:qe,campaign_id:re,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(pt.length===0)throw new Error("All selected prospects are already in this campaign");const{error:ye}=await H.from("recruit_campaign_assignments").insert(pt);if(ye)throw ye;return pt.length},onSuccess:Te=>{me.success(`${Te} prospect(s) added to campaign`),ne(!1),Q(new Set),oe(""),c.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:Te=>me.error(Te.message)});return n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm min-w-[200px]",children:[e.jsx(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search prospects...",value:k,onChange:Te=>S(Te.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[ee.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>ne(!0),className:"gap-1.5",children:[e.jsx($n,{className:"h-4 w-4"})," Add ",ee.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(di,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>p(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(ey,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ks,{value:M,onValueChange:L,children:[e.jsx(Gs,{className:"w-[160px] h-8 text-xs",children:e.jsx(Ys,{placeholder:"All stages"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All stages"}),s.map(Te=>e.jsx(Mt,{value:Te.id,children:Te.name},Te.id))]})]}),e.jsxs(Ks,{value:P,onValueChange:O,children:[e.jsxs(Gs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(Ca,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Ys,{placeholder:"All brokerages"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All brokerages"}),fe.map(Te=>e.jsx(Mt,{value:Te,children:Te},Te))]})]}),e.jsxs(Ks,{value:$,onValueChange:U,children:[e.jsxs(Gs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Ys,{placeholder:"Campaign status"})]}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All contacts"}),e.jsx(Mt,{value:"in_campaign",children:"In any campaign"}),e.jsx(Mt,{value:"not_in_campaign",children:"Not in any campaign"}),ge.map(Te=>e.jsxs(Mt,{value:Te.id,children:["In: ",Te.name]},Te.id))]})]}),(M!=="all"||P!=="all"||$!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{L("all"),O("all"),U("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{className:"w-[40px]",children:e.jsx(Oo,{checked:ke,onCheckedChange:we,"aria-label":"Select all",...pe&&!ke?{"data-state":"indeterminate"}:{}})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>_e("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx($e,{column:"name"})]})}),e.jsx(St,{className:"cursor-pointer select-none",onClick:()=>_e("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx($e,{column:"stage"})]})}),e.jsx(St,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>_e("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx($e,{column:"brokerage"})]})}),e.jsx(St,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>_e("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx($e,{column:"experience"})]})}),e.jsx(St,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>_e("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx($e,{column:"production"})]})}),e.jsx(St,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(St,{className:"w-[50px]"})]})}),e.jsx(Bn,{children:Ie.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Ie.map(Te=>{const pt=Me(Te.stage_id),ye=xe.get(Te.id),qe=(ye==null?void 0:ye.size)??0;return e.jsxs(Cs,{className:"cursor-pointer",onClick:()=>{g(Te),_(!0)},children:[e.jsx(dt,{onClick:at=>at.stopPropagation(),children:e.jsx(Oo,{checked:ee.has(Te.id),onCheckedChange:()=>Le(Te.id),"aria-label":`Select ${Te.first_name}`})}),e.jsxs(dt,{className:"font-medium",children:[Te.first_name," ",Te.last_name]}),e.jsx(dt,{children:pt?e.jsxs(st,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:pt.color,color:pt.color,backgroundColor:`${pt.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:pt.color}}),pt.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:Te.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(Ca,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:Te.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Te.email&&e.jsx(lr,{className:"h-3.5 w-3.5 text-muted-foreground"}),Te.phone&&e.jsx(Mn,{className:"h-3.5 w-3.5 text-muted-foreground"}),!Te.email&&!Te.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(dt,{className:"hidden lg:table-cell",children:Te.experience_years!=null?`${Te.experience_years} yr`:"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:Te.annual_production||"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:qe>0?e.jsxs(st,{variant:"secondary",className:"text-xs",children:[qe," campaign",qe>1?"s":""]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"None"})}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:at=>{at.stopPropagation(),l.mutate(Te.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})})]},Te.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ee.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[ee.size," selected · "]}),Ie.length," of ",r.length," prospects"]}),e.jsx(xs,{open:ce,onOpenChange:ne,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Add to Campaign"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Add ",e.jsx("span",{className:"font-medium text-foreground",children:ee.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Campaign"}),e.jsxs(Ks,{value:re,onValueChange:oe,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a campaign..."})}),e.jsx(Ws,{children:ge.map(Te=>e.jsxs(Mt,{value:Te.id,children:[Te.name," ",e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Te.warmth_level,")"]})]},Te.id))})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>Qe.mutate(),disabled:!re||Qe.isPending,children:Qe.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Zlt,{open:u,onOpenChange:p,stages:s,onSubmit:Te=>a.mutate(Te),isSubmitting:a.isPending}),e.jsx(Xlt,{prospect:f,stages:s,brokerageId:t,open:v,onOpenChange:_,onUpdate:Te=>{o.mutate(Te),g(pt=>pt?{...pt,...Te}:null)},onDelete:Te=>l.mutate(Te)}),e.jsx(Jlt,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function tct({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=Ame(t),a=N.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(k=>k.name==="Signed"),i=s.find(k=>k.name==="Onboarded"),c=r.filter(k=>k.stage_id===(l==null?void 0:l.id)||k.stage_id===(i==null?void 0:i.id)).length,u=o>0?(c/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((k,S)=>k+cy(p,new Date(S.created_at)),0)/o):0,g=s.map(k=>({...k,count:r.filter(S=>S.stage_id===k.id).length})),v={};r.forEach(k=>{const S=k.source||"unknown";v[S]=(v[S]||0)+1});const _=Object.entries(v).sort((k,S)=>S[1]-k[1]),w=new Date;w.setDate(w.getDate()-30);const j=r.filter(k=>new Date(k.created_at)>=w).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:g,bySrc:_,recentCount:j}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(hr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Prospects"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(Jo,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(un,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.avgDays,"d"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Avg Days in Pipeline"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(zm,{className:"h-5 w-5 text-violet-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.recentCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Added (30 days)"})]})]})})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(st,{variant:"secondary",className:"capitalize",children:o.replace(/_/g," ")}),e.jsx("span",{className:"text-sm font-medium",children:l})]},o)),a.bySrc.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No source data"})]})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No prospect data yet. Add prospects to see metrics."})}const Bze=[{id:"value-prop",category:"Outreach",title:"Value Proposition Introduction",subject:"A Better Way to Grow Your Real Estate Business",body:`Hi [First Name], I hope this message finds you well. I've been following your work in [Area/Market] and I'm impressed by what you've accomplished. I'm reaching out because I believe our brokerage offers unique tools and support that could help take your business to the next level: • Industry-leading commission splits • Full marketing suite with customizable templates • Advanced CRM and lead generation tools • Ongoing training and mentorship programs • Collaborative team environment I'd love to share more about how we're helping agents like you grow their business. Would you be open to a brief conversation this week? Best regards, [Your Name]`},{id:"follow-up",category:"Follow-up",title:"Gentle Follow-up",subject:"Following Up – Quick Chat?",body:`Hi [First Name], I wanted to follow up on my previous message. I understand you're busy – that's the sign of a successful agent! I'd love just 15 minutes of your time to show you what makes our brokerage different. Many agents who've made the switch tell us they wish they'd done it sooner. Would [Day/Time] work for a quick call or coffee? Looking forward to connecting, [Your Name]`},{id:"interview-invite",category:"Interview",title:"Interview / Meeting Invitation",subject:"Invitation to Learn More About [Brokerage Name]",body:`Hi [First Name], Thank you for your interest in exploring opportunities with [Brokerage Name]! I'd love to set up a time for us to meet and discuss how we can support your career goals. Here's what we'll cover: • Our commission structure and agent benefits • Technology and marketing tools available to you • Training and professional development opportunities • Culture and team dynamics • Your questions and goals I have availability on: • [Date/Time Option 1] • [Date/Time Option 2] • [Date/Time Option 3] Please let me know which time works best, or suggest an alternative that suits your schedule. Warm regards, [Your Name]`},{id:"offer",category:"Offer",title:"Formal Offer / Welcome",subject:"Welcome to the Team – Your Offer Details",body:`Hi [First Name], I'm thrilled to extend a formal invitation to join [Brokerage Name]! Based on our conversations, I'm confident this will be a great fit for both of us. Here's a summary of your offer: • Commission Split: [Details] • Start Date: [Date] • Desk/Office: [Details] • Technology Package: [Details] • Additional Benefits: [Details] Next steps: 1. Review the attached agreement 2. Complete the onboarding paperwork 3. Schedule your first-week orientation Please feel free to reach out with any questions. We're excited to have you on the team! Welcome aboard, [Your Name]`},{id:"referral-ask",category:"Referral",title:"Agent Referral Request",subject:"Know Any Great Agents Looking for a Change?",body:`Hi [First Name], Hope you're having a great [week/month]! I'm reaching out because our brokerage is growing and we're looking for talented agents to join our team. Since you know the industry well, I was wondering if you know any agents who might be: • Looking for better technology and support • Seeking a more collaborative environment • Ready to take their business to the next level We offer a referral bonus of [Amount/Details] for any successful placement. It's a great way to help a colleague while earning something extra. If anyone comes to mind, I'd appreciate the introduction! Thanks, [Your Name]`},{id:"market-update",category:"Outreach",title:"Market Insights Outreach",subject:"Market Update + Growth Opportunity",body:`Hi [First Name], With the recent changes in [local market conditions], I wanted to share some insights on how top-performing agents are adapting: 📊 [Market Stat 1] 📈 [Market Stat 2] 🏠 [Market Stat 3] At [Brokerage Name], we're equipping our agents with cutting-edge tools to thrive in this market: • AI-powered lead generation • Automated marketing campaigns • Real-time market analytics dashboard I'd love to share how our agents are outperforming the market. Do you have 15 minutes this week? Best, [Your Name]`}];function sct({brokerageId:t}){const{toast:s}=Ha(),[r,n]=N.useState(null),[a,o]=N.useState(null),l=(c,u)=>{navigator.clipboard.writeText(c),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(Bze.map(c=>c.category))];return e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pre-built email templates for recruiting outreach. Click to expand and copy."}),i.map(c=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(lr,{className:"h-4 w-4"})," ",c]}),Bze.filter(u=>u.category===c).map(u=>e.jsxs(Ee,{className:`cursor-pointer transition-all ${a===u.id?"ring-2 ring-primary/20":"hover:shadow-sm"}`,onClick:()=>o(a===u.id?null:u.id),children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(st,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ba,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Subject"]}),e.jsxs(K,{size:"sm",onClick:p=>{p.stopPropagation(),l(u.body,u.id+"-body")},children:[r===u.id+"-body"?e.jsx(ba,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const $ze={call:Mn,email:lr,text:so,meeting:hn,note:wn};function rct({brokerageId:t}){const{data:s,isLoading:r}=mt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await H.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(v=>v.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await H.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const c=[...new Set([...n.map(v=>v.created_by),...(l||[]).map(v=>v.created_by)])],{data:u}=await H.from("profiles").select("id, name, email").in("id",c),p=Object.fromEntries((u||[]).map(v=>[v.id,v])),f=Nie(new Date,30);return{recruiters:c.map(v=>{var S,M;const _=(l||[]).filter(L=>L.created_by===v),w=_.filter(L=>new Date(L.created_at)>=f),j={};w.forEach(L=>{j[L.activity_type]=(j[L.activity_type]||0)+1});const k=n.filter(L=>L.created_by===v).length;return{id:v,name:((S=p[v])==null?void 0:S.name)||"Unknown",email:((M=p[v])==null?void 0:M.email)||"",totalActivities:_.length,recentActivities:w.length,byType:j,prospectsCreated:k}}).sort((v,_)=>_.recentActivities-v.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:n.name})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(n.byType).map(([o,l])=>{const i=$ze[o]||wn;return e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=$ze[n.activity_type]||wn;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:ms(new Date(n.created_at),"MMM d, h:mm a")})]})]},n.id)})})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No recruiter activity yet."})}function nct({brokerageId:t}){const{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(!1),[o,l]=N.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=mt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:j,error:k}=await H.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(k)throw k;return j}}),u=[...new Set(i.map(j=>j.referred_by))],{data:p=[]}=mt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:j}=await H.from("profiles").select("id, name, email").in("id",u);return j||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(j=>[j.id,j])),g=Lt({mutationFn:async j=>{const{data:{user:k}}=await H.auth.getUser();if(!k)throw new Error("Not authenticated");const{error:S}=await H.from("recruit_referrals").insert({brokerage_id:t,referred_by:k.id,referee_first_name:j.first_name,referee_last_name:j.last_name||null,referee_email:j.email||null,referee_phone:j.phone||null,referee_current_brokerage:j.current_brokerage||null,notes:j.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),v=Lt({mutationFn:async({id:j,status:k,incentive_status:S})=>{const M={updated_at:new Date().toISOString()};k&&(M.status=k),S&&(M.incentive_status=S);const{error:L}=await H.from("recruit_referrals").update(M).eq("id",j);if(L)throw L},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),_=j=>j==="approved"||j==="signed"?e.jsx(ba,{className:"h-3 w-3"}):j==="rejected"?e.jsx(jc,{className:"h-3 w-3"}):e.jsx(un,{className:"h-3 w-3"}),w=j=>j==="approved"||j==="signed"||j==="paid"?"bg-green-500/10 text-green-600 border-green-200":j==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," referral",i.length!==1?"s":""]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(El,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(j=>{var k;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[j.referee_first_name," ",j.referee_last_name]}),e.jsxs(st,{variant:"outline",className:w(j.status),children:[_(j.status)," ",j.status]}),j.incentive_status&&e.jsxs(st,{variant:"outline",className:w(j.incentive_status),children:[e.jsx(So,{className:"h-3 w-3 mr-1"})," ",j.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[j.referee_email&&e.jsx("p",{children:j.referee_email}),j.referee_phone&&e.jsx("p",{children:j.referee_phone}),j.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",j.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((k=f[j.referred_by])==null?void 0:k.name)||"Unknown"," • ",ms(new Date(j.created_at),"MMM d, yyyy")]})]}),j.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:j.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Ks,{value:j.status,onValueChange:S=>v.mutate({id:j.id,status:S}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"pending",children:"Pending"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"approved",children:"Approved"}),e.jsx(Mt,{value:"signed",children:"Signed"}),e.jsx(Mt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(Ks,{value:j.incentive_status||"pending",onValueChange:S=>v.mutate({id:j.id,incentive_status:S}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[100px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"pending",children:"Unpaid"}),e.jsx(Mt,{value:"paid",children:"Paid"}),e.jsx(Mt,{value:"n/a",children:"N/A"})]})]})]})]})},j.id)})}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),g.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"First Name *"}),e.jsx(ze,{required:!0,value:o.first_name,onChange:j=>l(k=>({...k,first_name:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Last Name"}),e.jsx(ze,{value:o.last_name,onChange:j=>l(k=>({...k,last_name:j.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{type:"email",value:o.email,onChange:j=>l(k=>({...k,email:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:o.phone,onChange:j=>l(k=>({...k,phone:j.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Current Brokerage"}),e.jsx(ze,{value:o.current_brokerage,onChange:j=>l(k=>({...k,current_brokerage:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Notes"}),e.jsx(Pr,{value:o.notes,onChange:j=>l(k=>({...k,notes:j.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:g.isPending,children:"Submit"})]})]})]})})]})}function act({brokerageId:t}){const{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(!1),{data:o}=mt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:g,error:v}=await H.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(v)throw v;return g}}),{data:l=[]}=mt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:g,error:v}=await H.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(v)throw v;return g}}),i=Lt({mutationFn:async g=>{const{error:v}=await H.from("brokerages").update({recruit_form_enabled:g}).eq("id",t);if(v)throw v},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),c=Lt({mutationFn:async({id:g,status:v})=>{const{error:_}=await H.from("recruit_interest_submissions").update({status:v}).eq("id",g);if(_)throw _},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`https://bestbrokerage.relevelup.com/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=g=>g==="contacted"||g==="converted"?"bg-green-500/10 text-green-600":g==="dismissed"?"bg-red-500/10 text-red-600":"bg-blue-500/10 text-blue-600";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Enable Public Form"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow agents to express interest in joining via a public link"})]}),e.jsx(qr,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:g=>i.mutate(g)})]}),(o==null?void 0:o.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("code",{className:"text-xs flex-1 truncate",children:u}),e.jsx(K,{size:"sm",variant:"outline",onClick:p,children:n?e.jsx(ba,{className:"h-3.5 w-3.5"}):e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:e.jsx(en,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(El,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No submissions yet"})]}):e.jsx("div",{className:"space-y-3",children:l.map(g=>e.jsxs("div",{className:"flex items-start justify-between gap-4 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium text-sm",children:[g.first_name," ",g.last_name]}),e.jsx(st,{variant:"outline",className:f(g.status),children:g.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[g.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3"}),g.email]}),g.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),g.phone]}),g.current_brokerage&&e.jsxs("span",{children:["From: ",g.current_brokerage]}),g.experience_years&&e.jsxs("span",{children:[g.experience_years,"yr exp"]})]}),g.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',g.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ms(new Date(g.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Ks,{value:g.status,onValueChange:v=>c.mutate({id:g.id,status:v}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"new",children:"New"}),e.jsx(Mt,{value:"contacted",children:"Contacted"}),e.jsx(Mt,{value:"converted",children:"Converted"}),e.jsx(Mt,{value:"dismissed",children:"Dismissed"})]})]})]},g.id))})})]})]})}function ict({brokerageId:t}){const{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(!1),[o,l]=N.useState({prospect_id:"",title:"",description:"",due_date:ms(Il(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=N.useState("pending"),{data:u=[]}=mt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:P,error:O}=await H.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(O)throw O;return P}}),{data:p=[],isLoading:f}=mt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const P=u.map(U=>U.id);if(!P.length)return[];const{data:O,error:$}=await H.from("recruit_follow_ups").select("*").in("prospect_id",P).order("due_date");if($)throw $;return O},enabled:u.length>0}),g=Object.fromEntries(u.map(P=>[P.id,P])),v=Lt({mutationFn:async P=>{const{data:{user:O}}=await H.auth.getUser();if(!O)throw new Error("Not authenticated");const{error:$}=await H.from("recruit_follow_ups").insert({prospect_id:P.prospect_id,assigned_to:O.id,title:P.title,description:P.description||null,due_date:new Date(P.due_date).toISOString()});if($)throw $},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ms(Il(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:P=>s({title:"Error",description:P.message,variant:"destructive"})}),_=Lt({mutationFn:async({id:P,completed:O})=>{const{error:$}=await H.from("recruit_follow_ups").update({completed_at:O?new Date().toISOString():null}).eq("id",P);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=p.filter(P=>i==="pending"?!P.completed_at:i==="completed"?!!P.completed_at:!0),j=w.filter(P=>!P.completed_at&&k0(new Date(P.due_date))&&!_u(new Date(P.due_date))),k=w.filter(P=>!P.completed_at&&_u(new Date(P.due_date))),S=w.filter(P=>!P.completed_at&&!k0(new Date(P.due_date))&&!_u(new Date(P.due_date))),M=w.filter(P=>!!P.completed_at),L=P=>{const O=g[P.prospect_id],$=!P.completed_at&&k0(new Date(P.due_date))&&!_u(new Date(P.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Oo,{checked:!!P.completed_at,onCheckedChange:U=>_.mutate({id:P.id,completed:U}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${P.completed_at?"line-through text-muted-foreground":""}`,children:P.title}),P.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:P.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[O&&e.jsxs(st,{variant:"secondary",className:"text-[10px]",children:[O.first_name," ",O.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${$?"text-destructive font-medium":""}`,children:[$?e.jsx(Cl,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(P.due_date),"MMM d, h:mm a")]}),P.is_automated&&e.jsx(st,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},P.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(P=>e.jsxs(K,{size:"sm",variant:i===P?"default":"outline",onClick:()=>c(P),className:"capitalize text-xs",children:[P," ",P==="pending"&&j.length+k.length+S.length>0&&`(${j.length+k.length+S.length})`]},P))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(Cl,{className:"h-3.5 w-3.5"})," Overdue (",j.length,")"]}),j.map(L)]}),i!=="completed"&&k.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"})," Today (",k.length,")"]}),k.map(L)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(L)]}),i!=="pending"&&M.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ba,{className:"h-3.5 w-3.5"})," Completed (",M.length,")"]}),M.map(L)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:P=>{P.preventDefault(),v.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:P=>l(O=>({...O,prospect_id:P.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(P=>e.jsxs("option",{value:P.id,children:[P.first_name," ",P.last_name]},P.id))]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Task *"}),e.jsx(ze,{required:!0,value:o.title,onChange:P=>l(O=>({...O,title:P.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Details"}),e.jsx(Pr,{value:o.description,onChange:P=>l(O=>({...O,description:P.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Due Date *"}),e.jsx(ze,{type:"datetime-local",required:!0,value:o.due_date,onChange:P=>l(O=>({...O,due_date:P.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:v.isPending,children:"Schedule"})]})]})]})})]})}const lSs=[{title:"Competitive Splits",description:"Industry-leading commission structure",icon:"💰"},{title:"Tech & Tools",description:"CRM, marketing automation, and more",icon:"🛠️"},{title:"Training & Support",description:"Ongoing mentorship and education",icon:"📚"}];function oct({brokerageId:t}){const{toast:s}=Ha(),r=Xt(),[n,a]=N.useState(null),{data:o,isLoading:l}=mt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:j,error:k}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(k)throw k;return j}}),[i,c]=N.useState({brokerage_id:t,hero_headline:"Join Our Team",hero_subtext:"Take your real estate career to the next level.",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",benefits:lSs,testimonials:[],gallery_images:[]});N.useEffect(()=>{o&&c({id:o.id,brokerage_id:o.brokerage_id,hero_headline:o.hero_headline,hero_subtext:o.hero_subtext||"",hero_image_url:o.hero_image_url,logo_url:o.logo_url,primary_color:o.primary_color,accent_color:o.accent_color,benefits:o.benefits||[],testimonials:o.testimonials||[],gallery_images:o.gallery_images||[]})},[o]);const u=Lt({mutationFn:async()=>{const j={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:k}=await H.from("recruit_landing_page_settings").update(j).eq("id",i.id);if(k)throw k}else{const{error:k}=await H.from("recruit_landing_page_settings").insert(j);if(k)throw k}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),p=async(j,k)=>{const S=j.name.split(".").pop(),M=`${t}/${k}-${Date.now()}.${S}`,{error:L}=await H.storage.from("recruit-landing").upload(M,j);if(L)throw L;const{data:{publicUrl:P}}=H.storage.from("recruit-landing").getPublicUrl(M);return P},f=async(j,k)=>{var M;const S=(M=j.target.files)==null?void 0:M[0];if(S){a(k);try{const L=await p(S,k);c(P=>({...P,[k]:L})),s({title:"Image uploaded!"})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},g=async j=>{var S;const k=(S=j.target.files)==null?void 0:S[0];if(k){a("gallery");try{const M=await p(k,"gallery");c(L=>({...L,gallery_images:[...L.gallery_images,M]})),s({title:"Gallery image added!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}},v=async(j,k)=>{var M;const S=(M=j.target.files)==null?void 0:M[0];if(S){a(`testimonial-${k}`);try{const L=await p(S,`testimonial-${k}`);c(P=>{const O=[...P.testimonials];return O[k]={...O[k],photo_url:L},{...P,testimonials:O}})}catch(L){s({title:"Upload failed",description:L.message,variant:"destructive"})}finally{a(null)}}},{data:_}=mt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:j,error:k}=await H.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(k)throw k;return j}}),w=`https://bestbrokerage.relevelup.com/join-brokerage/${(_==null?void 0:_.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(_==null?void 0:_.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:w}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.logo_url&&e.jsx("img",{src:i.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:j=>c(k=>({...k,primary_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.primary_color,onChange:j=>c(k=>({...k,primary_color:j.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:j=>c(k=>({...k,accent_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.accent_color,onChange:j=>c(k=>({...k,accent_color:j.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Headline"}),e.jsx(ze,{value:i.hero_headline,onChange:j=>c(k=>({...k,hero_headline:j.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Subtext"}),e.jsx(Pr,{value:i.hero_subtext,onChange:j=>c(k=>({...k,hero_subtext:j.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.hero_image_url&&e.jsx("img",{src:i.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(j=>({...j,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,benefits:[...j.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((j,k)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Mu,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(ze,{value:j.icon,onChange:S=>{const M=[...i.benefits];M[k]={...j,icon:S.target.value},c(L=>({...L,benefits:M}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:j.title,onChange:S=>{const M=[...i.benefits];M[k]={...j,title:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Benefit title"}),e.jsx(ze,{value:j.description,onChange:S=>{const M=[...i.benefits];M[k]={...j,description:S.target.value},c(L=>({...L,benefits:M}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(S=>({...S,benefits:S.benefits.filter((M,L)=>L!==k)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,testimonials:[...j.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((j,k)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j.photo_url?e.jsx("img",{src:j.photo_url,alt:j.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=j.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${k}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:M=>v(M,k)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(ze,{value:j.name,onChange:M=>{const L=[...i.testimonials];L[k]={...j,name:M.target.value},c(P=>({...P,testimonials:L}))},placeholder:"Name"}),e.jsx(ze,{value:j.role,onChange:M=>{const L=[...i.testimonials];L[k]={...j,role:M.target.value},c(P=>({...P,testimonials:L}))},placeholder:"Role / Title"})]}),e.jsx(Pr,{value:j.quote,onChange:M=>{const L=[...i.testimonials];L[k]={...j,quote:M.target.value},c(P=>({...P,testimonials:L}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(M=>({...M,testimonials:M.testimonials.filter((L,P)=>P!==k)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},k)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{className:"text-base",children:"Team & Culture Gallery"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{size:"sm",variant:"outline",asChild:!0,disabled:n==="gallery",children:e.jsxs("span",{children:[e.jsx(vl,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:g})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((j,k)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Gallery ${k+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>c(S=>({...S,gallery_images:S.gallery_images.filter((M,L)=>L!==k)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},k))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(Uc,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function cSs(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function dSs({video:t}){return t.cta_clicked_at?e.jsx(st,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(st,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(Dn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(st,{variant:"secondary",children:[e.jsx($n,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(st,{variant:"outline",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Draft"]})}function lct({brokerageId:t}){const{data:s=[],isLoading:r}=eSs(t),{data:n=[]}=Qlt(t),a=rSs(),o=nSs(),l=Ylt(),[i,c]=N.useState(""),[u,p]=N.useState(!1),[f,g]=N.useState({title:"",script_text:"",category:"general"}),v=s.filter(S=>{var L,P,O,$;return i?`${((L=S.prospect)==null?void 0:L.first_name)||""} ${((P=S.prospect)==null?void 0:P.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(O=S.video)==null?void 0:O.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),_={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},w=N.useCallback(S=>{if(!S)return;const M=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(M),me.success("Share link copied")},[]),j=N.useCallback((S,M)=>{l.mutate({id:S,sent_via:M})},[l]),k=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{g({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:_.total,icon:Cn,color:"text-primary"},{label:"Sent",value:_.sent,icon:$n,color:"text-blue-500"},{label:"Viewed",value:_.viewed,icon:Dn,color:"text-amber-500"},{label:"CTA Clicked",value:_.ctaClicked,icon:sa,color:"text-emerald-500"}].map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(_a,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"videos",children:[e.jsx(Cn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(ns,{value:"scripts",children:[e.jsx(wn,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(ns,{value:"analytics",children:[e.jsx(yo,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(ws,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or title...",value:i,onChange:S=>c(S.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):v.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Cn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:v.map(S=>{var M,L,P,O,$,U;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(M=S.video)!=null&&M.thumbnail_url?e.jsx("img",{src:S.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Cn,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1 rounded",children:cSs(((L=S.video)==null?void 0:L.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(P=S.prospect)==null?void 0:P.first_name," ",(O=S.prospect)==null?void 0:O.last_name]}),e.jsx(dSs,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=S.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(S.created_at),"MMM d, yyyy"),((U=S.prospect)==null?void 0:U.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(yi,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.id,"email"),title:"Mark as sent",children:e.jsx($n,{className:"h-4 w-4"})}),S.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${S.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(en,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx(ws,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Rt,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(xs,{open:u,onOpenChange:p,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Category"}),e.jsxs(Ks,{value:f.category,onValueChange:S=>g(M=>({...M,category:S})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:wwe.map(S=>e.jsx(Mt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Script"}),e.jsx(Pr,{value:f.script_text,onChange:S=>g(M=>({...M,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:k,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(wn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var L;const M=((L=wwe.find(P=>P.value===S.category))==null?void 0:L.label)||S.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(st,{variant:"outline",className:"text-[10px] mb-2",children:M}),e.jsx("h4",{className:"font-medium text-sm",children:S.title})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity text-destructive",onClick:()=>o.mutate(S.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(st,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx(ws,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:_.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:_.sent,pct:_.total?Math.round(_.sent/_.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:_.viewed,pct:_.sent?Math.round(_.viewed/_.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:_.ctaClicked,pct:_.viewed?Math.round(_.ctaClicked/_.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,M)=>M.view_count-S.view_count).slice(0,5).map(S=>{var M,L;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(M=S.prospect)==null?void 0:M.first_name," ",(L=S.prospect)==null?void 0:L.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function cct({brokerageId:t}){const{toast:s}=Ha(),r=Xt(),{stages:n,prospects:a}=Ame(t),[o,l]=N.useState(!1),[i,c]=N.useState({title:"",target_count:"10",target_stage_id:"",period_start:ms(new Date,"yyyy-MM-dd"),period_end:ms(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=mt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:_,error:w}=await H.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return _}}),f=Lt({mutationFn:async _=>{const{data:{user:w}}=await H.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:j}=await H.from("recruit_goals").insert({brokerage_id:t,title:_.title,target_count:parseInt(_.target_count),target_stage_id:_.target_stage_id||null,period_start:_.period_start,period_end:_.period_end,created_by:w.id});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:_=>s({title:"Error",description:_.message,variant:"destructive"})}),g=Lt({mutationFn:async _=>{const{error:w}=await H.from("recruit_goals").delete().eq("id",_);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),v=_=>{const w=n.find(k=>k.id===_.target_stage_id);return{count:a.filter(k=>Bg(new Date(k.created_at),{start:new Date(_.period_start),end:new Date(_.period_end)})?_.target_stage_id?k.stage_id===_.target_stage_id:!0:!1).length,stage:w}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(zm,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(_=>{const{count:w,stage:j}=v(_),k=Math.min(100,w/_.target_count*100),S=Bg(new Date,{start:new Date(_.period_start),end:new Date(_.period_end)});return e.jsxs(Ee,{className:S?"":"opacity-60",children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{className:"text-sm",children:_.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ms(new Date(_.period_start),"MMM d")," – ",ms(new Date(_.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(st,{className:"text-[10px]",children:"Active"}):e.jsx(st,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>g.mutate(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j&&e.jsxs(st,{variant:"outline",className:"text-[10px]",style:{borderColor:j.color,color:j.color},children:["Stage: ",j.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",_.target_count]})]}),e.jsx(Bi,{value:k,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[k.toFixed(0),"% complete"]})]})]},_.id)})}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Goal Title *"}),e.jsx(ze,{required:!0,value:i.title,onChange:_=>c(w=>({...w,title:_.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Target Count *"}),e.jsx(ze,{type:"number",min:"1",required:!0,value:i.target_count,onChange:_=>c(w=>({...w,target_count:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:_=>c(w=>({...w,target_stage_id:_.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(_=>e.jsx("option",{value:_.id,children:_.name},_.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Start Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_start,onChange:_=>c(w=>({...w,period_start:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"End Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_end,onChange:_=>c(w=>({...w,period_end:_.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}const uSs={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function dct({email:t,mergeValues:s=uSs,selectedSubjectIndex:r,onClose:n}){var c;const a=u=>u.replace(/\{\{first_name\}\}/g,s.first_name).replace(/\{\{brokerage_name\}\}/g,s.brokerage_name).replace(/\{\{city\}\}/g,s.city).replace(/\{\{sender_name\}\}/g,s.sender_name).replace(/\{\{landing_page_link\}\}/g,"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"),o=((c=t.subject_line_options)==null?void 0:c.length)>0?t.subject_line_options:[t.subject_line],l=r??0,i=o[l]||t.subject_line;return e.jsx(xs,{open:!0,onOpenChange:()=>n(),children:e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_s,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(st,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),o.length>1&&e.jsxs(st,{variant:"secondary",className:"text-xs",children:[o.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[o.length>1&&e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/20",children:[e.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Subject Line Options"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o.map((u,p)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded ${p===l?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:p===l?"Selected":p===0?"Primary":`Alt ${p}`}),e.jsx("span",{className:"text-sm",children:a(u)})]},p))})]}),e.jsxs("div",{className:"border-b",children:[e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-14",children:"From:"}),e.jsxs("span",{children:[s.sender_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs text-muted-foreground border-t",children:[e.jsx("span",{className:"font-medium w-14",children:"To:"}),e.jsxs("span",{children:[s.first_name," "]})]}),e.jsxs("div",{className:"px-6 py-2 flex items-center gap-2 text-xs border-t",children:[e.jsx("span",{className:"font-medium w-14 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:a(i)})]})]}),e.jsx("div",{className:"bg-white px-8 py-6",children:e.jsx("div",{className:"prose prose-sm max-w-none [&_p]:my-3 [&_p+p]:mt-4 [&_br]:block [&_br]:mt-2",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:a(t.body_html)}})})]})]})})}function k3e({brokerageId:t}){const s=Xt(),[r,n]=N.useState({brokerage_id:t,sender_name:"LevelUp",sender_email:"recruiting@relevelup.com",reply_to_email:"",merge_fields:{city:"",broker_name:""}}),{data:a}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(u)throw u;return c}}),{data:o}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(u)throw u;return c}});N.useEffect(()=>{a?n({...a,merge_fields:a.merge_fields||{city:"",broker_name:""}}):o&&n(c=>({...c,merge_fields:{...c.merge_fields,brokerage_name:o.name,city:o.city||""}}))},[a,o]);const l=Lt({mutationFn:async()=>{const c={brokerage_id:t,sender_name:r.sender_name,sender_email:r.sender_email,reply_to_email:r.reply_to_email||null,merge_fields:r.merge_fields,updated_at:new Date().toISOString()};if(a!=null&&a.id){const{error:u}=await H.from("brokerage_recruit_settings").update(c).eq("id",a.id);if(u)throw u}else{const{error:u}=await H.from("brokerage_recruit_settings").insert(c);if(u)throw u}},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-recruit-settings",t]}),me.success("Recruiting email settings saved!")},onError:c=>me.error(c.message)}),i=(c,u)=>{n(p=>({...p,merge_fields:{...p.merge_fields,[c]:u}}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the sender identity and merge fields for recruiting emails sent to this brokerage's prospects."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Sender Display Name"}),e.jsx(ze,{value:r.sender_name,onChange:c=>n({...r,sender_name:c.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Sender Email Address"}),e.jsx(ze,{value:r.sender_email,onChange:c=>n({...r,sender_email:c.target.value}),placeholder:"recruiting@relevelup.com"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Must be a verified SES identity"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email (optional)"}),e.jsx(ze,{value:r.reply_to_email,onChange:c=>n({...r,reply_to_email:c.target.value}),placeholder:"jeremy@relevelup.com"})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",children:"Default Merge Fields"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"These values will auto-fill in campaign emails for this brokerage."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{brokerage_name}}"}),e.jsx(ze,{value:r.merge_fields.brokerage_name||"",onChange:c=>i("brokerage_name",c.target.value),placeholder:(o==null?void 0:o.name)||"Brokerage Name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{city}}"}),e.jsx(ze,{value:r.merge_fields.city||"",onChange:c=>i("city",c.target.value),placeholder:"e.g. Austin"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs",children:"{{sender_name}}"}),e.jsx(ze,{value:r.merge_fields.sender_name||"",onChange:c=>i("sender_name",c.target.value),placeholder:"e.g. Jeremy"})]})]})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",children:[e.jsx(Uc,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const hSs=dy.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Gc(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),qze=[{key:"first_name",label:"First Name",preview:"Sarah"},{key:"brokerage_name",label:"Brokerage Name",preview:"ABC Realty"},{key:"city",label:"City",preview:"Austin"},{key:"sender_name",label:"Sender Name",preview:"Jeremy"},{key:"landing_page_link",label:"Landing Page URL",preview:"https://bestbrokerage.relevelup.com/join-brokerage/your-slug"}];function gh({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:r,className:`h-8 w-8 p-0 ${s?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(n,{className:"h-4 w-4"})})}),e.jsx(ec,{side:"bottom",className:"text-xs",children:a})]})}function mSs({content:t,onChange:s}){const r=gke({extensions:[vke.configure({heading:{levels:[1,2,3]}}),hSs,Tke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),Ake.configure({types:["heading","paragraph"]}),Eke,Bat],content:t,editorProps:{attributes:{class:"prose prose-sm max-w-none focus:outline-none min-h-[350px] px-5 py-4",style:"font-size: 15px; line-height: 1.75; color: #1a1a1a;"}},onUpdate:({editor:o})=>{s(o.getHTML())}});N.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=N.useCallback(()=>{if(!r)return;const o=r.getAttributes("link").href,l=window.prompt("Enter URL",o);if(l!==null){if(l===""){r.chain().focus().extendMarkRange("link").unsetLink().run();return}r.chain().focus().extendMarkRange("link").setLink({href:l}).run()}},[r]),a=N.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(G1,{delayDuration:300,children:e.jsxs("div",{className:"border rounded-xl overflow-hidden bg-background shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30",children:[e.jsx(gh,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:tS,tooltip:"Bold"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:oS,tooltip:"Italic"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:WL,tooltip:"Underline"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:UL,tooltip:"Strikethrough"}),e.jsx(al,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:zM,tooltip:"Heading 1"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:BM,tooltip:"Heading 2"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:wL,tooltip:"Heading 3"}),e.jsx(al,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:rh,tooltip:"Bullet List"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:x0,tooltip:"Numbered List"}),e.jsx(gh,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:f1,tooltip:"Blockquote"}),e.jsx(gh,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:y0,tooltip:"Divider"}),e.jsx(al,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(gh,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:X4,tooltip:"Align Left"}),e.jsx(gh,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:Q4,tooltip:"Align Center"}),e.jsx(gh,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:J4,tooltip:"Align Right"}),e.jsx(al,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(gh,{onClick:n,active:r.isActive("link"),icon:Bo,tooltip:"Insert Link"}),e.jsx(al,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(gh,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:wS,tooltip:"Undo"}),e.jsx(gh,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:vS,tooltip:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",onClick:()=>{r&&r.chain().focus().insertContent('

Learn More About Us

').run()},children:"🔘 CTA Button"}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs font-medium",children:[e.jsx(XM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(Bd,{align:"end",className:"w-56",children:qze.map(o=>e.jsxs(Aa,{onClick:()=>a(o.key),className:"flex flex-col items-start gap-0.5",children:[e.jsx("span",{className:"font-medium text-sm",children:o.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${o.key}}}`})]},o.key))})]})]}),e.jsx("div",{className:"bg-white",children:e.jsx(fke,{editor:r,className:"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[350px] [&_.ProseMirror_p]:my-3 [&_.ProseMirror_ul]:my-3 [&_.ProseMirror_ol]:my-3 [&_.ProseMirror_blockquote]:my-3 [&_.ProseMirror_h1]:my-4 [&_.ProseMirror_h2]:my-3 [&_.ProseMirror_h3]:my-2"})}),e.jsx("div",{className:"border-t px-4 py-2.5 bg-muted/20",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Tags:"}),qze.map(o=>e.jsx(st,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-[10px] px-2 py-0.5",onClick:()=>a(o.key),children:`{{${o.key}}}`},o.key))]})})]})}):null}const Uze={cold:{icon:o0,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:v1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:sh,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function uct({brokerageId:t}){var $e,Me,Ie,ke;const{user:s}=Os(),r=Xt(),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(null),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState("editor"),[w,j]=N.useState(null),[k,S]=N.useState({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""}),{data:M}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:pe,error:we}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(we)throw we;return pe}}),{data:L}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:pe,error:we}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(we)throw we;return pe}}),P={first_name:"Sarah",brokerage_name:(($e=L==null?void 0:L.merge_fields)==null?void 0:$e.brokerage_name)||(M==null?void 0:M.name)||"Your Brokerage",city:((Me=L==null?void 0:L.merge_fields)==null?void 0:Me.city)||(M==null?void 0:M.city)||"Your City",sender_name:((Ie=L==null?void 0:L.merge_fields)==null?void 0:Ie.sender_name)||(L==null?void 0:L.sender_name)||"Your Name"},O=pe=>pe.replace(/\{\{first_name\}\}/g,P.first_name).replace(/\{\{brokerage_name\}\}/g,P.brokerage_name).replace(/\{\{city\}\}/g,P.city).replace(/\{\{sender_name\}\}/g,P.sender_name),{data:$=[],isLoading:U}=mt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:pe,error:we}=await H.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(we)throw we;return pe}}),{data:B={}}=mt({queryKey:["recruit-campaign-emails",t],enabled:$.length>0,queryFn:async()=>{const pe=$.map(Te=>Te.id),{data:we,error:Le}=await H.from("recruit_campaign_emails").select("*").in("campaign_id",pe).order("email_number");if(Le)throw Le;const Qe={};return we.forEach(Te=>{Qe[Te.campaign_id]||(Qe[Te.campaign_id]=[]),Qe[Te.campaign_id].push(Te)}),Qe}}),V=Object.values(B).flat().map(pe=>pe.id),{data:X=[]}=mt({queryKey:["recruit-subject-overrides",t],enabled:V.length>0,queryFn:async()=>{const{data:pe,error:we}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(we)throw we;return pe}}),Y={};X.forEach(pe=>{Y[pe.campaign_email_id]=pe.selected_subject_index});const ee=Lt({mutationFn:async({campaignEmailId:pe,selectedIndex:we})=>{const{error:Le}=await H.from("recruit_brokerage_subject_overrides").upsert({brokerage_id:t,campaign_email_id:pe,selected_subject_index:we,updated_at:new Date().toISOString()},{onConflict:"brokerage_id,campaign_email_id"});if(Le)throw Le},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-subject-overrides",t]}),me.success("Subject line updated for your brokerage")},onError:pe=>me.error(pe.message)}),Q=Lt({mutationFn:async pe=>{const{error:we}=await H.from("recruit_campaign_emails").update({title:pe.title,subject_line:pe.subject_line,subject_line_options:pe.subject_line_options,body_html:pe.body_html,body_text:pe.body_text,delay_days:pe.delay_days,updated_at:new Date().toISOString()}).eq("id",pe.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email template saved!"),l(null)},onError:pe=>me.error(pe.message)}),ce=Lt({mutationFn:async()=>{const pe=k.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:we,error:Le}=await H.from("recruit_campaigns").insert({name:k.name,slug:pe,description:k.description||null,theme:k.theme||null,goal:k.goal||null,primary_cta:k.primary_cta||"Learn more",warmth_level:k.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:k.sender_name||null,sender_email:k.sender_email||null,reply_to_email:k.reply_to_email||null,is_active:!0,sort_order:$.length+1}).select().single();if(Le)throw Le;const Qe=[{email_number:1,title:"Introduction",subject_line:"Hey {{first_name}}, quick question",delay_days:0},{email_number:2,title:"Follow Up",subject_line:"Following up, {{first_name}}",delay_days:7},{email_number:3,title:"Value Add",subject_line:"{{first_name}}, thought you'd want to see this",delay_days:14},{email_number:4,title:"Final Touch",subject_line:"Last note, {{first_name}}",delay_days:21}],{error:Te}=await H.from("recruit_campaign_emails").insert(Qe.map(pt=>({campaign_id:we.id,...pt,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",subject_line_options:[],is_active:!0})));if(Te)throw Te;return we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign created with 4 starter emails!"),g(!1),S({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""})},onError:pe=>me.error(pe.message)}),ne=Lt({mutationFn:async pe=>{const{error:we}=await H.from("recruit_campaigns").update({name:pe.name,description:pe.description,theme:pe.theme,goal:pe.goal,primary_cta:pe.primary_cta,warmth_level:pe.warmth_level,sender_name:pe.sender_name,sender_email:pe.sender_email,reply_to_email:pe.reply_to_email,updated_at:new Date().toISOString()}).eq("id",pe.id);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),me.success("Campaign settings saved!"),j(null)},onError:pe=>me.error(pe.message)}),re=Lt({mutationFn:async pe=>{var ye,qe;const{data:we}=await H.from("recruit_campaign_emails").select("email_number, delay_days").eq("campaign_id",pe).order("email_number",{ascending:!1}).limit(1),Le=((ye=we==null?void 0:we[0])==null?void 0:ye.email_number)??0,Qe=((qe=we==null?void 0:we[0])==null?void 0:qe.delay_days)??0,Te=Le+1,{error:pt}=await H.from("recruit_campaign_emails").insert({campaign_id:pe,email_number:Te,title:`Email ${Te}`,subject_line:"Hey {{first_name}}",subject_line_options:[],body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:Qe+7,is_active:!0});if(pt)throw pt},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email added to campaign!")},onError:pe=>me.error(pe.message)}),oe=Lt({mutationFn:async pe=>{const{error:we}=await H.from("recruit_campaigns").delete().eq("id",pe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Campaign deleted")},onError:pe=>me.error(pe.message)}),fe=Lt({mutationFn:async pe=>{const{error:we}=await H.from("recruit_campaign_emails").delete().eq("id",pe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Email removed from campaign")},onError:pe=>me.error(pe.message)}),ge=Lt({mutationFn:async({emailId:pe,delay_days:we})=>{const{error:Le}=await H.from("recruit_campaign_emails").update({delay_days:we,updated_at:new Date().toISOString()}).eq("id",pe);if(Le)throw Le},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),me.success("Send delay updated")},onError:pe=>me.error(pe.message)});if(U)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});const ue=$.filter(pe=>!pe.brokerage_id),xe=$.filter(pe=>pe.brokerage_id===t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Recruiting Campaigns"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System campaigns + custom campaigns · Each can have its own email settings"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-1.5",children:[e.jsx(Qo,{className:"h-4 w-4"})," Default Settings"]}),e.jsxs(K,{size:"sm",onClick:()=>g(!0),className:"gap-1.5",children:[e.jsx(qs,{className:"h-4 w-4"})," New Campaign"]})]})]}),e.jsx(Ee,{className:"border-primary/20 bg-primary/5",children:e.jsx(Oe,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(fn,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-semibold",children:"Per-Campaign Email Settings"}),e.jsxs("p",{className:"text-muted-foreground",children:["Each campaign can override the default sender name, email, and reply-to. Click the ",e.jsx(Qo,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),xe.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(NL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:xe.map(pe=>_e(pe,!0))})]}),ue.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-2",children:[e.jsx(fn,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:ue.map(pe=>_e(pe,!1))})]}),$.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(lr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No campaigns yet. Create your first campaign to start automated outreach."}),e.jsxs(K,{className:"mt-4",onClick:()=>g(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})}),i&&e.jsx(dct,{email:i,mergeValues:P,selectedSubjectIndex:Y[i.id],onClose:()=>c(null)}),e.jsx(xs,{open:!!o,onOpenChange:pe=>!pe&&l(null),children:e.jsxs(fs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(K_,{className:"h-5 w-5 text-primary"}),"Edit Email #",o==null?void 0:o.email_number]}),e.jsx(Wr,{children:o==null?void 0:o.title})]}),o&&e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(ze,{value:o.title,onChange:pe=>l({...o,title:pe.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Delay (days after previous)"}),e.jsx(ze,{type:"number",min:0,max:90,value:o.delay_days,onChange:pe=>l({...o,delay_days:parseInt(pe.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(ze,{value:o.subject_line,onChange:pe=>l({...o,subject_line:pe.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Alternative Subject Lines ",e.jsx("span",{className:"text-muted-foreground font-normal normal-case",children:"(one per line, for A/B testing)"})]}),e.jsx(Pr,{value:((ke=o.subject_line_options)==null?void 0:ke.join(` `))||"",onChange:pe=>l({...o,subject_line_options:pe.target.value.split(` `).filter(Boolean)}),rows:2,className:"text-sm resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(_a,{value:v,onValueChange:pe=>_(pe),children:e.jsxs(fa,{className:"h-7",children:[e.jsx(ns,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(ns,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),v==="editor"?e.jsx(mSs,{content:o.body_html,onChange:pe=>l({...o,body_html:pe})}):e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"bg-muted/50 px-4 py-2 border-b space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"From:"}),e.jsxs("span",{children:[P.sender_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium w-12",children:"To:"}),e.jsxs("span",{children:[P.first_name," "]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium w-12 text-muted-foreground",children:"Subject:"}),e.jsx("span",{className:"font-medium",children:O(o.subject_line)})]})]}),e.jsx("div",{className:"bg-white p-6",children:e.jsx("div",{className:"prose prose-sm max-w-none",style:{fontSize:"15px",lineHeight:"1.75",color:"#1a1a1a"},dangerouslySetInnerHTML:{__html:O(o.body_html)}})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes are saved to this campaign's templates"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:()=>Q.mutate(o),disabled:Q.isPending,className:"gap-1.5",children:[e.jsx(Uc,{className:"h-3.5 w-3.5"})," Save Changes"]})]})]})]})]})}),e.jsx(xs,{open:f,onOpenChange:g,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(qs,{className:"h-5 w-5 text-primary"})," Create Custom Campaign"]}),e.jsx(Wr,{children:"Build your own recruiting email sequence with custom sender settings."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(ze,{value:k.name,onChange:pe=>S({...k,name:pe.target.value}),placeholder:"e.g. Q2 Agent Outreach"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ks,{value:k.warmth_level,onValueChange:pe=>S({...k,warmth_level:pe}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold — Curiosity"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm — Growth"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot — Private Invite"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(ze,{value:k.primary_cta,onChange:pe=>S({...k,primary_cta:pe.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Description"}),e.jsx(Pr,{value:k.description,onChange:pe=>S({...k,description:pe.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:k.goal,onChange:pe=>S({...k,goal:pe.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(vf,{children:[e.jsx(bf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-between text-xs font-medium text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(oo,{className:"h-3.5 w-3.5"})]})}),e.jsxs(_f,{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave blank to use brokerage defaults."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:k.sender_name,onChange:pe=>S({...k,sender_name:pe.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:k.sender_email,onChange:pe=>S({...k,sender_email:pe.target.value}),placeholder:"e.g. recruiting@send.relevelup.com"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:k.reply_to_email,onChange:pe=>S({...k,reply_to_email:pe.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!k.name.trim()||ce.isPending,onClick:()=>ce.mutate(),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(xs,{open:!!w,onOpenChange:pe=>!pe&&j(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5 text-primary"})," Campaign Email Settings"]}),e.jsx(Wr,{children:"Override the default sender for this campaign. Leave blank to use brokerage defaults."})]}),w&&e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(ze,{value:w.name,onChange:pe=>j({...w,name:pe.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ks,{value:w.warmth_level,onValueChange:pe=>j({...w,warmth_level:pe}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"cold",children:"❄️ Cold"}),e.jsx(Mt,{value:"warm",children:"☀️ Warm"}),e.jsx(Mt,{value:"hot",children:"🔥 Hot"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:w.goal||"",onChange:pe=>j({...w,goal:pe.target.value})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(lr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:w.sender_name||"",onChange:pe=>j({...w,sender_name:pe.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:w.sender_email||"",onChange:pe=>j({...w,sender_email:pe.target.value}),placeholder:"Uses brokerage default"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must be a verified sending domain"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:w.reply_to_email||"",onChange:pe=>j({...w,reply_to_email:pe.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>ne.mutate(w),disabled:ne.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-1"})," Save Campaign Settings"]})]})]})}),e.jsx(xs,{open:u,onOpenChange:p,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Default Recruiting Email Settings"}),e.jsx(Wr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(k3e,{brokerageId:t})]})})]});function _e(pe,we){const Le=Uze[pe.warmth_level]||Uze.cold,Qe=Le.icon,Te=B[pe.id]||[],pt=n===pe.id,ye=!!(pe.sender_name||pe.sender_email||pe.reply_to_email);return e.jsxs(Ee,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(pt?null:pe.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`h-11 w-11 rounded-xl ${Le.bg} flex items-center justify-center`,children:e.jsx(Qe,{className:`h-5 w-5 ${Le.color}`})}),e.jsxs("div",{children:[e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[pe.name,e.jsx(st,{variant:pe.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:pe.is_active?"Active":"Draft"}),we&&e.jsx(st,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),ye&&e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(lr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(gr,{className:"text-xs mt-0.5",children:pe.theme||pe.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:qe=>{qe.stopPropagation(),j({...pe})},children:e.jsx(Qo,{className:"h-4 w-4 text-muted-foreground"})}),we&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:qe=>{qe.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&oe.mutate(pe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(lr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Te.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:pt?e.jsx(xf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(oo,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),pt&&e.jsxs(Oe,{className:"pt-0 pb-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 p-3 rounded-lg bg-muted/40 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Goal"}),e.jsx("p",{className:"mt-0.5",children:pe.goal||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Primary CTA"}),e.jsx("p",{className:"mt-0.5",children:pe.primary_cta||"—"})]})]}),ye&&e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-sm",children:[e.jsxs("p",{className:"text-xs font-semibold text-primary mb-1 flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[pe.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",pe.sender_name]}),pe.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",pe.sender_email]}),pe.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",pe.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Te.map((qe,at)=>{var tt,Ae;return e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[atrt.stopPropagation(),onBlur:rt=>{const He=parseInt(rt.target.value)||0;He!==qe.delay_days&&ge.mutate({emailId:qe.id,delay_days:He})},onKeyDown:rt=>{rt.key==="Enter"&&rt.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),qe.email_number===1?"Sent immediately":`Day ${qe.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",O(((tt=qe.subject_line_options)==null?void 0:tt.length)>0&&qe.subject_line_options[Y[qe.id]??0]||qe.subject_line)]})]}),((Ae=qe.subject_line_options)==null?void 0:Ae.length)>1&&e.jsx("div",{className:"mt-2",children:e.jsxs(Ks,{value:String(Y[qe.id]??0),onValueChange:rt=>ee.mutate({campaignEmailId:qe.id,selectedIndex:parseInt(rt)}),children:[e.jsx(Gs,{className:"h-7 text-xs w-full max-w-sm",children:e.jsx(Ys,{placeholder:"Choose subject line"})}),e.jsx(Ws,{children:qe.subject_line_options.map((rt,He)=>e.jsxs(Mt,{value:String(He),className:"text-xs",children:[e.jsxs("span",{className:"font-medium mr-1.5",children:[He===0?"Primary":`Alt ${He}`,":"]}),O(rt)]},He))})]})})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>c(qe),children:e.jsx(Dn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...qe}),_("editor")},children:e.jsx(za,{className:"h-4 w-4"})}),we&&Te.length>1&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{confirm("Delete this email from the sequence?")&&fe.mutate(qe.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})})]},qe.id)})}),we&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>re.mutate(pe.id),disabled:re.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},pe.id)}}const Vze={active:{icon:il,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:Rm,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:gi,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:jc,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},Hze={sent:{icon:lr,color:"text-blue-500"},opened:{icon:Dn,color:"text-amber-500"},clicked:{icon:Tx,color:"text-green-500"},failed:{icon:Yu,color:"text-destructive"}};function hct({brokerageId:t}){var xe,_e,$e,Me,Ie;const{user:s}=Os(),r=Xt(),[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(new Set),[u,p]=N.useState("assignments"),[f,g]=N.useState(null),[v,_]=N.useState(""),{data:w={}}=mt({queryKey:["recruit-campaign-emails-for-preview",t],queryFn:async()=>{const{data:ke,error:pe}=await H.from("recruit_campaign_emails").select("*").order("email_number");if(pe)throw pe;const we={};return(ke??[]).forEach(Le=>{we[Le.campaign_id]||(we[Le.campaign_id]=[]),we[Le.campaign_id].push(Le)}),we}}),{data:j}=mt({queryKey:["brokerage-detail",t],queryFn:async()=>{const{data:ke,error:pe}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(pe)throw pe;return ke}}),{data:k}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:ke,error:pe}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(pe)throw pe;return ke}}),{data:S=[]}=mt({queryKey:["recruit-subject-overrides",t],queryFn:async()=>{const{data:ke,error:pe}=await H.from("recruit_brokerage_subject_overrides").select("*").eq("brokerage_id",t);if(pe)throw pe;return ke}}),M={};S.forEach(ke=>{M[ke.campaign_email_id]=ke.selected_subject_index});const L={first_name:((xe=f==null?void 0:f.prospect)==null?void 0:xe.first_name)||"Sarah",brokerage_name:((_e=k==null?void 0:k.merge_fields)==null?void 0:_e.brokerage_name)||(j==null?void 0:j.name)||"Your Brokerage",city:(($e=k==null?void 0:k.merge_fields)==null?void 0:$e.city)||(j==null?void 0:j.city)||"Your City",sender_name:((Me=k==null?void 0:k.merge_fields)==null?void 0:Me.sender_name)||(k==null?void 0:k.sender_name)||"Your Name"},P=ke=>{const pe=w[ke.campaign_id]||[],we=ke.current_email_number+1;return pe.find(Le=>Le.email_number===we)||null},{data:O=[],isLoading:$}=mt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{let pe=[],we=0;for(;;){const{data:Le,error:Qe}=await H.from("recruit_campaign_assignments").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign:recruit_campaigns(name, warmth_level) `).eq("brokerage_id",t).order("created_at",{ascending:!1}).range(we,we+1e3-1);if(Qe)throw Qe;if(pe=pe.concat(Le??[]),!Le||Le.length<1e3)break;we+=1e3}return pe}}),{data:U=[]}=mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:ke,error:pe}=await H.from("recruit_campaign_sends").select(` *, prospect:recruit_prospects(first_name, last_name, email), campaign_email:recruit_campaign_emails(title) `).eq("brokerage_id",t).order("sent_at",{ascending:!1}).limit(100);if(pe)throw pe;return ke}}),{data:B=[]}=mt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:ke,error:pe}=await H.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(pe)throw pe;return ke}}),{data:V=[]}=mt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{let pe=[],we=0;for(;;){const{data:Le,error:Qe}=await H.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name").range(we,we+1e3-1);if(Qe)throw Qe;if(pe=pe.concat(Le??[]),!Le||Le.length<1e3)break;we+=1e3}return pe}}),X=new Set(O.map(ke=>`${ke.prospect_id}-${ke.campaign_id}`)),Y=Lt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const ke=new Date,pe=Array.from(i).filter(Le=>!X.has(`${Le}-${o}`)).map(Le=>({prospect_id:Le,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:ke.toISOString(),started_at:ke.toISOString()}));if(pe.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:we}=await H.from("recruit_campaign_assignments").insert(pe);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),c(new Set)},onError:ke=>me.error(ke.message)}),ee=Lt({mutationFn:async({id:ke,newStatus:pe})=>{const{error:we}=await H.from("recruit_campaign_assignments").update({status:pe,updated_at:new Date().toISOString()}).eq("id",ke);if(we)throw we},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),me.success("Assignment updated")}}),Q=Lt({mutationFn:async()=>{const{data:ke,error:pe}=await H.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(pe)throw pe;return ke},onSuccess:ke=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),me.success(`Wave sent! ${ke.sent} emails delivered, ${ke.skipped} skipped, ${ke.failed} failed`)},onError:ke=>me.error(`Send failed: ${ke.message}`)}),ce=O.filter(ke=>ke.status==="active").length;O.filter(ke=>ke.status==="completed").length;const ne=O.filter(ke=>ke.status==="active"&&ke.next_send_at&&new Date(ke.next_send_at)<=new Date).length,re=U.length,oe=U.filter(ke=>ke.opened_at).length,fe=U.filter(ke=>ke.clicked_at).length,ge=re>0?Math.round(oe/re*100):0,ue=re>0?Math.round(fe/re*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold",children:"Campaign Assignments"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assign recruiting campaigns to prospects — emails auto-send weekly via SES"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ne>0&&e.jsxs(K,{variant:"outline",onClick:()=>Q.mutate(),disabled:Q.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Yh,{className:"h-4 w-4 mr-1"}),Q.isPending?"Sending...":`Send Next Wave (${ne})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx($n,{className:"h-4 w-4 mr-1"})," Assign Campaign"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(hr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:O.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(il,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:ce}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(lr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:re}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Dn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[ge,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Rate"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Tx,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[ue,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click Rate"})]})]})})]}),e.jsxs(_a,{value:u,onValueChange:p,children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"assignments",children:["Active Drips (",ce,")"]}),e.jsxs(ns,{value:"history",children:["Send History (",re,")"]})]}),e.jsx(ws,{value:"assignments",className:"mt-4",children:$?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):O.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx($n,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No campaigns assigned yet"}),e.jsx("p",{className:"text-sm",children:"Assign a recruiting campaign to your prospects to start automated outreach"})]})}):e.jsx("div",{className:"space-y-2",children:O.map(ke=>{var pt,ye,qe,at;const pe=Vze[ke.status]||Vze.active,we=pe.icon,Qe=(w[ke.campaign_id]||[]).length||4,Te=P(ke);return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(st,{className:`text-xs ${pe.color} border-0`,children:[e.jsx(we,{className:"h-3 w-3 mr-1"}),pe.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(pt=ke.prospect)==null?void 0:pt.first_name," ",(ye=ke.prospect)==null?void 0:ye.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(qe=ke.prospect)==null?void 0:qe.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(at=ke.campaign)==null?void 0:at.name," · Email ",ke.current_email_number,"/",Qe,ke.next_send_at&&ke.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(un,{className:"h-3 w-3 inline"})," Next: ",ms(new Date(ke.next_send_at),"MMM d, h:mm a"),new Date(ke.next_send_at)<=new Date&&e.jsx(st,{variant:"outline",className:"ml-1 text-[10px] px-1 py-0 border-amber-500 text-amber-600",children:"DUE"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[Te&&e.jsx(K,{variant:"ghost",size:"sm",title:"Preview next email",onClick:()=>g(ke),children:e.jsx(Dn,{className:"h-3.5 w-3.5"})}),ke.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ee.mutate({id:ke.id,newStatus:"paused"}),children:e.jsx(Rm,{className:"h-3.5 w-3.5"})}),ke.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ee.mutate({id:ke.id,newStatus:"active"}),children:e.jsx(il,{className:"h-3.5 w-3.5"})}),(ke.status==="active"||ke.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>ee.mutate({id:ke.id,newStatus:"cancelled"}),children:e.jsx(jc,{className:"h-3.5 w-3.5"})})]})]},ke.id)})})}),e.jsx(ws,{value:"history",className:"mt-4",children:U.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(lr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No emails sent yet"}),e.jsx("p",{className:"text-sm",children:"Emails will appear here once campaigns start sending"})]})}):e.jsx("div",{className:"space-y-1",children:U.map(ke=>{var Le,Qe;const pe=Hze[ke.status]||Hze.sent,we=pe.icon;return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(we,{className:`h-4 w-4 flex-shrink-0 ${pe.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(Le=ke.prospect)==null?void 0:Le.first_name," ",(Qe=ke.prospect)==null?void 0:Qe.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",ke.email_number]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:ke.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[ke.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",ms(new Date(ke.opened_at),"MMM d")]}),ke.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Tx,{className:"h-3 w-3"})," ",ms(new Date(ke.clicked_at),"MMM d")]}),ke.status==="failed"&&e.jsx("span",{className:"text-destructive text-xs",children:"Failed"}),e.jsx("span",{children:ms(new Date(ke.sent_at),"MMM d, h:mm a")})]})]},ke.id)})})})]}),e.jsx(xs,{open:n,onOpenChange:ke=>{a(ke),ke||(_(""),c(new Set),l(""))},children:e.jsxs(fs,{className:"max-w-lg max-h-[85vh] flex flex-col p-0",children:[e.jsxs(js,{className:"px-6 pt-6 pb-4",children:[e.jsx(_s,{children:"Assign Campaign to Prospects"}),e.jsx(Wr,{children:"Select a campaign and choose which prospects to enroll. The first email will be sent automatically."})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 space-y-4 pb-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"1. Select Campaign"}),e.jsxs(Ks,{value:o,onValueChange:l,children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Choose a campaign..."})}),e.jsx(Ws,{children:B.map(ke=>e.jsx(Mt,{value:ke.id,children:ke.name},ke.id))})]})]}),o&&(()=>{const ke=v.toLowerCase(),pe=V.filter(Qe=>`${Qe.first_name} ${Qe.last_name}`.toLowerCase().includes(ke)||Qe.email.toLowerCase().includes(ke)),we=pe.filter(Qe=>!X.has(`${Qe.id}-${o}`)),Le=we.length>0&&we.every(Qe=>i.has(Qe.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-sm font-medium",children:"2. Select Prospects"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.size," selected"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:v,onChange:Qe=>_(Qe.target.value),className:"pl-9 h-9"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-9 whitespace-nowrap",onClick:()=>{if(Le){const Qe=new Set(i);we.forEach(Te=>Qe.delete(Te.id)),c(Qe)}else{const Qe=new Set(i);we.forEach(Te=>Qe.add(Te.id)),c(Qe)}},children:[e.jsx(mL,{className:"h-3.5 w-3.5 mr-1"}),Le?"Deselect All":`Select All (${we.length})`]})]}),e.jsx("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:pe.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:v?"No prospects match your search":"No prospects found for this brokerage"}):pe.map(Qe=>{const Te=X.has(`${Qe.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 hover:bg-muted/50 cursor-pointer ${Te?"opacity-40":""}`,children:[e.jsx(Oo,{checked:i.has(Qe.id),disabled:Te,onCheckedChange:pt=>{const ye=new Set(i);pt?ye.add(Qe.id):ye.delete(Qe.id),c(ye)}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Qe.first_name," ",Qe.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Qe.email})]}),Te&&e.jsx(st,{variant:"outline",className:"text-[10px] shrink-0",children:"Already assigned"})]},Qe.id)})}),pe.length>0&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Showing ",pe.length," of ",V.length," prospects",we.length0&&e.jsx(Ee,{className:"bg-primary/5 border-primary/20",children:e.jsxs(Oe,{className:"pt-3 pb-2 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-primary",children:["✅ Ready to assign ",i.size," prospect",i.size>1?"s":""]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["• Campaign: ",e.jsx("strong",{children:(Ie=B.find(ke=>ke.id===o))==null?void 0:Ie.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• First email sends immediately · follow-ups every 7 days"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"• You can pause or cancel any assignment at any time"})]})})]}),e.jsxs(Un,{className:"px-6 py-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>Y.mutate(),disabled:Y.isPending||!o||i.size===0,children:[e.jsx($n,{className:"h-4 w-4 mr-1"}),Y.isPending?"Assigning...":`Assign & Start (${i.size})`]})]})]})}),f&&(()=>{const ke=P(f);return ke?e.jsx(dct,{email:ke,mergeValues:L,selectedSubjectIndex:M[ke.id],onClose:()=>g(null)}):null})()]})}function mct({brokerageId:t}){const s=Xt(),[r,n]=N.useState([]),[a,o]=N.useState([]),[l,i]=N.useState(!1),c=N.useRef(!1),{data:u,isLoading:p}=mt({queryKey:["recruit-stages-editor",t],queryFn:async()=>{const{data:j,error:k}=await H.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(k)throw k;return j},enabled:!!t});N.useEffect(()=>{if(u){if(c.current){c.current=!1;return}n(u.map(j=>({id:j.id,name:j.name,color:j.color,sort_order:j.sort_order}))),o([]),i(!1)}},[u]);const f=Lt({mutationFn:async()=>{for(const S of a){const{error:M}=await H.from("recruit_pipeline_stages").delete().eq("id",S);if(M)throw M}const j=r.filter(S=>S.id&&!S.isNew),k=r.filter(S=>!S.id||S.isNew);for(const S of j){const{error:M}=await H.from("recruit_pipeline_stages").update({name:S.name,color:S.color,sort_order:S.sort_order}).eq("id",S.id);if(M)throw M}if(k.length>0){const{error:S}=await H.from("recruit_pipeline_stages").insert(k.map(M=>({brokerage_id:t,name:M.name,color:M.color,sort_order:M.sort_order})));if(S)throw S}},onSuccess:()=>{o([]),s.invalidateQueries({queryKey:["recruit-stages-editor",t]}),s.invalidateQueries({queryKey:["recruit-stages",t]}),me.success("Pipeline stages saved!"),i(!1)},onError:j=>me.error(j.message)}),g=(j,k,S)=>{n(M=>M.map((L,P)=>P===j?{...L,[k]:S}:L)),i(!0)},v=()=>{const j=r.length>0?Math.max(...r.map(k=>k.sort_order)):0;n(k=>[...k,{name:"",color:"#6366f1",sort_order:j+1,isNew:!0}]),i(!0)},_=j=>{const k=r[j];k.id&&!k.isNew&&o(S=>[...S,k.id]),n(S=>S.filter((M,L)=>L!==j)),i(!0)},w=(j,k)=>{const S=j+k;if(S<0||S>=r.length)return;const M=[...r];[M[j],M[S]]=[M[S],M[j]],M.forEach((L,P)=>L.sort_order=P+1),n(M),i(!0)};return p?e.jsx("div",{className:"text-sm text-muted-foreground py-8 text-center",children:"Loading stages…"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Customize the recruiting pipeline stages for this brokerage. Changes will apply to the Kanban board and all prospect tracking."})]}),e.jsx("div",{className:"space-y-2",children:r.map((j,k)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>w(k,-1),disabled:k===0,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▲"}),e.jsx("button",{type:"button",onClick:()=>w(k,1),disabled:k===r.length-1,className:"text-muted-foreground hover:text-foreground disabled:opacity-30 text-xs",children:"▼"})]}),e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground/50 shrink-0"}),e.jsx("input",{type:"color",value:j.color,onChange:S=>g(k,"color",S.target.value),className:"h-8 w-8 rounded cursor-pointer border-0 p-0 shrink-0"}),e.jsx(ze,{value:j.name,onChange:S=>g(k,"name",S.target.value),placeholder:"Stage name…",className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground w-6 text-center shrink-0",children:k+1}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(k),className:"text-destructive hover:text-destructive shrink-0 h-8 w-8",children:e.jsx(Nr,{className:"h-4 w-4"})})]},j.id||`new-${k}`))}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:v,className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Stage"]}),l&&e.jsxs(K,{size:"sm",onClick:()=>f.mutate(),disabled:f.isPending,className:"gap-1",children:[e.jsx(Uc,{className:"h-4 w-4"})," Save Changes"]})]}),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No stages configured. Add stages to build your recruiting pipeline."})]})}function pSs(){var i;const[t,s]=N.useState(""),[r,n]=N.useState("board"),{data:a=[],isLoading:o}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:c,error:u}=await H.from("brokerages").select("id, name").order("name");if(u)throw u;return c}}),l=t||((i=a[0])==null?void 0:i.id)||"";return o?e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[a.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Ks,{value:l,onValueChange:s,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:a.map(c=>e.jsx(Mt,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(_a,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx($n,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Qo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(y1,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(ws,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:r==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:r==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>n("table"),children:[e.jsx(YM,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(ect,{brokerageId:l}):e.jsx(mde,{brokerageId:l})]}),e.jsx(ws,{value:"contacts",children:e.jsx(mde,{brokerageId:l})}),e.jsx(ws,{value:"video-outreach",children:e.jsx(lct,{brokerageId:l})}),e.jsx(ws,{value:"follow-ups",children:e.jsx(ict,{brokerageId:l})}),e.jsx(ws,{value:"referrals",children:e.jsx(nct,{brokerageId:l})}),e.jsx(ws,{value:"interest",children:e.jsx(act,{brokerageId:l})}),e.jsx(ws,{value:"landing-page",children:e.jsx(oct,{brokerageId:l})}),e.jsx(ws,{value:"goals",children:e.jsx(cct,{brokerageId:l})}),e.jsx(ws,{value:"metrics",children:e.jsx(tct,{brokerageId:l})}),e.jsx(ws,{value:"templates",children:e.jsx(sct,{brokerageId:l})}),e.jsx(ws,{value:"campaigns",children:e.jsx(uct,{brokerageId:l})}),e.jsx(ws,{value:"drip-assignments",children:e.jsx(hct,{brokerageId:l})}),e.jsx(ws,{value:"activity",children:e.jsx(rct,{brokerageId:l})}),e.jsx(ws,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(k3e,{brokerageId:l})]})}),e.jsx(ws,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(mct,{brokerageId:l})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ca,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function fSs(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Os(),[n,a]=N.useState("board"),o=s||((l=t[0])==null?void 0:l.id)||"";return t.length===0?e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ca,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages assigned to you. Contact an admin for access."})]})}):e.jsx(Ts,{title:"Recruiting",description:"Agent Recruiting Pipeline",children:e.jsxs("div",{className:"space-y-6",children:[t.length>1&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage:"}),e.jsxs(Ks,{value:o,onValueChange:r,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),e.jsx(Ys,{placeholder:"Select brokerage"})]}),e.jsx(Ws,{children:t.map(i=>e.jsx(Mt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(_a,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap h-auto gap-1",children:[e.jsx(ns,{value:"pipeline",children:"Pipeline"}),e.jsxs(ns,{value:"contacts",children:[e.jsx(hr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(ns,{value:"video-outreach",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(ns,{value:"follow-ups",children:"Follow-ups"}),e.jsx(ns,{value:"referrals",children:"Referrals"}),e.jsx(ns,{value:"interest",children:"Interest Form"}),e.jsx(ns,{value:"landing-page",children:"Landing Page"}),e.jsx(ns,{value:"goals",children:"Goals"}),e.jsx(ns,{value:"metrics",children:"Metrics"}),e.jsx(ns,{value:"templates",children:"Email Templates"}),e.jsxs(ns,{value:"campaigns",children:[e.jsx(lr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(ns,{value:"drip-assignments",children:[e.jsx($n,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(ns,{value:"activity",children:"Recruiter Activity"}),e.jsxs(ns,{value:"email-settings",children:[e.jsx(Qo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]}),e.jsxs(ns,{value:"pipeline-stages",children:[e.jsx(y1,{className:"h-3.5 w-3.5 mr-1"}),"Pipeline Stages"]})]}),e.jsxs(ws,{value:"pipeline",children:[e.jsx("div",{className:"flex justify-end mb-3",children:e.jsxs("div",{className:"flex items-center rounded-md border bg-muted p-0.5",children:[e.jsxs(K,{variant:n==="board"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("board"),children:[e.jsx(Cp,{className:"h-3.5 w-3.5"})," Board"]}),e.jsxs(K,{variant:n==="table"?"default":"ghost",size:"sm",className:"h-7 px-2.5 gap-1.5",onClick:()=>a("table"),children:[e.jsx(YM,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(ect,{brokerageId:o}):e.jsx(mde,{brokerageId:o})]}),e.jsx(ws,{value:"contacts",children:e.jsx(mde,{brokerageId:o})}),e.jsx(ws,{value:"video-outreach",children:e.jsx(lct,{brokerageId:o})}),e.jsx(ws,{value:"follow-ups",children:e.jsx(ict,{brokerageId:o})}),e.jsx(ws,{value:"referrals",children:e.jsx(nct,{brokerageId:o})}),e.jsx(ws,{value:"interest",children:e.jsx(act,{brokerageId:o})}),e.jsx(ws,{value:"landing-page",children:e.jsx(oct,{brokerageId:o})}),e.jsx(ws,{value:"goals",children:e.jsx(cct,{brokerageId:o})}),e.jsx(ws,{value:"metrics",children:e.jsx(tct,{brokerageId:o})}),e.jsx(ws,{value:"templates",children:e.jsx(sct,{brokerageId:o})}),e.jsx(ws,{value:"campaigns",children:e.jsx(uct,{brokerageId:o})}),e.jsx(ws,{value:"drip-assignments",children:e.jsx(hct,{brokerageId:o})}),e.jsx(ws,{value:"activity",children:e.jsx(rct,{brokerageId:o})}),e.jsx(ws,{value:"email-settings",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"Email Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Configure sender identity, merge fields, and brokerage location for recruiting emails."}),e.jsx(k3e,{brokerageId:o})]})}),e.jsx(ws,{value:"pipeline-stages",children:e.jsx("div",{className:"max-w-2xl",children:e.jsx(mct,{brokerageId:o})})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Ca,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function xSs(){const[t,s]=N.useState(""),{data:r,isLoading:n}=mt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await H.from("brokerages").select("id, name");if(!i)return[];const{data:c}=await H.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await H.from("brokerage_content_categories").select("id, brokerage_id"),p=c||[],f=u||[],g=i.map(v=>{const _=p.filter(k=>k.brokerage_id===v.id),w=f.filter(k=>k.brokerage_id===v.id),j=_.length>0?_.reduce((k,S)=>S.created_at>k?S.created_at:k,_[0].created_at):null;return{brokerage_id:v.id,brokerage_name:v.name,total_items:_.length,videos:_.filter(k=>k.content_type==="video").length,pdfs:_.filter(k=>k.content_type==="pdf").length,links:_.filter(k=>k.content_type==="link"||k.content_type==="canva_link").length,events:_.filter(k=>k.content_type==="event").length,graphics:_.filter(k=>k.content_type==="graphic").length,latest_item_date:j,categories:w.length}});return g.sort((v,_)=>_.total_items-v.total_items),g}}),a=(r||[]).filter(i=>i.brokerage_name.toLowerCase().includes(t.toLowerCase())),o=a.reduce((i,c)=>i+c.total_items,0),l=a.filter(i=>i.total_items>0).length;return e.jsx(Ts,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ch,{title:"Brokerage Content Activity",description:"See which brokerages are creating custom content for their agents"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsx(Rt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Brokerage"}),e.jsx(St,{className:"text-center",children:"Total"}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Cn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(wn,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(ml,{className:"h-3 w-3"})," Links"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Od,{className:"h-3 w-3"})," Events"]})}),e.jsx(St,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(vl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(St,{className:"text-center",children:"Categories"}),e.jsx(St,{children:"Last Upload"})]})}),e.jsx(Bn,{children:n?e.jsx(Cs,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Cs,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Cs,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium",children:i.brokerage_name})]})}),e.jsx(dt,{className:"text-center",children:i.total_items>0?e.jsx(st,{variant:"secondary",className:"font-bold",children:i.total_items}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:i.videos||"–"}),e.jsx(dt,{className:"text-center",children:i.pdfs||"–"}),e.jsx(dt,{className:"text-center",children:i.links||"–"}),e.jsx(dt,{className:"text-center",children:i.events||"–"}),e.jsx(dt,{className:"text-center",children:i.graphics||"–"}),e.jsx(dt,{className:"text-center",children:i.categories||"–"}),e.jsx(dt,{children:i.latest_item_date?e.jsx("span",{className:"text-sm text-muted-foreground",children:ms(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function gSs(t,s){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),s&&(n.href=s),a.href=t,a.href}const ySs=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function dw(t){const s=[];for(let r=0,n=t.length;rQp||t.height>Qp)&&(t.width>Qp&&t.height>Qp?t.width>t.height?(t.height*=Qp/t.width,t.width=Qp):(t.width*=Qp/t.height,t.height=Qp):t.width>Qp?(t.height*=Qp/t.width,t.width=Qp):(t.width*=Qp/t.height,t.height=Qp))}function fde(t){return new Promise((s,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>s(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function jSs(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function NSs(t,s,r){const n="http://www.w3.org/2000/svg",a=document.createElementNS(n,"svg"),o=document.createElementNS(n,"foreignObject");return a.setAttribute("width",`${s}`),a.setAttribute("height",`${r}`),a.setAttribute("viewBox",`0 0 ${s} ${r}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),a.appendChild(o),o.appendChild(t),jSs(a)}const Ap=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||Ap(r,s)};function kSs(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function SSs(t,s){return pct(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function CSs(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?kSs(r):SSs(r,n);return document.createTextNode(`${a}{${o}}`)}function Gze(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=ySs();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(CSs(l,r,a,n)),s.appendChild(i)}function MSs(t,s,r){Gze(t,s,":before",r),Gze(t,s,":after",r)}const Wze="application/font-woff",Kze="image/jpeg",TSs={woff:Wze,woff2:Wze,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Kze,jpeg:Kze,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function ASs(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function S3e(t){const s=ASs(t).toLowerCase();return TSs[s]||""}function ESs(t){return t.split(/,/)[1]}function jwe(t){return t.search(/^(data:)/)!==-1}function PSs(t,s){return`data:${s};base64,${t}`}async function xct(t,s,r){const n=await fetch(t,s);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((o,l)=>{const i=new FileReader;i.onerror=l,i.onloadend=()=>{try{o(r({res:n,result:i.result}))}catch(c){l(c)}},i.readAsDataURL(a)})}const qye={};function ISs(t,s,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),s?`[${s}]${n}`:n}async function C3e(t,s,r){const n=ISs(t,s,r.includeQueryParams);if(qye[n]!=null)return qye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await xct(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),ESs(i)));a=PSs(o,s)}catch(o){a=r.imagePlaceholder||"";let l=`Failed to fetch resource: ${t}`;o&&(l=typeof o=="string"?o:o.message),l&&console.warn(l)}return qye[n]=a,a}async function LSs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):fde(s)}async function DSs(t,s){if(t.currentSrc){const o=document.createElement("canvas"),l=o.getContext("2d");o.width=t.clientWidth,o.height=t.clientHeight,l==null||l.drawImage(t,0,0,o.width,o.height);const i=o.toDataURL();return fde(i)}const r=t.poster,n=S3e(r),a=await C3e(r,n,s);return fde(a)}async function OSs(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await Eme(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function RSs(t,s){return Ap(t,HTMLCanvasElement)?LSs(t):Ap(t,HTMLVideoElement)?DSs(t,s):Ap(t,HTMLIFrameElement)?OSs(t,s):t.cloneNode(gct(t))}const FSs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",gct=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function zSs(t,s,r){var n,a;if(gct(s))return s;let o=[];return FSs(t)&&t.assignedNodes?o=dw(t.assignedNodes()):Ap(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=dw(t.contentDocument.body.childNodes):o=dw(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Ap(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>Eme(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function BSs(t,s,r){const n=s.style;if(!n)return;const a=window.getComputedStyle(t);a.cssText?(n.cssText=a.cssText,n.transformOrigin=a.transformOrigin):pct(r).forEach(o=>{let l=a.getPropertyValue(o);o==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),Ap(t,HTMLIFrameElement)&&o==="display"&&l==="inline"&&(l="block"),o==="d"&&s.getAttribute("d")&&(l=`path(${s.getAttribute("d")})`),n.setProperty(o,l,a.getPropertyPriority(o))})}function $Ss(t,s){Ap(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Ap(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function qSs(t,s){if(Ap(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function USs(t,s,r){return Ap(s,Element)&&(BSs(t,s,r),MSs(t,s,r),$Ss(t,s),qSs(t,s)),s}async function VSs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oRSs(n,s)).then(n=>zSs(t,n,s)).then(n=>USs(t,n,s)).then(n=>VSs(n,s))}const yct=/url\((['"]?)([^'"]+?)\1\)/g,HSs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,GSs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function WSs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function KSs(t){const s=[];return t.replace(yct,(r,n,a)=>(s.push(a),r)),s.filter(r=>!jwe(r))}async function ZSs(t,s,r,n,a){try{const o=r?gSs(s,r):s,l=S3e(s);let i;return a||(i=await C3e(o,l,n)),t.replace(WSs(s),`$1${i}$3`)}catch{}return t}function YSs(t,{preferredFontFormat:s}){return s?t.replace(GSs,r=>{for(;;){const[n,,a]=HSs.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function vct(t){return t.search(yct)!==-1}async function bct(t,s,r){if(!vct(t))return t;const n=YSs(t,r);return KSs(n).reduce((o,l)=>o.then(i=>ZSs(i,l,s,r)),Promise.resolve(n))}async function V5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await bct(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function QSs(t,s){await V5("background",t,s)||await V5("background-image",t,s),await V5("mask",t,s)||await V5("-webkit-mask",t,s)||await V5("mask-image",t,s)||await V5("-webkit-mask-image",t,s)}async function XSs(t,s){const r=Ap(t,HTMLImageElement);if(!(r&&!jwe(t.src))&&!(Ap(t,SVGImageElement)&&!jwe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await C3e(n,S3e(n),s);await new Promise((o,l)=>{t.onload=o,t.onerror=s.onImageErrorHandler?(...c)=>{try{o(s.onImageErrorHandler(...c))}catch(u){l(u)}}:l;const i=t;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),r?(t.srcset="",t.src=a):t.href.baseVal=a})}async function JSs(t,s){const n=dw(t.childNodes).map(a=>_ct(a,s));await Promise.all(n).then(()=>t)}async function _ct(t,s){Ap(t,Element)&&(await QSs(t,s),await XSs(t,s),await JSs(t,s))}function e3s(t,s){const{style:r}=t;s.backgroundColor&&(r.backgroundColor=s.backgroundColor),s.width&&(r.width=`${s.width}px`),s.height&&(r.height=`${s.height}px`);const n=s.style;return n!=null&&Object.keys(n).forEach(a=>{r[a]=n[a]}),t}const Zze={};async function Yze(t){let s=Zze[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},Zze[t]=s,s}async function Qze(t,s){let r=t.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,o=(r.match(/url\([^)]+\)/g)||[]).map(async l=>{let i=l.replace(n,"$1");return i.startsWith("https://")||(i=new URL(i,t.url).href),xct(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function Xze(t){if(t==null)return[];const s=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=a.exec(n);if(c===null)break;s.push(c[0])}n=n.replace(a,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(l,"gi");for(;;){let c=o.exec(n);if(c===null){if(c=i.exec(n),c===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;s.push(c[0])}return s}async function t3s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{dw(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=Yze(c).then(p=>Qze(p,s)).then(p=>Xze(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:f,error:g})}})).catch(p=>{console.error("Error loading remote css",p.toString())});n.push(u)}})}catch(o){const l=t.find(i=>i.href==null)||document.styleSheets[0];a.href!=null&&n.push(Yze(a.href).then(i=>Qze(i,s)).then(i=>Xze(i).forEach(c=>{l.insertRule(c,l.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(n).then(()=>(t.forEach(a=>{if("cssRules"in a)try{dw(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function s3s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>vct(s.style.getPropertyValue("src")))}async function r3s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=dw(t.ownerDocument.styleSheets),n=await t3s(r,s);return s3s(n)}function wct(t){return t.trim().replace(/["']/g,"")}function n3s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(wct(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function a3s(t,s){const r=await r3s(t,s),n=n3s(t);return(await Promise.all(r.filter(o=>n.has(wct(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return bct(o.cssText,l,s)}))).join(` `)}async function i3s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await a3s(t,s);if(r){const n=document.createElement("style"),a=document.createTextNode(r);n.appendChild(a),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function o3s(t,s={}){const{width:r,height:n}=fct(t,s),a=await Eme(t,s,!0);return await i3s(a,s),await _ct(a,s),e3s(a,s),await NSs(a,r,n)}async function l3s(t,s={}){const{width:r,height:n}=fct(t,s),a=await o3s(t,s),o=await fde(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||_Ss(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*c,l.height=p*c,s.skipAutoScale||wSs(l),l.style.width=`${u}`,l.style.height=`${p}`,s.backgroundColor&&(i.fillStyle=s.backgroundColor,i.fillRect(0,0,l.width,l.height)),i.drawImage(o,0,0,l.width,l.height),l}async function c3s(t,s={}){return(await l3s(t,s)).toDataURL()}const qA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Pme={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},x9={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},d3s=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.03,borderTop:"2px solid rgba(201,168,76,0.4)",paddingTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(201,168,76,0.7)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.038,fontWeight:700,letterSpacing:"0.03em"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.026,opacity:.8,marginTop:s.w*.005},children:t.brokerage})]})]}),jct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=Pme[s],p=[t.bedrooms?`${t.bedrooms} Bed`:null,t.bathrooms?`${t.bathrooms} Bath`:null,t.sqft?`${t.sqft.toLocaleString()} Sq Ft`:null].filter(Boolean).join(" • ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(10,10,30,0.3) 0%, rgba(10,10,30,0.85) 100%)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",padding:l.w*.06},children:[e.jsx("div",{children:e.jsx("div",{style:{display:"inline-block",background:"linear-gradient(135deg, #C9A84C, #E8D48B)",color:"#1A1A2E",padding:`${l.w*.012}px ${l.w*.035}px`,fontSize:l.w*.032,fontWeight:700,letterSpacing:"0.25em",textTransform:"uppercase"},children:u})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:l.w*.07,fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,textShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:qA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",qA(t.soldPrice)]}),e.jsx("div",{style:{fontSize:l.w*.028,opacity:.9,marginBottom:l.w*.008},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.7,marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"flex",gap:l.w*.015,fontSize:l.w*.022,letterSpacing:"0.05em",borderTop:"1px solid rgba(201,168,76,0.4)",paddingTop:l.w*.02},children:e.jsx("span",{children:p})}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.02,background:"rgba(201,168,76,0.15)",border:"1px solid rgba(201,168,76,0.4)",padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.024,letterSpacing:"0.1em",display:"inline-block"},children:"SAT & SUN • 1–4 PM"}),e.jsx(d3s,{branding:n,dim:l})]})]})]})});jct.displayName="LuxuryDarkTemplate";const u3s=({branding:t,dim:s,accentColor:r})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{borderTop:"2px solid #E5E7EB",paddingTop:s.w*.025,display:"flex",alignItems:"center",justifyContent:"center",gap:s.w*.025},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.14,height:s.w*.14,borderRadius:"50%",objectFit:"cover",border:`3px solid ${r}`,flexShrink:0}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.042,fontWeight:800,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.028,color:"#6B7280",marginTop:s.w*.005},children:t.brokerage})]})]}),Nct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var v;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(v=t.photos)==null?void 0:v[a],u=Pme[s],p=r==="instagram-story",f=r==="facebook-post",g=s==="just-sold"?"#7C3AED":s==="open-house"?"#2563EB":s==="price-drop"?"#DC2626":"#059669";return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Helvetica Neue', Arial, sans-serif",color:"#1A1A1A",background:"#FFFFFF",display:"flex",flexDirection:f?"row":"column"},children:[e.jsxs("div",{style:{width:f?"55%":"100%",height:f?"100%":p?"50%":"52%",position:"relative",overflow:"hidden",flexShrink:0},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",top:l.w*.04,left:0,background:g,color:"#FFFFFF",padding:`${l.w*.012}px ${l.w*.04}px`,fontSize:l.w*.026,fontWeight:800,letterSpacing:"0.15em"},children:u})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05},children:[e.jsx("div",{style:{fontSize:l.w*(f?.055:.065),fontWeight:800,lineHeight:1.1,color:g,marginBottom:l.w*.012},children:qA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.026,fontWeight:600,marginBottom:l.w*.006},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.02,color:"#6B7280",marginBottom:l.w*.02},children:[t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.03,marginBottom:l.w*.02},children:[t.bedrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bedrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Beds"})]}),t.bathrooms>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.bathrooms}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Baths"})]}),t.sqft>0&&e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:l.w*.035,fontWeight:700},children:t.sqft.toLocaleString()}),e.jsx("div",{style:{fontSize:l.w*.016,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.1em"},children:"Sq Ft"})]})]}),s==="open-house"&&e.jsx("div",{style:{background:`${g}10`,border:`2px solid ${g}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:g,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(u3s,{branding:n,dim:l,accentColor:g})]})]})});Nct.displayName="ModernCleanTemplate";const h3s=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:s.w*.025,display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.12,height:s.w*.12,borderRadius:"50%",objectFit:"cover",border:"3px solid rgba(255,255,255,0.5)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.035,fontWeight:900},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.024,opacity:.8,marginTop:s.w*.004,fontFamily:"'Helvetica Neue', sans-serif",fontWeight:400},children:t.brokerage})]})]}),kct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var g;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(g=t.photos)==null?void 0:g[a],u=Pme[s],p={"just-listed":"linear-gradient(135deg, #059669, #10B981)","just-sold":"linear-gradient(135deg, #7C3AED, #A855F7)","open-house":"linear-gradient(135deg, #2563EB, #3B82F6)","price-drop":"linear-gradient(135deg, #DC2626, #F43F5E)"},f=[t.bedrooms?`${t.bedrooms} BD`:null,t.bathrooms?`${t.bathrooms} BA`:null,t.sqft?`${t.sqft.toLocaleString()} SF`:null].filter(Boolean).join(" | ");return e.jsxs("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Arial Black', 'Helvetica Neue', sans-serif",color:"#FFFFFF"},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)"}}),e.jsxs("div",{style:{position:"relative",height:"100%",display:"flex",flexDirection:"column",padding:l.w*.05},children:[e.jsx("div",{style:{background:p[s],padding:`${l.w*.025}px ${l.w*.04}px`,fontSize:l.w*.055,fontWeight:900,letterSpacing:"0.08em",alignSelf:"flex-start",borderRadius:l.w*.01,boxShadow:"0 8px 32px rgba(0,0,0,0.3)",transform:"rotate(-2deg)",marginBottom:l.w*.03},children:u}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{background:"rgba(0,0,0,0.65)",backdropFilter:"blur(10px)",borderRadius:l.w*.015,padding:l.w*.04},children:[e.jsx("div",{style:{fontSize:l.w*.08,fontWeight:900,lineHeight:1,marginBottom:l.w*.01},children:qA(t.price)}),e.jsx("div",{style:{fontSize:l.w*.028,fontWeight:700,marginBottom:l.w*.005},children:t.address}),e.jsxs("div",{style:{fontSize:l.w*.022,opacity:.8,marginBottom:l.w*.015},children:[t.city,", ",t.state," ",t.zip]}),e.jsx("div",{style:{display:"inline-block",background:"rgba(255,255,255,0.15)",borderRadius:l.w*.008,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,letterSpacing:"0.08em"},children:f}),s==="open-house"&&e.jsx("div",{style:{marginTop:l.w*.015,background:p["open-house"],borderRadius:l.w*.008,padding:`${l.w*.012}px ${l.w*.025}px`,fontSize:l.w*.024,fontWeight:800,display:"inline-block",marginLeft:l.w*.01},children:"SAT & SUN 1–4 PM"}),e.jsx(h3s,{branding:n,dim:l})]})]})]})});kct.displayName="BoldColorfulTemplate";const m3s=({branding:t,dim:s})=>!(t!=null&&t.enabled)||!t.agentName?null:e.jsxs("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",gap:s.w*.02},children:[t.agentPhotoUrl&&e.jsx("img",{src:t.agentPhotoUrl,alt:"",crossOrigin:"anonymous",style:{width:s.w*.11,height:s.w*.11,borderRadius:"50%",objectFit:"cover",border:"3px solid #8B7355"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:s.w*.032,fontWeight:700,color:"#1A1A1A"},children:t.agentName}),t.brokerage&&e.jsx("div",{style:{fontSize:s.w*.022,color:"#8B7355",marginTop:s.w*.004},children:t.brokerage})]})]}),Sct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var f;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(f=t.photos)==null?void 0:f[a],u=Pme[s],p=r==="instagram-story";return e.jsx("div",{ref:o,style:{width:l.w,height:l.h,transform:`scale(${i})`,transformOrigin:"top left",position:"relative",overflow:"hidden",fontFamily:"'Georgia', 'Times New Roman', serif",color:"#1A1A1A",background:"#F5F0EB"},children:e.jsxs("div",{style:{display:"flex",flexDirection:p?"column":"row",height:"100%"},children:[e.jsxs("div",{style:{width:p?"100%":"42%",height:p?"40%":"100%",display:"flex",flexDirection:"column",justifyContent:"center",padding:l.w*.05,order:p?2:1},children:[e.jsx("div",{style:{fontSize:l.w*.016,letterSpacing:"0.3em",textTransform:"uppercase",color:"#8B7355",borderBottom:"2px solid #8B7355",paddingBottom:l.w*.01,marginBottom:l.w*.025,display:"inline-block",alignSelf:"flex-start"},children:u}),e.jsx("div",{style:{fontSize:l.w*(p?.06:.055),fontWeight:700,lineHeight:1.1,marginBottom:l.w*.015,fontStyle:"italic"},children:qA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",qA(t.soldPrice)]}),e.jsxs("div",{style:{fontSize:l.w*.022,lineHeight:1.5,marginBottom:l.w*.02},children:[t.address,e.jsx("br",{}),t.city,", ",t.state," ",t.zip]}),e.jsxs("div",{style:{display:"flex",gap:l.w*.02,fontSize:l.w*.016,color:"#6B5D4E",borderTop:"1px solid #D1C7B7",paddingTop:l.w*.015,marginBottom:l.w*.015,flexWrap:"wrap"},children:[t.bedrooms>0&&e.jsxs("span",{children:[t.bedrooms," Bedrooms"]}),t.bedrooms>0&&t.bathrooms>0&&e.jsx("span",{children:"·"}),t.bathrooms>0&&e.jsxs("span",{children:[t.bathrooms," Bathrooms"]}),t.sqft>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.sqft.toLocaleString()," Sq Ft"]})]})]}),s==="open-house"&&e.jsx("div",{style:{fontSize:l.w*.018,fontStyle:"italic",color:"#8B7355",marginBottom:l.w*.01},children:"Open House: Saturday & Sunday, 1–4 PM"}),e.jsx(m3s,{branding:n,dim:l})]}),e.jsxs("div",{style:{width:p?"100%":"58%",height:p?"60%":"100%",position:"relative",overflow:"hidden",order:p?1:2},children:[c&&e.jsx("img",{src:c,alt:"",crossOrigin:"anonymous",style:{width:"100%",height:"100%",objectFit:"cover"}}),e.jsx("div",{style:{position:"absolute",inset:l.w*.02,border:"1px solid rgba(255,255,255,0.4)",pointerEvents:"none"}})]})]})})});Sct.displayName="EditorialTemplate";const p3s=[{value:"just-listed",label:"Just Listed",icon:"🏠"},{value:"just-sold",label:"Just Sold",icon:"🎉"},{value:"open-house",label:"Open House",icon:"🚪"},{value:"price-drop",label:"Price Drop",icon:"📉"}],Jze=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Tu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Tu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(Cu,{className:"h-4 w-4"})}],f3s=[{value:"luxury-dark",label:"Luxury Dark",description:"Dark & gold, high-end feel",preview:"🌙"},{value:"modern-clean",label:"Modern Clean",description:"White, bold, contemporary",preview:"✨"},{value:"bold-colorful",label:"Bold & Vibrant",description:"Energetic gradients & punch",preview:"🔥"},{value:"editorial",label:"Editorial",description:"Magazine-style sophistication",preview:"📰"}],e9e=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),t9e={"luxury-dark":jct,"modern-clean":Nct,"bold-colorful":kct,editorial:Sct};function x3s(){const[t,s]=N.useState(""),[r,n]=N.useState("address"),[a,o]=N.useState(!1),[l,i]=N.useState([]),[c,u]=N.useState(null),[p,f]=N.useState(0),[g,v]=N.useState("just-listed"),[_,w]=N.useState(["instagram-square"]),[j,k]=N.useState("luxury-dark"),[S,M]=N.useState(!1),[L,P]=N.useState(""),[O,$]=N.useState(""),[U,B]=N.useState(""),[V,X]=N.useState(!1),[Y,ee]=N.useState(!1),[Q,ce]=N.useState([]),[ne,re]=N.useState("search"),oe=N.useRef({});N.useEffect(()=>{(async()=>{const{data:{user:pe}}=await H.auth.getUser();if(!pe)return;const{data:we}=await H.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",pe.id).single();if(we){P(we.name||""),B(we.avatar_url||"");const Le=we.brokerages;$((Le==null?void 0:Le.name)||"")}})()},[]);const fe=async()=>{var ke;if(t.trim()){o(!0),i([]);try{const{data:pe,error:we}=await H.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(we)throw we;if(pe.error)throw new Error(pe.error);i(pe.listings||[]),((ke=pe.listings)==null?void 0:ke.length)===0&&me.info("No listings found. Try a different search.")}catch(pe){me.error(pe.message||"Search failed")}finally{o(!1)}}},ge=ke=>{var pe;u(ke),f(0),re("customize"),ke.soldDate||(pe=ke.status)!=null&&pe.toLowerCase().includes("sold")?v("just-sold"):v("just-listed")},ue=ke=>{w(pe=>pe.includes(ke)?pe.filter(we=>we!==ke):[...pe,ke])},xe=N.useCallback(async()=>{if(!(!c||_.length===0)){X(!0),ce([]),re("generate");try{await new Promise(pe=>setTimeout(pe,500));const ke=[];for(const pe of _){const we=`${j}-${pe}`,Le=oe.current[we];if(!Le)continue;const Qe=x9[pe],Te=await c3s(Le,{width:Qe.width,height:Qe.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});ke.push({format:pe,imageUrl:Te})}ce(ke),me.success(`Generated ${ke.length} social post${ke.length>1?"s":""}!`)}catch(ke){me.error(ke.message||"Generation failed")}finally{X(!1)}}},[c,_,j,p,S,L,O,U,g]),_e=async()=>{if(!(!c||_.length===0)){X(!0),ce([]),re("generate");try{const ke={...c,photos:c.photos.length>0?[c.photos[p]]:[]},pe=[];for(const we of _){const{data:Le,error:Qe}=await H.functions.invoke("generate-listing-social-post",{body:{listing:ke,postType:g,format:we,branding:S?{enabled:!0,agentName:L,brokerage:O}:{enabled:!1}}});if(Qe)throw Qe;if(Le.error)throw new Error(Le.error);pe.push({format:we,imageUrl:Le.imageUrl})}ce(pe),me.success(`Generated ${pe.length} AI post${pe.length>1?"s":""}!`)}catch(ke){me.error(ke.message||"AI generation failed")}finally{X(!1)}}},$e=()=>Y?_e():xe(),Me=(ke,pe)=>{var Le;const we=document.createElement("a");we.href=ke,we.download=`${((Le=c==null?void 0:c.address)==null?void 0:Le.replace(/\s+/g,"-"))||"listing"}-${g}-${pe}.png`,document.body.appendChild(we),we.click(),document.body.removeChild(we)},Ie=c?{listing:c,postType:g,format:"instagram-square",branding:S?{enabled:!0,agentName:L,brokerage:O,agentPhotoUrl:U||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(ch,{title:"Social Post Generator",description:"Search MLS listings and generate stunning social media posts"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsxs("button",{onClick:()=>re("search"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ne==="search"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[e.jsx(sn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>c&&re("customize"),disabled:!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full transition-colors ${ne==="customize"?"bg-primary text-primary-foreground":c?"bg-muted text-muted-foreground hover:text-foreground":"bg-muted text-muted-foreground/50 cursor-not-allowed"}`,children:[e.jsx(fn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${ne==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(vl,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ne==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(sn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(wQe,{})]}),e.jsx(gr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(_a,{value:r,onValueChange:ke=>n(ke),children:e.jsxs(fa,{children:[e.jsxs(ns,{value:"address",children:[e.jsx(ia,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(ns,{value:"mls",children:[e.jsx(Fm,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:t,onChange:ke=>s(ke.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:ke=>ke.key==="Enter"&&fe()}),e.jsxs(K,{onClick:fe,disabled:a||!t.trim(),children:[a?e.jsx(bs,{className:"h-4 w-4 animate-spin"}):e.jsx(sn,{className:"h-4 w-4"})," Search"]})]})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground",children:[l.length," listing",l.length!==1?"s":""," found"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map((ke,pe)=>{var we;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>ge(ke),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(we=ke.photos)!=null&&we[0]?e.jsx("img",{src:ke.photos[0],alt:ke.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(dn,{className:"h-8 w-8 text-muted-foreground/40"})})}),e.jsxs("div",{className:"flex-1 p-3 min-w-0",children:[e.jsx("p",{className:"font-bold text-foreground",children:e9e(ke.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:ke.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ke.city,", ",ke.state," ",ke.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[ke.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(eS,{className:"h-3 w-3"})," ",ke.bedrooms]}),ke.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(su,{className:"h-3 w-3"})," ",ke.bathrooms]}),ke.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(mS,{className:"h-3 w-3"})," ",ke.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:ke.mlsNumber}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:ke.status})]})]})]})})},ke.mlsNumber||pe)})})]})]}),ne==="customize"&&c&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[c.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),c.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(ke=>Math.max(0,ke-1)),disabled:p===0,children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p+1," of ",c.photos.length]}),e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(ke=>Math.min(c.photos.length-1,ke+1)),disabled:p===c.photos.length-1,children:e.jsx(oa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:e9e(c.price)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.city,", ",c.state," ",c.zip]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[c.bedrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bedrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Beds"})]}),c.bathrooms>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.bathrooms}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Baths"})]}),c.sqft>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-2",children:[e.jsx("p",{className:"text-sm font-semibold",children:c.sqft.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Sq Ft"})]})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{re("search"),u(null)},children:[e.jsx(g1,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(gr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:Y?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Y?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(qr,{checked:Y,onCheckedChange:ee}),Y&&e.jsx(Hv,{className:"h-4 w-4 text-purple-500"})]})]}),!Y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Bl,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:f3s.map(ke=>e.jsxs("button",{onClick:()=>k(ke.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${j===ke.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:ke.preview}),e.jsx("span",{className:"text-sm font-medium",children:ke.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:ke.description})]},ke.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:p3s.map(ke=>e.jsxs("button",{onClick:()=>v(ke.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${g===ke.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:ke.icon})," ",ke.label]},ke.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:Jze.map(ke=>e.jsxs("button",{onClick:()=>ue(ke.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${_.includes(ke.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[ke.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:ke.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ke.dimensions})]})]},ke.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Wi,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(qr,{checked:S,onCheckedChange:M})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[U&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:U,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(ze,{value:L,onChange:ke=>P(ke.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(ze,{value:O,onChange:ke=>$(ke.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!Y&&Ie&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Preview"}),e.jsx("div",{className:"bg-muted/30 rounded-lg p-4 flex justify-center overflow-hidden",children:e.jsx("div",{style:{width:400,height:400*(x9[_[0]||"instagram-square"].height/x9[_[0]||"instagram-square"].width)},children:(()=>{const ke=t9e[j],pe=_[0]||"instagram-square";return e.jsx(ke,{...Ie,format:pe})})()})})]}),e.jsx(K,{onClick:$e,disabled:_.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-5 w-5 animate-spin"})," Generating ",_.length," post",_.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[Y?e.jsx(Hv,{className:"h-5 w-5"}):e.jsx(fn,{className:"h-5 w-5"}),"Generate ",_.length," Social Post",_.length>1?"s":"",Y&&e.jsx(st,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ne==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(bs,{className:"h-12 w-12 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Generating your social posts..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Y?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),Q.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Generated Posts"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>re("customize"),children:[e.jsx(g1,{className:"h-3.5 w-3.5 mr-1.5"})," Regenerate"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.map((ke,pe)=>{const we=Jze.find(Le=>Le.value===ke.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:ke.imageUrl,alt:`${ke.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[we==null?void 0:we.icon,e.jsx("span",{className:"text-sm font-medium",children:we==null?void 0:we.label})]}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:we==null?void 0:we.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Me(ke.imageUrl,ke.format),children:[e.jsx(vi,{className:"h-3.5 w-3.5"})," Download"]})]})]},pe)})})]})]}),ne==="generate"&&!Y&&c&&Ie&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:_.map(ke=>{const pe=t9e[j],we=x9[ke];return e.jsx("div",{style:{width:we.width,height:we.height},children:e.jsx(pe,{ref:Le=>{oe.current[`${j}-${ke}`]=Le},...Ie,format:ke})},`${j}-${ke}`)})})]})})}function g3s(){return mt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function y3s(t){return mt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function v3s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Cct(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function b3s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function _3s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function w3s(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function j3s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function N3s(){const t=Xt();return Lt({mutationFn:async s=>{const{data:r,error:n}=await H.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function k3s(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function S3s(){const t=Xt();return Lt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await H.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await H.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function C3s(){return mt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await H.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function M3s(t){return mt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function Mct(t){return mt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function T3s(){const t=Xt();return Lt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await H.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function A3s(){const{user:t}=Os(),s=nr(),{data:r,isLoading:n}=g3s(),a=v3s(),o=Cct(),l=b3s(),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(!0),w=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:v,created_by:t.id});me.success("Course created"),c(!1),p(""),g(""),_(!0),s(`/admin/lms/${S.id}`)}catch{me.error("Failed to create course")}},j=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),me.success(S.is_published?"Course unpublished":"Course published")}catch{me.error("Failed to update course")}},k=async S=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(S),me.success("Course deleted")}catch{me.error("Failed to delete")}};return e.jsxs(Ts,{title:"LevelUp U - Admin",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Zh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Course Manager"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage training courses for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(yo,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]})},S))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:r.map(S=>{var O,$;const M=(($=(O=S.modules)==null?void 0:O[0])==null?void 0:$.count)??0,L=S.access||[],P=L.length===0?"No access set":L.some(U=>U.access_type==="all")?"All agents":`${L.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(st,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Th,{className:"h-3.5 w-3.5"}),M," module",M!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(x0,{className:"h-3.5 w-3.5"}):e.jsx(bS,{className:"h-3.5 w-3.5"}),S.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hr,{className:"h-3.5 w-3.5"}),P]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:U=>{U.stopPropagation(),j(S)},children:[S.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Dn,{className:"h-3.5 w-3.5 mr-1"}),S.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:U=>{U.stopPropagation(),k(S.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Th,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:"No courses yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first training course to get started"}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create New Course"}),e.jsx(Wr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Course Title"}),e.jsx(ze,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:f,onChange:S=>g(S.target.value),placeholder:"What will agents learn?",rows:3})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order"})]}),e.jsx(qr,{checked:v,onCheckedChange:_})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:w,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function E3s(){const{courseId:t}=lo(),s=nr(),{data:r,isLoading:n}=y3s(t),a=Cct(),o=_3s(),l=w3s(),i=j3s(),c=N3s(),u=k3s(),p=S3s(),{data:f}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:Ue}=await H.from("brokerages").select("id, name").order("name");return Ue||[]}}),[g,v]=N.useState(null),[_,w]=N.useState(!1),[j,k]=N.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,M]=N.useState(null),[L,P]=N.useState({title:"",resource_type:"link",url:""}),[O,$]=N.useState(new Set),[U,B]=N.useState(null),[V,X]=N.useState(0),[Y,ee]=N.useState(!1),Q=N.useRef(null),ce=N.useRef(null),[ne,re]=N.useState(!1),[oe,fe]=N.useState(""),[ge,ue]=N.useState(""),[xe,_e]=N.useState(""),[$e,Me]=N.useState(!1);if(n)return e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})});if(!r)return e.jsx(Ts,{title:"Course Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/admin/lms"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ie=r.modules||[],ke=r.access||[],pe=ke.some(Ue=>Ue.access_type==="all"),we=ke.filter(Ue=>Ue.access_type==="brokerage").map(Ue=>Ue.brokerage_id),Le=(f||[]).filter(Ue=>Ue.name.toLowerCase().includes(oe.toLowerCase())),Qe=Ue=>{const Ze=new Set(O);Ze.has(Ue)?Ze.delete(Ue):Ze.add(Ue),$(Ze)},Te=async()=>{if(!U)return null;ee(!0),X(0);try{const{data:Ue,error:Ze}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:U.name}});if(Ze)throw new Error(Ze.message);const{videoId:Je,libraryId:Ge}=Ue,{data:et,error:it}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je,libraryId:Ge}});if(it)throw new Error(it.message);const Dt=new XMLHttpRequest;return await new Promise((Vt,hs)=>{Dt.upload.onprogress=As=>{As.lengthComputable&&X(Math.round(As.loaded/As.total*100))},Dt.onload=()=>Dt.status>=200&&Dt.status<300?Vt():hs(new Error(`Upload failed: ${Dt.status}`)),Dt.onerror=()=>hs(new Error("Upload failed")),Dt.open("PUT",et.uploadUrl),Dt.setRequestHeader("AccessKey",et.apiKey),Dt.send(U)}),`https://iframe.mediadelivery.net/embed/${Ge}/${Je}`}catch(Ue){return console.error("Bunny upload error:",Ue),me.error("Video upload failed"),null}finally{ee(!1),X(0)}},pt=async()=>{if(j.title.trim())try{let Ue=j.video_url.trim()||void 0;if(U){const Ze=await Te();if(!Ze)return;Ue=Ze}await o.mutateAsync({course_id:r.id,title:j.title.trim(),description:j.description.trim()||void 0,video_url:Ue,text_content:j.text_content.trim()||void 0,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):void 0,sort_order:Ie.length}),me.success("Module added"),w(!1),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{me.error("Failed to add module")}},ye=async()=>{if(g)try{let Ue=j.video_url.trim()||null;if(U){const Ze=await Te();if(!Ze)return;Ue=Ze}await l.mutateAsync({id:g.id,title:j.title.trim(),description:j.description.trim()||null,video_url:Ue,text_content:j.text_content.trim()||null,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):null}),me.success("Module updated"),v(null),B(null)}catch{me.error("Failed to update")}},qe=async Ue=>{if(confirm("Delete this module?"))try{await i.mutateAsync(Ue),me.success("Module deleted")}catch{me.error("Failed to delete")}},at=async Ue=>{if(L.title.trim())try{await c.mutateAsync({module_id:Ue,title:L.title.trim(),resource_type:L.resource_type,url:L.url.trim()||void 0}),me.success("Resource added"),M(null),P({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},tt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),me.success("Access updated: All brokerages / all agents")}catch{me.error("Failed to update access")}},Ae=async Ue=>{const Ze=ke.filter(it=>it.access_type==="brokerage").map(it=>it.brokerage_id),Je=Ze.includes(Ue);let Ge;Je?Ge=Ze.filter(it=>it!==Ue):Ge=[...Ze,Ue];const et=Ge.map(it=>({access_type:"brokerage",brokerage_id:it}));try{await p.mutateAsync({courseId:r.id,accessRules:et}),me.success(Je?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},rt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},He=async(Ue,Ze)=>{const Je=Ze==="up"?Ue-1:Ue+1;if(!(Je<0||Je>=Ie.length))try{await Promise.all([l.mutateAsync({id:Ie[Ue].id,sort_order:Je}),l.mutateAsync({id:Ie[Je].id,sort_order:Ue})])}catch{me.error("Failed to reorder")}},ct=async()=>{try{await a.mutateAsync({id:r.id,title:ge,description:xe||null}),me.success("Course updated"),Me(!1)}catch{me.error("Failed to update")}};return e.jsxs(Ts,{title:r.title,children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/admin/lms"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:r.title}),e.jsx(st,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"})]}),r.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[r.is_sequential?e.jsx(x0,{className:"h-3.5 w-3.5"}):e.jsx(bS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ie.length," module",Ie.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{ue(r.title),_e(r.description||""),Me(!0)},children:[e.jsx(za,{className:"h-3.5 w-3.5 mr-1"})," Edit"]}),e.jsxs(K,{variant:r.is_published?"secondary":"default",size:"sm",onClick:()=>a.mutateAsync({id:r.id,is_published:!r.is_published}).then(()=>me.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Dn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(_a,{defaultValue:"modules",className:"w-full",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"modules",children:"Modules"}),e.jsx(ns,{value:"access",children:"Access & Permissions"}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{value:"modules",className:"mt-6 space-y-4",children:[Ie.map((Ue,Ze)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>Qe(Ue.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:Je=>{Je.stopPropagation(),He(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(xf,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Je=>{Je.stopPropagation(),He(Ze,"down")},disabled:Ze===Ie.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(oo,{className:"h-3.5 w-3.5"})})]})}),e.jsx(st,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ze+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ue.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[Ue.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Cn,{className:"h-3 w-3"})," Video"]}),Ue.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(wn,{className:"h-3 w-3"})," Text"]}),Ue.duration_minutes&&e.jsxs("span",{children:[Ue.duration_minutes," min"]}),Ue.resources&&Ue.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(ml,{className:"h-3 w-3"})," ",Ue.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Je=>{var Ge;Je.stopPropagation(),v(Ue),k({title:Ue.title,description:Ue.description||"",video_url:Ue.video_url||"",text_content:Ue.text_content||"",duration_minutes:((Ge=Ue.duration_minutes)==null?void 0:Ge.toString())||""})},children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Je=>{Je.stopPropagation(),qe(Ue.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),O.has(Ue.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[Ue.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:Ue.description}),Ue.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:Ue.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Ue.video_url})]}),Ue.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:Ue.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{M(Ue.id),P({title:"",resource_type:"link",url:""})},children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),Ue.resources&&Ue.resources.length>0?e.jsx("div",{className:"space-y-1",children:Ue.resources.map(Je=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(st,{variant:"outline",className:"text-[10px]",children:Je.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:Je.title}),Je.url&&e.jsx("a",{href:Je.url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline text-xs",children:"Open"}),e.jsx(K,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>u.mutateAsync(Je.id),children:e.jsx(Mr,{className:"h-3 w-3"})})]},Je.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},Ue.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{w(!0),k({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(ws,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:It("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",pe?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:tt,children:[e.jsx("div",{className:It("h-10 w-10 rounded-full flex items-center justify-center shrink-0",pe?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(ru,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(qr,{checked:pe,onCheckedChange:tt})]}),!pe&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Select Brokerages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:we.length===0?"No brokerages selected — agents won't see this course":`${we.length} brokerage${we.length!==1?"s":""} selected`})]}),we.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:rt,children:"Clear all"})]}),e.jsx(ze,{placeholder:"Search brokerages...",value:oe,onChange:Ue=>fe(Ue.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:Le.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):Le.map(Ue=>{const Ze=we.includes(Ue.id);return e.jsxs("div",{className:It("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Ae(Ue.id),children:[e.jsx("div",{className:It("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ze?"bg-primary border-primary":"border-muted-foreground/30"),children:Ze&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:Ue.name}),Ze&&e.jsx(st,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},Ue.id)})})]})]})]})}),e.jsxs(ws,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>me.success("Thumbnail removed")),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"w-48 h-28 rounded-lg border-2 border-dashed border-muted-foreground/25 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx(u1,{className:"h-8 w-8 mb-1 opacity-50"}),e.jsx("span",{className:"text-xs",children:"No thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a thumbnail image for this course. Recommended: 800×450px (16:9)."}),e.jsx("input",{ref:ce,type:"file",accept:"image/*",className:"hidden",onChange:async Ue=>{var Je;const Ze=(Je=Ue.target.files)==null?void 0:Je[0];if(!(!Ze||!r)){re(!0);try{const Ge=Ze.name.split(".").pop(),et=`${r.id}/thumbnail.${Ge}`,{error:it}=await H.storage.from("lms-thumbnails").upload(et,Ze,{upsert:!0});if(it)throw it;const{data:Dt}=H.storage.from("lms-thumbnails").getPublicUrl(et),Vt=`${Dt.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Vt}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{re(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ne,onClick:()=>{var Ue;return(Ue=ce.current)==null?void 0:Ue.click()},children:[ne?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(di,{className:"h-4 w-4 mr-2"}),ne?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(qr,{checked:r.is_sequential,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_sequential:Ue}).then(()=>me.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(qr,{checked:r.is_published,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_published:Ue}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(xs,{open:_||!!g,onOpenChange:Ue=>{Ue||(w(!1),v(null))},children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsx(_s,{children:g?"Edit Module":"Add Module"}),e.jsx(Wr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:j.title,onChange:Ue=>k(Ze=>({...Ze,title:Ue.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:j.description,onChange:Ue=>k(Ze=>({...Ze,description:Ue.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:It("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",U?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var Ue;return(Ue=Q.current)==null?void 0:Ue.click()},children:[e.jsx("input",{ref:Q,type:"file",accept:"video/*",className:"hidden",onChange:Ue=>{var Je;const Ze=(Je=Ue.target.files)==null?void 0:Je[0];Ze&&(B(Ze),k(Ge=>({...Ge,video_url:""})))}}),U?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(Cn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:U.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:Ue=>{Ue.stopPropagation(),B(null)},children:e.jsx(Mr,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(di,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),Y&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(bs,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Bi,{value:V,className:"h-1.5"})]}),!U&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(ze,{value:j.video_url,onChange:Ue=>k(Ze=>({...Ze,video_url:Ue.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Text Content"}),e.jsx(Pr,{value:j.text_content,onChange:Ue=>k(Ze=>({...Ze,text_content:Ue.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",value:j.duration_minutes,onChange:Ue=>k(Ze=>({...Ze,duration_minutes:Ue.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>{w(!1),v(null),B(null)},children:"Cancel"}),e.jsxs(K,{onClick:g?ye:pt,disabled:!j.title.trim()||Y,children:[Y?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Uc,{className:"h-4 w-4 mr-2"}),Y?"Uploading...":g?"Save Changes":"Add Module"]})]})]})}),e.jsx(xs,{open:!!S,onOpenChange:Ue=>{Ue||M(null)},children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Add Resource"}),e.jsx(Wr,{children:"Add a link, document, or other resource to this module"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:L.title,onChange:Ue=>P(Ze=>({...Ze,title:Ue.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Type"}),e.jsxs(Ks,{value:L.resource_type,onValueChange:Ue=>P(Ze=>({...Ze,resource_type:Ue})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"link",children:"Link"}),e.jsx(Mt,{value:"pdf",children:"PDF"}),e.jsx(Mt,{value:"template",children:"Template"}),e.jsx(Mt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"URL"}),e.jsx(ze,{value:L.url,onChange:Ue=>P(Ze=>({...Ze,url:Ue.target.value})),placeholder:"https://..."})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsx(K,{onClick:()=>S&&at(S),disabled:!L.title.trim(),children:"Add Resource"})]})]})}),e.jsx(xs,{open:$e,onOpenChange:Me,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Edit Course"}),e.jsx(Wr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Title"}),e.jsx(ze,{value:ge,onChange:Ue=>ue(Ue.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:xe,onChange:Ue=>_e(Ue.target.value),rows:3})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(K,{onClick:ct,disabled:!ge.trim(),children:"Save"})]})]})})]})}function P3s(){return mt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_stats");if(s)throw s;return t}})}function I3s(){return mt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await H.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function L3s(t){return mt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function D3s(){const t=nr(),{data:s,isLoading:r}=P3s(),{data:n,isLoading:a}=I3s(),[o,l]=N.useState(null),{data:i,isLoading:c}=L3s(o),[u,p]=N.useState(""),f=n==null?void 0:n.find(_=>_.course_id===o),g=i==null?void 0:i.filter(_=>{var w,j;return!u||((w=_.agent_name)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=_.email)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))}),v=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:Th,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:sa,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:hr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:vo,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Jo,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:yo,color:"text-rose-500"}];return e.jsx(Ts,{title:"LevelUp U - Stats",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/admin/lms"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(Zh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:v.map(_=>e.jsx(Ee,{className:It("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_.icon,{className:It("h-4 w-4",_.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:_.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":_.value})]})},_.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(yo,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},_))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(_=>{const w=o===_.course_id;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",w?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(w?null:_.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:_.course_title}),e.jsx(st,{variant:_.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:_.is_published?"Live":"Draft"})]})}),e.jsx(oa,{className:It("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",w&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:_.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[_.avg_completion_pct,"%"]})]}),e.jsx(Bi,{value:_.avg_completion_pct,className:"h-2"})]})]})},_.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(X_,{className:"h-5 w-5 text-primary"}),f?`Agent Progress — ${f.course_title}`:"Agent Progress"]}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:u,onChange:_=>p(_.target.value),placeholder:"Search agents...",className:"pl-9"})]}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(_=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},_))}):g!=null&&g.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:g.map((_,w)=>{const j=_.completion_pct>=100;return e.jsx(Ee,{className:It("transition-all",j&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:It("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",w===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":w===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":w===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:w+1}),e.jsxs(kn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Ua,{src:_.avatar_url||void 0}),e.jsx(Sn,{className:"text-xs bg-primary/10 text-primary",children:(_.agent_name||_.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:_.agent_name||_.email}),j&&e.jsxs(st,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(sa,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[_.modules_completed,"/",_.total_modules," modules"]}),_.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(_.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:It("text-sm font-bold",j?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[_.completion_pct,"%"]}),e.jsx(Bi,{value:_.completion_pct,className:"h-1.5 mt-1"})]})]})})},_.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(hr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a course to view agent progress"})]})})]})]})]})})}function O3s(){const{user:t}=Os(),s=nr(),{data:r,isLoading:n}=C3s();return e.jsx(Ts,{title:"LevelUp U",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-background border p-8",children:[e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(Zh,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"LevelUp U"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your training & development hub"})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-primary/5 rounded-full -translate-y-1/2 translate-x-1/2"})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(R3s,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(Th,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No courses available yet"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Check back soon for new training content"})]})})]})})}function R3s({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Mct(t.id),o=(a==null?void 0:a.filter(c=>c.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(Zh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Th,{className:"h-3.5 w-3.5"}),n," module",n!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[t.is_sequential?e.jsx(x0,{className:"h-3.5 w-3.5"}):e.jsx(bS,{className:"h-3.5 w-3.5"}),t.is_sequential?"In order":"Any order"]})]}),n>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:[o," of ",n," completed"]}),e.jsxs("span",{className:"font-medium text-foreground",children:[l,"%"]})]}),e.jsx(Bi,{value:l,className:"h-1.5"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"text-xs text-primary font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l===100?"Review":l>0?"Continue":"Start"," Course",e.jsx(oa,{className:"h-3.5 w-3.5"})]})})]})]})}function F3s(){const{courseId:t}=lo(),s=nr(),{user:r}=Os(),{data:n,isLoading:a}=M3s(t),{data:o}=Mct(t),l=T3s(),[i,c]=N.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(S=>S.completed).map(S=>S.module_id))||[]),f=p.size,g=u.length>0?Math.round(f/u.length*100):0;N.useEffect(()=>{if(u.length>0&&!i){const S=u.find(M=>!p.has(M.id));c((S==null?void 0:S.id)||u[0].id)}},[u,i,p]);const v=u.find(S=>S.id===i),_=u.findIndex(S=>S.id===i),w=(S,M)=>{if(!(n!=null&&n.is_sequential)||M===0)return!1;for(let L=0;L{if(!(!v||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:v.id,userId:r.id}),me.success("Module completed! 🎉"),_{const M=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(M)return`https://www.youtube.com/embed/${M[1]}`;const L=S.match(/vimeo\.com\/(\d+)/);if(L)return`https://player.vimeo.com/video/${L[1]}`;const P=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return P?`https://iframe.mediadelivery.net/embed/${P[1]}/${P[2]}?responsive=true`:S};return a?e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):n?e.jsx(Ts,{title:n.title,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/levelup-u"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-bold text-foreground truncate",children:n.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[f,"/",u.length," completed"]}),e.jsxs("span",{children:[g,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Bi,{value:g,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Ki,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,M)=>{const L=w(S,M),P=p.has(S.id),O=S.id===i;return e.jsxs("button",{disabled:L,onClick:()=>!L&&c(S.id),className:It("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",O?"bg-primary/10 text-primary":"hover:bg-muted/50",L&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:L?e.jsx(Eh,{className:"h-4 w-4 text-muted-foreground"}):P?e.jsx(sa,{className:"h-4 w-4 text-green-500"}):e.jsx(wd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:It("font-medium truncate",O&&"text-primary"),children:[M+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(un,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[v.video_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:k(v.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:v.title}),v.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:v.description})]}),p.has(v.id)?e.jsxs(st,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(sa,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:j,disabled:l.isPending,children:[e.jsx(sa,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),v.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:v.text_content}),v.resources&&v.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:v.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(wn,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(Zh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(ml,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(en,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},S.id))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t pt-4",children:[e.jsxs(K,{variant:"outline",size:"sm",disabled:_===0,onClick:()=>_>0&&c(u[_-1].id),children:[e.jsx(Qa,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),_c(u[_+1].id),children:["Next ",e.jsx(oa,{className:"h-3.5 w-3.5 ml-1"})]}):g===100&&e.jsx(st,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-muted-foreground",children:"Course not found"}),e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>s("/levelup-u"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function z3s({headline:t,subtext:s,primaryColor:r,accentColor:n,heroImageUrl:a,logoUrl:o,brokerageName:l}){return e.jsxs("section",{className:"relative min-h-screen flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(160deg, ${n} 0%, ${r} 50%, ${n}ee 100%)`}}),a&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center opacity-20",style:{backgroundImage:`url(${a})`}}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px), radial-gradient(circle at 75% 75%, white 1px, transparent 1px)",backgroundSize:"60px 60px"}}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-white to-transparent"}),e.jsxs("div",{className:"relative z-10 text-center max-w-4xl mx-auto px-6 py-24",children:[o&&e.jsx(ps.img,{src:o,alt:l,className:"h-14 md:h-20 w-auto mx-auto mb-10 drop-shadow-2xl",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.8,delay:.2}}),e.jsx(ps.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.3},children:e.jsx("span",{className:"inline-block text-white/70 text-sm md:text-base font-medium tracking-[0.2em] uppercase mb-6",children:"Your Next Chapter Starts Here"})}),e.jsx(ps.h1,{className:"text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-8 leading-[1.1] tracking-tight",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.9,delay:.5},children:t}),e.jsx(ps.p,{className:"text-lg md:text-xl text-white/80 mb-12 max-w-2xl mx-auto leading-relaxed font-light",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.7},children:s}),e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,delay:.9},className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"#apply",className:"group inline-flex items-center gap-3 px-10 py-4 rounded-full text-lg font-semibold shadow-2xl transition-all duration-300 hover:scale-105 hover:shadow-3xl",style:{backgroundColor:"white",color:n},children:["Get In Touch",e.jsx(Sa,{className:"h-5 w-5 transition-transform group-hover:translate-x-1"})]}),e.jsx("a",{href:"#benefits",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-base font-medium text-white/90 border border-white/30 backdrop-blur-sm transition-all duration-300 hover:bg-white/10 hover:border-white/50",children:"Learn More"})]})]}),e.jsx(ps.div,{className:"absolute bottom-8 left-1/2 -translate-x-1/2 z-10",animate:{y:[0,8,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:e.jsx("div",{className:"w-6 h-10 border-2 border-white/40 rounded-full flex justify-center pt-2",children:e.jsx("div",{className:"w-1.5 h-3 bg-white/60 rounded-full"})})})]})}function Sw({children:t,className:s="",delay:r=0,direction:n="up"}){const a=N.useRef(null),o=k3(a,{once:!0,margin:"-80px"}),l={hidden:{opacity:0,y:n==="up"?40:0,x:n==="left"?-40:n==="right"?40:0},visible:{opacity:1,y:0,x:0}};return e.jsx(ps.div,{ref:a,initial:"hidden",animate:o?"visible":"hidden",variants:l,transition:{duration:.7,delay:r,ease:[.25,.46,.45,.94]},className:s,children:t})}function B3s({benefits:t,accentColor:s,primaryColor:r}){return t.length===0?null:e.jsx("section",{id:"benefits",className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(Sw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:r},children:"Why Top Agents Choose Us"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold mb-4 tracking-tight",style:{color:s},children:"Built For Your Success"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:r}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8",children:t.map((n,a)=>e.jsx(Sw,{delay:a*.1,children:e.jsxs("div",{className:"group relative p-8 rounded-2xl border border-gray-100 bg-white hover:border-transparent hover:shadow-2xl transition-all duration-500 h-full",children:[e.jsx("div",{className:"absolute inset-0 rounded-2xl opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{background:`linear-gradient(135deg, ${r}08, ${s}05)`}}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center text-2xl mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${r}12`},children:n.icon}),e.jsx("h3",{className:"text-xl font-bold mb-3 tracking-tight",style:{color:s},children:n.title}),e.jsx("p",{className:"text-gray-500 leading-relaxed text-[15px]",children:n.description})]})]})},a))})]})})}function $3s({images:t,primaryColor:s,accentColor:r}){const[n,a]=N.useState(null);return t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"py-24 md:py-32 px-6 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(Sw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white border border-gray-200 mb-6",children:[e.jsx(hr,{className:"h-4 w-4",style:{color:s}}),e.jsx("span",{className:"text-sm font-medium text-gray-600",children:"Life at Our Brokerage"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Our Team & Culture"})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 md:gap-4",children:t.map((o,l)=>e.jsx(Sw,{delay:l*.08,children:e.jsxs("button",{onClick:()=>a(l),className:"relative w-full aspect-[4/3] overflow-hidden rounded-xl group cursor-pointer",children:[e.jsx("img",{src:o,alt:`Team ${l+1}`,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-all duration-500"})]})},l))})]})}),n!==null&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4 cursor-pointer",onClick:()=>a(null),children:[e.jsx("button",{onClick:()=>a(null),className:"absolute top-6 right-6 text-white/80 hover:text-white transition-colors",children:e.jsx(Mr,{className:"h-8 w-8"})}),e.jsx("img",{src:t[n],alt:"Gallery",className:"max-w-full max-h-[85vh] object-contain rounded-lg",onClick:o=>o.stopPropagation()})]})]})}function q3s({testimonials:t,primaryColor:s,accentColor:r}){return t.length===0?null:e.jsx("section",{className:"py-24 md:py-32 px-6 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx(Sw,{children:e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("span",{className:"text-sm font-semibold tracking-[0.15em] uppercase mb-4 block",style:{color:s},children:"Agent Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-5xl font-bold tracking-tight",style:{color:r},children:"Hear From Our Agents"}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full mt-6",style:{backgroundColor:s}})]})}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:t.map((n,a)=>{var o;return e.jsx(Sw,{delay:a*.15,direction:a%2===0?"left":"right",children:e.jsxs("div",{className:"relative p-8 md:p-10 rounded-2xl bg-gray-50 border border-gray-100 h-full",children:[e.jsx(f1,{className:"h-8 w-8 mb-5 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-gray-700 text-lg leading-relaxed mb-8 font-light italic",children:['"',n.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-4",children:[n.photo_url?e.jsx("img",{src:n.photo_url,alt:n.name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white shadow-md"}):e.jsx("div",{className:"h-12 w-12 rounded-full flex items-center justify-center text-white text-base font-bold shadow-md",style:{background:`linear-gradient(135deg, ${s}, ${r})`},children:((o=n.name)==null?void 0:o[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-base",style:{color:r},children:n.name}),n.role&&e.jsx("p",{className:"text-sm text-gray-500",children:n.role})]})]})]})},a)})})]})})}function U3s({form:t,setForm:s,onSubmit:r,isPending:n,primaryColor:a,accentColor:o}){return e.jsxs("section",{id:"apply",className:"py-24 md:py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 top-0 h-1/2",style:{background:`linear-gradient(160deg, ${o}, ${a})`}}),e.jsx("div",{className:"absolute inset-0 top-1/2 bg-gray-50"}),e.jsxs("div",{className:"relative z-10 max-w-xl mx-auto",children:[e.jsx(Sw,{children:e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-3 tracking-tight",children:"Want to Learn More?"}),e.jsx("p",{className:"text-white/70 text-lg font-light",children:"Drop your info below and we'll share more about what makes us different."})]})}),e.jsx(Sw,{delay:.2,children:e.jsxs("form",{onSubmit:l=>{l.preventDefault(),r()},className:"bg-white rounded-3xl shadow-2xl p-8 md:p-10 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"First Name *"}),e.jsx(ze,{required:!0,value:t.first_name,onChange:l=>s(i=>({...i,first_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"John"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Last Name"}),e.jsx(ze,{value:t.last_name,onChange:l=>s(i=>({...i,last_name:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Smith"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Email *"}),e.jsx(ze,{type:"email",required:!0,value:t.email,onChange:l=>s(i=>({...i,email:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"john@email.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Phone"}),e.jsx(ze,{value:t.phone,onChange:l=>s(i=>({...i,phone:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Current Brokerage"}),e.jsx(ze,{value:t.current_brokerage,onChange:l=>s(i=>({...i,current_brokerage:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"Your current brokerage name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"License #"}),e.jsx(ze,{value:t.license_number,onChange:l=>s(i=>({...i,license_number:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Years Experience"}),e.jsx(ze,{type:"number",min:"0",value:t.experience_years,onChange:l=>s(i=>({...i,experience_years:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Annual Production"}),e.jsx(ze,{value:t.annual_production,onChange:l=>s(i=>({...i,annual_production:l.target.value})),className:"h-11 rounded-lg border-gray-200 focus:border-gray-400 transition-colors",placeholder:"e.g. $5M, 20 transactions"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(Pr,{value:t.why_interested,onChange:l=>s(i=>({...i,why_interested:l.target.value})),rows:3,className:"rounded-lg border-gray-200 focus:border-gray-400 transition-colors resize-none",placeholder:"Tell us about your goals and what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-13 text-base font-semibold rounded-xl group transition-all duration-300 hover:shadow-lg",style:{background:`linear-gradient(135deg, ${a}, ${o})`},disabled:n,children:n?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Submitting..."]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Send My Info",e.jsx(Sa,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-gray-400 pt-1",children:[e.jsx(Au,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function V3s(){const{slug:t}=lo(),{toast:s}=Ha(),[r,n]=N.useState(!1),[a,o]=N.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:c}=mt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:M,error:L}=await H.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(L)throw L;return M},enabled:!!t}),{data:u}=mt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:M,error:L}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(L&&L.code!=="PGRST116")throw L;return M},enabled:!!(l!=null&&l.id)}),p=Lt({mutationFn:async()=>{const M={brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null},{error:L}=await H.from("recruit_interest_submissions").insert(M);if(L)throw L;H.functions.invoke("recruit-lead-notify",{body:{lead:M,brokerage_id:l.id}}).catch(P=>console.error("Lead notification error:",P))},onSuccess:()=>n(!0),onError:M=>s({title:"Error",description:M.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-3 border-gray-200 border-t-gray-800"}),e.jsx("span",{className:"text-sm text-gray-400 tracking-wide",children:"Loading..."})]})});if(c||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(Ca,{className:"h-10 w-10 mx-auto text-gray-300 mb-4"}),e.jsx("p",{className:"text-gray-400 text-lg",children:"This page is not available."})]})});const f=u,g=(f==null?void 0:f.primary_color)||"#406E71",v=(f==null?void 0:f.accent_color)||"#2a4c64",_=(f==null?void 0:f.benefits)||[],w=(f==null?void 0:f.testimonials)||[],j=(f==null?void 0:f.gallery_images)||[],k=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,S=(f==null?void 0:f.hero_subtext)||"Take your real estate career to the next level with a brokerage that invests in your growth.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs(ps.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.6},className:"max-w-md w-full mx-4 text-center",children:[e.jsx("div",{className:"h-20 w-20 rounded-full flex items-center justify-center mx-auto mb-6 shadow-lg",style:{background:`linear-gradient(135deg, ${g}, ${v})`},children:e.jsx(ba,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:v},children:"Thank You!"}),e.jsxs("p",{className:"text-gray-500 text-lg leading-relaxed mb-8",children:["Your interest in joining ",e.jsx("span",{className:"font-semibold",style:{color:v},children:l.name})," has been received. A member of our recruitment team will be in touch shortly."]}),e.jsx("div",{className:"w-16 h-1 mx-auto rounded-full",style:{backgroundColor:g}})]})}):e.jsxs("div",{className:"min-h-screen bg-white",style:{"--recruit-primary":g,"--recruit-accent":v},children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-40 bg-white/80 backdrop-blur-lg border-b border-gray-100/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 h-14 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-8 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight",style:{color:v},children:l.name})]}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-5 py-2 rounded-full text-sm font-semibold text-white transition-all duration-300 hover:shadow-md hover:scale-105",style:{background:`linear-gradient(135deg, ${g}, ${v})`},children:["Apply Now ",e.jsx(Sa,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(z3s,{headline:k,subtext:S,primaryColor:g,accentColor:v,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(B3s,{benefits:_,accentColor:v,primaryColor:g}),e.jsx($3s,{images:j,primaryColor:g,accentColor:v}),e.jsx(q3s,{testimonials:w,primaryColor:g,accentColor:v}),e.jsx(U3s,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:g,accentColor:v}),e.jsx("footer",{className:"py-10 text-center bg-white border-t border-gray-100",children:e.jsxs("p",{className:"text-sm text-gray-400",children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function H3s(t){const s=t.match(/(?:iframe\.mediadelivery\.net\/(?:embed|play)\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return s?`https://iframe.mediadelivery.net/embed/${s[1]}/${s[2]}?autoplay=false&responsive=true`:t}function G3s(){var g,v,_,w;const{shareToken:t}=lo(),s=N.useRef(!1),{data:r,isLoading:n,error:a}=mt({queryKey:["public-recruit-video",t],queryFn:async()=>{var P;if(!t)throw new Error("No token");const{data:j,error:k}=await H.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(k)throw k;const{data:S}=await H.from("profiles").select("name, avatar_url, title").eq("id",(P=j.video)==null?void 0:P.owner_user_id).single(),{data:M}=await H.from("brokerages").select("name").eq("id",j.brokerage_id).single(),{data:L}=await H.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",j.brokerage_id).maybeSingle();return{rv:j,profile:S,brokerage:M,settings:L}},enabled:!!t});if(N.useEffect(()=>{var j;!((j=r==null?void 0:r.rv)!=null&&j.id)||s.current||(s.current=!0,H.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(g=r==null?void 0:r.rv)==null?void 0:g.id]),n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(a||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("p",{className:"text-muted-foreground",children:"This video is no longer available."})});const{rv:o,profile:l,brokerage:i,settings:c}=r,u=(c==null?void 0:c.primary_color)||"#3b82f6",p=((v=o.prospect)==null?void 0:v.first_name)||"there",f=(_=o.video)!=null&&_.playback_url?H3s(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx($l,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(c==null?void 0:c.logo_url)&&e.jsx("img",{src:c.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{H.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(hn,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}function W3s(){const t=nr(),s=Xt(),{isAdmin:r}=Os(),[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState(null),{data:u,isLoading:p}=mt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:P},error:O}=await H.auth.getUser();if(O)throw O;if(!P)return[];const{data:$,error:U}=await H.from("social_accounts").select("*").eq("user_id",P.id).order("created_at",{ascending:!1});if(U)throw U;return $}}),f=Lt({mutationFn:async P=>{const{data:{user:O},error:$}=await H.auth.getUser();if($)throw $;if(!O)throw new Error("Not authenticated");const{error:U}=await H.from("social_accounts").delete().eq("id",P).eq("user_id",O.id);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),me.success("Account disconnected successfully")},onError:()=>{me.error("Failed to disconnect account")}}),g=async()=>{a(!0);try{const{data:P,error:O}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get authorization URL")}catch(P){console.error("Meta OAuth error:",P),me.error("Failed to start connection. Please try again."),a(!1)}},v=async()=>{a(!0);try{const{data:P,error:O}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(P){console.error("LinkedIn OAuth error:",P),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:P,error:O}=await H.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(O)throw O;if(P!=null&&P.authUrl)window.location.href=P.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(P){console.error("Google OAuth error:",P),me.error("Failed to start Google connection. Please try again."),a(!1)}},w=(u==null?void 0:u.filter(P=>P.platform==="facebook"))||[],j=(u==null?void 0:u.filter(P=>P.platform==="instagram"))||[],k=(u==null?void 0:u.filter(P=>P.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(P=>P.platform==="google_business"))||[],M=((u==null?void 0:u.length)||0)>0,L=async(P,O)=>{l(P),c(null);try{const{data:$,error:U}=await H.functions.invoke("meta-api-test",{body:{testType:"all",accountId:P}});if(U)throw U;c($.results||[]),me.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),me.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Ts,{title:"Social Connections",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500 p-6 md:p-8 text-white",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs(st,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(fn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),e.jsx("p",{className:"text-white/90 max-w-xl",children:"Link your Facebook Pages and Instagram Business accounts to post content directly from Social Swag with one click."})]})]}),e.jsxs(K,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(un,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(st,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[M&&e.jsx(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(gi,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),e.jsx("p",{className:"text-sm text-green-600 dark:text-green-400",children:"You can now post directly to your connected accounts from Social Swag."})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:e.jsx(Cu,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Facebook"}),e.jsx(gr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Wo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:P.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Cu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.page_name||P.platform_username||"Facebook Page"}),e.jsx(st,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Facebook?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:e.jsx(Tu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Instagram"}),e.jsx(gr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Wo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:P.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Tu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",P.platform_username||"Instagram Account"]}),e.jsx(st,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Instagram?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:g,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),j.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:e.jsx(Mp,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"LinkedIn"}),e.jsx(gr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Wo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):k.length>0?e.jsx("div",{className:"space-y-3",children:k.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:P.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(Mp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.platform_username||"LinkedIn Account"}),e.jsx(st,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect LinkedIn?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:v,disabled:n,className:"w-full gap-2",variant:k.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),k.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(st,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(st,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:e.jsx(ia,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Google Business"}),e.jsx(gr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Wo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:P.profile_picture_url||""}),e.jsx(Sn,{children:e.jsx(ia,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:P.page_name||P.platform_username||"Google Business"}),e.jsx(st,{variant:P.is_active?"default":"secondary",className:"text-xs",children:P.is_active?"Connected":"Inactive"})]})]}),e.jsxs(Mc,{children:[e.jsx(Mm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Disconnect Google Business?"}),e.jsx(ic,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>f.mutate(P.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},P.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?_:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||j.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:e.jsx(W_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(gr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Cu,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:P.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(P.id),disabled:o===P.id,children:o===P.id?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${P.id}`)),j.map(P=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Tu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",P.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>L(P.id),disabled:o===P.id,children:o===P.id?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${P.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((P,O)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[P.status==="success"?e.jsx(sa,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):P.status==="pending"?e.jsx(bs,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(jc,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:P.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:P.details})]})]},O))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function K3s(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Processing your connection...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:v}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(v)throw v;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((g==null?void 0:g.error)||"Unknown error")}catch(g){console.error("OAuth callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect accounts"),me.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(bs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(jc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Z3s(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your Google Business Profile...");return N.useEffect(()=>{(async()=>{const i=t.get("code"),c=t.get("error"),u=t.get("error_description"),p=t.get("state");if(c){n("error"),o(u||"Authorization was denied"),me.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:f,error:g}=await H.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(g)throw g;if(f!=null&&f.success)n("success"),o(f.message||"Successfully connected Google Business Profile!"),me.success("Google Business Profile connected!");else throw new Error((f==null?void 0:f.error)||"Unknown error")}catch(f){console.error("Google OAuth callback error:",f),n("error"),o(f instanceof Error?f.message:"Failed to connect Google Business Profile"),me.error("Failed to connect: "+(f instanceof Error?f.message:"Unknown error"))}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[r==="loading"&&e.jsx(bs,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(gi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(jc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Rt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function Y3s(){const[t]=uc(),s=nr(),[r,n]=N.useState("loading"),[a,o]=N.useState("Connecting your LinkedIn account...");return N.useEffect(()=>{(async()=>{var f;const i=t.get("code"),c=t.get("state"),u=t.get("error"),p=t.get("error_description");if(u){console.error("LinkedIn OAuth error:",u,p),n("error"),o(p||"Failed to connect LinkedIn account"),me.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),me.error("No authorization code received");return}try{const{data:g,error:v}=await H.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(v)throw v;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||1} LinkedIn account`),me.success("LinkedIn connected successfully!");else throw new Error((g==null?void 0:g.error)||"Failed to connect LinkedIn account")}catch(g){console.error("LinkedIn callback error:",g),n("error"),o(g instanceof Error?g.message:"Failed to connect LinkedIn account"),me.error("Failed to connect LinkedIn")}})()},[t]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(Pt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[r==="loading"&&e.jsx(bs,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(gi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(jc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Rt,{className:"flex items-center justify-center gap-2",children:[e.jsx(Mp,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(gr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function Q3s(){const t=nr(),[s,r]=N.useState(null),{data:n,isLoading:a}=Glt(s||void 0,!0),{data:o,isLoading:l}=N3e(!0),{cartItems:i}=Pue(),c=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Ts,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>e.jsx(vs,{className:"h-10 w-24 flex-shrink-0"},p))}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>e.jsx(vs,{className:"h-72 w-full"},p))})]})}):e.jsx(Ts,{title:"Marketplace",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),e.jsxs(K,{variant:"outline",onClick:()=>t("/marketplace/cart"),className:"relative",children:[e.jsx(vp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(st,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:c})]})]}),o&&o.length>0&&e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.jsx(K,{variant:s===null?"default":"outline",size:"sm",onClick:()=>r(null),children:"All"}),o.map(p=>e.jsx(K,{variant:s===p.id?"default":"outline",size:"sm",onClick:()=>r(p.id),children:p.name},p.id))]}),n&&n.length>0?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var f;return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>u(p),children:[e.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?e.jsx("img",{src:((f=p.images.find(g=>g.is_primary))==null?void 0:f.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Al,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(st,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Al,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No products available yet."})]})]})})}const Tct=N.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Tct.displayName="Breadcrumb";const Act=N.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:It("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Act.displayName="BreadcrumbList";const Wie=N.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:It("inline-flex items-center gap-1.5",t),...s}));Wie.displayName="BreadcrumbItem";const Nwe=N.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?j2e:"a";return e.jsx(a,{ref:n,className:It("transition-colors hover:text-foreground",s),...r})});Nwe.displayName="BreadcrumbLink";const Ect=N.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:It("font-normal text-foreground",t),...s}));Ect.displayName="BreadcrumbPage";const kwe=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:It("[&>svg]:size-3.5",s),...r,children:t??e.jsx(oa,{})});kwe.displayName="BreadcrumbSeparator";function X3s(){var ee,Q;const{productId:t}=lo(),s=nr(),{data:r,isLoading:n}=l4s(t||""),{addToCart:a,cartItems:o}=Pue(),[l,i]=N.useState(null),[c,u]=N.useState(1),[p,f]=N.useState(0),[g,v]=N.useState(null),[_,w]=N.useState(!1),[j,k]=N.useState(!1),S=(ee=r==null?void 0:r.variants)==null?void 0:ee.find(ce=>ce.id===l),M=((Q=r==null?void 0:r.variants)==null?void 0:Q.filter(ce=>ce.is_active))||[],L=Number((r==null?void 0:r.base_price)||0),P=S?Number(S.price_adjustment):0,O=L+P,$=Number((r==null?void 0:r.shipping_fee)||0),U=o.reduce((ce,ne)=>ce+ne.quantity,0),B=async ce=>{if(!ce.target.files||ce.target.files.length===0)return;w(!0);const ne=ce.target.files[0],re=ne.name.split(".").pop(),oe=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${re}`;try{const{error:fe}=await H.storage.from("marketplace").upload(oe,ne);if(fe)throw fe;const{data:{publicUrl:ge}}=H.storage.from("marketplace").getPublicUrl(oe);v(ge),me.success("Artwork uploaded successfully")}catch(fe){me.error("Failed to upload artwork: "+fe.message)}finally{w(!1)}},V=()=>{if(r){if(M.length>0&&!l){me.error("Please select an option");return}a(r,S||void 0,c,g||void 0),k(!0),me.success("Added to cart!"),setTimeout(()=>k(!1),2e3)}},X=()=>{r!=null&&r.images&&f(ce=>(ce+1)%r.images.length)},Y=()=>{r!=null&&r.images&&f(ce=>(ce-1+r.images.length)%r.images.length)};return n?e.jsx(Ts,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(vs,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{className:"h-8 w-3/4"}),e.jsx(vs,{className:"h-6 w-1/4"}),e.jsx(vs,{className:"h-24 w-full"}),e.jsx(vs,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Ts,{title:r.name,children:[e.jsx(Tct,{className:"mb-6",children:e.jsxs(Act,{children:[e.jsx(Wie,{children:e.jsx(Nwe,{asChild:!0,children:e.jsx(pa,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(kwe,{}),e.jsx(Wie,{children:e.jsx(Nwe,{asChild:!0,children:e.jsx(pa,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(kwe,{}),e.jsx(Wie,{children:e.jsx(Ect,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:Y,children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:X,children:e.jsx(oa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Al,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((ce,ne)=>e.jsx("button",{onClick:()=>f(ne),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ne===p?"border-primary":"border-transparent"}`,children:e.jsx("img",{src:ce.image_url,alt:"",className:"w-full h-full object-cover"})},ce.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(st,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",O.toFixed(2)]}),$>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",$.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),M.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(ce=>e.jsxs(K,{variant:l===ce.id?"default":"outline",onClick:()=>i(ce.id),children:[ce.name,Number(ce.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(ce.price_adjustment)>0?"+":"","$",Number(ce.price_adjustment).toFixed(2),")"]})]},ce.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Upload Your Artwork (Optional)"}),g?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:g,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(K,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>v(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:B,className:"hidden",id:"artwork-upload",disabled:_}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(di,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>Math.max(1,ce-1)),children:"-"}),e.jsx(ze,{type:"number",value:c,onChange:ce=>u(Math.max(1,parseInt(ce.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(ce=>ce+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:V,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ba,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(vp,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),e.jsxs(K,{variant:"outline",size:"lg",onClick:()=>s("/marketplace/cart"),className:"relative",children:[e.jsx(vp,{className:"h-5 w-5"}),U>0&&e.jsx(st,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:U})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Ts,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Al,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),e.jsx(K,{onClick:()=>s("/marketplace"),children:"Back to Marketplace"})]})})}function J3s(){const t=nr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=Pue(),[u,p]=N.useState(!1),[f,g]=N.useState(""),v=async()=>{if(s.length===0){me.error("Your cart is empty");return}p(!0);try{const{data:_,error:w}=await H.functions.invoke("marketplace-checkout",{body:{items:s.map(j=>{var k;return{product_id:j.product.id,variant_id:((k=j.variant)==null?void 0:k.id)||null,quantity:j.quantity,artwork_url:j.artworkUrl||null}}),notes:f.trim()||null}});if(w)throw w;if(_!=null&&_.url)c(),window.open(_.url,"_blank");else throw new Error("No checkout URL received")}catch(_){me.error("Checkout failed: "+_.message)}finally{p(!1)}};return s.length===0?e.jsx(Ts,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(b0,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ts,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(_=>{var w,j;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:_.product.images&&_.product.images.length>0?e.jsx("img",{src:((w=_.product.images.find(k=>k.is_primary))==null?void 0:w.image_url)||_.product.images[0].image_url,alt:_.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(b0,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:_.product.name}),_.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:_.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(_).toFixed(2),Number(_.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(_.product.shipping_fee).toFixed(2)," shipping"]})]}),_.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return r(_.product.id,(k=_.variant)==null?void 0:k.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(_.product.id,(k=_.variant)==null?void 0:k.id,_.quantity-1)},disabled:_.quantity<=1,children:e.jsx(y0,{className:"h-3 w-3"})}),e.jsx(ze,{type:"number",value:_.quantity,onChange:k=>{var S;return n(_.product.id,(S=_.variant)==null?void 0:S.id,parseInt(k.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var k;return n(_.product.id,(k=_.variant)==null?void 0:k.id,_.quantity+1)},children:e.jsx(qs,{className:"h-3 w-3"})})]})]})]})})},`${_.product.id}-${((j=_.variant)==null?void 0:j.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((_,w)=>_+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(al,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",i().toFixed(2)]})]}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Pr,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:_=>g(_.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:v,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Sa,{className:"h-5 w-5 ml-2"})]})}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Secure checkout powered by Stripe"})]})]})})]})})}function eCs(){const t=nr(),{data:s,isLoading:r}=v4s();return r?e.jsx(Ts,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(vs,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Ts,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Al,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),e.jsx(K,{onClick:()=>t("/marketplace"),children:"Browse Marketplace"})]})}):e.jsx(Ts,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ms(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(st,{className:j3e[n.status],children:vT[n.status]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,c)=>e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",style:{zIndex:3-c},children:[i.quantity,"×"]},i.id)),n.items&&n.items.length>3&&e.jsxs("div",{className:"w-10 h-10 bg-muted rounded border-2 border-background flex items-center justify-center text-xs font-medium",children:["+",n.items.length-3]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:((o=n.items)==null?void 0:o.length)===1?n.items[0].product_name:`${(l=n.items)==null?void 0:l.length} items`}),e.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&e.jsxs(K,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[e.jsx(en,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(oa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const s9e=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function tCs({currentStatus:t,statusHistory:s}){const r=s9e.indexOf(t);return e.jsx("div",{className:"space-y-3",children:s9e.map((n,a)=>{const o=s==null?void 0:s.find(u=>u.status===n),l=ar;return e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${l?"bg-green-500 text-white":i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:l?e.jsx(sa,{className:"h-4 w-4"}):i?e.jsx(un,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${c?"text-muted-foreground":""}`,children:vT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ms(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function sCs(){var k;const{orderId:t}=lo(),s=nr(),{data:r,isLoading:n,refetch:a}=b4s(t||""),o=j4s(),l=N4s(),[i,c]=N.useState(!1),[u,p]=N.useState(null),[f,g]=N.useState(""),[v,_]=N.useState(null),w=async S=>{_(S);try{await o.mutateAsync({orderId:t,itemId:S}),me.success("Proof approved!"),a()}catch{me.error("Failed to approve proof")}finally{_(null)}},j=async()=>{if(u){_(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),c(!1),g(""),p(null),a()}catch{me.error("Failed to request revision")}finally{_(null)}}};return n?e.jsx(Ts,{title:"Order Details",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(vs,{className:"h-64 w-full"}),e.jsx(vs,{className:"h-48 w-full"})]}),e.jsx(vs,{className:"h-96 w-full"})]})}):r?e.jsxs(Ts,{title:`Order ${r.order_number}`,children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsx(Rt,{children:"Order Status"}),e.jsx(st,{className:j3e[r.status],children:vT[r.status]})]}),e.jsx(Oe,{children:e.jsx(tCs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(k=r.items)==null?void 0:k.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(G_,{className:"h-4 w-4"}),"View Artwork",e.jsx(en,{className:"h-3 w-3"})]})]}),S.proof_url&&e.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),e.jsxs("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(G_,{className:"h-4 w-4"}),"View Proof",e.jsx(en,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>w(S.id),disabled:v===S.id,children:[v===S.id?e.jsx(bs,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(nh,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(S.id),c(!0)},disabled:v===S.id,children:[e.jsx(HL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(st,{className:"bg-green-100 text-green-800",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(st,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(QM,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(en,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ms(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Subtotal"}),e.jsxs("span",{children:["$",Number(r.subtotal).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",Number(r.shipping_total).toFixed(2)]})]})]}),e.jsx(al,{}),e.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{children:["$",Number(r.total).toFixed(2)]})]}),r.notes&&e.jsxs(e.Fragment,{children:[e.jsx(al,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-1",children:"Order Notes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.notes})]})]})]})]})})]}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Request Changes"}),e.jsx(Wr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Pr,{placeholder:"Describe the changes needed...",value:f,onChange:S=>g(S.target.value),rows:4}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:j,disabled:!f.trim()||v!==null,children:[v?e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Ts,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Al,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),e.jsx(K,{onClick:()=>s("/marketplace/orders"),children:"View All Orders"})]})})}function rCs(){const t=nr(),[s]=uc();return s.get("session_id"),N.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Ts,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(sa,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Your order has been confirmed and is being processed. You'll receive an email confirmation shortly."}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[e.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"What happens next?"]}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("li",{children:"• We'll review your order and prepare it for production"}),e.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),e.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),e.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{className:"flex-1",onClick:()=>t("/marketplace/orders"),children:["View My Orders",e.jsx(Sa,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function nCs(){const{user:t}=Os(),[s,r]=N.useState("store"),[n,a]=N.useState(null),[o,l]=N.useState(null),[i,c]=N.useState(!1),[u,p]=N.useState(5),[f,g]=N.useState(""),[v,_]=N.useState(!1),[w,j]=N.useState(!1),[k,S]=N.useState(""),[M,L]=N.useState(null),[P,O]=N.useState(!1),{hasSubmittedReview:$,submitReview:U,markPostedToGoogle:B}=JYe(),{data:V}=Klt(),{data:X,isLoading:Y}=Wlt(),{data:ee,isLoading:Q}=E4s(n),{data:ce,isLoading:ne}=P4s(t==null?void 0:t.id),{data:re=0}=L4s(t==null?void 0:t.id),oe=D4s(),fe=new Set((ce==null?void 0:ce.map(Ie=>Ie.item_id))||[]),ge=async()=>{if(o)try{const Ie=await oe.mutateAsync(o.id);o.item_type==="reelflow_credits"?me.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):me.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ie){me.error(Ie.message||"Failed to purchase item")}},ue=async()=>{if(!f.trim()){me.error("Please write a review");return}_(!0);const Ie=await U(u,f);_(!1),Ie.success?(me.success("Thank you for your review! You earned 25 points!"),S(f),j(!0),g(""),p(5)):me.error(Ie.error||"Failed to submit review")},xe=()=>{navigator.clipboard.writeText(k),me.success("Review copied to clipboard!")},_e=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},$e=()=>{j(!1),c(!1),S("")};return Y||Q||ne?e.jsx(Ts,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-24 w-full"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(Ie=>e.jsx(vs,{className:"h-64"},Ie))})]})}):e.jsxs(Ts,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),e.jsx(Ee,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Jn,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),e.jsx("p",{className:"text-3xl font-bold text-primary",children:re.toLocaleString()})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vo,{className:"h-4 w-4"}),e.jsx("span",{children:"Earn points by attending events"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(sh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(vf,{open:P,onOpenChange:O,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(bf,{asChild:!0,children:e.jsx(Pt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(vo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"How to Earn Points"}),e.jsx(gr,{children:"See all the ways you can earn spendable points"})]})]}),P?e.jsx(xf,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(oo,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(_f,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[V==null?void 0:V.filter(Ie=>Ie.is_active).map(Ie=>{const ke=pe=>{switch(pe){case"event_attendance":return e.jsx(hn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Jn,{className:"h-5 w-5"});case"add_listing":return e.jsx(dn,{className:"h-5 w-5"});case"first_contact":return e.jsx(hr,{className:"h-5 w-5"});case"first_video":return e.jsx(Cn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(so,{className:"h-5 w-5"});default:return e.jsx(So,{className:"h-5 w-5"})}};return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0",children:ke(Ie.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ie.action_name}),Ie.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ie.description})]}),e.jsxs(st,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ie.points]})]},Ie.id)}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:e.jsx(sh,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),e.jsx(st,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(so,{className:"h-6 w-6 text-yellow-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),e.jsxs(K,{onClick:()=>c(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(_a,{value:s,onValueChange:r,children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"store",className:"flex items-center gap-2",children:[e.jsx(b0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(ns,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(Al,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(st,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(ws,{value:"store",className:"mt-6",children:[X&&X.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),X.map(Ie=>e.jsxs(K,{variant:n===Ie.id?"default":"outline",size:"sm",onClick:()=>a(Ie.id),children:[Ie.icon&&`${Ie.icon} `,Ie.name]},Ie.id))]}),!ee||ee.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(So,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No items available"}),e.jsx("p",{className:"text-sm",children:"Check back later for new rewards!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ee.map(Ie=>{const ke=Ie.item_type==="reelflow_credits",pe=!ke&&fe.has(Ie.id),we=!ke&&Ie.max_quantity!==null&&Ie.current_quantity===0,Le=re>=Ie.points_cost;return e.jsxs(Ee,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${pe?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>L(Ie),children:[Ie.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ie.preview_image_url,alt:Ie.name,className:"w-full h-full object-cover"}),pe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})}),we&&!pe&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(st,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(So,{className:"h-12 w-12 text-muted-foreground/50"}),pe&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(st,{className:"bg-green-500 text-white",children:[e.jsx(sa,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Pt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Rt,{className:"text-lg",children:Ie.name}),e.jsxs(st,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ie.points_cost]})]}),Ie.category&&e.jsxs(st,{variant:"outline",className:"w-fit",children:[Ie.category.icon&&`${Ie.category.icon} `,Ie.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(gr,{className:"mb-4 line-clamp-2",children:Ie.description||"No description available"}),Ie.max_quantity!==null&&!pe&&!ke&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ie.current_quantity," of ",Ie.max_quantity," remaining"]}),ke&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Ie.max_quantity," ReelFlow credits per purchase"]}),pe?e.jsx(K,{className:"w-full",onClick:Qe=>{Qe.stopPropagation(),Ie.file_url&&$ye(Ie.file_url,Ie.name)},disabled:!Ie.file_url,children:Ie.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:Qe=>{Qe.stopPropagation(),l(Ie)},disabled:we||!Le,children:we?"Sold Out":Le?e.jsxs(e.Fragment,{children:[e.jsx(b0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ie.points_cost-re} more pts`})]})]},Ie.id)})})]}),e.jsx(ws,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Al,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ce.map(Ie=>{var ke,pe,we,Le,Qe,Te,pt;return e.jsxs(Ee,{className:"overflow-hidden",children:[(ke=Ie.item)!=null&&ke.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ie.item.preview_image_url,alt:((pe=Ie.item)==null?void 0:pe.name)||"Reward",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:e.jsx(So,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Pt,{className:"pb-2",children:[e.jsx(Rt,{className:"text-lg",children:((we=Ie.item)==null?void 0:we.name)||"Unknown Item"}),e.jsxs(gr,{className:"text-xs",children:["Purchased for ",Ie.points_spent," points • ",new Date(Ie.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:((Le=Ie.item)==null?void 0:Le.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(sa,{className:"h-4 w-4 mr-2 text-green-500"}),(Qe=Ie.item)==null?void 0:Qe.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var ye,qe;(ye=Ie.item)!=null&&ye.file_url&&$ye(Ie.item.file_url,(qe=Ie.item)==null?void 0:qe.name)},disabled:!((Te=Ie.item)!=null&&Te.file_url),children:((pt=Ie.item)==null?void 0:pt.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ie.id)})})})]})]}),e.jsx(Mc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Confirm Purchase"}),e.jsxs(ic,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",(o==null?void 0:o.item_type)==="reelflow_credits"&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{}),"🎬 ",e.jsxs("strong",{children:[o==null?void 0:o.max_quantity," ReelFlow credits"]})," will be added to your balance instantly."]}),e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[re," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[re-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:ge,disabled:oe.isPending,children:oe.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(xs,{open:i,onOpenChange:Ie=>{!Ie&&w?$e():c(Ie)},children:e.jsx(fs,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Wr,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',k,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:xe,children:[e.jsx(yi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(Un,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:$e,children:"Maybe Later"}),e.jsxs(K,{onClick:_e,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Leave a Review"}),e.jsx(Wr,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Ie=>e.jsx("button",{type:"button",onClick:()=>p(Ie),className:"focus:outline-none",children:e.jsx(Jn,{className:`h-8 w-8 transition-colors ${u>=Ie?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ie))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Pr,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ie=>g(Ie.target.value),rows:4})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:ue,disabled:v,className:"bg-yellow-600 hover:bg-yellow-700",children:v?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(xs,{open:!!M,onOpenChange:()=>L(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[M==null?void 0:M.name,e.jsxs(st,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),M==null?void 0:M.points_cost]})]}),(M==null?void 0:M.category)&&e.jsxs(st,{variant:"outline",className:"w-fit",children:[M.category.icon&&`${M.category.icon} `,M.category.name]})]}),(M==null?void 0:M.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:M.preview_image_url,alt:M.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(M==null?void 0:M.description)||"No description available"}),(M==null?void 0:M.item_type)==="reelflow_credits"&&e.jsxs("p",{className:"text-sm text-violet-600 font-medium",children:["🎬 Grants ",M==null?void 0:M.max_quantity," ReelFlow credits per purchase"]}),(M==null?void 0:M.item_type)!=="reelflow_credits"&&(M==null?void 0:M.max_quantity)!==null&&!fe.has((M==null?void 0:M.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[M==null?void 0:M.current_quantity," of ",M==null?void 0:M.max_quantity," remaining"]})]}),e.jsx(Un,{children:M&&M.item_type!=="reelflow_credits"&&fe.has(M.id)?e.jsx(K,{className:"w-full",onClick:()=>{M.file_url&&$ye(M.file_url,M.name)},disabled:!M.file_url,children:M.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Access"]})}):M&&e.jsx(K,{className:"w-full",onClick:()=>{L(null),l(M)},disabled:M.item_type!=="reelflow_credits"&&M.max_quantity!==null&&M.current_quantity===0||re{const{user:t}=Os(),s=Xt(),r=mt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=mt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await H.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Lt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Lt({mutationFn:async({id:u,...p})=>{const{data:f,error:g}=await H.from("smart_presentations").update(p).eq("id",u).select().single();if(g)throw g;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Lt({mutationFn:async u=>{const{data:p,error:f}=await H.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=Lt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation archived")}}),c=Lt({mutationFn:async u=>{const{error:p}=await H.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),me.success("Saved as template!")}});return{presentations:r.data||[],templates:n.data||[],isLoading:r.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:c}},aCs=()=>{const t=nr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Pct(),o=i=>i.status==="draft"?e.jsx(st,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(st,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(st,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(st,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const c=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(c),me.success("Link copied!")};return e.jsx(Ts,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(vs,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ty,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Create your first Smart Presentation to impress clients with personalized, video-first content."}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(wn,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",ms(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&e.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>t(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Aa,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(en,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Aa,{onClick:()=>a.mutate(i),children:[e.jsx(wn,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Aa,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(IM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},r9e={Welcome:[{label:"Warm & Personal",text:"Hey there! I'm so glad you're here. I put this presentation together just for you because I truly believe we'd make a great team. Over the next few minutes, I'll walk you through exactly how I can help you achieve your real estate goals. Let's dive in!"},{label:"Professional & Confident",text:"Welcome! Thank you for taking the time to check this out. I've prepared this presentation specifically with your needs in mind. I want to show you what sets me apart, the results I've delivered, and how I plan to make your experience smooth and successful. Let's get started!"}],"About Me":[{label:"Relatable Story",text:"Let me tell you a little about myself. I didn't just fall into real estate — I chose it because I love helping people with one of the biggest decisions of their lives. Every client I work with gets my full attention, my honest advice, and someone who truly has their back from start to finish."},{label:"Results-Focused",text:"Here's what I want you to know about me: I'm not just another agent. I've helped dozens of families find their perfect home and get top dollar for their properties. I stay on top of the market, I communicate constantly, and I don't stop until we hit your goals."}],"Market Update":[{label:"Engaging Overview",text:"Let's talk about what's happening in the market right now. I want you to feel confident and informed, so here's the honest picture. I'll break down the key numbers, what they mean for you, and how we can use current conditions to your advantage. Knowledge is power!"},{label:"Buyer-Focused",text:"The market is always moving, and I want to make sure you're in the best position possible. Here's what the latest data tells us, what opportunities are out there for you, and why timing matters. Let me walk you through it."}],"My Process":[{label:"Step-by-Step",text:"I want you to know exactly what to expect when we work together. My process is simple, clear, and designed to take the stress out of the equation. From our first conversation all the way to closing day, I'll be right there guiding you every step of the way. Here's how it works."},{label:"Client-Centered",text:"One thing my clients always tell me is how easy and stress-free the process was. That's not by accident — I've refined my approach over the years to make sure you always know what's happening, what's next, and that someone's got your back. Let me show you how."}],Testimonials:[{label:"Social Proof",text:"Don't just take my word for it — let me share what some of my past clients have said. These are real people, real experiences, and real results. I'm proud of the relationships I've built and the outcomes we've achieved together."}],Pricing:[{label:"Transparent & Value-Driven",text:"Let's talk about the investment. I believe in being completely transparent about pricing because trust is everything. Here's what you get when you work with me, and why my clients say it's the best decision they made. Let me walk you through it."}],"Call to Action":[{label:"Warm Close",text:"So here's my ask — let's connect! I'd love to hop on a quick call, answer any questions you have, and see how I can help. No pressure, no obligation — just a real conversation about your goals. Click the button below and let's make it happen!"},{label:"Urgency Close",text:"The market waits for no one, and neither should you. Let's get started today! Click the link below to schedule a quick chat. I promise — this could be the best 15 minutes you invest in your real estate journey."}]},iCs=[{label:"Engaging Introduction",text:"In this section, I want to share something important with you. I've put real thought into this, and I think you'll find it valuable. Let me walk you through what I've prepared — I'm excited for you to see it!"},{label:"Keep It Simple",text:"Let me keep this short and sweet. Here's what you need to know, and why it matters for you. I'm always about giving you the real picture — no fluff, just the facts and my honest take."}];function oCs(t){const s=r9e[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(r9e))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return iCs}function lCs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=N.useState(!1),[o,l]=N.useState("script"),[i,c]=N.useState(0),[u,p]=N.useState(0),{canRecord:f}=iit(),g=L3(),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(!0),[M,L]=N.useState(!1),[P,O]=N.useState(null),$=oCs(t),U=()=>{l("script"),c(0),p(0),_(""),j(!1),S(!0),L(!1),O(null)},B=Q=>{!Q&&(o==="uploading"||o==="processing")||(a(Q),Q||U())},V=Q=>{O(Q),_($[Q].text),j(!1)},X=()=>{l("record"),S(v.trim().length>0)},Y=()=>{_(""),S(!1),l("record")},ee=N.useCallback(async(Q,ce)=>{l("uploading");try{const ne=t||"Presentation Video",{videoId:re,uploadUrl:oe,libraryId:fe}=await SR(ne),{apiKey:ge}=await CR(re),ue=new XMLHttpRequest;ue.upload.onprogress=Ie=>{Ie.lengthComputable&&c(Ie.loaded/Ie.total*100)},await new Promise((Ie,ke)=>{ue.onload=()=>ue.status>=200&&ue.status<300?Ie():ke(new Error("Upload failed")),ue.onerror=()=>ke(new Error("Upload failed")),ue.open("PUT",oe),ue.setRequestHeader("AccessKey",ge),ue.send(Q)}),l("processing");let xe=0;const _e=Date.now(),$e=9e4;let Me=null;for(;xe<4;){if(await new Promise(ke=>setTimeout(ke,3e3)),Date.now()-_e>$e){const ke=Q.size/1048576,pe=`https://iframe.mediadelivery.net/embed/${fe}/${re}?responsive=true`;await g.mutateAsync({bunny_video_id:re,playback_url:pe,file_size_mb:ke,title:ne,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(pe),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ie=await AA(re);if(xe=Ie.status,p(Ie.encodeProgress||0),xe===4)Me={playbackUrl:Ie.directPlayUrl,thumbnailUrl:Ie.thumbnailUrl,previewUrl:Ie.previewUrl||null,duration:Ie.length||ce,fileSizeMb:(Ie.storageSize||Q.size)/(1024*1024)};else if(xe===5||xe===6)throw new Error("Video processing failed")}if(!Me)throw new Error("No video data");await g.mutateAsync({bunny_video_id:re,contact_id:s||void 0,playback_url:Me.playbackUrl,thumbnail_url:Me.thumbnailUrl,preview_url:Me.previewUrl,duration_seconds:Me.duration,file_size_mb:Me.fileSizeMb,title:ne,status:"ready",touch_type:"presentation"}),r(Me.playbackUrl),me.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ne){console.error("Recording upload error:",ne),me.error("Failed to process video. Please try again."),l("record")}},[t,s,r,g]);return e.jsxs(xs,{open:n,onOpenChange:B,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(js,{children:e.jsxs(_s,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:$.map((Q,ce)=>e.jsxs("button",{onClick:()=>V(ce),className:It("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",P===ce?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(wn,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Q.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Q.text})]},ce))})]}),v&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 text-xs gap-1",children:[e.jsx(za,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Pr,{value:v,onChange:Q=>_(Q.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):e.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:v})]}),!v&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),e.jsx(Pr,{value:v,onChange:Q=>{_(Q.target.value),O(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:Y,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:X,disabled:!1,children:v.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(Yu,{className:"h-10 w-10 text-destructive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached your video storage limit. Delete some videos to free up space."})]}):o==="record"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 5 minutes. Saved to your library & auto-attached."}),v.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>S(!k),className:"h-7 text-xs gap-1",children:[k?e.jsx(kp,{className:"h-3 w-3"}):e.jsx(Dn,{className:"h-3 w-3"}),k?"Hide Script":"Show Script"]})]}),e.jsx(Tme,{maxDurationSeconds:300,onRecordingComplete:ee,onRecordingStateChange:L,onError:Q=>me.error(Q),teleprompterContent:v.trim()?e.jsx(jlt,{text:v,isVisible:k,onToggleVisibility:()=>S(!k),isRecording:M,startCountdown:!1}):void 0}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(bs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:i,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(bs,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Bi,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(u),"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[e.jsx(gi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function cCs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(null),[i,c]=N.useState("idle"),[u,p]=N.useState(0),f=N.useRef(null),g=L3(),{data:v}=rme(),_=(v==null?void 0:v.total_storage_mb)||0,j=((v==null?void 0:v.max_storage_mb)||1024)-_,k=()=>{l(null),c("idle"),p(0)},S=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||k())},M=$=>{var V;const U=(V=$.target.files)==null?void 0:V[0];if(!U)return;if(!U.type.startsWith("video/")){me.error("Please select a video file");return}const B=U.size/(1024*1024);if(B>500){me.error("Video file must be less than 500MB");return}if(B>j){me.error(`Not enough storage. You have ${j.toFixed(1)} MB remaining.`);return}l(U)},L=N.useCallback(async()=>{if(o){c("creating"),p(0);try{const $=t||o.name,{data:U,error:B}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(B)throw new Error(B.message);const{videoId:V,libraryId:X}=U;c("uploading");const{data:Y,error:ee}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(ee)throw new Error(ee.message);await new Promise((ne,re)=>{const oe=new XMLHttpRequest;oe.upload.addEventListener("progress",fe=>{fe.lengthComputable&&p(Math.round(fe.loaded/fe.total*100))}),oe.addEventListener("load",()=>oe.status>=200&&oe.status<300?ne():re(new Error(`Upload failed (${oe.status})`))),oe.addEventListener("error",()=>re(new Error("Upload failed"))),oe.open("PUT",Y.uploadUrl),oe.setRequestHeader("AccessKey",Y.apiKey),oe.send(o)}),c("processing");const Q=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${X}/${V}`;await g.mutateAsync({bunny_video_id:V,playback_url:ce,file_size_mb:Q,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),c("done"),me.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),me.error($ instanceof Error?$.message:"Failed to upload video"),c("idle")}}},[o,t,s,r,g]),P=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},O=i!=="idle"&&i!=="done";return e.jsxs(xs,{open:n,onOpenChange:S,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(js,{children:e.jsxs(_s,{children:['Upload Video for "',t,'"']})}),e.jsxs("div",{className:"space-y-4 py-2",children:[o?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Cn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!O&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},children:[e.jsx(di,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:f,type:"file",accept:"video/*",className:"hidden",onChange:M,disabled:O}),O&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:P()})]}),e.jsx(Bi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),disabled:O,children:"Cancel"}),e.jsx(K,{onClick:L,disabled:!o||O,children:O?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const n9e=[{value:"schedule_call",label:"Schedule a Call"},{value:"ready_to_list",label:"Ready to List"},{value:"request_pricing",label:"Request Pricing Update"},{value:"sign_agreement",label:"Sign Buyer Agreement"},{value:"text_questions",label:"Text Me Questions"}],a9e=()=>{const t=nr(),{id:s}=lo(),{user:r}=Os(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Pct(),{isGmailConnected:c,gmailEmail:u}=Zx(),[p,f]=N.useState(!1),[g,v]=N.useState("client"),[_,w]=N.useState(!1),[j,k]=N.useState(""),[S,M]=N.useState([]),[L,P]=N.useState(!1),[O,$]=N.useState(null),[U,B]=N.useState(!1),[V,X]=N.useState(""),[Y,ee]=N.useState(""),[Q,ce]=N.useState(""),[ne,re]=N.useState("buyer"),[oe,fe]=N.useState(""),[ge,ue]=N.useState(null),[xe,_e]=N.useState(""),[$e,Me]=N.useState([]),[Ie,ke]=N.useState("schedule_call"),[pe,we]=N.useState("Schedule a Call"),[Le,Qe]=N.useState(""),[Te,pt]=N.useState(""),[ye,qe]=N.useState(null),[at,tt]=N.useState(s||null),[Ae,rt]=N.useState(null),[He,ct]=N.useState(!1),Ue=async(xt,Ps)=>{if(!r)return;const mr=5*1024*1024;if(xt.size>mr){me.error("Image must be under 5MB");return}if(!xt.type.startsWith("image/")){me.error("Please upload an image file");return}qe(Ps);try{const Tr=xt.name.split(".").pop()||"jpg",Dr=`${r.id}/${Date.now()}.${Tr}`,{error:xn}=await H.storage.from("listing-photos").upload(Dr,xt);if(xn)throw xn;const{data:{publicUrl:Si}}=H.storage.from("listing-photos").getPublicUrl(Dr);Dt(Ps,{image_url:Si}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{qe(null)}};N.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async xt=>{const{data:Ps,error:mr}=await H.from("smart_presentations").select("*").eq("id",xt).single();if(mr||!Ps)return;const Tr=Ps;if(w(!0),_e(Tr.title),X(Tr.client_name||""),fe(Tr.property_address||""),Me(Tr.sections||[]),ke(Tr.cta_type||"schedule_call"),we(Tr.cta_label||"Schedule a Call"),Qe(Tr.cta_url||""),pt(Tr.heading||""),rt(Tr.share_token),ct(Tr.status==="published"),tt(Tr.id),v("builder"),Tr.contact_id){const{data:Dr}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",Tr.contact_id).maybeSingle();Dr&&($(Dr),ee(Dr.email||""),ce(Dr.phone||""))}};N.useEffect(()=>{if(!r||j.length<1){M([]);return}const xt=setTimeout(async()=>{P(!0);const{data:Ps}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${j}%,last_name.ilike.%${j}%,email.ilike.%${j}%`).limit(10);M(Ps||[]),P(!1)},300);return()=>clearTimeout(xt)},[j,r]);const Je=xt=>{$(xt),X(`${xt.first_name} ${xt.last_name||""}`.trim()),ee(xt.email||""),ce(xt.phone||""),B(!1)},Ge=async()=>{if(!V.trim()){me.error("Client name is required");return}const xt=V.trim().split(" "),Ps=xt[0],mr=xt.slice(1).join(" ")||null,{data:Tr,error:Dr}=await H.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:Ps,last_name:mr,email:Y||null,phone:Q||null,lead_source:"Smart Presentation"}).select().single();if(Dr){me.error("Failed to create client");return}$(Tr),me.success("Client created & saved to Agent OS"),v("template")},et=xt=>{ue(xt);const Ps=(xt.sections||[]).map(mr=>({...mr,is_visible:!0,video_url:"",text:""}));if(Me(Ps),_e(xt.name+(V?` for ${V}`:"")),xt.cta_config){const mr=xt.cta_config;ke(mr.type||"schedule_call"),we(mr.label||"Schedule a Call")}v("builder")},it=()=>{Me([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),_e(V?`Presentation for ${V}`:"New Presentation"),v("builder")},Dt=(xt,Ps)=>{Me(mr=>mr.map((Tr,Dr)=>Dr===xt?{...Tr,...Ps}:Tr))},Vt=xt=>{Dt(xt,{is_visible:!$e[xt].is_visible})},hs=()=>{Me(xt=>[...xt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},As=xt=>{Me(Ps=>Ps.filter((mr,Tr)=>Tr!==xt))},Ms=async()=>{if(!xe.trim()){me.error("Title is required");return}try{if(at){const xt=await l.mutateAsync({id:at,title:xe,sections:$e,client_name:V,property_address:oe||null,cta_type:Ie,cta_label:pe,cta_url:Le||null,heading:Te||null});me.success("Saved")}else{const xt=await o.mutateAsync({title:xe,contact_id:(O==null?void 0:O.id)||void 0,client_name:V,property_address:oe||void 0,template_id:(ge==null?void 0:ge.id)||void 0,sections:$e,cta_type:Ie,cta_label:pe,cta_url:Le||void 0,heading:Te||void 0});tt(xt.id),rt(xt.share_token),me.success("Presentation created!")}}catch(xt){console.error("Failed to save presentation:",xt);const Ps=(xt==null?void 0:xt.message)||(xt==null?void 0:xt.toString())||"Unknown error";me.error(`Failed to save: ${Ps}`)}},cs=async()=>{try{await Ms();const xt=at;if(xt){const Ps=await i.mutateAsync(xt);rt(Ps.share_token),ct(!0),v("share")}}catch(xt){console.error("Failed to publish presentation:",xt),me.error(`Failed to publish: ${(xt==null?void 0:xt.message)||"Unknown error"}`)}},er=Ae?`https://presentations.relevelup.com/${Ae}`:"";return e.jsx(Ts,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t("/mission-control/presentations"),children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:_?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[g==="client"&&"Who is this presentation for?",g==="template"&&"Choose a starting template",g==="builder"&&"Customize your presentation",g==="share"&&"Share with your client"]})]})]}),!_&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((xt,Ps)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:It("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",g===xt?"bg-primary text-primary-foreground":Ps<["client","template","builder","share"].indexOf(g)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Ps<["client","template","builder","share"].indexOf(g)?e.jsx(ba,{className:"h-4 w-4"}):Ps+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:xt}),Ps<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},xt))}),g==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),X(""),ee(""),ce(""),B(!1),v("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx($n,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Skip — Use as Lead Gen Tool"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No specific client. Share broadly to capture new leads."})]})]}),e.jsx(Sa,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name or email...",value:j,onChange:xt=>k(xt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[L&&e.jsx(vs,{className:"h-12 w-full"}),S.map(xt=>e.jsxs("button",{onClick:()=>Je(xt),className:It("w-full text-left p-3 rounded-lg border transition-colors",(O==null?void 0:O.id)===xt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[xt.first_name," ",xt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.email||xt.phone||"No contact info"})]},xt.id)),!j&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),j&&S.length===0&&!L&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),O&&e.jsxs(K,{onClick:()=>v("template"),className:"w-full gap-2",children:["Continue with ",O.first_name,e.jsx(Sa,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(El,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(be,{className:"text-xs",children:"Name *"}),e.jsx(ze,{value:V,onChange:xt=>{X(xt.target.value),B(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Email"}),e.jsx(ze,{value:Y,onChange:xt=>ee(xt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Phone"}),e.jsx(ze,{value:Q,onChange:xt=>ce(xt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Client Type"}),e.jsxs(Ks,{value:ne,onValueChange:re,children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"}),e.jsx(Mt,{value:"recruit",children:"Recruit"}),e.jsx(Mt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Property Address"}),e.jsx(ze,{value:oe,onChange:xt=>fe(xt.target.value),placeholder:"Optional"})]})]}),U&&V&&e.jsxs(K,{onClick:Ge,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Sa,{className:"h-4 w-4"})]})]})]})]})]}),g==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(_a,{defaultValue:"system",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"mine",children:"My Core Templates"}),e.jsx(ns,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(ns,{value:"blank",children:"+ Start Blank"})]}),e.jsx(ws,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(xt=>e.jsx(vs,{className:"h-32"},xt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>!xt.is_system).length===0?e.jsx("p",{className:"text-muted-foreground col-span-2 text-center py-8",children:"You haven't saved any templates yet. Create a presentation and save it as a template!"}):n.filter(xt=>!xt.is_system).map(xt=>e.jsx(i9e,{template:xt,onSelect:et},xt.id))})}),e.jsx(ws,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(xt=>xt.is_system).map(xt=>e.jsx(i9e,{template:xt,onSelect:et},xt.id))})}),e.jsx(ws,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:it,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>v("client"),className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back"]})]}),g==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Presentation Title"}),e.jsx(ze,{value:xe,onChange:xt=>_e(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Page Heading"}),e.jsx(ze,{value:Te,onChange:xt=>pt(xt.target.value),placeholder:V?`Welcome, ${V}!`:"e.g. Welcome! or Your Custom Listing Plan"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Client Name"}),e.jsx(ze,{value:V,onChange:xt=>X(xt.target.value)})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:oe,onChange:xt=>fe(xt.target.value),placeholder:"Optional"})]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),e.jsx(K,{variant:"outline",size:"sm",onClick:hs,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:$e.map((xt,Ps)=>e.jsx(Ee,{className:It(!xt.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(Mu,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:xt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ze,{value:xt.title,onChange:mr=>Dt(Ps,{title:mr.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Vt(Ps),children:xt.is_visible?e.jsx(Dn,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>As(Ps),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx(ze,{value:xt.description||"",onChange:mr=>Dt(Ps,{description:mr.target.value}),placeholder:"Section description...",className:"text-sm"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs",children:"Video URL"}),e.jsx(ze,{value:xt.video_url||"",onChange:mr=>Dt(Ps,{video_url:mr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(lCs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:mr=>Dt(Ps,{video_url:mr})}),e.jsx(cCs,{sectionTitle:xt.title,contactId:O==null?void 0:O.id,onVideoReady:mr=>Dt(Ps,{video_url:mr})}),e.jsx(b3e,{userId:r==null?void 0:r.id,onSelect:mr=>Dt(Ps,{video_url:mr})})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),xt.image_url?e.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[e.jsx("img",{src:xt.image_url,alt:"",className:"w-full max-h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Dt(Ps,{image_url:""}),children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[ye===Ps?e.jsx(bs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(u1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:ye===Ps?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:ye===Ps,onChange:mr=>{var Dr;const Tr=(Dr=mr.target.files)==null?void 0:Dr[0];Tr&&Ue(Tr,Ps),mr.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Text (optional)"}),e.jsx(fy,{content:xt.text||"",onChange:mr=>Dt(Ps,{text:mr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Ps))})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"CTA Type"}),e.jsxs(Ks,{value:Ie,onValueChange:xt=>{ke(xt);const Ps=n9e.find(mr=>mr.value===xt);Ps&&we(Ps.label)},children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:n9e.map(xt=>e.jsx(Mt,{value:xt.value,children:xt.label},xt.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Button Label"}),e.jsx(ze,{value:pe,onChange:xt=>we(xt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(be,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(ze,{value:Le,onChange:xt=>Qe(xt.target.value),placeholder:"https://calendly.com/..."}),!Le&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!_&&e.jsxs(K,{variant:"outline",onClick:()=>v("template"),className:"gap-2",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:Ms,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:cs,disabled:i.isPending,className:"gap-2",children:[e.jsx($n,{className:"h-4 w-4"}),He?"Update & Reshare":"Publish & Share"]})]})]})]}),g==="share"&&Ae&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(ba,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",V||"your client",". You'll be notified when they view it."]}),e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[e.jsx(ze,{value:er,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(er),me.success("Link copied!")},children:e.jsx(yi,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{const xt=`Hi ${V||""}! I put together something for you — check it out: ${er}`;navigator.clipboard.writeText(xt),me.success("Message copied!")},children:[e.jsx(so,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${Y||""}?subject=${encodeURIComponent(xe)}&body=${encodeURIComponent(`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`)}`)},children:[e.jsx(lr,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(Kw,{open:p,onOpenChange:f,contact:O?{id:O.id,first_name:O.first_name,last_name:O.last_name,email:Y||O.email||""}:Y?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:Y}:void 0,defaultSubject:xe,defaultBody:`Hi ${(O==null?void 0:O.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${er} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>v("builder"),children:[e.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},i9e=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(st,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),dCs=()=>{var w;const{shareToken:t}=lo(),[s,r]=N.useState(null),[n,a]=N.useState(!0),[o,l]=N.useState(0),[i,c]=N.useState(!1);N.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),N.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:j,error:k}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(k||!j){c(!0),a(!1);return}const{data:S}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let M;if(S!=null&&S.brokerage_id){const{data:P}=await H.from("brokerages").select("name").eq("id",S.brokerage_id).single();M=(P==null?void 0:P.name)||void 0}let L=null;if(j.contact_id){const{data:P}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();L=P}r({...j,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:M,contact_name:L?[L.first_name,L.last_name].filter(Boolean).join(" "):void 0,contact_email:(L==null?void 0:L.email)||void 0,contact_phone:(L==null?void 0:L.phone)||void 0}),a(!1);try{await H.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await H.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(vs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(vs,{className:"h-64 w-full"}),e.jsx(vs,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(j=>j.is_visible!==!1),g=f[o],v=j=>{const k=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(k)return`https://www.youtube.com/embed/${k[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const L=j.replace("/play/","/embed/"),P=L.includes("?")?"&":"?";return`${L}${P}responsive=true`}if(j.includes("iframe.mediadelivery.net")){if(j.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const P=j.includes("?")?"&":"?";return`${j}${P}responsive=true`}return""}const S=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const M=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return M?`https://iframe.mediadelivery.net/embed/${M[1]}/${M[2]}?responsive=true`:j},_=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[g!=null&&g.video_url&&v(g.video_url)?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:v(g.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):g!=null&&g.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:g.image_url,alt:g.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:g==null?void 0:g.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:g==null?void 0:g.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:g==null?void 0:g.description})]}),(g==null?void 0:g.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:g.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:f.map((j,k)=>e.jsx("button",{onClick:()=>l(k),className:It("w-full text-left p-4 rounded-xl border transition-all",o===k?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(k+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},k))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),_?e.jsxs(K,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[s.cta_label,e.jsx(en,{className:"h-5 w-5 ml-2"})]}):e.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:e.jsx(kWe,{presentationId:s.id,ctaLabel:s.cta_label,agentName:s.owner_name||void 0,prefillName:s.contact_name,prefillEmail:s.contact_email,prefillPhone:s.contact_phone})})]})]}),e.jsx("footer",{className:"border-t border-gray-100 bg-white mt-12 py-6 text-center text-xs text-gray-400",children:"Powered by LevelUp"})]})};function uCs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=m4t(t),o=g4t(),l=y4t(),i=v4t(),c=b4t(),[u,p]=N.useState(""),[f,g]=N.useState("rating"),v=async k=>{r(k),k&&(!n||n.length===0)&&await c.mutateAsync(t)},_=async()=>{if(!u.trim())return;const k=(n==null?void 0:n.reduce((S,M)=>Math.max(S,M.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:k+1}),p("")},w=async k=>{await l.mutateAsync({id:k.id,open_house_id:t,is_active:!k.is_active})},j=async k=>{await i.mutateAsync({id:k.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(be,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(H_,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(qr,{checked:s,onCheckedChange:v})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(bs,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(k=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Mu,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:k.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:k.question_type.replace("_"," ")})]}),e.jsx(qr,{checked:k.is_active,onCheckedChange:()=>w(k),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>j(k),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},k.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(ze,{value:u,onChange:k=>p(k.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:k=>k.key==="Enter"&&_()})]}),e.jsxs(Ks,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-28 h-9 text-xs",children:e.jsx(Ys,{})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"rating",children:"Rating"}),e.jsx(Mt,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:_,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})]})})]})}function hCs({open:t,onOpenChange:s,openHouse:r}){const n=CWe(),{user:a}=Os(),o=N.useRef(null),[l,i]=N.useState(r.auto_forward_to_card??!1),[c,u]=N.useState(r.disclosure_pdf_url??""),[p,f]=N.useState(r.enable_survey??!1),[g,v]=N.useState(!1),[_,w]=N.useState(!1),j=async M=>{var U;const L=(U=M.target.files)==null?void 0:U[0];if(!L||!a)return;if(L.size>20*1024*1024){jn({title:"File must be under 20MB",variant:"destructive"});return}if(L.type!=="application/pdf"){jn({title:"Only PDF files are accepted",variant:"destructive"});return}v(!0);const P=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:O}=await H.storage.from("open-house-photos").upload(P,L,{upsert:!0});if(O){jn({title:"Upload failed",description:O.message,variant:"destructive"}),v(!1);return}const{data:$}=H.storage.from("open-house-photos").getPublicUrl(P);u($.publicUrl),v(!1),jn({title:"PDF uploaded!"})},k=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{w(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:p}),jn({title:"Settings saved!"}),s(!1)}catch{jn({title:"Failed to save",variant:"destructive"})}finally{w(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Guest Book Settings"}),e.jsx(Wr,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(be,{className:"text-sm font-medium",children:"Auto-forward to Digital Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After check-in, redirect visitors to your digital business card"})]}),e.jsx(qr,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:j,className:"hidden"}),c?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(wn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:k,children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var M;return(M=o.current)==null?void 0:M.click()},disabled:g,className:"w-full h-24 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:g?e.jsx(bs,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(uCs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:S,disabled:_,className:"w-full",children:_?"Saving...":"Save Settings"})]})]})})}const Ict={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function mCs({question:t,responses:s}){const r=s.filter(l=>l.question_id===t.id&&l.rating_value!=null),n=r.length;if(n===0)return null;const a=r.reduce((l,i)=>l+(i.rating_value||0),0)/n,o=[5,4,3,2,1].map(l=>({val:l,count:r.filter(i=>i.rating_value===l).length,pct:Math.round(r.filter(i=>i.rating_value===l).length/n*100)}));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:t.question_text}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.toFixed(1)," avg (",n," responses)"]})]}),e.jsx("div",{className:"space-y-1",children:o.map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-16 text-muted-foreground text-right",children:Ict[l.val]}),e.jsx("div",{className:"flex-1 h-4 bg-muted/30 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary/70 rounded-full transition-all",style:{width:`${l.pct}%`}})}),e.jsx("span",{className:"w-8 text-muted-foreground",children:l.count})]},l.val))})]})}function pCs({openHouseId:t}){const{data:s,isLoading:r}=x4t(t),{data:n}=SWe(t),a=N.useMemo(()=>{const f={};return n==null||n.forEach(g=>{f[g.id]=g}),f},[n]);if(r||!s)return null;const{questions:o,responses:l}=s;if(o.length===0)return null;const i=o.filter(f=>f.question_type==="rating"),c=o.filter(f=>f.question_type!=="rating"),u=[...new Set(l.map(f=>f.visitor_id))],p=u.length;return p===0?e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(H_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(H_,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(_a,{defaultValue:"summary",children:[e.jsxs(fa,{className:"mb-4",children:[e.jsxs(ns,{value:"summary",className:"text-xs gap-1",children:[e.jsx(yo,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(ns,{value:"individual",className:"text-xs gap-1",children:[e.jsx(Wi,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(ws,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(mCs,{question:f,responses:l},f.id)),c.map(f=>{const g=l.filter(v=>v.question_id===f.id&&v.text_value);return g.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f.question_text}),e.jsx("div",{className:"space-y-1.5 max-h-40 overflow-y-auto",children:g.map(v=>{const _=a[v.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[_?`${_.first_name} ${_.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:v.text_value})]},v.id)})})]},f.id)})]}),e.jsx(ws,{value:"individual",className:"space-y-4",children:u.map(f=>{const g=a[f],v=l.filter(_=>_.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[g?`${g.first_name} ${g.last_name||""}`.trim():"Unknown Visitor",(g==null?void 0:g.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:g.email})]}),e.jsx("div",{className:"space-y-1",children:v.map(_=>{const w=o.find(j=>j.id===_.question_id);return w?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:w.question_text}),e.jsx("span",{className:"font-medium",children:_.rating_value!=null?Ict[_.rating_value]||_.rating_value:_.text_value})]},_.id):null})})]},f)})})]})})]})}const Swe="guestbook.relevelup.com";function fCs(){const{data:t,isLoading:s}=c4t(),r=d4t(),n=CWe(),a=u4t(),[o,l]=N.useState(!1),[i,c]=N.useState(null),{user:u}=Os(),p=ri(),[f,g]=N.useState(null),[v,_]=N.useState(null),[w,j]=N.useState(!1),k=N.useRef(null),[S,M]=N.useState({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];if(B){if(B.size>5*1024*1024){jn({title:"Photo must be under 5MB",variant:"destructive"});return}g(B),_(URL.createObjectURL(B))}},P=()=>{g(null),_(null),k.current&&(k.current.value="")},O=async()=>{if(!S.property_address){jn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let U;if(f&&u){j(!0);const B=f.name.split(".").pop(),V=`${p}/${Date.now()}.${B}`,{error:X}=await H.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(X){jn({title:"Photo upload failed",description:X.message,variant:"destructive"}),j(!1);return}const{data:Y}=H.storage.from("open-house-photos").getPublicUrl(V);U=Y.publicUrl,j(!1)}await r.mutateAsync({...S,photo_url:U}),l(!1),M({property_address:"",city:"",state:"",zip:"",event_date:ms(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),P()},$=U=>{navigator.clipboard.writeText(`https://${Swe}/${U}`),jn({title:"Link copied!"})};return e.jsxs(Ts,{title:"Guest Book",children:[e.jsx($l,{children:e.jsx("title",{children:"Guest Book | LevelUp"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold font-serif text-foreground",children:"Guest Book"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"The modern open house sign-in experience"})]}),e.jsxs(xs,{open:o,onOpenChange:l,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"Create Open House"}),e.jsx(Wr,{children:"Set up a new open house sign-in page"})]}),e.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[e.jsx("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:e.jsxs("div",{className:"flex gap-1 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"property"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="property"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Single Property"}),e.jsx("button",{type:"button",onClick:()=>M(U=>({...U,event_type:"community"})),className:`flex-1 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S.event_type==="community"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Community Event"})]})}),e.jsxs("div",{children:[e.jsx(be,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(ze,{value:S.property_address,onChange:U=>M(B=>({...B,property_address:U.target.value})),placeholder:S.event_type==="community"?"Spring Festival at Riverside Estates":"123 Main Street"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"City"}),e.jsx(ze,{value:S.city,onChange:U=>M(B=>({...B,city:U.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"State"}),e.jsx(ze,{value:S.state,onChange:U=>M(B=>({...B,state:U.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"ZIP"}),e.jsx(ze,{value:S.zip,onChange:U=>M(B=>({...B,zip:U.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Date"}),e.jsx(ze,{type:"date",value:S.event_date,onChange:U=>M(B=>({...B,event_date:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Start Time"}),e.jsx(ze,{type:"time",value:S.start_time,onChange:U=>M(B=>({...B,start_time:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"End Time"}),e.jsx(ze,{type:"time",value:S.end_time,onChange:U=>M(B=>({...B,end_time:U.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),e.jsx(Pr,{value:S.agent_greeting,onChange:U=>M(B=>({...B,agent_greeting:U.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(be,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:L,className:"hidden"}),v?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:v,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:P,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var U;return(U=k.current)==null?void 0:U.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(u1,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",S.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:O,disabled:r.isPending||w,className:"w-full",children:w?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(U=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Pt,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},U))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(U=>e.jsx(xCs,{openHouse:U,isExpanded:i===U.id,onToggle:()=>c(i===U.id?null:U.id),onCopyLink:()=>$(U.slug||""),onToggleActive:()=>n.mutate({id:U.id,is_active:!U.is_active}),onDelete:()=>a.mutate(U.id)},U.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(p1,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function xCs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=SWe(s?t.id:void 0),{data:i}=mt({queryKey:["agent-profile-flyer",t.agent_id],queryFn:async()=>{const{data:P,error:O}=await H.from("profiles").select("name, avatar_url, phone, title, brokerages:brokerage_id(name)").eq("id",t.agent_id).single();if(O)throw O;const $=P.brokerages;return{...P,brokerage_name:($==null?void 0:$.name)||null}},enabled:!!t.agent_id}),[c,u]=N.useState(!1),[p,f]=N.useState(!1),[g,v]=N.useState(!1),_=N.useRef(null),w=`https://${Swe}/${t.slug}`,j=P=>{if(!P)return"";const[O,$]=P.split(":"),U=parseInt(O),B=U>=12?"PM":"AM";return`${U>12?U-12:U||12}:${$} ${B}`},k=()=>{if(!(l!=null&&l.length))return;const P=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],O=l.map(X=>[X.first_name,X.last_name||"",X.email||"",X.phone||"",X.visitor_intent||"",X.wants_market_updates?"Yes":"No",(X.message||"").replace(/"/g,'""'),ms(new Date(X.created_at),"MM/dd/yyyy h:mm a")]),$=[P,...O].map(X=>X.map(Y=>`"${Y}"`).join(",")).join(` `),U=new Blob([$],{type:"text/csv"}),B=URL.createObjectURL(U),V=document.createElement("a");V.href=B,V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,V.click(),URL.revokeObjectURL(B)},S=N.useCallback(()=>{if(!_.current)return;const P=_.current.querySelector("svg");if(!P)return;const O=new XMLSerializer().serializeToString(P),$=document.createElement("canvas");$.width=1024,$.height=1024;const U=$.getContext("2d"),B=new Image;B.onload=()=>{U==null||U.drawImage(B,0,0,1024,1024);const V=document.createElement("a");V.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,V.href=$.toDataURL("image/png"),V.click()},B.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O)))},[t.property_address]),M=N.useCallback(()=>{var Te;if(!_.current)return;const P=_.current.querySelector("svg");if(!P)return;const O=new XMLSerializer().serializeToString(P),$="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(O))),U=ms(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),B=t.start_time?`${j(t.start_time)}${t.end_time?" – "+j(t.end_time):""}`:"",V=[t.city,t.state].filter(Boolean).join(", "),X=t.agent_greeting||"Welcome! Please sign in below.",Y=!!t.photo_url,ee=!!i,Q=Y||ee,ce=Y&&ee,ne=ce?"0.35in 0.75in 0.3in":"0.55in 0.75in 0.45in",re=ce?"28px":"34px",oe=ce?"0.2in 0.75in":Q?"0.3in 0.75in":"0.4in 0.75in",fe=Q?"0.15in":"0.3in",ge=Q?"0.15in":"0.3in",ue=ce?"14px 36px":"22px 44px",xe=ce?"20px":"24px",_e=Q?"0.2in":"0.35in",$e=ce?"1.8in":"2.4in",Me=Q?"0.15in":"0.3in",Ie=ce?"140px":Q?"160px":"200px",ke=ce?"16px":"24px",pe=ce?"10px 20px":"16px 28px",we=ce?"44px":"56px",Le="0.15in",Qe=window.open("","_blank");Qe&&(Qe.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${V?`
${V}${t.zip?" "+t.zip:""}
`:""}
Date
${U}
${B?`
Time
${B}
`:""}
${X}
${i?`
${i.avatar_url?`${i.name}`:`
${((Te=i.name)==null?void 0:Te.charAt(0))||"A"}
`}
Hosted By
${i.name}
${i.title?`
${i.title}
`:""} ${i.brokerage_name?`
${i.brokerage_name}
`:""} ${i.phone?`
${i.phone}
`:""}
`:""} ${t.photo_url?`Property`:""}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),Qe.document.close(),setTimeout(()=>{Qe.focus(),Qe.print()},500))},[t,w,i]),L=async()=>{v(!0);try{const{error:P}=await H.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(P)throw P;jn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(P){jn({title:"Failed to send",description:P.message,variant:"destructive"})}finally{v(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-base leading-snug break-words",children:t.property_address}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 flex-wrap",children:[e.jsx(st,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(st,{variant:"outline",className:"shrink-0 gap-1 text-[11px] bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:[e.jsx(Wi,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(st,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(Ca,{className:"h-3 w-3"}),"Community"]})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0 -mr-2 -mt-1",children:s?e.jsx(xf,{className:"h-4 w-4"}):e.jsx(oo,{className:"h-4 w-4"})})]}),e.jsxs(gr,{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs",children:[t.city&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),ms(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),j(t.start_time),t.end_time?` – ${j(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(hr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx(x1,{className:"h-3.5 w-3.5"}),"Live"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:n,title:"Copy link",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>u(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(p1,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>f(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(Qo,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(w,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(en,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:a,title:t.is_active?"Deactivate":"Activate",className:"shrink-0 h-8 text-xs",children:t.is_active?e.jsx(kp,{className:"h-3.5 w-3.5"}):e.jsx(Dn,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:o,title:"Delete",className:"shrink-0 h-8 text-xs text-destructive border-destructive/30 hover:bg-destructive/10",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(al,{className:"mb-4"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Share Link"}),e.jsxs("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block truncate",children:["https://",Swe,"/",t.slug]})]}),l!=null&&l.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:k,className:"h-7 text-xs gap-1",children:[e.jsx(vi,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(P=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[P.first_name,P.last_name?` ${P.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[P.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:P.email}),P.phone&&e.jsx("div",{className:"text-xs",children:P.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:P.visitor_intent&&e.jsx(st,{variant:"outline",className:"text-xs capitalize",children:P.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ms(new Date(P.created_at),"h:mm a")})]},P.id))})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"}),t.enable_survey&&e.jsx("div",{className:"mt-4",children:e.jsx(pCs,{openHouseId:t.id})})]}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{className:"sm:max-w-sm",children:[e.jsxs(js,{children:[e.jsx(_s,{children:"QR Code"}),e.jsx(Wr,{className:"truncate",children:t.property_address})]}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx("div",{ref:_,className:"bg-white p-4 rounded-xl",children:e.jsx(RR,{value:w,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:w}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(vi,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:M,children:[e.jsx(LL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:L,disabled:g,children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),g?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(hCs,{open:p,onOpenChange:f,openHouse:t})]})}function gCs(){const{slug:t}=lo();return t?e.jsx(JZe,{slug:t}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Found"}),e.jsx("p",{className:"text-slate-500",children:"No portal slug was provided."})]})})}function Lct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Os(),l=L3(),i=N.useRef(null),c=N.useRef(null),[u,p]=N.useState(!1),[f,g]=N.useState(!1),[v,_]=N.useState(0),w=async k=>{if(o){p(!0);try{const S=k.name.split(".").pop()||"jpg",M=`${o.id}/card-${Date.now()}.${S}`,{error:L}=await H.storage.from("listing-photos").upload(M,k);if(L)throw L;const{data:{publicUrl:P}}=H.storage.from("listing-photos").getPublicUrl(M);r(P),me.success("Photo uploaded")}catch(S){me.error(S.message||"Failed to upload photo")}finally{p(!1)}}},j=async k=>{if(o){if(k.size>500*1024*1024){me.error("Video must be under 500MB");return}g(!0),_(0);try{const{videoId:S,libraryId:M}=await SR(`Card Video - ${Date.now()}`),{uploadUrl:L,apiKey:P}=await CR(S);await new Promise((U,B)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",X=>{X.lengthComputable&&_(Math.round(X.loaded/X.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?U():B(new Error("Upload failed"))}),V.addEventListener("error",()=>B(new Error("Upload failed"))),V.open("PUT",L),V.setRequestHeader("AccessKey",P),V.send(k)});const O=`https://iframe.mediadelivery.net/embed/${M}/${S}`;n(O);const $=parseFloat((k.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${M}/${S}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),me.success("Video uploaded & added to your library")}catch(S){me.error(S.message||"Failed to upload video")}finally{g(!1),_(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{children:"Media (optional)"}),e.jsxs(_a,{defaultValue:"photo",className:"w-full",children:[e.jsxs(fa,{className:"grid w-full grid-cols-2",children:[e.jsxs(ns,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(vl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(ns,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(ws,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=i.current)==null?void 0:k.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(bs,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ff,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:k=>{var M;const S=(M=k.target.files)==null?void 0:M[0];S&&w(S),k.target.value=""}})]}),e.jsxs(ws,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var k;return(k=c.current)==null?void 0:k.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(bs,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",v,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${v}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(di,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!s&&!f&&e.jsx("div",{className:"mt-2",children:e.jsx(_3e,{contactId:a,onVideoReady:k=>n(k)})}),e.jsx("input",{ref:c,type:"file",accept:"video/*",className:"hidden",onChange:k=>{var M;const S=(M=k.target.files)==null?void 0:M[0];S&&j(S),k.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const yCs=[{type:"home_anniversary",label:"Home Anniversary",emoji:"🏡",description:"Celebrate their homeownership milestone",gradient:"from-blue-500/20 to-slate-500/20 border-blue-200 dark:border-blue-800"},{type:"birthday",label:"Birthday",emoji:"🎂",description:"Wish them a happy birthday",gradient:"from-pink-500/20 to-purple-500/20 border-pink-200 dark:border-pink-800"},{type:"just_sold",label:"Just Sold",emoji:"🎉",description:"Announce a successful closing",gradient:"from-emerald-500/20 to-teal-500/20 border-emerald-200 dark:border-emerald-800"},{type:"just_listed",label:"Just Listed",emoji:"🏠",description:"Share a new listing announcement",gradient:"from-amber-500/20 to-orange-500/20 border-amber-200 dark:border-amber-800"},{type:"thank_you",label:"Thank You",emoji:"💐",description:"Show your appreciation",gradient:"from-rose-500/20 to-pink-500/20 border-rose-200 dark:border-rose-800"},{type:"congratulations",label:"Congratulations",emoji:"🏆",description:"Celebrate their achievements",gradient:"from-yellow-500/20 to-amber-500/20 border-yellow-200 dark:border-yellow-800"},{type:"holiday",label:"Holiday",emoji:"🎄",description:"Send seasonal greetings",gradient:"from-red-500/20 to-green-500/20 border-red-200 dark:border-red-800"},{type:"thinking_of_you",label:"Thinking of You",emoji:"💭",description:"Stay top of mind with a personal touch",gradient:"from-violet-500/20 to-indigo-500/20 border-violet-200 dark:border-violet-800"}];function vCs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:yCs.map((s,r)=>e.jsxs(ps.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const KE={home_anniversary:{title:["Happy Home","Anniversary"],icon:"🏡",emojis:["🏡","✨","🎉","❤️","🎊","🏠"],defaultMessage:"Wishing you many more wonderful years of memories in your beautiful home. Thank you for letting me be part of your journey."},just_listed:{title:["Just","Listed!"],icon:"🏠",emojis:["🏠","📋","🔑","⭐","🎯","✨"],defaultMessage:"Exciting news — this beautiful property just hit the market! Contact me for a private showing."},just_sold:{title:["Just","Sold!"],icon:"🎉",emojis:["🎉","🏡","🔑","🥂","🎊","💰"],defaultMessage:"Another successful closing! Congratulations to the new homeowners. It was a pleasure making this happen."},congratulations:{title:["Congratulations!",""],icon:"🏆",emojis:["🎉","🥳","🏆","⭐","🎊","✨"],defaultMessage:"What an incredible milestone! I'm so happy for you. Wishing you all the best in this exciting new chapter."},birthday:{title:["Happy","Birthday!"],icon:"🎂",emojis:["🎂","🎈","🎁","🥳","🎉","🧁"],defaultMessage:"Wishing you the happiest of birthdays! May this year bring you joy, laughter, and everything you've been dreaming of."},holiday:{title:["Happy","Holidays!"],icon:"🎄",emojis:["🎄","❄️","🎁","⭐","🕯️","🎅"],defaultMessage:"Wishing you and your family a season filled with warmth, joy, and cherished moments. Happy Holidays!"},thank_you:{title:["Thank","You!"],icon:"💐",emojis:["💐","🙏","❤️","⭐","✨","🤝"],defaultMessage:"Thank you so much for your trust and confidence. It truly means the world to me. I'm always here for you!"},thinking_of_you:{title:["Thinking","Of You"],icon:"💭",emojis:["💭","❤️","🌸","☀️","🦋","💫"],defaultMessage:"Just wanted to reach out and let you know I'm thinking of you. I hope you're doing well — don't hesitate to reach out anytime!"}};function o9e({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Os(),c=Xt(),[u,p]=N.useState(!1),[f,g]=N.useState("type"),[v,_]=N.useState(""),[w,j]=N.useState(null),[k,S]=N.useState(!1),[M,L]=N.useState("home_anniversary"),[P,O]=N.useState(""),[$,U]=N.useState(""),[B,V]=N.useState(""),[X,Y]=N.useState(""),[ee,Q]=N.useState("elegant"),[ce,ne]=N.useState(null),[re,oe]=N.useState(null),fe=N.useState(!1);!fe[0]&&t&&s&&(fe[1](!0),p(!0),L(s),r&&j(r),n&&O(n),a&&U(a),o&&V(o),g(n?"details":"contact"));const{data:ge}=mt({queryKey:["contacts-for-card",i==null?void 0:i.id,v],queryFn:async()=>{let Le=H.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);v&&(Le=Le.or(`first_name.ilike.%${v}%,last_name.ilike.%${v}%`));const{data:Qe,error:Te}=await Le;if(Te)throw Te;return Qe},enabled:!!(i!=null&&i.id)&&u}),{data:ue}=mt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:Le,error:Qe}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(Qe)throw Qe;return Le},enabled:!!(i!=null&&i.id)}),xe=Le=>{j(Le.id),O(`${Le.first_name}${Le.last_name?" "+Le.last_name:""}`),U([Le.address,Le.city,Le.state].filter(Boolean).join(", ")),V(Le.home_anniversary||""),g("details")},_e=Le=>{L(Le),g("contact")},$e=async()=>{var Le;if(!(!i||!ue)){S(!0);try{const Qe={owner_user_id:i.id,contact_id:w,card_type:M,template:ee,recipient_name:P,property_address:$||null,home_anniversary_date:B||null,custom_message:X||null,property_photo_url:ce||null,video_url:re||null,agent_name:ue.name||"Agent",agent_photo_url:ue.avatar_url,agent_phone:ue.phone,agent_email:ue.email,agent_brokerage:((Le=ue.brokerage)==null?void 0:Le.name)||null},{error:Te}=await H.from("sendable_cards").insert(Qe);if(Te)throw Te;me.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),Me()}catch(Qe){me.error(Qe.message||"Failed to create card")}finally{S(!1)}}},Me=()=>{p(!1),g("type"),L("home_anniversary"),_(""),j(null),O(""),U(""),V(""),Y(""),Q("elegant"),ne(null),oe(null)},Ie={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"},ke=KE[M],pe=M==="home_anniversary",we=["home_anniversary","just_listed","just_sold"].includes(M);return e.jsxs(xs,{open:u,onOpenChange:Le=>{Le?p(!0):(Me(),l==null||l(!1))},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:f==="type"?"What type of card?":f==="contact"?`${Ie[M]} — Choose a Contact`:`${Ie[M]} — Customize`})}),f==="type"&&e.jsx(vCs,{onSelect:_e}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("type"),children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search contacts...",value:v,onChange:Le=>_(Le.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[ge==null?void 0:ge.map(Le=>e.jsxs("button",{onClick:()=>xe(Le),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(Wi,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[Le.first_name," ",Le.last_name]}),Le.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(dn,{className:"h-3 w-3"}),Le.address]})]}),Le.home_anniversary&&M==="home_anniversary"&&e.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},Le.id)),(ge==null?void 0:ge.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),e.jsx("div",{className:"border-t pt-3",children:e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{g("details")},children:"Skip — enter details manually"})})]}),f==="details"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>g("contact"),children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Recipient Name"}),e.jsx(ze,{value:P,onChange:Le=>O(Le.target.value),placeholder:"John & Jane Smith"})]}),we&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:$,onChange:Le=>U(Le.target.value),placeholder:"123 Main St, Austin, TX"})]}),pe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:B,onChange:Le=>V(Le.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Message (optional)"}),e.jsx(Pr,{value:X,onChange:Le=>Y(Le.target.value),placeholder:ke.defaultMessage,rows:3})]}),e.jsx(Lct,{photoUrl:ce,videoUrl:re,onPhotoChange:ne,onVideoChange:oe,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:Le,label:Qe,gradient:Te})=>e.jsxs("button",{onClick:()=>Q(Le),className:`p-2 rounded-lg border-2 transition-all text-center ${ee===Le?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${Te}`}),e.jsx("span",{className:"text-[10px] font-medium",children:Qe})]},Le))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>g("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:$e,disabled:!P||k,className:"flex-1 gap-2",children:k?"Creating...":"Create Card"})]})]})]})]})}const bCs={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};function _Cs({card:t}){const{user:s}=Os(),{isGmailConnected:r}=Zx(),n=Xt(),[a,o]=N.useState(!1),[l,i]=N.useState("");N.useEffect(()=>{a&&t.contact_id&&!l&&H.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,t.contact_id]);const c={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=N.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,g]=N.useState(""),v=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Lt({mutationFn:async()=>{var M;if(!l)throw new Error("Recipient email is required");const w=`
${f?`

${f.replace(/\n/g,"
")}


`:""}

I made you a special ${bCs[t.card_type]||t.card_type} card — click below to view it!

${t.property_address?`

${t.property_address}

`:""}
`,{data:j}=await H.auth.getSession(),k=(M=j==null?void 0:j.session)==null?void 0:M.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:JSON.stringify({to:l,subject:u,body:w,contactId:t.contact_id||void 0})});if(!S.ok){const L=await S.json();throw new Error(L.error||"Failed to send")}return S.json()},onSuccess:async()=>{await H.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${l}!`),o(!1)},onError:w=>{me.error(w.message||"Failed to send email")}});return r?e.jsxs(xs,{open:a,onOpenChange:o,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx($n,{className:"h-3 w-3"})})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(js,{children:e.jsx(_s,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"To"}),e.jsx(ze,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Subject"}),e.jsx(ze,{value:u,onChange:w=>p(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Note (optional)"}),e.jsx(Pr,{value:f,onChange:w=>g(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:v})]}),e.jsx(K,{onClick:()=>_.mutate(),disabled:!l||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx($n,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs opacity-50 cursor-not-allowed",title:"Connect Gmail in Settings to send cards via email",disabled:!0,children:e.jsx($n,{className:"h-3 w-3"})})}function wCs({card:t}){const s=Xt(),[r,n]=N.useState(!1),[a,o]=N.useState(!1),[l,i]=N.useState(t.recipient_name),[c,u]=N.useState(t.property_address||""),[p,f]=N.useState(t.home_anniversary_date||""),[g,v]=N.useState(t.custom_message||""),[_,w]=N.useState(t.template),[j,k]=N.useState(t.property_photo_url),[S,M]=N.useState(t.video_url||null),L=O=>{O&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),v(t.custom_message||""),w(t.template),k(t.property_photo_url),M(t.video_url||null)),n(O)},P=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:O}=await H.from("sendable_cards").update({recipient_name:l.trim(),property_address:c.trim()||null,home_anniversary_date:p||null,custom_message:g.trim()||null,template:_,property_photo_url:j||null,video_url:S||null}).eq("id",t.id);if(O)throw O;s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card updated"),n(!1)}catch(O){me.error(O.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(xs,{open:r,onOpenChange:L,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(za,{className:"h-3 w-3"})})}),e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(js,{children:e.jsx(_s,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Recipient Name"}),e.jsx(ze,{value:l,onChange:O=>i(O.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:c,onChange:O=>u(O.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:p,onChange:O=>f(O.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Personal Message (optional)"}),e.jsx(Pr,{value:g,onChange:O=>v(O.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Lct,{photoUrl:j,videoUrl:S,onPhotoChange:k,onVideoChange:M,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(O=>e.jsxs("button",{onClick:()=>w(O),className:`p-3 rounded-lg border-2 transition-all text-center ${_===O?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${O==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":O==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:O})]},O))})]}),e.jsx(K,{onClick:P,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function jCs(){const{user:t}=Os(),s=Xt(),[r,n]=N.useState(""),[a,o]=uc(),l=a.get("cardType"),i=a.get("contactId"),c=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:g,isLoading:v}=mt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:M,error:L}=await H.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(L)throw L;return M},enabled:!!(t!=null&&t.id)}),_=Lt({mutationFn:async M=>{const{error:L}=await H.from("sendable_cards").delete().eq("id",M);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),w=M=>{const L=`https://cardstudio.relevelup.com/c/${M}`;navigator.clipboard.writeText(L),me.success("Share link copied!")},j=g==null?void 0:g.filter(M=>{var L;return!r||M.recipient_name.toLowerCase().includes(r.toLowerCase())||((L=M.property_address)==null?void 0:L.toLowerCase().includes(r.toLowerCase()))}),k={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Ts,{title:"Card Studio",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),e.jsx(o9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search cards...",value:r,onChange:M=>n(M.target.value),className:"pl-9"})]}),v?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(M=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},M))}):j!=null&&j.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(M=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[e.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${M.template==="elegant"?"bg-gradient-to-br from-slate-50 via-slate-100 to-slate-200 dark:from-slate-900 dark:via-slate-800 dark:to-slate-700":M.template==="bold"?"bg-gradient-to-br from-violet-600 via-fuchsia-500 to-pink-500":"bg-gradient-to-br from-amber-100 via-orange-200 to-rose-200 dark:from-amber-900 dark:via-orange-800 dark:to-rose-800"}`,children:[M.template==="elegant"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[e.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),e.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-32 h-32 rounded-full border border-primary/10"})]}),M.template==="bold"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),M.template==="warm"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),e.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),e.jsxs("div",{className:"text-center px-4 relative z-10",children:[e.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:M.card_type==="home_anniversary"?"🏡":M.card_type==="birthday"?"🎂":M.card_type==="just_sold"?"🎉":M.card_type==="just_listed"?"🏠":M.card_type==="thank_you"?"💐":M.card_type==="congratulations"?"🏆":M.card_type==="holiday"?"🎄":M.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${M.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[M.card_type]||M.card_type}),e.jsx("p",{className:`font-semibold text-base ${M.template==="bold"?"text-white":"text-foreground"}`,children:M.recipient_name}),M.property_address&&e.jsx("p",{className:`text-xs mt-1 ${M.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:M.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(st,{variant:M.template==="bold"?"outline":"secondary",className:`text-[10px] ${M.template==="bold"?"border-white/30 text-white/80":""}`,children:k[M.template]||M.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Dn,{className:"h-3 w-3"}),M.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Vc(new Date(M.created_at),{addSuffix:!0})})]}),M.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ms(new Date(M.sent_at),"MMM d, yyyy")," via ",M.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(M.share_token),children:[e.jsx(yi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(wCs,{card:M}),e.jsx(_Cs,{card:M}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${M.share_token}`,"_blank"),children:e.jsx(en,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>_.mutate(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})]},M.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(lr,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create your first digital card to send to a client"}),e.jsx(o9e,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function jI({delay:t,x:s,y:r,size:n}){return e.jsx(ps.div,{className:"absolute rounded-full bg-slate-300/30 dark:bg-slate-500/20",style:{left:s,top:r,width:n,height:n},animate:{y:[0,-20,0],opacity:[.3,.7,.3],scale:[1,1.2,1]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeInOut"}})}function NCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,v=KE[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(ps.div,{className:"absolute -top-20 -right-20 w-72 h-72 rounded-full bg-gradient-to-br from-blue-100/40 to-slate-100/20 blur-3xl",animate:{scale:[1,1.1,1],rotate:[0,5,0]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),e.jsx(ps.div,{className:"absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-gradient-to-tr from-slate-200/30 to-blue-100/20 blur-3xl",animate:{scale:[1,1.15,1],rotate:[0,-5,0]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),e.jsx(jI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(jI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(jI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(jI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(jI,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(ps.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},children:[e.jsxs(ps.div,{className:"bg-white/80 dark:bg-slate-900/80 backdrop-blur-xl rounded-3xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.1)] overflow-hidden border border-slate-200/60 dark:border-slate-700/50",initial:{scale:.95},animate:{scale:1},transition:{duration:.6,delay:.2},children:[e.jsx("div",{className:"relative h-2 bg-gradient-to-r from-slate-200 via-blue-300 to-slate-200 dark:from-slate-700 dark:via-blue-500 dark:to-slate-700 overflow-hidden",children:e.jsx(ps.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(ps.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-slate-100 to-blue-50 dark:from-slate-800 dark:to-slate-700 flex items-center justify-center shadow-lg relative",initial:{scale:0,rotate:-10},animate:{scale:1,rotate:0},transition:{duration:.5,delay:.4,type:"spring",stiffness:200},children:[e.jsx(ps.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:v.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(ps.div,{className:"inline-block mb-4",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:e.jsxs("span",{className:"text-sm font-semibold tracking-[0.25em] uppercase text-blue-400 dark:text-blue-300",children:[a," ",a===1?"Year":"Years"]})}),e.jsx(ps.h1,{className:"text-4xl font-light text-slate-800 dark:text-slate-100 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:v.title[0]}),v.title[1]&&e.jsx(ps.h2,{className:"text-4xl font-bold text-slate-800 dark:text-slate-100 mb-8 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:v.title[1]}),e.jsxs(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-slate-700 dark:text-slate-200 mb-1",children:r}),n&&e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mb-6",children:n})]}),e.jsx(ps.div,{className:"h-px bg-gradient-to-r from-transparent via-slate-300 dark:via-slate-600 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"80%"},transition:{duration:.8,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(ps.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(ps.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(ps.p,{className:"text-sm text-slate-500 dark:text-slate-400 leading-relaxed max-w-xs mx-auto mb-8 italic",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:o||v.defaultMessage}),e.jsxs(ps.div,{className:"border-t border-slate-100 dark:border-slate-800 pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5,delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(ps.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[c&&e.jsxs(ps.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ps.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ps.p,{className:"text-center text-[10px] text-slate-400 dark:text-slate-600 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function Uye({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(ps.div,{className:`absolute rounded-full blur-2xl ${n}`,style:{left:s,top:r,width:a,height:a},animate:{scale:[1,1.4,1],opacity:[.2,.5,.2]},transition:{duration:5,delay:t,repeat:1/0,ease:"easeInOut"}})}function NI({delay:t,x:s,y:r}){return e.jsx(ps.div,{className:"absolute text-white/30 text-lg",style:{left:s,top:r},animate:{opacity:[0,1,0],scale:[.5,1,.5],rotate:[0,180,360]},transition:{duration:3,delay:t,repeat:1/0,ease:"easeInOut"},children:"✦"})}const l9e={home_anniversary:{bg:"from-violet-950 via-purple-900 to-fuchsia-950",orbs:["bg-violet-500/30","bg-fuchsia-500/25","bg-purple-400/20"]},birthday:{bg:"from-pink-950 via-rose-900 to-fuchsia-950",orbs:["bg-pink-500/30","bg-rose-500/25","bg-fuchsia-400/20"]},just_sold:{bg:"from-emerald-950 via-teal-900 to-cyan-950",orbs:["bg-emerald-500/30","bg-teal-500/25","bg-cyan-400/20"]},just_listed:{bg:"from-amber-950 via-orange-900 to-yellow-950",orbs:["bg-amber-500/30","bg-orange-500/25","bg-yellow-400/20"]},thank_you:{bg:"from-rose-950 via-pink-900 to-red-950",orbs:["bg-rose-500/30","bg-pink-500/25","bg-red-400/20"]},congratulations:{bg:"from-yellow-950 via-amber-900 to-orange-950",orbs:["bg-yellow-500/30","bg-amber-500/25","bg-orange-400/20"]},holiday:{bg:"from-red-950 via-rose-900 to-emerald-950",orbs:["bg-red-500/30","bg-green-500/25","bg-rose-400/20"]},thinking_of_you:{bg:"from-indigo-950 via-violet-900 to-purple-950",orbs:["bg-indigo-500/30","bg-violet-500/25","bg-purple-400/20"]}};function kCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,v=KE[s],_=l9e[s]||l9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(Uye,{delay:0,x:"10%",y:"10%",color:_.orbs[0],size:200}),e.jsx(Uye,{delay:1,x:"70%",y:"60%",color:_.orbs[1],size:180}),e.jsx(Uye,{delay:2,x:"50%",y:"20%",color:_.orbs[2],size:150}),e.jsx(NI,{delay:0,x:"20%",y:"25%"}),e.jsx(NI,{delay:.8,x:"75%",y:"15%"}),e.jsx(NI,{delay:1.6,x:"85%",y:"65%"}),e.jsx(NI,{delay:2.4,x:"10%",y:"75%"}),e.jsx(NI,{delay:.4,x:"45%",y:"85%"}),e.jsxs(ps.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.7,ease:"easeOut"},children:[e.jsxs(ps.div,{className:"relative rounded-3xl overflow-hidden",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsx(ps.div,{className:"absolute -inset-[1px] rounded-3xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-violet-500 opacity-50",animate:{backgroundPosition:["0% 50%","100% 50%","0% 50%"]},transition:{duration:4,repeat:1/0,ease:"linear"},style:{backgroundSize:"200% 200%"}}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-xl border border-white/10 rounded-3xl px-8 py-10 text-center m-[1px]",children:[e.jsxs(ps.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-2xl shadow-violet-500/40 relative",initial:{scale:0,rotate:-20},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:200},children:[e.jsx(ps.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:v.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(ps.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/10 border border-white/15 backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(ps.span,{className:"text-3xl font-black text-white",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-xs font-semibold text-violet-200 uppercase tracking-widest",children:a===1?"Year":"Years"})]}),e.jsx(ps.h1,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-violet-200 via-white to-fuchsia-200 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:v.title[0]}),v.title[1]&&e.jsx(ps.h2,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-300 via-violet-200 to-purple-300 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:v.title[1]}),e.jsx(ps.div,{className:"text-3xl mb-4",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.4,delay:1,type:"spring",stiffness:300},children:v.emojis.slice(0,3).join("")}),e.jsxs(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:"text-xl font-semibold text-white/90 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-violet-300/70 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(dn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(ps.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(ps.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(ps.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||v.defaultMessage})}),e.jsxs(ps.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(ps.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[c&&e.jsxs(ps.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(ps.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ps.p,{className:"text-center text-[10px] text-violet-400/40 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function SCs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(ps.div,{className:"absolute text-2xl pointer-events-none",style:{left:r,bottom:-20},animate:{y:[0,-600],opacity:[0,1,1,0],x:[0,15,-10,5],rotate:[0,20,-15,10]},transition:{duration:n,delay:s,repeat:1/0,ease:"easeOut"},children:t})}const c9e={home_anniversary:{bg:"from-amber-50 via-orange-50 to-rose-50",header:"from-amber-400 via-orange-400 to-rose-400",accent:"text-amber-900",text:"text-amber-800"},birthday:{bg:"from-pink-50 via-rose-50 to-fuchsia-50",header:"from-pink-400 via-rose-400 to-fuchsia-400",accent:"text-pink-900",text:"text-pink-800"},just_sold:{bg:"from-emerald-50 via-teal-50 to-cyan-50",header:"from-emerald-400 via-teal-400 to-cyan-400",accent:"text-emerald-900",text:"text-emerald-800"},just_listed:{bg:"from-sky-50 via-blue-50 to-indigo-50",header:"from-sky-400 via-blue-400 to-indigo-400",accent:"text-blue-900",text:"text-blue-800"},thank_you:{bg:"from-rose-50 via-pink-50 to-red-50",header:"from-rose-400 via-pink-400 to-red-400",accent:"text-rose-900",text:"text-rose-800"},congratulations:{bg:"from-yellow-50 via-amber-50 to-orange-50",header:"from-yellow-400 via-amber-400 to-orange-400",accent:"text-amber-900",text:"text-amber-800"},holiday:{bg:"from-red-50 via-green-50 to-emerald-50",header:"from-red-500 via-green-500 to-emerald-500",accent:"text-green-900",text:"text-green-800"},thinking_of_you:{bg:"from-violet-50 via-purple-50 to-indigo-50",header:"from-violet-400 via-purple-400 to-indigo-400",accent:"text-violet-900",text:"text-violet-800"}};function CCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,v=KE[s],_=c9e[s]||c9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[v.emojis.map((w,j)=>e.jsx(SCs,{emoji:w,delay:j*1.2,x:`${15+j*14}%`,duration:5+j%3},j)),e.jsx(ps.div,{className:"absolute top-1/4 left-1/2 -translate-x-1/2 w-96 h-96 bg-gradient-to-r from-amber-200/30 to-rose-200/30 rounded-full blur-[100px]",animate:{scale:[1,1.2,1],opacity:[.3,.5,.3]},transition:{duration:6,repeat:1/0,ease:"easeInOut"}}),e.jsxs(ps.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7},children:[e.jsxs(ps.div,{className:"bg-white rounded-3xl shadow-[0_20px_60px_-15px_rgba(251,146,60,0.2)] overflow-hidden border border-amber-100",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsxs(ps.div,{className:`h-28 bg-gradient-to-r ${_.header} relative overflow-hidden`,children:[e.jsx(ps.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}}),e.jsx(ps.div,{className:"absolute top-3 left-10 text-5xl",animate:{rotate:[0,10,-5,0],y:[0,-3,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:v.emojis[0]}),e.jsx(ps.div,{className:"absolute top-2 right-14 text-3xl",animate:{scale:[1,1.3,1],rotate:[0,15,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut",delay:.5},children:v.emojis[1]}),e.jsx(ps.div,{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-3xl",animate:{y:[0,-5,0],scale:[1,1.1,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut",delay:1},children:v.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(ps.div,{className:"mx-auto mb-4 h-20 w-20 rounded-full bg-white shadow-xl flex items-center justify-center border-4 border-white relative",initial:{scale:0},animate:{scale:1},transition:{delay:.4,type:"spring",stiffness:300},children:e.jsx(ps.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:v.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(ps.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${_.accent}`,children:[e.jsx(ps.span,{className:"text-5xl font-black",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-sm font-semibold",children:a===1?"year":"wonderful years"})]})}),e.jsxs(ps.h1,{className:`text-3xl font-bold ${_.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[v.title.join(" ")," ",v.emojis[4]]}),e.jsxs(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${_.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${_.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(ia,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(ps.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(ps.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(ps.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${_.text} leading-relaxed italic`,children:['"',o||v.defaultMessage,'"']})}),e.jsxs(ps.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center gap-3 justify-center",children:[i?e.jsx(ps.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${_.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${_.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(ps.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ps.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ps.p,{className:"text-center text-[10px] text-amber-400 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function g9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(ps.div,{className:`absolute rounded-full ${a} blur-3xl`,style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.3,1],opacity:[.4,.7,.4],x:[0,20,-10,0],y:[0,-15,10,0]},transition:{duration:8,delay:t,repeat:1/0,ease:"easeInOut"}})}function Vye({delay:t,x:s,y:r,size:n}){return e.jsx(ps.div,{className:"absolute rounded-full border border-white/10",style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.2,1],opacity:[.1,.3,.1],rotate:[0,180,360]},transition:{duration:12,delay:t,repeat:1/0,ease:"linear"}})}const d9e={home_anniversary:{mesh:["bg-sky-400/40","bg-indigo-500/30","bg-violet-400/25"],accent:"text-sky-200",glow:"shadow-sky-500/20"},birthday:{mesh:["bg-pink-400/40","bg-fuchsia-500/30","bg-purple-400/25"],accent:"text-pink-200",glow:"shadow-pink-500/20"},just_sold:{mesh:["bg-emerald-400/40","bg-teal-500/30","bg-cyan-400/25"],accent:"text-emerald-200",glow:"shadow-emerald-500/20"},just_listed:{mesh:["bg-amber-400/40","bg-orange-500/30","bg-yellow-400/25"],accent:"text-amber-200",glow:"shadow-amber-500/20"},thank_you:{mesh:["bg-rose-400/40","bg-pink-500/30","bg-red-400/25"],accent:"text-rose-200",glow:"shadow-rose-500/20"},congratulations:{mesh:["bg-yellow-400/40","bg-amber-500/30","bg-orange-400/25"],accent:"text-yellow-200",glow:"shadow-yellow-500/20"},holiday:{mesh:["bg-red-400/40","bg-emerald-500/30","bg-green-400/25"],accent:"text-red-200",glow:"shadow-red-500/20"},thinking_of_you:{mesh:["bg-violet-400/40","bg-indigo-500/30","bg-blue-400/25"],accent:"text-violet-200",glow:"shadow-violet-500/20"}};function MCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,v=KE[s],_=d9e[s]||d9e.home_anniversary;return e.jsxs("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsx(g9,{delay:0,x:"5%",y:"10%",size:300,color:_.mesh[0]}),e.jsx(g9,{delay:2,x:"60%",y:"50%",size:250,color:_.mesh[1]}),e.jsx(g9,{delay:4,x:"30%",y:"70%",size:200,color:_.mesh[2]}),e.jsx(g9,{delay:1,x:"80%",y:"15%",size:180,color:_.mesh[0]}),e.jsx(Vye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Vye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Vye,{delay:6,x:"40%",y:"10%",size:80}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`}}),e.jsxs(ps.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.8,ease:[.16,1,.3,1]},children:[e.jsxs(ps.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${_.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(ps.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:4,repeat:1/0,repeatDelay:3,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(ps.div,{className:"mx-auto mb-6 h-24 w-24 rounded-3xl bg-white/[0.08] backdrop-blur-xl border border-white/[0.15] flex items-center justify-center relative",initial:{scale:0,rotate:-15},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:180},children:[e.jsx(ps.div,{className:"absolute -inset-1 rounded-3xl border border-white/[0.08]",animate:{scale:[1,1.1,1],opacity:[.3,0,.3]},transition:{duration:3,repeat:1/0,ease:"easeInOut"}}),e.jsx(ps.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:v.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(ps.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/[0.06] border border-white/[0.1] backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(ps.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${_.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(ps.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:v.title[0]}),v.title[1]&&e.jsx(ps.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:v.title[1]}),e.jsxs(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-white/80 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-white/30 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(ia,{className:"h-3 w-3"})," ",n]})]}),e.jsx(ps.div,{className:"h-px bg-gradient-to-r from-transparent via-white/15 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"70%"},transition:{duration:1,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(ps.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),g&&e.jsx(ps.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(ps.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||v.defaultMessage,'"']})}),e.jsxs(ps.div,{className:"border-t border-white/[0.06] pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(ps.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(ps.a,{href:`tel:${c}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ps.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(ps.p,{className:"text-center text-[10px] text-white/20 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function Hye({delay:t,x:s,angle:r,color:n}){return e.jsx(ps.div,{className:`absolute h-[400px] w-[1px] ${n} origin-top`,style:{left:s,top:"-10%",transform:`rotate(${r}deg)`},animate:{opacity:[0,.4,0],scaleY:[.5,1,.5]},transition:{duration:6,delay:t,repeat:1/0,ease:"easeInOut"}})}function y9({delay:t,x:s}){return e.jsx(ps.div,{className:"absolute w-1 h-1 rounded-full bg-amber-400/60",style:{left:s,bottom:"20%"},animate:{y:[0,-200,-400],x:[0,15,-10],opacity:[0,.8,0],scale:[0,1.5,0]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeOut"}})}const u9e={home_anniversary:{gradient:"from-slate-950 via-blue-950 to-slate-950",accent:"from-blue-400 to-cyan-300",stripe:"bg-blue-400/20"},birthday:{gradient:"from-slate-950 via-rose-950 to-slate-950",accent:"from-rose-400 to-pink-300",stripe:"bg-rose-400/20"},just_sold:{gradient:"from-slate-950 via-emerald-950 to-slate-950",accent:"from-emerald-400 to-green-300",stripe:"bg-emerald-400/20"},just_listed:{gradient:"from-slate-950 via-amber-950 to-slate-950",accent:"from-amber-400 to-yellow-300",stripe:"bg-amber-400/20"},thank_you:{gradient:"from-slate-950 via-pink-950 to-slate-950",accent:"from-pink-400 to-rose-300",stripe:"bg-pink-400/20"},congratulations:{gradient:"from-slate-950 via-yellow-950 to-slate-950",accent:"from-yellow-400 to-amber-300",stripe:"bg-yellow-400/20"},holiday:{gradient:"from-slate-950 via-red-950 to-slate-950",accent:"from-red-400 to-green-400",stripe:"bg-red-400/20"},thinking_of_you:{gradient:"from-slate-950 via-purple-950 to-slate-950",accent:"from-purple-400 to-violet-300",stripe:"bg-purple-400/20"}};function TCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:g}=t,v=KE[s],_=u9e[s]||u9e.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${_.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(Hye,{delay:0,x:"20%",angle:15,color:_.stripe}),e.jsx(Hye,{delay:2,x:"75%",angle:-12,color:_.stripe}),e.jsx(Hye,{delay:4,x:"50%",angle:5,color:_.stripe}),e.jsx(y9,{delay:0,x:"30%"}),e.jsx(y9,{delay:1.5,x:"60%"}),e.jsx(y9,{delay:3,x:"45%"}),e.jsx(y9,{delay:.7,x:"75%"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.015] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`}}),e.jsxs(ps.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(ps.div,{className:"relative overflow-hidden",initial:{y:50},animate:{y:0},transition:{duration:.8,delay:.3,ease:[.16,1,.3,1]},children:e.jsxs("div",{className:"px-8 py-12 text-center",children:[e.jsx(ps.div,{className:"mx-auto mb-8 relative",initial:{scale:0},animate:{scale:1},transition:{duration:.8,delay:.5,type:"spring",stiffness:100},children:e.jsx(ps.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:v.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(ps.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(ps.span,{className:`text-6xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(ps.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:v.title[0]})}),v.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(ps.h2,{className:`text-5xl font-black bg-gradient-to-r ${_.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:v.title[1]})}),e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.1,duration:.6},children:[e.jsx("p",{className:"text-lg font-light text-white/70 tracking-wide",children:r}),n&&e.jsxs("p",{className:"text-xs text-white/25 mt-1 flex items-center justify-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(ps.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(ps.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-r from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"right"}}),e.jsx(ps.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(ps.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-l from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"left"}})]}),f&&e.jsxs(ps.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),g&&e.jsx(ps.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.35,duration:.6},children:e.jsx("iframe",{src:`${g}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(ps.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||v.defaultMessage}),e.jsxs(ps.div,{className:"pt-6 border-t border-white/[0.04]",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:1.6,duration:.6},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[i?e.jsx(ps.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${_.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c&&e.jsxs(ps.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${_.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(ps.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/60 hover:bg-white/[0.12] transition-colors",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(ps.p,{className:"text-center text-[10px] text-white/10 mt-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:2.2},children:"Powered by LevelUp"})]})]})}function Dct(){const{shareToken:t}=lo(),{data:s,isLoading:r,error:n}=mt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await H.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(N.useEffect(()=>{t&&H.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-Rl(s.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:s.card_type||"home_anniversary",recipientName:s.recipient_name,propertyAddress:s.property_address,anniversaryYears:a,customMessage:s.custom_message,agentName:s.agent_name,agentPhotoUrl:s.agent_photo_url,agentPhone:s.agent_phone,agentEmail:s.agent_email,agentBrokerage:s.agent_brokerage,propertyPhotoUrl:s.property_photo_url,videoUrl:s.video_url||null};switch(s.template){case"bold":return e.jsx(kCs,{...o});case"warm":return e.jsx(CCs,{...o});case"glass":return e.jsx(MCs,{...o});case"cinematic":return e.jsx(TCs,{...o});case"elegant":default:return e.jsx(NCs,{...o})}}function ACs(){const t=ri();return mt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await H.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function ECs(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await H.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await H.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await H.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function PCs(){const t=nr(),{isGmailConnected:s,gmailEmail:r}=Zx(),{data:n,isLoading:a}=ACs(),o=ECs(),[l,i]=N.useState(!1),[c,u]=N.useState(!0),[p,f]=N.useState(!1);N.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const g=async _=>{if(_&&!s){me.error("Connect your Gmail account first before enabling Smart Drips");return}i(_);try{await o.mutateAsync({is_globally_enabled:_}),me.success(_?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!_),me.error("Failed to update settings")}},v=async _=>{u(_);try{await o.mutateAsync({append_signature:_}),me.success(_?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!_),me.error("Failed to update settings")}};return e.jsxs(xs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Qo,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(js,{children:[e.jsxs(_s,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Wr,{children:"Configure how your automated drip emails are sent."})]}),e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email Connection"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${s?"bg-emerald-500/10":"bg-destructive/10"}`,children:e.jsx(lr,{className:`h-4 w-4 ${s?"text-emerald-600":"text-destructive"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s?"Gmail Connected":"Gmail Not Connected"}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]}),s?e.jsxs(st,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(sa,{className:"h-3 w-3"}),"Active"]}):e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:()=>{f(!1),t("/mission-control/integrations")},children:[e.jsx(en,{className:"h-3 w-3"}),"Connect"]})]}),!s&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Smart Drips sends emails from your Gmail account. Connect Gmail to get started."})]}),e.jsx(al,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${l?"bg-emerald-500/10":"bg-muted"}`,children:e.jsx(IL,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(qr,{checked:l,onCheckedChange:g,disabled:a||o.isPending})]}),e.jsx(al,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${c?"bg-primary/10":"bg-muted"}`,children:e.jsx(s0,{className:`h-4 w-4 ${c?"text-primary":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Append Email Signature"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"Your signature from Profile settings will be added":"Drip emails will send without a signature"})]})]}),e.jsx(qr,{checked:c,onCheckedChange:v,disabled:a||o.isPending})]}),c&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>{f(!1),t("/profile")},children:[e.jsx(s0,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function ICs(){const t=ri();return mt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function LCs(){const t=ri();return mt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function DCs(){const t=ri(),s=Xt();return Lt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function OCs(){const t=Xt();return Lt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await H.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function RCs(){const t=Xt();return Lt({mutationFn:async s=>{const{error:r}=await H.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function FCs(){const t=ri(),s=Xt();return Lt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await H.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await H.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const zCs=[{key:"{{client_first_name}}",label:"Client First Name"},{key:"{{client_last_name}}",label:"Client Last Name"},{key:"{{property_address}}",label:"Property Address"},{key:"{{agent_name}}",label:"Your Name"},{key:"{{agent_phone}}",label:"Your Phone"},{key:"{{close_date}}",label:"Target Close Date"},{key:"{{stage_name}}",label:"Current Stage"},{key:"{{portal_link}}",label:"Portal Link"},{key:"{{review_link}}",label:"Review Link"}];function BCs(){const t=ri(),{data:s,isLoading:r}=ICs(),{data:n,isLoading:a}=LCs(),o=DCs(),l=OCs(),i=RCs(),c=FCs(),[u,p]=N.useState(null),[f,g]=N.useState(null),v=(s==null?void 0:s.filter(P=>!P.is_starter&&P.owner_user_id===t))||[],_=(s==null?void 0:s.filter(P=>P.is_starter))||[],w=P=>v.filter(O=>O.stage_id===P),j=async P=>{try{await l.mutateAsync({id:P.id,is_enabled:!P.is_enabled}),me.success(P.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},k=async P=>{try{const O=n==null?void 0:n.find($=>$.id===P);await o.mutateAsync({stage_id:P,title:`${(O==null?void 0:O.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(P),me.success("Drip template created")}catch{me.error("Failed to create template")}},S=async P=>{try{await i.mutateAsync(P),me.success("Template deleted")}catch{me.error("Failed to delete")}},M=async P=>{if(!n||n.length===0){me.error("No pipeline stages found");return}const O=n[0].id;try{await c.mutateAsync({templateId:P,stageId:O}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},L=r||a;return e.jsx(Ts,{children:e.jsxs("div",{className:"container max-w-4xl mx-auto py-6 px-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yh,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(st,{variant:"outline",className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 border-amber-500 text-amber-600 bg-amber-500/10",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Automatically send personalized emails when deals move through your pipeline."})]}),e.jsx(PCs,{})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-xl p-4 mb-6 flex items-start gap-3",children:[e.jsx(jL,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"How it works"}),e.jsxs("p",{children:["When a deal moves to a new stage in your pipeline, Smart Drips automatically sends your pre-written email to the client. Nothing sends until you create a template ",e.jsx("strong",{children:"and"})," toggle it on."]})]})]}),e.jsxs(_a,{defaultValue:"my-drips",children:[e.jsxs(fa,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(ns,{value:"my-drips",children:"My Drips"}),e.jsxs(ns,{value:"starters",children:["Starter Templates",_.length>0&&e.jsx(st,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:_.length})]})]}),e.jsx(ws,{value:"my-drips",children:L?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(P=>e.jsx(vs,{className:"h-16 w-full rounded-xl"},P))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Yh,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create pipeline stages first to set up drip automations."})]}):e.jsxs("div",{className:"space-y-2",children:[n.filter(P=>!P.is_won_stage&&!P.is_lost_stage).map(P=>{const O=w(P.id),$=u===P.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p($?null:P.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:P.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:P.name}),O.length>0&&e.jsxs(st,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),$?e.jsx(oo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(P.id),disabled:o.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(h9e,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>j(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(P.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},P.id)}),n.filter(P=>P.is_won_stage||P.is_lost_stage).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium mb-2 px-1",children:"Closing Stages"}),n.filter(P=>P.is_won_stage||P.is_lost_stage).map(P=>{const O=w(P.id),$=u===P.id,U=O.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p($?null:P.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:P.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:P.name}),O.length>0&&e.jsxs(st,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[O.length," drip",O.length!==1?"s":"",U&&" · Active"]}),$?e.jsx(oo,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:O.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>k(P.id),disabled:o.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[O.map(B=>e.jsx(h9e,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>j(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>S(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>k(P.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},P.id)})]})]})}),e.jsx(ws,{value:"starters",children:_.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(fn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Starter Templates Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Admin-created starter templates will appear here. You'll be able to copy them into your own drips."})]}):e.jsx("div",{className:"space-y-3",children:_.map(P=>e.jsx($Cs,{template:P,onCopy:()=>M(P.id),isCopying:c.isPending},P.id))})})]})]})})}function h9e({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=N.useState(t.title),[u,p]=N.useState(t.subject),[f,g]=N.useState(t.body),[v,_]=N.useState(t.video_url||""),[w,j]=N.useState(t.channel),[k,S]=N.useState(t.delay_type),[M,L]=N.useState(t.delay_minutes),[P,O]=N.useState(!1),$=async()=>{O(!0);try{await a({title:i,subject:u,body:f,video_url:v||null,channel:w,delay_type:k,delay_minutes:M}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{O(!1)}},U=B=>{g(V=>V+B)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(lr,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.delay_type==="instant"?"Sends instantly":`Sends after ${t.delay_minutes>=60?`${Math.round(t.delay_minutes/60)}h`:`${t.delay_minutes}m`}`}),t.video_url&&e.jsx(Cn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(qr,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(ze,{value:i,onChange:B=>c(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(B=>e.jsxs("button",{onClick:()=>j(B),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w===B?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[B==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(lr,{className:"h-3 w-3"}),B==="sms"?"SMS":"Email"]},B))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(be,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>S("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${k==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(un,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),k==="scheduled"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ze,{type:"number",min:1,value:M>=60?Math.round(M/60):M,onChange:B=>{const V=parseInt(B.target.value)||0;L(M>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:M<60?M:30},{label:"Hours",mins:M>=60?M:60},{label:"Days",mins:M>=1440?M:1440}].map(B=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${B.label==="Minutes"&&M<60||B.label==="Hours"&&M>=60&&M<1440||B.label==="Days"&&M>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{B.label==="Minutes"?L(30):B.label==="Hours"?L(60):L(1440)},children:B.label},B.label))})]})]}),w==="email"&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(ze,{value:u,onChange:B=>p(B.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(be,{className:"text-xs font-medium",children:w==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:B=>{B.target.value&&U(B.target.value),B.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),zCs.map(B=>e.jsx("option",{value:B.key,children:B.label},B.key))]})]})]}),e.jsx("textarea",{value:f,onChange:B=>g(B.target.value),placeholder:w==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs font-medium",children:"Attached Video"}),v?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(Cn,{className:"h-3 w-3 inline mr-1 text-primary"}),v.length>50?v.slice(0,50)+"...":v]}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>_(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(_3e,{onVideoReady:B=>_(B)}),e.jsx(b3e,{userId:l,onSelect:B=>_(B),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const B=prompt("Paste a YouTube or Loom URL:");B&&_(B)},children:[e.jsx(Bo,{className:"h-3 w-3"})," Paste URL"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive",onClick:o,children:[e.jsx(Nr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:$,disabled:P,children:P?"Saving...":"Save Drip"})]})]})]})]})}function $Cs({template:t,onCopy:s,isCopying:r}){const[n,a]=N.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(st,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(so,{className:"h-3 w-3"}):e.jsx(lr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(st,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(oo,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(oa,{className:"h-4 w-4 text-muted-foreground ml-1"})]})]}),n&&e.jsxs("div",{className:"border-t bg-muted/10 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Subject Line"}),e.jsx("p",{className:"text-sm font-medium",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Email Body"}),e.jsx("div",{className:"text-sm text-foreground/80 bg-background rounded-lg border p-4 prose prose-sm max-w-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_p]:my-2 [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:t.body}})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i})]}),e.jsxs(K,{onClick:c=>{c.stopPropagation(),s()},size:"sm",className:"w-full gap-1.5",disabled:r,children:[e.jsx(yi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const Oct=()=>{const t=dc();return N.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),e.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),e.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function qCs(){return N.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Z2e,{children:[e.jsx(Ns,{path:"/c/:shareToken",element:e.jsx(Dct,{})}),e.jsx(Ns,{path:"*",element:e.jsx(Oct,{})})]})}const Gye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Rct({slugOverride:t}){const s=lo(),r=t||s.slug,[n,a]=N.useState("types"),[o,l]=N.useState(null),[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState(new Date),[v,_]=N.useState({name:"",email:"",phone:"",message:""}),[w,j]=N.useState(!1),{data:k,isLoading:S}=mt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return Q},enabled:!!r}),{data:M}=mt({queryKey:["public-booking-profile",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",k.user_id).single();if(ce)throw ce;return Q},enabled:!!(k!=null&&k.user_id)}),{data:L=[]}=mt({queryKey:["public-booking-types",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",k.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return Q},enabled:!!(k!=null&&k.user_id)}),{data:P=[]}=mt({queryKey:["public-availability",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",k.user_id).eq("is_active",!0);if(ce)throw ce;return Q},enabled:!!(k!=null&&k.user_id)}),{data:O=[]}=mt({queryKey:["public-blocked-dates",k==null?void 0:k.user_id],queryFn:async()=>{const{data:Q,error:ce}=await H.from("agent_blocked_dates").select("blocked_date").eq("user_id",k.user_id);if(ce)throw ce;return Q.map(ne=>ne.blocked_date)},enabled:!!(k!=null&&k.user_id)}),{data:$=[]}=mt({queryKey:["public-existing-bookings",k==null?void 0:k.user_id,i],queryFn:async()=>{if(!i)return[];const Q=ms(i,"yyyy-MM-dd"),{data:ce,error:ne}=await H.from("bookings").select("start_time, end_time").eq("agent_user_id",k.user_id).eq("booking_date",Q).eq("status","confirmed");if(ne)throw ne;return ce},enabled:!!(k!=null&&k.user_id)&&!!i}),U=N.useMemo(()=>[...new Set(P.map(Q=>Q.day_of_week))],[P]),B=Q=>{const ce=$m(new Date),ne=Il(ce,(k==null?void 0:k.max_advance_days)||30),re=Il(ce,0);return YS(Q,re)||ZS(Q,ne)||O.includes(ms(Q,"yyyy-MM-dd"))?!1:U.includes(Q.getDay())},V=N.useMemo(()=>{if(!i||!o||!k)return[];const Q=P.filter(ge=>ge.day_of_week===i.getDay()),ce=o.duration_minutes,ne=k.buffer_minutes||0,re=[],oe=new Date,fe=(k.min_notice_hours||2)*60*60*1e3;for(const ge of Q){const[ue,xe]=ge.start_time.split(":").map(Number),[_e,$e]=ge.end_time.split(":").map(Number);let Me=r8(s8(i,ue),xe);const Ie=r8(s8(i,_e),$e);for(;pM(Me,ce)<=Ie;){const ke=ms(Me,"HH:mm"),pe=ms(pM(Me,ce),"HH:mm");Me.getTime()-oe.getTime()>=fe&&($.some(Le=>{const Qe=Le.start_time.slice(0,5),Te=Le.end_time.slice(0,5);return keQe})||re.push(ke)),Me=pM(Me,ce+ne)}}return re},[i,o,P,k,$]),X=N.useMemo(()=>{const Q=f.getFullYear(),ce=f.getMonth(),ne=new Date(Q,ce,1),re=new Date(Q,ce+1,0),oe=ne.getDay(),fe=[];for(let ge=0;ge{if(!(!o||!i||!u||!v.name||!k)){j(!0);try{const Q=ms(pM(r8(s8(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:ce}=await H.from("bookings").insert({agent_user_id:k.user_id,booking_type_id:o.id,booking_date:ms(i,"yyyy-MM-dd"),start_time:u,end_time:Q,guest_name:v.name,guest_email:v.email||null,guest_phone:v.phone||null,guest_message:v.message||null});if(ce)throw ce;H.functions.invoke("booking-notify",{body:{agentUserId:k.user_id,guestName:v.name,guestEmail:v.email||null,guestPhone:v.phone||null,guestMessage:v.message||null,bookingTypeName:o.name,bookingDate:ms(i,"yyyy-MM-dd"),startTime:u,endTime:Q,durationMinutes:o.duration_minutes,meetingLink:k.meeting_link||null}}).catch(ne=>console.error("Booking notify error:",ne)),a("confirmed")}catch(Q){me.error("Failed to book: "+Q.message)}finally{j(!1)}}},ee=Q=>{const[ce,ne]=Q.split(":").map(Number),re=ce>=12?"PM":"AM";return`${ce%12||12}:${ne.toString().padStart(2,"0")} ${re}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):k?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[M!=null&&M.avatar_url?e.jsx("img",{src:M.avatar_url,alt:(M==null?void 0:M.name)||"Agent",className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl object-cover border-4 border-white shadow-md"}):e.jsx("div",{className:"w-20 h-20 sm:w-24 sm:h-24 rounded-2xl bg-gradient-to-br from-[#406E71] to-[#2a4c64] border-4 border-white shadow-md flex items-center justify-center",children:e.jsx(Wi,{className:"h-10 w-10 text-white"})}),e.jsxs("div",{className:"pb-1.5",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-slate-800 leading-tight",children:(M==null?void 0:M.name)||"Agent"}),(M==null?void 0:M.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:M.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#406E71]/8 hover:bg-[#406E71]/15 text-[#406E71] text-xs font-medium transition-colors",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[#2a4c64]/8 hover:bg-[#2a4c64]/15 text-[#2a4c64] text-xs font-medium transition-colors",children:[e.jsx(lr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:M.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:L.map(Q=>e.jsx("button",{onClick:()=>{l(Q),a("date")},className:"w-full text-left group",children:e.jsx("div",{className:"relative rounded-xl border border-slate-150 p-4 transition-all duration-200 hover:shadow-md hover:border-[#406E71]/30 hover:-translate-y-0.5 active:translate-y-0",style:{borderLeftWidth:"3px",borderLeftColor:Q.color},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("span",{className:"text-2xl shrink-0 mt-0.5",children:Gye[Q.icon]||"📅"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-slate-800 group-hover:text-[#406E71] transition-colors",children:Q.name}),Q.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:Q.description})]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full bg-slate-100 text-slate-600 text-xs font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),Q.duration_minutes,"m"]})]})})},Q.id))})]}),n==="date"&&o&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>{a("types"),c(null),p(null)},className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Back to meeting types"]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl border",style:{borderColor:o.color+"40",backgroundColor:o.color+"08"},children:[e.jsx("span",{className:"text-xl",children:Gye[o.icon]||"📅"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(un,{className:"h-3 w-3"}),o.duration_minutes," min"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(f,"MMMM yyyy")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(Xo,{className:"h-4 w-4"})}),e.jsx("button",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors",onClick:()=>g(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(oa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(Q=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Q},Q)),X.map((Q,ce)=>{if(!Q)return e.jsx("div",{},`pad-${ce}`);const ne=B(Q),re=i&&Tl(Q,i),oe=Tl(Q,new Date);return e.jsx("button",{disabled:!ne,onClick:()=>{c(Q),p(null)},className:`h-10 w-10 mx-auto rounded-xl text-sm font-medium transition-all duration-150 ${re?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-105":ne?"hover:bg-[#406E71]/10 text-slate-700 hover:text-[#406E71]":"text-slate-200 cursor-not-allowed"} ${oe&&!re?"ring-1 ring-[#406E71]/40":""}`,children:Q.getDate()},Q.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Od,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ms(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(un,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:V.map(Q=>{const ce=u===Q;return e.jsx("button",{onClick:()=>p(Q),className:`px-3 py-2.5 rounded-xl text-sm font-medium transition-all duration-150 ${ce?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children:ee(Q)},Q)})}),u&&e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg",onClick:()=>a("form"),children:"Continue to Details"})]})]}),n==="form"&&o&&i&&u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("button",{onClick:()=>a("date"),className:"flex items-center gap-1.5 text-xs font-medium text-slate-500 hover:text-slate-800 transition-colors",children:[e.jsx(Qa,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"rounded-xl bg-gradient-to-r from-[#406E71]/5 to-[#2a4c64]/5 border border-[#406E71]/15 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:Gye[o.icon]||"📅"}),e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-slate-600",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Od,{className:"h-3.5 w-3.5 text-[#406E71]"}),ms(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5 text-[#406E71]"}),ee(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(ze,{value:v.name,onChange:Q=>_({...v,name:Q.target.value}),placeholder:"Jane Smith",className:"h-11 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(lr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"email",value:v.email,onChange:Q=>_({...v,email:Q.target.value}),placeholder:"jane@email.com",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Mn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"tel",value:v.phone,onChange:Q=>_({...v,phone:Q.target.value}),placeholder:"(555) 123-4567",className:"h-11 pl-9 rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Pr,{value:v.message,onChange:Q=>_({...v,message:Q.target.value}),placeholder:"Anything you'd like the agent to know ahead of time?",rows:3,className:"rounded-xl border-slate-200 focus:border-[#406E71] focus:ring-[#406E71]/20 resize-none"})]})]}),e.jsx(K,{className:"w-full h-12 rounded-xl bg-[#406E71] hover:bg-[#365c5e] text-white font-semibold shadow-md shadow-[#406E71]/20 transition-all hover:shadow-lg disabled:opacity-60",onClick:Y,disabled:!v.name||w,children:w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(sa,{className:"h-10 w-10 text-white"})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-slate-800",children:"You're booked!"}),e.jsxs("p",{className:"text-slate-500 mt-1.5",children:[o==null?void 0:o.name," with ",(M==null?void 0:M.name)||"your agent"]})]}),e.jsx("div",{className:"inline-flex items-center gap-3 px-5 py-3 rounded-xl bg-slate-50 border border-slate-100",children:e.jsxs("div",{className:"text-left text-sm",children:[e.jsx("p",{className:"font-semibold text-slate-800",children:i&&ms(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&ee(u)," · ",o==null?void 0:o.duration_minutes," min"]})]})}),e.jsx("p",{className:"text-sm text-slate-400 max-w-xs mx-auto",children:"A confirmation with meeting details will be sent to you shortly."}),((M==null?void 0:M.phone)||(M==null?void 0:M.email))&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wider font-semibold",children:"Contact"}),e.jsxs("div",{className:"flex gap-3",children:[(M==null?void 0:M.phone)&&e.jsxs("a",{href:`tel:${M.phone}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#406E71]/10 text-[#406E71] text-xs font-medium hover:bg-[#406E71]/20 transition-colors",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Call"]}),(M==null?void 0:M.email)&&e.jsxs("a",{href:`mailto:${M.email}`,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-full bg-[#2a4c64]/10 text-[#2a4c64] text-xs font-medium hover:bg-[#2a4c64]/20 transition-colors",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]})}),e.jsx("p",{className:"text-center text-[10px] text-slate-300 mt-6 font-medium tracking-wide uppercase",children:"Powered by LevelUp"})]})]}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-sm w-full text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center",children:e.jsx(Od,{className:"h-8 w-8 text-slate-400"})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-700",children:"Page Not Available"}),e.jsx("p",{className:"text-sm text-slate-500",children:"This booking page doesn't exist or is currently inactive."})]})})}function UCs(){const s=dc().pathname.slice(1).split("/")[0];return N.useEffect(()=>{document.body.classList.add("booking-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("booking-page"),n.forEach(clearTimeout)}},[]),s?e.jsx(Rct,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground",children:"Visit a specific agent's booking URL to schedule a meeting."})]})})}function VCs(){const s=dc().pathname.slice(1);return N.useEffect(()=>{document.body.classList.add("connect-page");const r=()=>{['[id*="lc_text_widget"]','[id*="lc_text-widget"]','[class*="lc-text-widget"]','[class*="lc_text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("connect-page"),n.forEach(clearTimeout)}},[]),!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Connect"}),e.jsx("p",{className:"text-slate-500",children:"Stay connected with your real estate professional."}),e.jsx("p",{className:"text-slate-400 text-sm mt-2",children:"Visit a specific agent link to get started."})]})}):e.jsx(rQe,{slugOverride:s})}function Fct({slugOverride:t}){const{slug:s}=lo(),r=t||s,[n,a]=N.useState(!1),[o,l]=N.useState({}),[i,c]=N.useState(0),[u,p]=N.useState(!1),{data:f,isLoading:g}=mt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:$,error:U}=await H.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(U)throw U;return $},enabled:!!r}),{data:v=[]}=mt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:$,error:U}=await H.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(U)throw U;return $},enabled:!!(f!=null&&f.id)});N.useEffect(()=>{f!=null&&f.id&&H.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const _=Lt({mutationFn:async()=>{const $=v.find(Q=>Q.field_type==="text"&&Q.label.toLowerCase().includes("name")),U=v.find(Q=>Q.field_type==="email"),B=v.find(Q=>Q.field_type==="phone"),V=$?String(o[$.label]||""):null,X=U?String(o[U.label]||""):null,Y=B?String(o[B.label]||""):null,{error:ee}=await H.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:X,contact_phone:Y,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(ee)throw ee;H.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:X,contact_phone:Y,answers:o}}).catch(Q=>console.error("Landing page lead notification error:",Q))},onSuccess:()=>a(!0)}),w=$=>{$.preventDefault(),!(v.filter(B=>B.is_required&&!o[B.label]).length>0)&&_.mutate()};if(g)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const j=f.primary_color||"#406E71",k=f.accent_color||"#2a4c64",S=f,M=f.page_type==="lead_magnet",L=f.page_type==="just_listed"||f.page_type==="just_sold",P=Array.isArray(S.property_photos)?S.property_photos:[],O=S.lead_magnet_file_url||S.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(sa,{className:"h-16 w-16 mx-auto mb-4",style:{color:j}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:M?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),M&&O&&e.jsxs("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:j},children:[e.jsx(vi,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(Mn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(lr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(L){const $=U=>{const B=parseFloat(U.replace(/[^0-9.]/g,""));return isNaN(B)?U:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(B)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&P.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Mr,{className:"h-8 w-8"})}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===0?P.length-1:B-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx("img",{src:P[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:U=>U.stopPropagation()}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===P.length-1?0:B+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(oa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",P.length]})]}),P.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":j},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),P.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),p(!0)},children:[e.jsx("img",{src:P[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(J_,{className:"h-4 w-4"})," View"]})]}):P.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:P.slice(0,2).map((U,B)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{c(B),p(!0)},children:e.jsx("img",{src:U,alt:`Property ${B+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},B))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{c(0),p(!0)},children:e.jsx("img",{src:P[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),P.slice(1,5).map((U,B)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{c(B+1),p(!0)},children:[e.jsx("img",{src:U,alt:`Property ${B+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),B===3&&P.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",P.length-5," more"]})]},B))]}),P.length>2&&e.jsxs("button",{onClick:()=>{c(0),p(!0)},className:"absolute bottom-4 right-8 bg-white shadow-lg hover:shadow-xl text-gray-800 px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-2 transition-shadow",children:[e.jsx(J_,{className:"h-4 w-4"})," View all ",P.length," photos"]})]}),P.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[S.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:j},children:$(S.property_price)}),S.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(ia,{className:"h-5 w-5 shrink-0"})," ",S.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[S.property_beds&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Mh,{className:"h-5 w-5",style:{color:j}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(su,{className:"h-5 w-5",style:{color:j}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(Ax,{className:"h-5 w-5",style:{color:j}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:j},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Mn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(lr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-3",children:[v.map(U=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-xs font-medium",children:[U.label,U.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),m9e(U,o,l)]},U.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:_.isPending,children:_.isPending?"Submitting...":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${k})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),M&&S.lead_magnet_file_name&&e.jsxs("div",{className:"mt-6 inline-flex items-center gap-2 bg-white/20 backdrop-blur px-4 py-2 rounded-full text-sm",children:[e.jsx(vi,{className:"h-4 w-4"}),"Free Download: ",S.lead_magnet_file_name]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 -mt-8",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[M&&e.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"Fill out the form below to get your free download!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-6 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:f.agent_name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(Mn,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(lr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[v.map($=>e.jsxs("div",{children:[e.jsxs(be,{className:"text-sm font-medium",children:[$.label,$.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),m9e($,o,l)]},$.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:_.isPending,children:_.isPending?"Submitting...":M?"Get My Free Download":"Submit"}),_.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function m9e(t,s,r,n){const a=s[t.label]||"",o=Array.isArray(t.options)?t.options:[];switch(t.field_type){case"text":case"email":case"phone":return e.jsx(ze,{type:t.field_type==="email"?"email":t.field_type==="phone"?"tel":"text",value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",className:"mt-1"});case"textarea":return e.jsx(Pr,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),placeholder:t.placeholder||"",rows:3,className:"mt-1"});case"select":return e.jsxs(Ks,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Ys,{placeholder:"Select..."})}),e.jsx(Ws,{children:o.map(l=>e.jsx(Mt,{value:l,children:l},l))})]});case"multiselect":return e.jsx("div",{className:"mt-1 space-y-2",children:o.map(l=>{const i=Array.isArray(a)?a:[];return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Oo,{checked:i.includes(l),onCheckedChange:c=>{const u=c?[...i,l]:i.filter(p=>p!==l);r(p=>({...p,[t.label]:u}))}}),e.jsx("span",{className:"text-sm",children:l})]},l)})});case"toggle":return e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(qr,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(ze,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function HCs(){const s=dc().pathname.slice(1).split("/")[0];return N.useEffect(()=>{document.body.classList.add("landing-page-public");const r=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[class*="lc_text_widget"]',".lc_text-widget--bubble",'[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="leadconnector"]','iframe[src*="msgsndr"]',"[data-chat-widget]","[data-widget-id]",'div[style*="z-index"][style*="position: fixed"][style*="bottom"]','div[id^="fc_"]','div[id^="hubspot"]',".widget-visible"].forEach(o=>{document.querySelectorAll(o).forEach(l=>{l.style.display="none"})})};r();const n=[setTimeout(r,500),setTimeout(r,1500),setTimeout(r,3e3),setTimeout(r,5e3)];return()=>{document.body.classList.remove("landing-page-public"),n.forEach(clearTimeout)}},[]),s?e.jsx(Fct,{slugOverride:s}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"LevelUp Pages"}),e.jsx("p",{className:"text-gray-500",children:"Visit a specific page URL to view content."})]})})}const Ime=[{type:"hero",enabled:!0},{type:"featured_listings",enabled:!0},{type:"new_listings",enabled:!1},{type:"open_houses",enabled:!1},{type:"my_listings",enabled:!1},{type:"city_pages",enabled:!1},{type:"featured_areas",enabled:!0},{type:"about",enabled:!0},{type:"testimonials",enabled:!0},{type:"cta_banner",enabled:!0}],rAs={hero:"Hero Section",featured_listings:"Featured Listings",featured_areas:"Featured Areas",about:"About Me",testimonials:"Testimonials",cta_banner:"Call To Action",new_listings:"New Listings Carousel",open_houses:"Open Houses Carousel",my_listings:"My Listings Carousel",city_pages:"City Pages Grid",property_types:"Property Types Gallery",advantages:"Advantages / Why Choose Us",lifestyle_gallery:"Lifestyle Gallery",market_pulse:"Market Pulse",concierge_services:"Concierge Services",land_use_guide:"Land Use Guide",land_valuation_cta:"Land Valuation CTA",acreage_showcase:"Acreage Showcase"},nAs={hero:"Full-screen background image with headline, subtitle, and search bar",featured_listings:"Grid of highlighted properties from the MLS",featured_areas:"Spotlight regions or neighborhoods that link to property search",about:"Agent photo, bio, and credentials section",testimonials:"Client reviews carousel with quotes",cta_banner:"Call-to-action block to drive contact and search engagement",new_listings:"Horizontal carousel of newest listings, filterable by city",open_houses:"Horizontal carousel of open house listings, filterable by city",my_listings:"Showcase the agent's own active listings in a carousel",city_pages:"Grid of your city landing pages with photos and links",property_types:"Visual gallery of property categories (Ranch, Farm, Land, etc.)",advantages:"Feature cards highlighting your expertise and unique value",lifestyle_gallery:"Cinematic photo grid showcasing luxury living — pools, views, interiors",market_pulse:"Sleek market stats dashboard with avg price, days on market, inventory",concierge_services:"White-glove services showcase — staging, design, moving coordination",land_use_guide:"Interactive land use cards — Agriculture, Hunting, Equestrian, Recreational",land_valuation_cta:`"What's Your Land Worth?" — bold call-to-action for landowners`,acreage_showcase:"Large visual cards emphasizing lot size with aerial imagery"},p9e={basic:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner"],luxury:["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","lifestyle_gallery","market_pulse","concierge_services"],"land-ranch":["hero","featured_listings","new_listings","open_houses","my_listings","city_pages","featured_areas","about","testimonials","cta_banner","property_types","advantages","land_use_guide","land_valuation_cta","acreage_showcase"]};function aAs(t){return p9e[t]||p9e.basic}function GCs(t){const s=t.theme_config||{};return{themeTier:t.theme_tier||"basic",brandColor:t.brand_color||"#0f172a",accentColor:t.accent_color||"#3b82f6",fontFamily:t.font_family||"Inter",heroImageUrl:t.hero_image_url||null,homepageModules:Array.isArray(t.homepage_modules)&&t.homepage_modules.length?t.homepage_modules:Ime,testimonials:Array.isArray(t.testimonials)?t.testimonials:[],featuredListingIds:t.featured_listing_ids||[],searchCities:Array.isArray(s.searchCities)?s.searchCities:[],searchZipCodes:Array.isArray(s.searchZipCodes)?s.searchZipCodes:[],searchCounties:Array.isArray(s.searchCounties)?s.searchCounties:[]}}function WCs(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function KCs(){const t=WCs(),{data:s,isLoading:r,error:n}=mt({queryKey:["lead-site",t],queryFn:async()=>{var p;if(!t)return null;const{data:a,error:o}=await H.from("lead_sites").select("*").eq("subdomain_slug",t).eq("is_active",!0).maybeSingle();if(o)throw o;if(!a)return null;const{data:l}=await H.from("profiles").select("id, name, avatar_url, email, phone, title, bio").eq("id",a.agent_id).single();let i=null;if(a.show_team_logo)if(a.team_logo_url)i=a.team_logo_url;else{const{data:f}=await H.from("team_members").select("team_id, teams(avatar_url, name)").eq("user_id",a.agent_id).limit(1).maybeSingle();f&&((p=f.teams)!=null&&p.avatar_url)&&(i=f.teams.avatar_url)}const c={id:a.id,agentId:a.agent_id,subdomainSlug:a.subdomain_slug,mlsProviderId:a.mls_provider_id,siteTitle:a.site_title,siteTagline:a.site_tagline,leadRegistrationMode:a.lead_registration_mode||"disabled",registrationTriggerCount:a.registration_trigger_count??1,themeConfig:a.theme_config||{},isActive:a.is_active,brokerageLegalName:a.brokerage_legal_name||null,brokerageLicenseNumber:a.brokerage_license_number||null,agentLicenseNumber:a.agent_license_number||null,mlsDisclaimerText:a.mls_disclaimer_text||null,mlsLogoUrl:a.mls_logo_url||null,equalHousingEnabled:a.equal_housing_enabled??!0,faviconUrl:a.favicon_url||null,ogImageUrl:a.og_image_url||null,showTeamLogo:a.show_team_logo??!1,teamLogoUrl:i,agent:l?{id:l.id,full_name:l.name||"",avatar_url:l.avatar_url,email:l.email,phone:l.phone,title:l.title,bio:l.bio}:void 0},u=GCs(a);return{siteConfig:c,themeConfig:u}},enabled:!!t});return{siteConfig:(s==null?void 0:s.siteConfig)??null,themeConfig:(s==null?void 0:s.themeConfig)??null,isLoading:r,error:n,slug:t}}async function ZE(t,s){try{await H.functions.invoke("lead-site-notify",{body:{lead:s,lead_site_id:t}})}catch(r){console.warn("Lead notification failed:",r)}}const zct=N.createContext(null);function F3(){const t=N.useContext(zct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function ZCs({siteConfig:t,children:s}){const[r,n]=N.useState(null),[a,o]=N.useState(null),[l,i]=N.useState(!0);N.useEffect(()=>{const{data:{subscription:f}}=H.auth.onAuthStateChange(async(g,v)=>{const _=(v==null?void 0:v.user)??null;if(n(_),_){const{data:w}=await H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",_.id).eq("lead_site_id",t.id).maybeSingle();w&&o({...w,email:_.email||""})}else o(null);i(!1)});return H.auth.getSession().then(({data:{session:g}})=>{n((g==null?void 0:g.user)??null),g!=null&&g.user?H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",g.user.id).eq("lead_site_id",t.id).maybeSingle().then(({data:v})=>{v&&o({...v,email:g.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const c=N.useCallback(async f=>{const g=f.email.toLowerCase().trim(),v=f.phone.replace(/\D/g,""),{data:_,error:w}=await H.auth.signUp({email:g,password:v,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(w){if(w.message.includes("already registered")){await u(g,v);return}throw w}if(_.user){const{error:j}=await H.from("lead_site_consumer_profiles").insert({user_id:_.user.id,lead_site_id:t.id,name:f.name.trim(),phone:f.phone.trim()});j&&console.warn("Consumer profile insert error:",j);const{error:k}=await H.from("lead_site_leads").insert({lead_site_id:t.id,name:f.name.trim(),email:g,phone:f.phone.trim(),message:"Created account on website",source_page:window.location.pathname,lead_type:"website_registration",metadata:{registered:!0,has_account:!0}});k&&console.error("Lead insert error (CRM sync may not trigger):",k),ZE(t.id,{name:f.name.trim(),email:g,phone:f.phone.trim(),lead_type:"website_registration",message:"Created account on website",source_page:window.location.pathname})}},[t.id]),u=N.useCallback(async(f,g)=>{const v=g.replace(/\D/g,""),{error:_}=await H.auth.signInWithPassword({email:f.toLowerCase().trim(),password:v});if(_)throw _},[]),p=N.useCallback(async()=>{await H.auth.signOut(),n(null),o(null)},[]);return e.jsx(zct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:c,signIn:u,signOut:p},children:s})}function FR({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a}){var O;const{signUp:o,signIn:l}=F3(),[i,c]=N.useState(!1),[u,p]=N.useState(""),[f,g]=N.useState(""),[v,_]=N.useState(""),[w,j]=N.useState(!1),[k,S]=N.useState(""),M=s==="required",L=((O=r.agent)==null?void 0:O.full_name)||"the agent",P=async $=>{var B;if($.preventDefault(),S(""),!f.trim()||!v.trim()){S("Email and phone number are required.");return}if(!i&&!u.trim()){S("Name is required.");return}if(v.replace(/\D/g,"").length<7){S("Please enter a valid phone number.");return}j(!0);try{i?await l(f,v):await o({name:u,email:f,phone:v}),n()}catch(V){(B=V==null?void 0:V.message)!=null&&B.includes("Invalid login")?S("Invalid email or phone number. Please try again."):S((V==null?void 0:V.message)||"Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(xs,{open:t,onOpenChange:M?void 0:$=>{$||a()},children:e.jsxs(fs,{className:"sm:max-w-md",onPointerDownOutside:M?$=>$.preventDefault():void 0,onEscapeKeyDown:M?$=>$.preventDefault():void 0,children:[e.jsxs(js,{children:[e.jsx(_s,{className:"text-xl",children:i?"Welcome Back":M?"Create a Free Account to Continue":"Save Your Search & Get Updates"}),e.jsx(Wr,{children:i?"Sign in with your email and phone number.":`Create a free account to save favorites, get alerts, and connect with ${L}.`})]}),e.jsxs("form",{onSubmit:P,className:"space-y-3 mt-2",children:[!i&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:u,onChange:$=>p($.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address",value:f,onChange:$=>g($.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsxs("div",{children:[e.jsx("input",{type:"tel",required:!0,placeholder:"Phone number",value:v,onChange:$=>_($.target.value),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:i?"Your phone number is your password":"Your phone number will be used as your password"})]}),k&&e.jsx("p",{className:"text-red-600 text-sm",children:k}),e.jsx("button",{type:"submit",disabled:w,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:w?i?"Signing in...":"Creating account...":i?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{c(!i),S("")},className:"w-full text-center text-sm text-blue-600 hover:text-blue-700",children:i?"Don't have an account? Sign up":"Already have an account? Sign in"}),!M&&!i&&e.jsx("button",{type:"button",onClick:a,className:"w-full py-2 text-gray-500 text-sm hover:text-gray-700 transition-colors",children:"Skip for now"})]}),e.jsx("p",{className:"text-xs text-gray-400 text-center mt-1",children:"By registering you agree to receive property updates. You can unsubscribe anytime."})]})})}function zR({siteConfig:t,pagePath:s}){const r=t.agent;if(!r)return null;const n=`https://${t.subdomainSlug}.thelocalmove.com`,a={"@context":"https://schema.org","@type":"RealEstateAgent","@id":`${n}/#agent`,name:r.full_name,url:n,image:r.avatar_url||void 0,email:r.email,telephone:r.phone||void 0,jobTitle:r.title||"Real Estate Agent",description:r.bio||`${r.full_name} is a trusted real estate professional.`,...t.brokerageLegalName&&{worksFor:{"@type":"RealEstateAgent",name:t.brokerageLegalName}}},o={"@context":"https://schema.org","@type":"WebSite","@id":`${n}/#website`,name:t.siteTitle||`${r.full_name} Real Estate`,url:n,publisher:{"@id":`${n}/#agent`},potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${n}/search?q={search_term_string}`},"query-input":"required name=search_term_string"}};return e.jsxs($l,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(a)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(o)})]})}function Lme({items:t,siteConfig:s}){const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((a,o)=>({"@type":"ListItem",position:o+1,name:a.name,item:`${r}${a.path}`}))};return e.jsx($l,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function Bct({listing:t,siteConfig:s}){var a;const r=`https://${s.subdomainSlug}.thelocalmove.com`,n={"@context":"https://schema.org","@type":"SingleFamilyResidence",name:`${t.address}, ${t.city}, ${t.state} ${t.zip}`,url:`${r}/listing/${t.mlsNumber}`,image:((a=t.photos)==null?void 0:a[0])||void 0,numberOfRooms:t.bedrooms,numberOfBathroomsTotal:t.bathrooms,floorSize:t.sqft?{"@type":"QuantitativeValue",value:t.sqft,unitCode:"FTK"}:void 0,address:{"@type":"PostalAddress",streetAddress:t.address,addressLocality:t.city,addressRegion:t.state,postalCode:t.zip},...t.latitude&&t.longitude&&{geo:{"@type":"GeoCoordinates",latitude:t.latitude,longitude:t.longitude}},offers:{"@type":"Offer",price:t.price,priceCurrency:"USD",availability:t.status==="Active"?"https://schema.org/InStock":"https://schema.org/SoldOut"},...t.yearBuilt&&{yearBuilt:t.yearBuilt}};return e.jsx($l,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function YCs({faqs:t}){if(!t.length)return null;const s={"@context":"https://schema.org","@type":"FAQPage",mainEntity:t.map(r=>({"@type":"Question",name:r.question,acceptedAnswer:{"@type":"Answer",text:r.answer}}))};return e.jsx($l,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function QCs({title:t,description:s,publishedAt:r,imageUrl:n,slug:a,siteConfig:o}){const l=`https://${o.subdomainSlug}.thelocalmove.com`,i=o.agent,c={"@context":"https://schema.org","@type":"Article",headline:t,description:s,url:`${l}/blog/${a}`,datePublished:r,...n&&{image:n},author:i?{"@type":"Person",name:i.full_name,url:l}:void 0,publisher:{"@type":"Organization",name:o.siteTitle||(i==null?void 0:i.full_name)||"Agent",url:l}};return e.jsx($l,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(c)})})}const f9e="ls_visitor_geo",XCs=1e3*60*60;function JCs(t){return t==="/"?"home":t==="/search"?"search":t==="/sell"?"sell":t==="/blog"?"blog":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":t==="/dashboard"?"dashboard":"other"}function e5s(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"sell":return"Sell Your Home";case"blog":return"Blog";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");case"dashboard":return"My Dashboard";default:return t}}async function t5s(){try{const t=localStorage.getItem(f9e);if(t){const s=JSON.parse(t);if(Date.now()-s.ts{o.current||(o.current=!0,t5s().then(l=>{a.current=l}))},[]),N.useEffect(()=>{if(!(t!=null&&t.id))return;const l=r.pathname;if(l===n.current)return;n.current=l;const i=JCs(l),c=e5s(l,i),u=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,p=a.current;H.from("lead_site_page_views").insert({lead_site_id:t.id,page_type:i,page_path:l,page_title:c,visitor_fingerprint:u,auth_user_id:s||null,visitor_city:(p==null?void 0:p.city)||null,visitor_region:(p==null?void 0:p.region)||null,visitor_country:(p==null?void 0:p.country)||null,visitor_lat:(p==null?void 0:p.lat)||null,visitor_lng:(p==null?void 0:p.lng)||null}).then(({error:f})=>{f&&console.error("[PageTracking] insert failed:",f.message)})},[r.pathname,t==null?void 0:t.id,s])}const s5s=3e4;function T3e(t,s){const r=dc(),n=N.useRef(null),a=N.useRef(null),o=N.useRef(0),l=r.pathname,i=r5s(l),c=n5s(l,i),u=i==="listing"&&l.split("/listing/")[1]||null;N.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;i==="listing"&&(o.current+=1);const p=localStorage.getItem(`ls_visitor_fp_${t.id}`)||null,f=async()=>{const{data:g,error:v}=await H.from("lead_site_active_visitors").upsert({lead_site_id:t.id,auth_user_id:s,visitor_fingerprint:p,current_page_path:l,current_page_title:c,current_mls_number:u,last_seen_at:new Date().toISOString(),listing_views_count:o.current},{onConflict:"lead_site_id,coalesce(auth_user_id::text,visitor_fingerprint,'')"}).select("id, notified_agent").single();!v&&g&&(n.current=g.id,o.current>=2&&!g.notified_agent&&H.functions.invoke("lead-site-presence-notify",{body:{visitor_id:g.id,lead_site_id:t.id}}).catch(()=>{}))};return f(),a.current&&clearInterval(a.current),a.current=setInterval(f,s5s),()=>{a.current&&clearInterval(a.current)}},[t==null?void 0:t.id,s,l]),N.useEffect(()=>{if(!(t!=null&&t.id)||!s)return;const p=()=>{n.current&&H.from("lead_site_active_visitors").delete().eq("id",n.current).then(()=>{})};return window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[t==null?void 0:t.id,s])}function r5s(t){return t==="/"?"home":t==="/search"?"search":t.startsWith("/listing/")?"listing":t.startsWith("/homes-for-sale-in-")?"city":"other"}function n5s(t,s){switch(s){case"home":return"Home";case"search":return"Search";case"listing":return`Listing ${t.split("/listing/")[1]||""}`;case"city":return t.replace("/homes-for-sale-in-","").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ");default:return t}}function a5s({children:t,siteConfig:s}){var X,Y,ee,Q,ce,ne,re,oe,fe;const r=dc(),n=nr(),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(!1),[p,f]=N.useState([]),g=N.useRef(null),{user:v,profile:_,signOut:w}=F3();M3e(s,v==null?void 0:v.id),T3e(s,v==null?void 0:v.id);const j=((X=s.agent)==null?void 0:X.full_name)||"Agent",k=s.siteTitle||`${j} Real Estate`,S=r.pathname==="/search",M=r.pathname==="/",L=s.leadRegistrationMode!=="disabled";N.useEffect(()=>{(async()=>{const{data:ue}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(ue||[])})()},[s.id]),N.useEffect(()=>{const ge=ue=>{g.current&&!g.current.contains(ue.target)&&u(!1)};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]);const P=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],O=M?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",$=s.siteTitle||`${j} - Real Estate`,U=s.siteTagline||`Browse homes and listings with ${j}`,B=s.ogImageUrl||((Y=s.agent)==null?void 0:Y.avatar_url)||"",V=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${S?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(zR,{siteConfig:s,pagePath:r.pathname}),e.jsxs($l,{children:[e.jsx("title",{children:$}),e.jsx("meta",{name:"description",content:U}),e.jsx("meta",{property:"og:title",content:$}),e.jsx("meta",{property:"og:description",content:U}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:V+r.pathname}),B&&e.jsx("meta",{property:"og:image",content:B}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:$}),e.jsx("meta",{name:"twitter:description",content:U}),B&&e.jsx("meta",{name:"twitter:image",content:B}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${V}${r.pathname}`}),s.subdomainSlug==="matthogg"&&e.jsx("script",{src:"https://analytics.ahrefs.com/analytics.js","data-key":"kyFjzruyvE0yTdMokzgCBw",async:!0})]}),e.jsxs("header",{className:`${M?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsxs(pa,{to:"/",className:"flex items-center gap-3",children:[((ee=s.agent)==null?void 0:ee.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:j,className:"h-10 w-10 rounded-full object-cover ring-2 ring-white/20"}),e.jsx("div",{children:e.jsx("span",{className:"font-bold text-lg leading-none tracking-tight",children:k})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[P.map(ge=>e.jsx(pa,{to:ge.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===ge.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:ge.label},ge.to)),p.length>0&&e.jsxs("div",{ref:g,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!c),className:`flex items-center gap-1 px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname.startsWith("/homes-for-sale-in-")?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:["Cities ",e.jsx(oo,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-52 bg-white rounded-xl shadow-xl border border-gray-100 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(ge=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ge.city_slug}`),u(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 hover:bg-gray-50 hover:text-gray-900 transition-colors",children:ge.city_name},ge.city_slug))})]}),v?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(pa,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Ya,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(pa,{to:"/account",className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${M?"text-white/70 hover:text-white hover:bg-white/10":"text-gray-500 hover:text-gray-900 hover:bg-gray-50"}`,children:[e.jsx(Wi,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((Q=_==null?void 0:_.name)==null?void 0:Q.split(" ")[0])||"Account"})]})]}):L?e.jsx("button",{onClick:()=>i(!0),className:`ml-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${M?"bg-white/15 text-white hover:bg-white/25":"bg-blue-600 text-white hover:bg-blue-700"}`,children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>o(!a),className:`md:hidden p-2 rounded-lg ${M?"text-white hover:bg-white/10":"text-gray-600 hover:bg-gray-100"}`,children:a?e.jsx(Mr,{className:"h-5 w-5"}):e.jsx(pS,{className:"h-5 w-5"})})]})}),a&&e.jsx("div",{className:`md:hidden border-t ${M?"border-white/10 bg-black/80 backdrop-blur":"border-gray-100 bg-white"}`,children:e.jsxs("div",{className:"px-4 py-3 space-y-1",children:[P.map(ge=>e.jsx(pa,{to:ge.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===ge.to?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ge.label},ge.to)),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-3 pt-3 pb-1 text-xs font-semibold uppercase tracking-wider ${M?"text-white/40":"text-gray-400"}`,children:"Cities"}),p.map(ge=>e.jsx(pa,{to:`/homes-for-sale-in-${ge.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${ge.city_slug}`?M?"bg-white/15 text-white":"bg-gray-100 text-gray-900":M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:ge.city_name},ge.city_slug))]}),v?e.jsxs(e.Fragment,{children:[e.jsx(pa,{to:"/account",onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"My Account"}),e.jsx("button",{onClick:async()=>{await w(),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-gray-500 hover:bg-gray-50"}`,children:"Sign Out"})]}):L?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:`block w-full text-left px-3 py-2.5 rounded-lg text-sm font-medium ${M?"text-white/70 hover:bg-white/10":"text-blue-600 hover:bg-blue-50"}`,children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!S&&e.jsx("footer",{className:"bg-gray-950 text-gray-400",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[((ce=s.agent)==null?void 0:ce.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:j,className:"h-16 w-16 rounded-2xl object-cover ring-2 ring-white/10"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-white text-lg tracking-tight",children:j}),e.jsx("p",{className:"text-sm text-gray-500",children:((ne=s.agent)==null?void 0:ne.title)||"Real Estate Professional"})]})]}),((re=s.agent)==null?void 0:re.phone)&&e.jsx("p",{className:"text-sm mt-3",children:e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((oe=s.agent)==null?void 0:oe.email)&&e.jsx("p",{className:"text-sm mt-1",children:e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"hover:text-white transition-colors flex items-center gap-2",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("ul",{className:"space-y-3 text-sm",children:P.map(ge=>e.jsx("li",{children:e.jsx(pa,{to:ge.to,className:"hover:text-white transition-colors",children:ge.label})},ge.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-white mb-4 text-sm tracking-wider uppercase",children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed mb-4",children:"Ready to find your dream home? Get in touch today for a personalized consultation."}),e.jsx(pa,{to:"/contact",className:"inline-block px-5 py-2.5 bg-white text-gray-900 text-sm font-semibold rounded-lg hover:bg-gray-100 transition-colors",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-14 pt-6 border-t border-gray-800/50",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-12 w-auto object-contain"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-gray-500 mb-3",children:[e.jsxs("span",{children:[j," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-8 w-auto flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-gray-600 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-600",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-5 w-5 text-gray-500",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",j,". Powered by LevelUp."]})]})]})]})}),!S&&((fe=s.agent)==null?void 0:fe.avatar_url)&&e.jsx(i5s,{agent:s.agent}),l&&e.jsx(FR,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function i5s({agent:t}){var a;const[s,r]=N.useState(!1),n=nr();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:s?e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl border border-gray-200 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-2 ring-gray-100"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900 text-sm",children:t.full_name}),e.jsx("p",{className:"text-xs text-gray-500",children:t.title||"Real Estate Professional"})]})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Have questions about a property or the area? I'm here to help!"}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(Mn,{className:"h-4 w-4 text-gray-400"}),t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2 bg-gray-50 hover:bg-gray-100 rounded-xl text-sm text-gray-700 transition-colors",children:[e.jsx(lr,{className:"h-4 w-4 text-gray-400"}),"Email Me"]}),e.jsx("button",{onClick:()=>{r(!1),n("/contact")},className:"w-full px-3 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold rounded-xl transition-colors",children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>r(!1),className:"absolute top-3 right-3 p-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100",children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>r(!0),className:"group flex items-center gap-3 bg-white pl-1.5 pr-5 py-1.5 rounded-full shadow-xl border border-gray-200 hover:shadow-2xl transition-all hover:scale-105",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-2 ring-blue-100"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-xs font-bold text-gray-900 leading-none",children:(a=t.full_name)==null?void 0:a.split(" ")[0]}),e.jsx("p",{className:"text-[10px] text-blue-600 font-medium mt-0.5",children:"Chat with me →"})]})]})}):null}function o5s({children:t,siteConfig:s}){var Q,ce,ne,re,oe,fe,ge;const r=dc(),n=nr(),[a,o]=N.useState(!1),[l,i]=N.useState(!1),[c,u]=N.useState(!1),[p,f]=N.useState([]),[g,v]=N.useState(!1),_=N.useRef(null),{user:w,profile:j,signOut:k}=F3();M3e(s,w==null?void 0:w.id),T3e(s,w==null?void 0:w.id);const S=((Q=s.agent)==null?void 0:Q.full_name)||"Agent",M=s.siteTitle||`${S} Real Estate`,L=r.pathname==="/search",P=r.pathname==="/",O=s.leadRegistrationMode!=="disabled",$="#c9a96e";N.useEffect(()=>{const ue=()=>v(window.scrollY>80);return window.addEventListener("scroll",ue,{passive:!0}),()=>window.removeEventListener("scroll",ue)},[]),N.useEffect(()=>{(async()=>{const{data:xe}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order",{ascending:!0});f(xe||[])})()},[s.id]),N.useEffect(()=>{const ue=xe=>{_.current&&!_.current.contains(xe.target)&&u(!1)};return document.addEventListener("mousedown",ue),()=>document.removeEventListener("mousedown",ue)},[]);const U=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/sell",label:"Sell"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],B=s.siteTitle||`${S} - Real Estate`,V=s.siteTagline||`Browse homes and listings with ${S}`,X=s.ogImageUrl||((ce=s.agent)==null?void 0:ce.avatar_url)||"",Y=`https://${s.subdomainSlug||""}.thelocalmove.com`,ee=P?g?"bg-[#0d0b0a]/95 backdrop-blur-lg border-b border-white/5":"bg-transparent":"bg-[#0d0b0a] border-b border-white/5";return e.jsxs("div",{className:`flex flex-col ${L?"h-screen overflow-hidden":"min-h-screen"} bg-[#0d0b0a]`,children:[e.jsx(zR,{siteConfig:s,pagePath:r.pathname}),e.jsxs($l,{children:[e.jsx("title",{children:B}),e.jsx("meta",{name:"description",content:V}),e.jsx("meta",{property:"og:title",content:B}),e.jsx("meta",{property:"og:description",content:V}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:Y+r.pathname}),X&&e.jsx("meta",{property:"og:image",content:X}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:B}),e.jsx("meta",{name:"twitter:description",content:V}),X&&e.jsx("meta",{name:"twitter:image",content:X}),s.faviconUrl&&e.jsx("link",{rel:"icon",href:s.faviconUrl,type:"image/png"}),e.jsx("link",{rel:"canonical",href:`${Y}${r.pathname}`}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap",rel:"stylesheet"})]}),e.jsxs("header",{className:`${P?"fixed":"sticky"} top-0 left-0 right-0 z-50 transition-all duration-500 ${ee}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-20",children:[e.jsx(pa,{to:"/",className:"flex items-center gap-3",children:e.jsx("span",{className:"text-white text-xl tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:M})}),e.jsxs("nav",{className:"hidden lg:flex items-center gap-1",children:[U.map(ue=>e.jsx(pa,{to:ue.to,className:`px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname===ue.to?"text-white":"text-white/40 hover:text-white"}`,children:ue.label},ue.to)),p.length>0&&e.jsxs("div",{ref:_,className:"relative",children:[e.jsxs("button",{onClick:()=>u(!c),className:`flex items-center gap-1 px-4 py-2 text-xs tracking-[0.15em] uppercase transition-colors duration-300 ${r.pathname.startsWith("/homes-for-sale-in-")?"text-white":"text-white/40 hover:text-white"}`,children:["Cities ",e.jsx(oo,{className:`h-3 w-3 transition-transform ${c?"rotate-180":""}`})]}),c&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-[#1a1715] border border-white/10 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-150",children:p.map(ue=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${ue.city_slug}`),u(!1)},className:"w-full text-left px-5 py-2.5 text-xs tracking-wider text-white/50 hover:text-white hover:bg-white/5 uppercase transition-colors",children:ue.city_name},ue.city_slug))})]}),w?e.jsxs("div",{className:"flex items-center gap-1 ml-3",children:[e.jsxs(pa,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Ya,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Saved"})]}),e.jsxs(pa,{to:"/account",className:"flex items-center gap-1.5 px-3 py-2 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:[e.jsx(Wi,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:((ne=j==null?void 0:j.name)==null?void 0:ne.split(" ")[0])||"Account"})]})]}):O?e.jsx("button",{onClick:()=>i(!0),className:"ml-3 px-5 py-2 text-xs tracking-[0.2em] uppercase border border-white/20 text-white/60 hover:bg-white hover:text-black transition-all duration-500",children:"Sign In"}):null]}),e.jsxs("button",{onClick:()=>o(!a),className:"lg:hidden p-2 text-white/60 hover:text-white",children:[e.jsx("div",{className:"flex flex-col items-center gap-0.5",children:a?e.jsx(Mr,{className:"h-5 w-5"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-px bg-current"}),e.jsx("div",{className:"w-4 h-px bg-current mt-1.5"}),e.jsx("div",{className:"w-6 h-px bg-current mt-1.5"})]})}),e.jsx("span",{className:"text-[8px] tracking-[0.3em] uppercase mt-1 block",children:"MENU"})]})]})}),a&&e.jsx("div",{className:"lg:hidden border-t border-white/5 bg-[#0d0b0a]/98 backdrop-blur-lg",children:e.jsxs("div",{className:"px-6 py-4 space-y-1",children:[U.map(ue=>e.jsx(pa,{to:ue.to,onClick:()=>o(!1),className:`block px-3 py-3 text-xs tracking-[0.2em] uppercase transition-colors ${r.pathname===ue.to?"text-white":"text-white/40 hover:text-white"}`,children:ue.label},ue.to)),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-4 pb-2 text-[10px] tracking-[0.3em] uppercase",style:{color:$},children:"Cities"}),p.map(ue=>e.jsx(pa,{to:`/homes-for-sale-in-${ue.city_slug}`,onClick:()=>o(!1),className:"block px-3 py-2.5 text-xs tracking-wider text-white/40 hover:text-white uppercase transition-colors",children:ue.city_name},ue.city_slug))]}),w?e.jsxs(e.Fragment,{children:[e.jsx(pa,{to:"/account",onClick:()=>o(!1),className:"block px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"My Account"}),e.jsx("button",{onClick:async()=>{await k(),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign Out"})]}):O?e.jsx("button",{onClick:()=>{i(!0),o(!1)},className:"block w-full text-left px-3 py-3 text-xs tracking-[0.2em] uppercase text-white/40 hover:text-white",children:"Sign In / Register"}):null]})})]}),e.jsx("main",{className:"flex-1 min-h-0 flex flex-col",children:t}),!L&&e.jsx("footer",{className:"bg-[#0a0908] text-white/30 border-t border-white/5",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-20",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-16",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white text-xl tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:S}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.15em] uppercase mb-6",children:((re=s.agent)==null?void 0:re.title)||"Real Estate Professional"}),((oe=s.agent)==null?void 0:oe.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors mb-3",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," ",s.agent.phone]}),((fe=s.agent)==null?void 0:fe.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-3 text-sm text-white/30 hover:text-white transition-colors",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," ",s.agent.email]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:$},children:"Quick Links"}),e.jsx("ul",{className:"space-y-3",children:U.map(ue=>e.jsx("li",{children:e.jsx(pa,{to:ue.to,className:"text-xs tracking-wider uppercase text-white/30 hover:text-white transition-colors",children:ue.label})},ue.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs tracking-[0.3em] uppercase mb-6",style:{color:$},children:"Get In Touch"}),e.jsx("p",{className:"text-sm text-white/20 leading-relaxed mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Ready to experience luxury real estate? Let's connect."}),e.jsx(pa,{to:"/contact",className:"inline-block px-8 py-3 text-xs tracking-[0.3em] uppercase border border-white/15 text-white/50 hover:bg-white hover:text-black transition-all duration-500",children:"Contact Me"})]})]}),e.jsxs("div",{className:"mt-16 pt-8 border-t border-white/5",children:[s.showTeamLogo&&s.teamLogoUrl&&e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("img",{src:s.teamLogoUrl,alt:"Team",className:"h-10 w-auto object-contain opacity-40"})}),s.brokerageLegalName&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-[10px] text-white/15 tracking-wider uppercase mb-3",children:[e.jsxs("span",{children:[S," · ",s.brokerageLegalName]}),s.agentLicenseNumber&&e.jsx("span",{children:s.agentLicenseNumber}),s.brokerageLicenseNumber&&e.jsxs("span",{children:["Brokerage #",s.brokerageLicenseNumber]})]}),s.mlsDisclaimerText&&e.jsxs("div",{className:"flex items-start justify-center gap-3 mb-4",children:[s.mlsLogoUrl&&e.jsx("img",{src:s.mlsLogoUrl,alt:"MLS",className:"h-6 w-auto flex-shrink-0 mt-0.5 opacity-30"}),e.jsx("p",{className:"text-[10px] text-white/15 leading-relaxed max-w-3xl text-center",children:s.mlsDisclaimerText})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px] text-white/15 tracking-wider uppercase",children:[s.equalHousingEnabled&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4",children:e.jsx("path",{d:"M12 2L2 8v2h20V8L12 2zm0 2.5L18.5 8h-13L12 4.5zM4 12v8h4v-6h8v6h4v-8H4zm6 8v-4h4v4h-4z"})}),e.jsx("span",{children:"Equal Housing Opportunity"})]}),e.jsxs("span",{children:["© ",new Date().getFullYear()," ",S,". Powered by LevelUp."]})]})]})]})}),!L&&((ge=s.agent)==null?void 0:ge.avatar_url)&&e.jsx(l5s,{agent:s.agent,accentColor:$}),l&&e.jsx(FR,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function l5s({agent:t,accentColor:s}){var o;const[r,n]=N.useState(!1),a=nr();return t?e.jsx("div",{className:"fixed bottom-6 right-6 z-40",children:r?e.jsxs("div",{className:"bg-[#1a1715] border border-white/10 w-72 overflow-hidden animate-in slide-in-from-bottom-4 fade-in duration-200",children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-12 w-12 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:t.full_name}),e.jsx("p",{className:"text-white/30 text-[10px] tracking-[0.1em] uppercase",children:t.title||"Real Estate Professional"})]})]}),e.jsxs("div",{className:"space-y-2",children:[t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 w-full px-3 py-2.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," ",t.phone]}),t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 w-full px-3 py-2.5 bg-white/5 hover:bg-white/10 text-xs text-white/50 hover:text-white transition-colors tracking-wider",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email Me"]}),e.jsx("button",{onClick:()=>{n(!1),a("/contact")},className:"w-full px-3 py-2.5 text-xs tracking-[0.2em] uppercase text-black hover:opacity-90 transition-colors",style:{backgroundColor:s},children:"Send a Message"})]})]}),e.jsx("button",{onClick:()=>n(!1),className:"absolute top-3 right-3 p-1 text-white/20 hover:text-white/50",children:e.jsx(Mr,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-3 bg-[#1a1715] border border-white/10 pl-1.5 pr-5 py-1.5 hover:border-white/20 transition-all",children:[e.jsx("img",{src:t.avatar_url,alt:t.full_name,className:"h-10 w-10 rounded-full object-cover ring-1 ring-white/10"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-[11px] text-white leading-none",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(o=t.full_name)==null?void 0:o.split(" ")[0]}),e.jsx("p",{className:"text-[9px] tracking-[0.15em] uppercase mt-1",style:{color:s},children:"Let's connect →"})]})]})}):null}const kI="#2c1810",Hy="#b8860b";function c5s({children:t,siteConfig:s}){var U,B,V;const r=dc();nr();const[n,a]=N.useState(!1),[o,l]=N.useState(!1),[i,c]=N.useState(!1),[u,p]=N.useState([]),[f,g]=N.useState(!1),v=N.useRef(null),{user:_,profile:w,signOut:j}=F3();M3e(s,_==null?void 0:_.id),T3e(s,_==null?void 0:_.id);const k=((U=s.agent)==null?void 0:U.full_name)||"Agent",S=s.siteTitle||`${k} Land & Ranch`,M=r.pathname==="/",L=s.leadRegistrationMode!=="disabled";N.useEffect(()=>{const X=()=>g(window.scrollY>80);return window.addEventListener("scroll",X,{passive:!0}),()=>window.removeEventListener("scroll",X)},[]),N.useEffect(()=>{(async()=>{const{data:Y}=await H.from("lead_site_city_pages").select("city_name, city_slug").eq("site_id",s.id).eq("is_published",!0).order("sort_order");Y&&p(Y)})()},[s.id]),N.useEffect(()=>{const X=Y=>{v.current&&!v.current.contains(Y.target)&&c(!1)};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[]);const P=[{label:"Home",path:"/"},{label:"Search Properties",path:"/search"},{label:"About",path:"/about"},{label:"Contact",path:"/contact"}],O=f||!M?"bg-white/95 backdrop-blur-md shadow-sm":"bg-transparent",$=f||!M?kI:"#ffffff";return e.jsxs("div",{className:"min-h-screen",style:{fontFamily:"'Lora', Georgia, serif"},children:[e.jsxs($l,{children:[e.jsx("title",{children:S}),e.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=Lora:wght@400;500;600&display=swap",rel:"stylesheet"})]}),e.jsx(zR,{siteConfig:s}),e.jsxs("header",{className:`fixed top-0 left-0 right-0 z-50 transition-all duration-300 ${O}`,children:[e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6",children:e.jsxs("div",{className:"flex items-center justify-between h-16 md:h-20",children:[e.jsxs(pa,{to:"/",className:"flex items-center gap-2.5",children:[e.jsx(o1,{className:"w-7 h-7",style:{color:Hy}}),e.jsx("span",{className:"text-lg font-bold tracking-wide",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:S})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[P.map(X=>e.jsx(pa,{to:X.path,className:"px-4 py-2 text-sm font-medium tracking-wide uppercase transition-colors hover:opacity-80",style:{color:r.pathname===X.path?Hy:$},children:X.label},X.path)),u.length>0&&e.jsxs("div",{ref:v,className:"relative",children:[e.jsxs("button",{onClick:()=>c(!i),className:"px-4 py-2 text-sm font-medium tracking-wide uppercase flex items-center gap-1 transition-colors hover:opacity-80",style:{color:$},children:["Areas ",e.jsx(oo,{className:`w-3.5 h-3.5 transition-transform ${i?"rotate-180":""}`})]}),i&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-56 bg-white rounded-xl shadow-xl border border-gray-100 py-2 animate-in fade-in-0 slide-in-from-top-2",children:u.map(X=>e.jsx(pa,{to:`/homes-for-sale-in-${X.city_slug}`,className:"block px-4 py-2.5 text-sm hover:bg-gray-50 transition-colors",style:{color:kI},onClick:()=>c(!1),children:X.city_name},X.city_slug))})]}),_?e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs(pa,{to:"/account",className:"px-4 py-2 text-sm font-medium rounded-full border-2 transition-all hover:scale-105",style:{borderColor:Hy,color:$},children:[e.jsx(Wi,{className:"w-4 h-4 inline mr-1.5"}),(w==null?void 0:w.name)||"Account"]})}):L?e.jsx("button",{onClick:()=>l(!0),className:"ml-3 px-5 py-2.5 text-sm font-semibold text-white rounded-full hover:shadow-lg transition-all hover:scale-105",style:{backgroundColor:Hy},children:"Sign In"}):null]}),e.jsx("button",{onClick:()=>a(!n),className:"md:hidden p-2",style:{color:$},children:n?e.jsx(Mr,{className:"w-6 h-6"}):e.jsx(pS,{className:"w-6 h-6"})})]})}),n&&e.jsx("div",{className:"md:hidden bg-white border-t border-gray-100 shadow-xl animate-in slide-in-from-top-2",children:e.jsxs("div",{className:"px-4 py-4 space-y-1",children:[P.map(X=>e.jsx(pa,{to:X.path,className:"block px-4 py-3 text-base font-medium rounded-lg hover:bg-gray-50 transition-colors",style:{color:r.pathname===X.path?Hy:kI},onClick:()=>a(!1),children:X.label},X.path)),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-2 text-xs font-semibold tracking-wider uppercase text-gray-400",children:"Areas"}),u.map(X=>e.jsx(pa,{to:`/homes-for-sale-in-${X.city_slug}`,className:"block px-4 py-2.5 text-sm rounded-lg hover:bg-gray-50",style:{color:kI},onClick:()=>a(!1),children:X.city_name},X.city_slug))]}),!_&&L&&e.jsx("button",{onClick:()=>{l(!0),a(!1)},className:"w-full mt-3 px-5 py-3 text-white font-semibold rounded-full",style:{backgroundColor:Hy},children:"Sign In"})]})})]}),e.jsx("main",{children:t}),e.jsx("footer",{className:"py-16 px-4",style:{backgroundColor:kI},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(o1,{className:"w-6 h-6",style:{color:Hy}}),e.jsx("span",{className:"text-lg font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:S})]}),e.jsx("p",{className:"text-white/60 text-sm leading-relaxed",children:"Your trusted specialist in land, ranch, and rural properties. Expert guidance for every acre."})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Quick Links"}),e.jsx("div",{className:"space-y-2",children:P.map(X=>e.jsx(pa,{to:X.path,className:"block text-white/60 hover:text-white text-sm transition-colors",children:X.label},X.path))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-white font-semibold mb-4 text-sm tracking-wider uppercase",children:"Contact"}),e.jsxs("div",{className:"space-y-3",children:[((B=s.agent)==null?void 0:B.phone)&&e.jsxs("a",{href:`tel:${s.agent.phone}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(Mn,{className:"w-4 h-4",style:{color:Hy}}),s.agent.phone]}),((V=s.agent)==null?void 0:V.email)&&e.jsxs("a",{href:`mailto:${s.agent.email}`,className:"flex items-center gap-2 text-white/60 hover:text-white text-sm transition-colors",children:[e.jsx(lr,{className:"w-4 h-4",style:{color:Hy}}),s.agent.email]})]})]})]}),e.jsxs("div",{className:"mt-12 pt-8 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("p",{className:"text-white/40 text-xs",children:["© ",new Date().getFullYear()," ",S,". All rights reserved."]}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:Hy}})]})]})}),o&&e.jsx(FR,{open:o,mode:s.leadRegistrationMode==="required"?"required":"optional",siteConfig:s,onSkip:()=>l(!1),onComplete:()=>l(!1)})]})}const d5s={city:{icon:ia,label:"City"},zip:{icon:K_,label:"ZIP Code"},county:{icon:g0,label:"County"}};function Dme({suggestions:t,cities:s,value:r,onChange:n,onSelect:a,placeholder:o,className:l,inputClassName:i}){const[c,u]=N.useState(!1),p=N.useRef(null),f=t.length>0?t:(s||[]).map(j=>({label:j,type:"city"})),g=r.trim()?f.filter(j=>j.label.toLowerCase().includes(r.toLowerCase())).slice(0,10):f.slice(0,10),v=g.reduce((j,k)=>(j[k.type]||(j[k.type]=[]),j[k.type].push(k),j),{}),_=c&&g.length>0;N.useEffect(()=>{const j=k=>{p.current&&!p.current.contains(k.target)&&u(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const w=["city","zip","county"];return e.jsxs("div",{ref:p,className:`relative ${l||""}`,children:[e.jsx("input",{type:"text",value:r,onChange:j=>{n(j.target.value),u(!0)},onFocus:()=>u(!0),placeholder:o,className:i,autoComplete:"off"}),_&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden z-50 max-h-[360px] overflow-y-auto",children:w.map(j=>{const k=v[j];if(!k||k.length===0)return null;const S=d5s[j],M=S.icon;return e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:[S.label,"s"]}),k.map(L=>e.jsxs("button",{type:"button",onMouseDown:P=>{P.preventDefault(),a(L.label),u(!1)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-left text-sm text-gray-800 hover:bg-blue-50 transition-colors",children:[e.jsx(M,{className:"h-4 w-4 text-gray-400 shrink-0"}),e.jsx("span",{className:"font-medium",children:L.label})]},`${j}-${L.label}`))]},j)})})]})}function A3e({siteId:t,accentColor:s}){const r=nr(),{data:n}=mt({queryKey:["public-featured-areas",t],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_featured_areas").select("*").eq("lead_site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});if(!(n!=null&&n.length))return null;const a=o=>{const l=new URLSearchParams;o.search_query&&l.set("q",o.search_query),o.search_county&&l.set("county",o.search_county),r(`/search?${l.toString()}`)};return e.jsx("section",{className:"py-20",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Explore"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:"Featured Areas"})]}),e.jsx("div",{className:"space-y-8",children:n.map((o,l)=>e.jsxs(ps.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:l*.1},onClick:()=>a(o),className:"group grid grid-cols-1 lg:grid-cols-2 gap-0 bg-white rounded-3xl overflow-hidden shadow-sm hover:shadow-2xl transition-all duration-500 cursor-pointer border border-gray-100",children:[e.jsxs("div",{className:"relative h-64 lg:h-80 overflow-hidden",children:[e.jsx("img",{src:o.image_url||"https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&q=80",alt:o.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/30 to-transparent"}),o.badge_text&&e.jsx("span",{className:"absolute top-5 left-5 px-4 py-1.5 text-xs font-bold uppercase tracking-wider text-white rounded-full",style:{backgroundColor:s},children:o.badge_text})]}),e.jsxs("div",{className:"flex flex-col justify-center p-8 lg:p-12",children:[o.subtitle&&e.jsx("p",{className:"text-sm font-medium uppercase tracking-wider text-gray-400 mb-2",children:o.subtitle}),e.jsx("h3",{className:"text-2xl lg:text-3xl font-bold text-gray-900 mb-4 group-hover:text-gray-700 transition-colors",children:o.title}),o.description&&e.jsx("p",{className:"text-gray-600 leading-relaxed mb-6 line-clamp-3 lg:line-clamp-none",children:o.description}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-2 px-5 py-2.5 text-sm font-semibold text-white rounded-xl transition-all group-hover:opacity-90",style:{backgroundColor:s},children:[e.jsx(ia,{className:"h-4 w-4"}),"View Properties",e.jsx(Sa,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})})]})]},o.id))})]})})}function S1({siteConfig:t,accentColor:s,sectionTitle:r,cities:n,count:a=12,mode:o,luxuryMode:l=!1}){const i=nr(),[c,u]=N.useState([]),[p,f]=N.useState(!0),g=N.useRef(null),[v,_]=N.useState(!1),[w,j]=N.useState(!1);N.useEffect(()=>{(async()=>{try{const O="https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",$={leadSiteId:t.id,pageSize:a},U=async V=>{var ee;const X=await fetch(O,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify(V),signal:AbortSignal.timeout(15e3)});return X.ok?((ee=(await X.json()).listings)==null?void 0:ee.slice(0,a))||[]:[]};if(n){const V=n.split(",").map(X=>X.trim()).filter(Boolean);V.length>0&&($.query=V[0],$.filterCities=V)}o==="open_houses"&&($.openHousesOnly=!0),o==="my_listings"&&($.agentListings=!0,$.agentId=t.agentId),o==="new_listings"&&($.sortBy="newest");let B=await U($);if(B.length===0&&n&&o!=="my_listings"){const V={...$};delete V.query,delete V.filterCities,B=await U(V)}u(B)}catch{}finally{f(!1)}})()},[t.id,n,a,o,t.agentId]);const k=()=>{const P=g.current;P&&(_(P.scrollLeft>10),j(P.scrollLeft{const P=g.current;if(P)return k(),P.addEventListener("scroll",k,{passive:!0}),window.addEventListener("resize",k),()=>{P.removeEventListener("scroll",k),window.removeEventListener("resize",k)}},[c]);const S=P=>{const O=g.current;if(!O)return;const $=340;O.scrollBy({left:P==="left"?-$*2:$*2,behavior:"smooth"})},M={new_listings:"New on the Market",open_houses:"Open Houses",my_listings:"My Active Listings"},L={new_listings:"The latest properties just listed",open_houses:"Tour these homes in person",my_listings:"Properties I'm currently representing"};return p?e.jsx("section",{className:`py-16 md:py-20 overflow-hidden ${l?"bg-[#0d0b0a]":""}`,children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:`h-4 w-20 rounded mx-auto mb-3 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-8 w-72 rounded mx-auto mb-2 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-4 w-56 rounded mx-auto animate-pulse ${l?"bg-white/5":"bg-gray-200"}`})]}),e.jsx("div",{className:"flex gap-5",children:[1,2,3,4].map(P=>e.jsxs("div",{className:`min-w-[320px] rounded-2xl overflow-hidden ${l?"bg-white/5":"bg-gray-100"}`,children:[e.jsx("div",{className:`h-56 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:`h-5 rounded w-24 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`}),e.jsx("div",{className:`h-4 rounded w-40 animate-pulse ${l?"bg-white/5":"bg-gray-200"}`})]})]},P))})]})}):c.length?e.jsx("section",{className:`py-16 md:py-20 overflow-hidden ${l?"bg-[#0d0b0a]":""}`,children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(ps.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:`text-sm tracking-[0.2em] uppercase font-semibold mb-2 ${l?"tracking-[0.4em]":""}`,style:{color:s},children:o==="open_houses"?"Open Houses":o==="my_listings"?"My Listings":"Just Listed"}),e.jsx(ps.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:`text-3xl md:text-4xl tracking-tight ${l?"text-white":"text-gray-900 font-bold"}`,style:l?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:r||M[o]}),e.jsx(ps.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:`mt-1.5 ${l?"text-white/40":"text-gray-500"}`,children:L[o]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>S("left"),disabled:!v,className:`p-3 rounded-full border transition-all disabled:opacity-30 disabled:cursor-not-allowed ${l?"border-white/10 text-white/50 hover:border-white/30":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"}`,children:e.jsx(Xo,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>S("right"),disabled:!w,className:`p-3 rounded-full border transition-all disabled:opacity-30 disabled:cursor-not-allowed ${l?"border-white/10 text-white/50 hover:border-white/30":"border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300"}`,children:e.jsx(oa,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:g,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[c.map((P,O)=>{var $,U,B,V;return e.jsx(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:O*.05},onClick:()=>i(`/listing/${P.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:`overflow-hidden h-full flex flex-col ${l?"bg-[#161312] hover:bg-[#1a1715] transition-all duration-500":"bg-white rounded-2xl shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500"}`,children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:(($=P.photos)==null?void 0:$[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:P.address,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${s}cc`},children:o==="open_houses"?"Open House":P.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(U=P.price)==null?void 0:U.toLocaleString()]})}),((B=P.photos)==null?void 0:B.length)>1&&e.jsxs("div",{className:"absolute bottom-3 right-3 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[11px] text-white font-medium",children:[P.photos.length," photos"]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:`font-semibold text-[15px] leading-snug mb-1 truncate ${l?"text-white/80":"text-gray-900"}`,children:P.address}),e.jsxs("p",{className:`text-sm mb-3 truncate ${l?"text-white/30":"text-gray-500"}`,children:[P.city,", ",P.state," ",P.zip]}),e.jsxs("div",{className:`flex items-center gap-4 mt-auto pt-3 border-t ${l?"border-white/5":"border-gray-100"}`,children:[e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(Mh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:P.bedrooms})]}),e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(su,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:P.bathrooms})]}),e.jsxs("div",{className:`flex items-center gap-1.5 ${l?"text-white/30":"text-gray-600"}`,children:[e.jsx(mS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(V=P.sqft)==null?void 0:V.toLocaleString()," sqft"]})]})]})]})]})},P.mlsNumber)}),e.jsx(ps.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>i("/search"),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${s}15`},children:e.jsx(Sa,{className:"h-6 w-6",style:{color:s}})}),e.jsx("p",{className:`text-sm font-semibold transition-colors ${l?"text-white/50 group-hover:text-white":"text-gray-700 group-hover:text-gray-900"}`,children:"View All"})]})})]}),e.jsx("div",{className:`absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l pointer-events-none md:hidden ${l?"from-[#0d0b0a]":"from-white"} to-transparent`})]})]})}):null}function E3e({siteId:t,accentColor:s,sectionTitle:r}){const n=nr(),[a,o]=N.useState([]),[l,i]=N.useState(!0);if(N.useEffect(()=>{(async()=>{const{data:p}=await H.from("lead_site_city_pages").select("city_name, city_slug, description, hero_image_url").eq("site_id",t).eq("is_published",!0).order("sort_order",{ascending:!0});o(p||[]),i(!1)})()},[t]),l)return e.jsx("section",{className:"py-16 md:py-20",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"h-4 w-20 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-64 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:[1,2,3].map(u=>e.jsx("div",{className:"h-48 bg-gray-100 rounded-2xl animate-pulse"},u))})]})});if(!a.length)return null;const c=["https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=600&q=75","https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=600&q=75","https://images.unsplash.com/photo-1444723121867-7a241cacace9?w=600&q=75","https://images.unsplash.com/photo-1480714378408-67cf0d13bc1b?w=600&q=75","https://images.unsplash.com/photo-1514565131-fce0801e5785?w=600&q=75","https://images.unsplash.com/photo-1519999482648-25049ddd37b1?w=600&q=75"];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(ps.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.2em] uppercase font-semibold mb-3",style:{color:s},children:"Explore Areas"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Browse by City"}),e.jsx("p",{className:"text-gray-500 mt-2 max-w-xl mx-auto",children:"Discover homes in the communities we serve"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:a.map((u,p)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:p*.06},onClick:()=>n(`/homes-for-sale-in-${u.city_slug}`),className:"group relative h-52 rounded-2xl overflow-hidden cursor-pointer shadow-sm hover:shadow-xl transition-all duration-500",children:[e.jsx("img",{src:u.hero_image_url||c[p%c.length],alt:`Homes in ${u.city_name}`,className:"absolute inset-0 w-full h-full object-cover group-hover:scale-110 transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5 flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-bold text-xl tracking-tight mb-1",children:u.city_name}),u.description&&e.jsxs("p",{className:"text-white/70 text-sm line-clamp-1 max-w-[240px]",children:[u.description.split(` `)[0].slice(0,80),"..."]})]}),e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-white/20 backdrop-blur-sm group-hover:bg-white/30 transition-colors flex-shrink-0",children:e.jsx(Sa,{className:"h-5 w-5 text-white"})})]})]},u.city_slug))})]})})}function u5s({siteConfig:t,themeConfig:s}){var p;const r=nr(),[n,a]=N.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ime,i=(s==null?void 0:s.brandColor)||"#0f172a",c=(s==null?void 0:s.accentColor)||"#3b82f6",u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{children:l.map((f,g)=>{if(!f.enabled)return null;const v=f.config||{};switch(f.type){case"hero":return e.jsx(m5s,{agentName:o,tagline:v.headline||t.siteTagline,subtitle:v.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:v.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(p5s,{siteConfig:t,accentColor:c,sectionTitle:v.sectionTitle,count:v.count},g);case"featured_areas":return e.jsx(A3e,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(f5s,{siteConfig:t,accentColor:c,config:v},g);case"testimonials":return e.jsx(x5s,{testimonials:v.testimonials||(s==null?void 0:s.testimonials)||[],brandColor:i,sectionTitle:v.sectionTitle},g);case"cta_banner":return e.jsx(g5s,{agentName:o,accentColor:c,brandColor:i,config:v},g);case"new_listings":return e.jsx(S1,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:v.sectionTitle,cities:v.cities,count:v.count},g);case"open_houses":return e.jsx(S1,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:v.sectionTitle,cities:v.cities,count:v.count},g);case"my_listings":return e.jsx(S1,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:v.sectionTitle,count:v.count},g);case"city_pages":return e.jsx(E3e,{siteId:t.id,accentColor:c,sectionTitle:v.sectionTitle},g);default:return null}})})}function h5s(t){if(!t)return[];const s=[];return(t.searchCities||[]).forEach(r=>s.push({label:r,type:"city"})),(t.searchZipCodes||[]).forEach(r=>s.push({label:r,type:"zip"})),(t.searchCounties||[]).forEach(r=>s.push({label:r,type:"county"})),s}function m5s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){const f=nr(),g=n||"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=1920&q=80";return e.jsxs("section",{className:"relative min-h-[85vh] flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:g,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/40 to-black/70"})]}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 text-center",children:[e.jsx(ps.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6},className:"text-white/70 text-sm tracking-[0.3em] uppercase mb-4 font-medium",children:"Welcome"}),e.jsx(ps.h1,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7,delay:.1},className:"text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-bold text-white leading-[1.1] tracking-tight mb-6",children:s||`Find Your Perfect Home with ${t}`}),e.jsx(ps.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},className:"text-white/70 text-lg md:text-xl max-w-2xl mx-auto mb-10",children:r||"Expert guidance. Local knowledge. Personalized service."}),e.jsx(ps.form,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.35},onSubmit:c,className:"max-w-2xl mx-auto",children:e.jsxs("div",{className:"flex bg-white/10 backdrop-blur-md border border-white/20 rounded-2xl p-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-white/50 z-10"}),(()=>{const v=h5s(p);return v.length>0?e.jsx(Dme,{suggestions:v,value:l,onChange:i,onSelect:_=>{i(_),f(`/search?q=${encodeURIComponent(_)}`)},placeholder:u||"Search by city, zip, county, or address...",className:"flex-1",inputClassName:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"}):e.jsx("input",{type:"text",value:l,onChange:_=>i(_.target.value),placeholder:u||"Search by city, zip, county, or address...",className:"w-full pl-12 pr-4 py-4 bg-transparent text-white placeholder:text-white/40 focus:outline-none text-lg"})})()]}),e.jsx("button",{type:"submit",className:"px-8 py-4 rounded-xl font-semibold text-white transition-all hover:opacity-90",style:{backgroundColor:o},children:"Search"})]})}),e.jsx(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:.5},className:"flex flex-wrap gap-3 justify-center mt-8",children:["Browse All Listings","Get In Touch"].map((v,_)=>e.jsx("button",{onClick:()=>f(_===0?"/search":"/contact"),className:"px-5 py-2.5 text-sm text-white/80 border border-white/20 rounded-full hover:bg-white/10 hover:text-white transition-all",children:v},v))})]})]})}function p5s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=nr(),[o,l]=N.useState([]),[i,c]=N.useState(!0);return N.useEffect(()=>{(async()=>{var p;try{const g=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({siteId:t.id,params:{pageSize:n||6,page:1}})});if(g.ok){const v=await g.json();l(((p=v.listings)==null?void 0:p.slice(0,6))||[])}}catch{}finally{c(!1)}})()},[t.id]),i?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-64 mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-96 mx-auto animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(u=>e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm",children:[e.jsx("div",{className:"h-64 bg-gray-200 animate-pulse"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-5 bg-gray-200 rounded w-24 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-48 animate-pulse"})]})]},u))})]})}):o.length?e.jsx("section",{className:"py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium",children:"Properties"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:r||"Featured Listings"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map(u=>{var p,f,g;return e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all duration-300 cursor-pointer",children:[e.jsxs("div",{className:"relative h-64 overflow-hidden",children:[e.jsx("img",{src:((p=u.photos)==null?void 0:p[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:u.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-white/90 backdrop-blur rounded-full text-xs font-semibold text-gray-900",children:u.status})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("p",{className:"text-2xl font-bold text-gray-900 mb-1",children:["$",(f=u.price)==null?void 0:f.toLocaleString()]}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[u.address,", ",u.city]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{children:[u.bedrooms," Beds"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[u.bathrooms," Baths"]}),e.jsx("span",{className:"w-1 h-1 bg-gray-300 rounded-full"}),e.jsxs("span",{children:[(g=u.sqft)==null?void 0:g.toLocaleString()," Sqft"]})]})]})]},u.mlsNumber)})}),e.jsx("div",{className:"text-center mt-10",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-2 px-6 py-3 text-sm font-semibold rounded-full border border-gray-300 text-gray-700 hover:bg-gray-100 transition-colors",children:["View All Properties ",e.jsx(Sa,{className:"h-4 w-4"})]})})]})}):null}function f5s({siteConfig:t,accentColor:s,config:r}){const n=nr(),a=t.agent;return a?e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-7xl mx-auto px-6",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[a.avatar_url&&e.jsx(ps.div,{initial:{opacity:0,x:-30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:e.jsx("img",{src:a.avatar_url,alt:a.full_name,className:"w-full max-w-md mx-auto rounded-3xl object-cover shadow-2xl aspect-[3/4]"})}),e.jsxs(ps.div,{initial:{opacity:0,x:30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-3 font-medium",children:(r==null?void 0:r.sectionTitle)||"About"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight mb-2",children:(r==null?void 0:r.headline)||a.full_name}),e.jsx("p",{className:"text-gray-400 font-medium mb-6",children:(r==null?void 0:r.customTitle)||a.title||"Real Estate Professional"}),e.jsx("p",{className:"text-gray-600 leading-relaxed text-lg mb-8",children:(()=>{const o=(r==null?void 0:r.customBio)||a.bio;return o?o.substring(0,400)+(o.length>400?"...":""):"Dedicated to providing exceptional real estate service with deep local market expertise."})()}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{onClick:()=>n("/contact"),className:"px-6 py-3 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:"Get In Touch"}),e.jsx("button",{onClick:()=>n("/about"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-xl hover:bg-gray-50 transition-colors",children:"Read More"})]})]})]})})}):null}function x5s({testimonials:t,brandColor:s,sectionTitle:r}){const[n,a]=N.useState(0),o=t.length?t:[{name:"Happy Client",quote:"An amazing experience from start to finish. Truly a trusted advisor who goes above and beyond.",role:"Buyer"},{name:"Satisfied Seller",quote:"Professional, knowledgeable, and always available. Made the selling process smooth and stress-free.",role:"Seller"},{name:"First-Time Buyer",quote:"Guided us through every step with patience and expertise. Could not have asked for a better agent.",role:"Buyer"}];return o.length?e.jsx("section",{className:"py-20 text-white",style:{backgroundColor:s},children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 text-center",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-white/50 mb-3 font-medium",children:"Testimonials"}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-12",children:r||"What Clients Say"}),e.jsxs("div",{className:"relative",children:[e.jsx(f1,{className:"h-10 w-10 text-white/20 mx-auto mb-6"}),e.jsxs(ps.blockquote,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-xl md:text-2xl font-light leading-relaxed text-white/90 mb-8 italic",children:['"',o[n].quote,'"']},n),e.jsx("p",{className:"font-semibold text-lg",children:o[n].name}),o[n].role&&e.jsx("p",{className:"text-white/50 text-sm mt-1",children:o[n].role})]}),o.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-10",children:[e.jsx("button",{onClick:()=>a((n-1+o.length)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(Xo,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex gap-2",children:o.map((l,i)=>e.jsx("button",{onClick:()=>a(i),className:`w-2 h-2 rounded-full transition-all ${i===n?"bg-white w-6":"bg-white/30"}`},i))}),e.jsx("button",{onClick:()=>a((n+1)%o.length),className:"p-2 rounded-full border border-white/20 hover:bg-white/10 transition-colors",children:e.jsx(oa,{className:"h-5 w-5"})})]})]})}):null}function g5s({agentName:t,accentColor:s,brandColor:r,config:n}){const a=nr();return e.jsx("section",{className:"py-20",children:e.jsx("div",{className:"max-w-5xl mx-auto px-6",children:e.jsxs("div",{className:"rounded-3xl p-12 md:p-16 text-white text-center",style:{backgroundColor:r},children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight mb-4",children:(n==null?void 0:n.headline)||"Ready to Make Your Move?"}),e.jsx("p",{className:"text-white/70 text-lg max-w-2xl mx-auto mb-8",children:(n==null?void 0:n.subtitle)||"Whether you're buying, selling, or just exploring — let's connect and find the right path for you."}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>a("/search"),className:"px-8 py-4 text-white font-semibold rounded-xl transition-all hover:opacity-90",style:{backgroundColor:s},children:(n==null?void 0:n.primaryButtonText)||"Browse Listings"}),e.jsx("button",{onClick:()=>a("/contact"),className:"px-8 py-4 bg-white/10 border border-white/25 font-semibold rounded-xl hover:bg-white/20 transition-colors",children:(n==null?void 0:n.secondaryButtonText)||`Contact ${t}`})]})]})})})}const y5s="/assets/luxury-hero-mobile-DKoFc_7O.jpg";function v5s({siteConfig:t,themeConfig:s}){var p;const r=nr(),[n,a]=N.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ime,i=(s==null?void 0:s.brandColor)||"#1a1110",c=(s==null?void 0:s.accentColor)||"#c9a96e",u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{className:"bg-[#0d0b0a]",children:l.map((f,g)=>{if(!f.enabled)return null;const v=f.config||{};switch(f.type){case"hero":return e.jsx(b5s,{agentName:o,tagline:v.headline||t.siteTagline,subtitle:v.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:v.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(_5s,{siteConfig:t,accentColor:c,sectionTitle:v.sectionTitle,count:v.count},g);case"featured_areas":return e.jsx(w5s,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(j5s,{siteConfig:t,accentColor:c,brandColor:i,config:v},g);case"testimonials":return e.jsx(N5s,{testimonials:v.testimonials||(s==null?void 0:s.testimonials)||[],accentColor:c,sectionTitle:v.sectionTitle},g);case"cta_banner":return e.jsx(k5s,{agentName:o,accentColor:c,brandColor:i,config:v},g);case"new_listings":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"new_listings",luxuryMode:!0,sectionTitle:v.sectionTitle,cities:v.cities,count:v.count})},g);case"open_houses":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"open_houses",luxuryMode:!0,sectionTitle:v.sectionTitle,cities:v.cities,count:v.count})},g);case"my_listings":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"my_listings",luxuryMode:!0,sectionTitle:v.sectionTitle,count:v.count})},g);case"city_pages":return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(E3e,{siteId:t.id,accentColor:c,sectionTitle:v.sectionTitle})},g);case"lifestyle_gallery":return e.jsx(S5s,{accentColor:c,config:v},g);case"market_pulse":return e.jsx(C5s,{accentColor:c,config:v},g);case"concierge_services":return e.jsx(T5s,{accentColor:c,config:v},g);default:return null}})})}function b5s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){var k,S;const f=nr(),g=n||"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=1920&q=80",v="https://id-preview--b4ed24ae-0b44-4f4d-8676-c620f649ed8a.lovable.app/__l5e/assets-v1/e1224ec9-d0e0-4ab9-ae12-caff5849bf4d/luxury-hero-video.mp4",_=(k=p==null?void 0:p.homepageModules)==null?void 0:k.find(M=>M.type==="hero"),j=((S=_==null?void 0:_.config)==null?void 0:S.heroVideoUrl)||v;return e.jsxs("section",{className:"relative h-screen flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 hidden md:block",children:[e.jsx("video",{autoPlay:!0,muted:!0,loop:!0,playsInline:!0,preload:"metadata",crossOrigin:"anonymous",poster:g,className:"w-full h-full object-cover scale-110",children:e.jsx("source",{src:j,type:"video/mp4"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/50 via-black/30 to-black/70"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/40 to-transparent"})]}),e.jsxs("div",{className:"absolute inset-0 md:hidden",children:[e.jsx("img",{src:y5s,alt:"Luxury real estate",className:"w-full h-full object-cover",width:1080,height:1920}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/50 via-black/30 to-black/70"})]}),e.jsxs("div",{className:"relative z-10 max-w-5xl mx-auto px-6 text-center",children:[e.jsxs(ps.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:1,ease:[.16,1,.3,1]},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-8",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:o}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:o},children:t}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:o}})]}),e.jsx("h1",{className:"text-5xl sm:text-6xl md:text-7xl lg:text-8xl text-white leading-[0.95] tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s||"A Luxury Experience"}),e.jsx("p",{className:"text-lg md:text-xl text-white/60 tracking-[0.2em] uppercase font-light mb-12",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:r||"At Every Price Point"})]}),e.jsx(ps.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,delay:.4,ease:[.16,1,.3,1]},className:"flex flex-wrap gap-4 justify-center mb-12",children:[{label:"PROPERTY SEARCH",action:()=>f("/search")},{label:"BUY A HOME",action:()=>f("/search")},{label:"VALUE MY HOME",action:()=>f("/sell")}].map(M=>e.jsx("button",{onClick:M.action,className:"px-8 py-3.5 text-xs tracking-[0.3em] text-white border border-white/30 hover:bg-white hover:text-black transition-all duration-500",children:M.label},M.label))}),e.jsx(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2,duration:.6},className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-0 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("span",{className:"text-white/30 text-[10px] tracking-[0.4em] uppercase",children:"Scroll"}),e.jsx("div",{className:"w-px h-8 bg-gradient-to-b from-white/30 to-transparent animate-pulse"})]})})]})]})}function _5s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=nr(),[o,l]=N.useState([]),[i,c]=N.useState(!0);return N.useEffect(()=>{(async()=>{var p;try{const g=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,pageSize:n||6,page:1})});if(g.ok){const v=await g.json();l(((p=v.listings)==null?void 0:p.slice(0,6))||[])}}catch{}finally{c(!1)}})()},[t.id]),i?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsx("div",{className:"text-center mb-16",children:e.jsx("div",{className:"h-8 bg-white/5 rounded w-64 mx-auto mb-3 animate-pulse"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(u=>e.jsxs("div",{className:"bg-white/5 rounded overflow-hidden",children:[e.jsx("div",{className:"h-72 bg-white/5 animate-pulse"}),e.jsx("div",{className:"p-5 space-y-3",children:e.jsx("div",{className:"h-5 bg-white/5 rounded w-24 animate-pulse"})})]},u))})]})}):o.length?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Properties"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:r||"Featured Listings"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:o.map((u,p)=>{var f,g,v;return e.jsxs(ps.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:p*.1},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group cursor-pointer",children:[e.jsxs("div",{className:"relative overflow-hidden aspect-[4/3]",children:[e.jsx("img",{src:((f=u.photos)==null?void 0:f[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:u.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5",children:[e.jsxs("p",{className:"text-2xl font-bold text-white mb-1",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["$",(g=u.price)==null?void 0:g.toLocaleString()]}),e.jsx("p",{className:"text-white/70 text-sm truncate",children:u.address}),e.jsxs("p",{className:"text-white/50 text-xs",children:[u.city,", ",u.state]})]}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:s}})]}),e.jsx("div",{className:"bg-[#161312] px-5 py-4",children:e.jsxs("div",{className:"flex items-center gap-6 text-xs text-white/40 tracking-wider uppercase",children:[e.jsxs("span",{children:[u.bedrooms," Beds"]}),e.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:s}}),e.jsxs("span",{children:[u.bathrooms," Baths"]}),e.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:s}}),e.jsxs("span",{children:[(v=u.sqft)==null?void 0:v.toLocaleString()," Sqft"]})]})})]},u.mlsNumber)})}),e.jsx("div",{className:"text-center mt-14",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-3 px-10 py-4 text-xs tracking-[0.3em] uppercase border border-white/20 text-white/70 hover:bg-white hover:text-black transition-all duration-500",children:["View All Properties ",e.jsx(Sa,{className:"h-3.5 w-3.5"})]})})]})}):null}function w5s({siteId:t,accentColor:s}){return e.jsx("div",{className:"bg-[#0d0b0a] py-4",children:e.jsx(A3e,{siteId:t,accentColor:s})})}function j5s({siteConfig:t,accentColor:s,brandColor:r,config:n}){const a=nr(),o=t.agent;return o?e.jsx("section",{className:"py-0 bg-[#0d0b0a]",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 min-h-[80vh]",children:[o.avatar_url&&e.jsxs(ps.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{duration:.8},className:"relative overflow-hidden",children:[e.jsx("img",{src:o.avatar_url,alt:o.full_name,className:"w-full h-full object-cover min-h-[500px] lg:min-h-full"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent to-[#0d0b0a]/30 lg:block hidden"})]}),e.jsx(ps.div,{initial:{opacity:0,x:40},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8,delay:.2},className:"flex items-center px-8 lg:px-16 py-20",children:e.jsxs("div",{children:[e.jsx("div",{className:"w-16 h-0.5 mb-8",style:{backgroundColor:s}}),e.jsx("p",{className:"text-xs tracking-[0.4em] uppercase mb-4",style:{color:s},children:(n==null?void 0:n.sectionTitle)||"About"}),e.jsx("h2",{className:"text-4xl md:text-5xl text-white tracking-tight mb-3 leading-[1.1]",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.headline)||o.full_name}),e.jsx("p",{className:"text-white/40 font-light tracking-wider text-sm mb-8 uppercase",children:(n==null?void 0:n.customTitle)||o.title||"Real Estate Professional"}),e.jsx("p",{className:"text-white/60 leading-relaxed text-lg mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(()=>{const l=(n==null?void 0:n.customBio)||o.bio;return l?l.substring(0,500)+(l.length>500?"...":""):"Dedicated to providing an exceptional luxury real estate experience with deep local market expertise and unwavering commitment to client success."})()}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx("button",{onClick:()=>a("/contact"),className:"px-8 py-3.5 text-xs tracking-[0.3em] uppercase text-black transition-all duration-500 hover:opacity-90",style:{backgroundColor:s},children:"Get in Touch"}),e.jsx("button",{onClick:()=>a("/about"),className:"px-8 py-3.5 text-xs tracking-[0.3em] uppercase text-white/70 border border-white/20 hover:bg-white hover:text-black transition-all duration-500",children:"Read More"})]})]})})]})}):null}function N5s({testimonials:t,accentColor:s,sectionTitle:r}){const[n,a]=N.useState(0),o=t.length?t:[{name:"Happy Client",quote:"An amazing experience from start to finish. Truly a trusted advisor who goes above and beyond.",role:"Buyer"},{name:"Satisfied Seller",quote:"Professional, knowledgeable, and always available. Made the selling process smooth and stress-free.",role:"Seller"},{name:"First-Time Buyer",quote:"Guided us through every step with patience and expertise. Could not have asked for a better agent.",role:"Buyer"}];return o.length?e.jsxs("section",{className:"py-28 bg-[#0d0b0a] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.02]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),e.jsxs("div",{className:"max-w-4xl mx-auto px-6 text-center relative",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Testimonials"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight mb-16",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:r||"Success Stories"}),e.jsx("div",{className:"text-6xl leading-none mb-8",style:{color:s,fontFamily:"'Playfair Display', Georgia, serif"},children:'"'}),e.jsxs(ps.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5},children:[e.jsx("blockquote",{className:"text-xl md:text-2xl text-white/80 leading-relaxed mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:o[n].quote}),e.jsx("div",{className:"w-12 h-px mx-auto mb-6",style:{backgroundColor:s}}),e.jsx("p",{className:"text-white text-sm tracking-[0.2em] uppercase font-medium",children:o[n].name}),o[n].role&&e.jsx("p",{className:"text-white/30 text-xs tracking-[0.15em] uppercase mt-1",children:o[n].role})]},n),o.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-6 mt-14",children:[e.jsx("button",{onClick:()=>a((n-1+o.length)%o.length),className:"p-3 border border-white/10 hover:border-white/30 transition-colors",children:e.jsx(Xo,{className:"h-4 w-4 text-white/50"})}),e.jsx("div",{className:"flex gap-3",children:o.map((l,i)=>e.jsx("button",{onClick:()=>a(i),className:"w-2 h-2 transition-all duration-300",style:{backgroundColor:i===n?s:"rgba(255,255,255,0.15)",width:i===n?"2rem":"0.5rem"}},i))}),e.jsx("button",{onClick:()=>a((n+1)%o.length),className:"p-3 border border-white/10 hover:border-white/30 transition-colors",children:e.jsx(oa,{className:"h-4 w-4 text-white/50"})})]})]})]}):null}function k5s({agentName:t,accentColor:s,brandColor:r,config:n}){const a=nr();return e.jsx("section",{className:"py-28 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:s},children:"Work With Us"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.headline)||"Let's Get Started"}),e.jsx("p",{className:"text-white/40 text-lg max-w-2xl mx-auto",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(n==null?void 0:n.subtitle)||"We promise to guide you through a successful and enjoyable real estate experience."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-px bg-white/5",children:[{icon:dn,title:"Buy",desc:"Find your dream property with personalized search and expert guidance.",action:"/search"},{icon:hl,title:"Sell",desc:"Maximize your home's value with strategic marketing and pricing.",action:"/sell"},{icon:Jo,title:"Home Value",desc:"Discover what your property is worth in today's market.",action:"/contact"}].map((o,l)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:l*.15},onClick:()=>a(o.action),className:"bg-[#0d0b0a] p-12 text-center cursor-pointer group hover:bg-[#161312] transition-colors duration-500",children:[e.jsx(o.icon,{className:"h-8 w-8 mx-auto mb-6 text-white/20 group-hover:text-white/40 transition-colors",style:{color:s}}),e.jsx("h3",{className:"text-2xl text-white tracking-tight mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o.title}),e.jsx("p",{className:"text-white/40 text-sm leading-relaxed mb-6",children:o.desc}),e.jsx("div",{className:"w-8 h-px mx-auto opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:s}})]},o.title))})]})})}function S5s({accentColor:t,config:s}){const r=Array.from({length:6}).map((n,a)=>({url:s[`image_${a}`],caption:s[`caption_${a}`]})).filter(n=>n.url);return r.length||r.push({url:"https://images.unsplash.com/photo-1600596542815-ffad4c1539a9?w=800&q=75",caption:"Luxury Estates"},{url:"https://images.unsplash.com/photo-1540518614846-7eded433c457?w=800&q=75",caption:"Elegant Interiors"},{url:"https://images.unsplash.com/photo-1613490493576-7fde63acd811?w=800&q=75",caption:"Pool & Spa"},{url:"https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?w=800&q=75",caption:"Wine Country"},{url:"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=800&q=75",caption:"Gourmet Kitchen"},{url:"https://images.unsplash.com/photo-1512917774080-9991f1c4c750?w=800&q=75",caption:"Panoramic Views"}),e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Experience"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"The Luxury Lifestyle"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:r.map((n,a)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:a*.1},className:`relative group overflow-hidden ${a===0||a===3?"row-span-2 aspect-[3/4]":"aspect-square"}`,children:[e.jsx("img",{src:n.url,alt:n.caption||"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),n.caption&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4 translate-y-full group-hover:translate-y-0 transition-transform duration-500",children:e.jsx("p",{className:"text-white text-sm tracking-[0.2em] uppercase",children:n.caption})}),e.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:t}})]},a))})]})})}function C5s({accentColor:t,config:s}){const r=[{label:"Median Home Price",value:"$485,000",change:"+4.2%",icon:hl},{label:"Average Days on Market",value:"28",change:"-12%",icon:Jo},{label:"Active Listings",value:"142",change:"+8",icon:dn},{label:"Sold This Month",value:"37",change:"+15%",icon:yo}],a=(s.style||"dark")==="dark";return e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Insights"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"Market Pulse"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle}),s.marketArea&&e.jsx("p",{className:"text-white/30 mt-2 text-xs tracking-[0.3em] uppercase",children:s.marketArea})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:r.map((o,l)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:l*.1},className:"bg-[#161312] border border-white/5 p-8 text-center group hover:border-white/10 transition-colors duration-500",children:[e.jsx(o.icon,{className:"h-6 w-6 mx-auto mb-4 text-white/20",style:{color:t}}),e.jsx("p",{className:"text-3xl md:text-4xl font-bold text-white mb-2",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o.value}),e.jsx("p",{className:"text-white/40 text-xs tracking-[0.2em] uppercase mb-3",children:o.label}),e.jsx("span",{className:"text-xs px-3 py-1 rounded-full",style:{backgroundColor:`${t}20`,color:t},children:o.change})]},o.label))}),s.showChart!==!1&&e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.6,delay:.4},className:"mt-8 bg-[#161312] border border-white/5 p-8",children:[e.jsx("p",{className:"text-white/30 text-xs tracking-[0.3em] uppercase mb-6",children:"12-Month Price Trend"}),e.jsx("div",{className:"flex items-end gap-2 h-32",children:[65,58,72,80,68,75,85,78,90,88,95,92].map((o,l)=>e.jsx("div",{className:"flex-1 rounded-t transition-all duration-500 hover:opacity-80",style:{height:`${o}%`,backgroundColor:l===11?t:`${t}40`}},l))}),e.jsx("div",{className:"flex justify-between mt-3 text-white/20 text-[10px] tracking-wider uppercase",children:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(o=>e.jsx("span",{children:o},o))})]})]})})}const M5s={default:th,home:dn,camera:ff,truck:QM,search:sn,palette:Bl,video:Cn};function T5s({accentColor:t,config:s}){const r=[{title:"Home Staging",desc:"Professional staging to showcase your property at its absolute best",icon:"home"},{title:"Interior Design",desc:"Connect with top designers for pre-sale or post-purchase renovations",icon:"palette"},{title:"Moving Coordination",desc:"Seamless relocation support from packing to settling in",icon:"truck"},{title:"Pre-Inspection",desc:"Comprehensive property inspections before listing or buying",icon:"search"},{title:"Photography",desc:"Cinematic photography and videography for your listing",icon:"camera"},{title:"Virtual Tours",desc:"3D walkthroughs and immersive virtual experiences",icon:"video"}],n=Array.from({length:6}).map((a,o)=>{var l,i,c;return{title:s[`service_title_${o}`]||((l=r[o])==null?void 0:l.title)||"",desc:s[`service_desc_${o}`]||((i=r[o])==null?void 0:i.desc)||"",icon:s[`service_icon_${o}`]||((c=r[o])==null?void 0:c.icon)||"default"}}).filter(a=>a.title);return n.length?e.jsx("section",{className:"py-24 bg-[#0d0b0a]",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-4",children:[e.jsx("div",{className:"h-px w-16 bg-white/10"}),e.jsx("span",{className:"text-xs tracking-[0.4em] uppercase",style:{color:t},children:"Excellence"}),e.jsx("div",{className:"h-px w-16 bg-white/10"})]}),e.jsx("h2",{className:"text-3xl md:text-5xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:s.sectionTitle||"Concierge Services"}),s.subtitle&&e.jsx("p",{className:"text-white/40 mt-4 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map((a,o)=>{const l=M5s[a.icon]||th;return e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:o*.1},className:"bg-[#161312] border border-white/5 p-10 group hover:border-white/10 transition-all duration-500",children:[e.jsx(l,{className:"h-8 w-8 mb-6 text-white/20 group-hover:text-white/40 transition-colors",style:{color:t}}),e.jsx("h3",{className:"text-xl text-white tracking-tight mb-3",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.title}),e.jsx("p",{className:"text-white/40 text-sm leading-relaxed",children:a.desc}),e.jsx("div",{className:"w-8 h-px mt-6 opacity-0 group-hover:opacity-100 transition-opacity duration-500",style:{backgroundColor:t}})]},o)})})]})}):null}const $ct="/assets/land-ranch-hero-DPocQo93.jpg",A5s="/assets/land-ranch-type-ranch-BheMsKzQ.jpg",E5s="/assets/land-ranch-type-farm-cZzpYUqq.jpg",P5s="/assets/land-ranch-type-land-BCRXswKZ.jpg",I5s="/assets/land-ranch-type-equestrian-D0B3dJ3D.jpg",L5s="/assets/land-ranch-type-vineyard-CFy8-2Ud.jpg",V1="#2c1810",D5s="#b8860b",l_="#faf6f1",qct="#f5efe6";function O5s({siteConfig:t,themeConfig:s}){var p;const r=nr(),[n,a]=N.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??Ime,i=(s==null?void 0:s.brandColor)||V1,c=(s==null?void 0:s.accentColor)||D5s,u=f=>{f.preventDefault(),n.trim()&&r(`/search?q=${encodeURIComponent(n.trim())}`)};return e.jsx("div",{style:{backgroundColor:l_},children:l.map((f,g)=>{if(!f.enabled)return null;const v=f.config||{};switch(f.type){case"hero":return e.jsx(F5s,{agentName:o,tagline:v.headline||t.siteTagline,subtitle:v.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:v.searchPlaceholder,themeConfig:s},g);case"property_types":return e.jsx(B5s,{accentColor:c},g);case"featured_listings":return e.jsx($5s,{siteConfig:t,accentColor:c,sectionTitle:v.sectionTitle,count:v.count},g);case"advantages":return e.jsx(U5s,{agentName:o,accentColor:c},g);case"featured_areas":return e.jsx("div",{className:"py-4",style:{backgroundColor:l_},children:e.jsx(A3e,{siteId:t.id,accentColor:c})},g);case"about":return e.jsx(V5s,{siteConfig:t,accentColor:c,brandColor:i,config:v},g);case"testimonials":return e.jsx(H5s,{testimonials:v.testimonials||(s==null?void 0:s.testimonials)||[],accentColor:c,sectionTitle:v.sectionTitle},g);case"cta_banner":return e.jsx(G5s,{agentName:o,accentColor:c},g);case"new_listings":return e.jsx("div",{className:"py-4",style:{backgroundColor:l_},children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:v.sectionTitle,cities:v.cities,count:v.count})},g);case"open_houses":return e.jsx("div",{className:"py-4",style:{backgroundColor:l_},children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:v.sectionTitle,cities:v.cities,count:v.count})},g);case"my_listings":return e.jsx("div",{className:"py-4",style:{backgroundColor:l_},children:e.jsx(S1,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:v.sectionTitle,count:v.count})},g);case"city_pages":return e.jsx("div",{className:"py-4",style:{backgroundColor:l_},children:e.jsx(E3e,{siteId:t.id,accentColor:c,sectionTitle:v.sectionTitle})},g);case"land_use_guide":return e.jsx(K5s,{accentColor:c,config:v},g);case"land_valuation_cta":return e.jsx(Z5s,{agentName:o,accentColor:c,config:v},g);case"acreage_showcase":return e.jsx(Y5s,{siteConfig:t,accentColor:c,config:v},g);default:return null}})})}function R5s(t){if(!t)return[];const s=[];return(t.searchCities||[]).forEach(r=>s.push({label:r,type:"city"})),(t.searchZipCodes||[]).forEach(r=>s.push({label:r,type:"zip"})),(t.searchCounties||[]).forEach(r=>s.push({label:r,type:"county"})),s}function F5s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){const f=nr(),g=n||$ct;return e.jsxs("section",{className:"relative h-screen flex items-center justify-center overflow-hidden",children:[e.jsx(ps.div,{className:"absolute inset-0",initial:{scale:1.1},animate:{scale:1},transition:{duration:20,ease:"linear"},children:e.jsx("img",{src:g,alt:"Ranch landscape",className:"w-full h-full object-cover",width:1920,height:1080})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/40 via-black/20 to-black/70"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1",style:{backgroundColor:o}}),e.jsxs("div",{className:"relative z-10 text-center px-4 max-w-4xl mx-auto",children:[e.jsxs(ps.div,{initial:{opacity:0,scaleX:0},animate:{opacity:1,scaleX:1},transition:{delay:.3,duration:.8},className:"flex items-center justify-center gap-4 mb-8",children:[e.jsx("div",{className:"h-px w-16",style:{backgroundColor:o}}),e.jsx(o1,{className:"w-6 h-6",style:{color:o}}),e.jsx("div",{className:"h-px w-16",style:{backgroundColor:o}})]}),e.jsx(ps.h1,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{delay:.5,duration:.8},className:"text-5xl md:text-7xl font-bold text-white mb-6 tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif",textShadow:"0 4px 20px rgba(0,0,0,0.4)"},children:s||"Where Land Meets Legacy"}),e.jsx(ps.p,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.7,duration:.8},className:"text-lg md:text-xl text-white/90 mb-10 max-w-2xl mx-auto leading-relaxed",style:{fontFamily:"'Lora', Georgia, serif"},children:r||"Discover extraordinary ranch, farm, and land properties. Connect with a specialist who understands the lifestyle behind every acre."}),e.jsx(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.9,duration:.6},className:"max-w-xl mx-auto",children:e.jsxs("form",{onSubmit:c,className:"relative",children:[e.jsx(Dme,{value:l,onChange:i,placeholder:u||"Search by city, county, or zip code...",suggestions:R5s(p),onSelect:v=>{f(`/search?q=${encodeURIComponent(v)}`)},className:"w-full",inputClassName:"w-full h-14 pl-14 pr-6 rounded-full bg-white/95 backdrop-blur-sm text-gray-900 text-lg shadow-2xl border-2 border-transparent focus:border-amber-600/50 focus:outline-none transition-all placeholder:text-gray-400"}),e.jsx(sn,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"})]})}),e.jsx(ps.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.5},className:"absolute bottom-12 left-1/2 -translate-x-1/2",children:e.jsx(ps.div,{animate:{y:[0,8,0]},transition:{repeat:1/0,duration:2},className:"w-10 h-10 rounded-full border-2 border-white/50 flex items-center justify-center cursor-pointer",onClick:()=>window.scrollBy({top:window.innerHeight,behavior:"smooth"}),children:e.jsx(oo,{className:"w-5 h-5 text-white/80"})})})]})]})}const z5s=[{label:"Ranch",image:A5s,searchParam:"ranch"},{label:"Farm",image:E5s,searchParam:"farm"},{label:"Land",image:P5s,searchParam:"land"},{label:"Equestrian",image:I5s,searchParam:"horse"},{label:"Vineyard",image:L5s,searchParam:"vineyard"}];function B5s({accentColor:t}){const s=N.useRef(null),r=k3(s,{once:!0,margin:"-100px"}),n=nr();return e.jsx("section",{ref:s,className:"py-20 px-4",style:{backgroundColor:qct},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:r?{opacity:1,y:0}:{},transition:{duration:.6},className:"text-center mb-14",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:t}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:t},children:"Explore"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:t}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",style:{color:V1,fontFamily:"'Playfair Display', Georgia, serif"},children:"Property Types"}),e.jsx("p",{className:"text-gray-600 max-w-2xl mx-auto",style:{fontFamily:"'Lora', Georgia, serif"},children:"Discover extraordinary properties across various categories that match your lifestyle and investment goals."})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:z5s.map((a,o)=>e.jsxs(ps.div,{initial:{opacity:0,y:30},animate:r?{opacity:1,y:0}:{},transition:{delay:o*.1,duration:.5},onClick:()=>n(`/search?q=${a.searchParam}`),className:"group cursor-pointer relative aspect-[3/4] rounded-2xl overflow-hidden shadow-lg hover:shadow-2xl transition-all duration-500",children:[e.jsx("img",{src:a.image,alt:a.label,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110",loading:"lazy",width:800,height:1024}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:[e.jsx("h3",{className:"text-white text-lg font-bold tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.label}),e.jsx("div",{className:"h-0.5 w-0 group-hover:w-full transition-all duration-500 mt-2 rounded-full",style:{backgroundColor:t}})]})]},a.label))})]})})}function $5s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=nr(),o=N.useRef(null),l=k3(o,{once:!0,margin:"-100px"}),[i,c]=N.useState([]);return N.useEffect(()=>{(async()=>{try{const{data:p}=await H.functions.invoke("fetch-mls-listings",{body:{siteId:t.id,mode:"featured",count:n||6}});p!=null&&p.listings&&c(p.listings)}catch{}})()},[t.id,n]),i.length?e.jsx("section",{ref:o,className:"py-20 px-4",style:{backgroundColor:l_},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:l?{opacity:1,y:0}:{},className:"text-center mb-12",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Featured"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:V1,fontFamily:"'Playfair Display', Georgia, serif"},children:r||"Featured Properties"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:i.slice(0,n||6).map((u,p)=>{var f,g;return e.jsxs(ps.div,{initial:{opacity:0,y:30},animate:l?{opacity:1,y:0}:{},transition:{delay:p*.1},onClick:()=>a(`/listing/${u.mlsNumber}`),className:"group cursor-pointer bg-white rounded-2xl overflow-hidden shadow-md hover:shadow-xl transition-all duration-300",children:[e.jsxs("div",{className:"relative aspect-[4/3] overflow-hidden",children:[e.jsx("img",{src:((f=u.photos)==null?void 0:f[0])||$ct,alt:u.address,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",loading:"lazy"}),u.lotSize&&e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-white text-xs font-semibold backdrop-blur-sm",style:{backgroundColor:`${s}dd`},children:u.lotSize})]}),e.jsxs("div",{className:"p-5",children:[e.jsx("div",{className:"flex items-start justify-between mb-2",children:e.jsx("h3",{className:"text-lg font-bold line-clamp-1",style:{color:V1,fontFamily:"'Playfair Display', Georgia, serif"},children:u.address})}),e.jsxs("p",{className:"text-gray-500 text-sm flex items-center gap-1 mb-3",children:[e.jsx(ia,{className:"w-3.5 h-3.5"}),u.city,u.state?`, ${u.state}`:""]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xl font-bold",style:{color:s},children:["$",(g=u.price)==null?void 0:g.toLocaleString()]}),e.jsxs("span",{className:"text-xs text-gray-400 flex items-center gap-1 group-hover:gap-2 transition-all",children:["View Details ",e.jsx(Sa,{className:"w-3.5 h-3.5"})]})]})]})]},u.mlsNumber)})}),e.jsx(ps.div,{initial:{opacity:0},animate:l?{opacity:1}:{},transition:{delay:.5},className:"text-center mt-10",children:e.jsxs("button",{onClick:()=>a("/search"),className:"inline-flex items-center gap-2 px-8 py-3.5 rounded-full text-white font-semibold tracking-wide hover:shadow-lg transition-all duration-300 hover:scale-105",style:{backgroundColor:s},children:["View All Properties ",e.jsx(Sa,{className:"w-4 h-4"})]})})]})}):null}const q5s=[{icon:ia,title:"Local Expertise",desc:"Deep knowledge of local land values, zoning regulations, and rural market dynamics."},{icon:hr,title:"Personal Touch",desc:"One-on-one guidance through every step of buying or selling specialized properties."},{icon:o1,title:"Smarter Technology",desc:"Innovative tools providing enhanced visibility and exposure for your property."},{icon:Au,title:"Trusted Network",desc:"Access to a curated network of qualified buyers, lenders, and industry professionals."}];function U5s({agentName:t,accentColor:s}){const r=N.useRef(null),n=k3(r,{once:!0,margin:"-100px"});return e.jsx("section",{ref:r,className:"py-20 px-4",style:{backgroundColor:V1},children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:n?{opacity:1,y:0}:{},className:"text-center mb-14",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Why Choose Us"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["The ",t," Advantage"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:q5s.map((a,o)=>{const l=a.icon;return e.jsxs(ps.div,{initial:{opacity:0,y:30},animate:n?{opacity:1,y:0}:{},transition:{delay:o*.15},className:"group p-6 rounded-2xl border border-white/10 hover:border-white/25 bg-white/5 backdrop-blur-sm transition-all duration-300 hover:bg-white/10",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center mb-5 transition-transform duration-300 group-hover:scale-110",style:{backgroundColor:`${s}22`},children:e.jsx(l,{className:"w-7 h-7",style:{color:s}})}),e.jsx("h3",{className:"text-lg font-bold text-white mb-2 tracking-wide",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.title}),e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",style:{fontFamily:"'Lora', Georgia, serif"},children:a.desc})]},a.title)})})]})})}function V5s({siteConfig:t,accentColor:s,brandColor:r,config:n}){var u,p,f;const a=N.useRef(null),o=k3(a,{once:!0,margin:"-100px"}),l=((u=t.agent)==null?void 0:u.full_name)||"Your Agent",i=(p=t.agent)==null?void 0:p.avatar_url,c=((f=t.agent)==null?void 0:f.bio)||"";return e.jsx("section",{ref:a,className:"py-20 px-4",style:{backgroundColor:qct},children:e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"grid md:grid-cols-2 gap-12 items-center",children:[i&&e.jsxs(ps.div,{initial:{opacity:0,x:-30},animate:o?{opacity:1,x:0}:{},transition:{duration:.7},className:"relative",children:[e.jsx("div",{className:"absolute -inset-3 rounded-2xl border-2 opacity-30",style:{borderColor:s}}),e.jsx("img",{src:i,alt:l,className:"w-full aspect-[3/4] object-cover rounded-2xl shadow-xl",loading:"lazy"})]}),e.jsxs(ps.div,{initial:{opacity:0,x:30},animate:o?{opacity:1,x:0}:{},transition:{duration:.7,delay:.2},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Your Specialist"})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",style:{color:V1,fontFamily:"'Playfair Display', Georgia, serif"},children:(n==null?void 0:n.sectionTitle)||`Meet ${l}`}),e.jsx("p",{className:"text-gray-600 leading-relaxed mb-8 text-base",style:{fontFamily:"'Lora', Georgia, serif"},children:c||`With deep expertise in rural and specialty properties, ${l} guides clients through every step of acquiring or selling their dream land, ranch, or farm property.`}),e.jsxs("button",{onClick:()=>window.location.href="/about",className:"inline-flex items-center gap-2 px-6 py-3 rounded-full text-white font-semibold tracking-wide hover:shadow-lg transition-all duration-300",style:{backgroundColor:s},children:["Learn More ",e.jsx(Sa,{className:"w-4 h-4"})]})]})]})})})}function H5s({testimonials:t,accentColor:s,sectionTitle:r}){const n=N.useRef(null),a=k3(n,{once:!0,margin:"-100px"}),[o,l]=N.useState(0);return t.length?e.jsx("section",{ref:n,className:"py-20 px-4",style:{backgroundColor:l_},children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:a?{opacity:1,y:0}:{},className:"mb-12",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}}),e.jsx("span",{className:"text-sm font-semibold tracking-[0.2em] uppercase",style:{color:s},children:"Testimonials"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:s}})]}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:V1,fontFamily:"'Playfair Display', Georgia, serif"},children:r||"What Our Clients Say"})]}),e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:a?{opacity:1,y:0}:{},transition:{delay:.2},className:"relative",children:[e.jsx(f1,{className:"w-12 h-12 mx-auto mb-6 opacity-20",style:{color:s}}),e.jsxs("p",{className:"text-xl md:text-2xl italic leading-relaxed mb-8 text-gray-700",style:{fontFamily:"'Lora', Georgia, serif"},children:['"',t[o].quote,'"']}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("div",{className:"h-px w-8",style:{backgroundColor:s}}),e.jsx("span",{className:"font-semibold",style:{color:V1},children:t[o].name}),t[o].role&&e.jsxs("span",{className:"text-gray-400 text-sm",children:["— ",t[o].role]}),e.jsx("div",{className:"h-px w-8",style:{backgroundColor:s}})]}),t.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mt-8",children:[e.jsx("button",{onClick:()=>l(i=>(i-1+t.length)%t.length),className:"w-10 h-10 rounded-full border-2 flex items-center justify-center hover:bg-white transition-colors",style:{borderColor:s,color:s},children:e.jsx(Xo,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex gap-2",children:t.map((i,c)=>e.jsx("button",{onClick:()=>l(c),className:"w-2.5 h-2.5 rounded-full transition-all duration-300",style:{backgroundColor:c===o?s:"#d4c5b0",transform:c===o?"scale(1.3)":"scale(1)"}},c))}),e.jsx("button",{onClick:()=>l(i=>(i+1)%t.length),className:"w-10 h-10 rounded-full border-2 flex items-center justify-center hover:bg-white transition-colors",style:{borderColor:s,color:s},children:e.jsx(oa,{className:"w-5 h-5"})})]})]})]})}):null}function G5s({agentName:t,accentColor:s}){const r=N.useRef(null),n=k3(r,{once:!0,margin:"-100px"});return e.jsxs("section",{ref:r,className:"relative py-24 px-4 overflow-hidden",style:{backgroundColor:V1},children:[e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),e.jsxs(ps.div,{ref:r,initial:{opacity:0,y:20},animate:n?{opacity:1,y:0}:{},className:"relative z-10 max-w-3xl mx-auto text-center",children:[e.jsx(o1,{className:"w-10 h-10 mx-auto mb-6",style:{color:s}}),e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:["Ready to Find Your",e.jsx("br",{}),"Dream Property?"]}),e.jsx("p",{className:"text-white/80 text-lg mb-10 max-w-xl mx-auto",style:{fontFamily:"'Lora', Georgia, serif"},children:"Whether you're searching for a working ranch, farmland, or a quiet piece of country to call home — let's make it happen."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs("a",{href:"/search",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-white font-semibold tracking-wide hover:shadow-xl transition-all duration-300 hover:scale-105",style:{backgroundColor:s},children:["Search Properties ",e.jsx(Sa,{className:"w-4 h-4"})]}),e.jsxs("a",{href:"/contact",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full border-2 text-white font-semibold tracking-wide hover:bg-white/10 transition-all duration-300",style:{borderColor:s},children:["Contact ",t.split(" ")[0]]})]})]})]})}const W5s="#f5f0eb";function K5s({accentColor:t,config:s}){const r=nr(),n=[{name:"Agriculture",desc:"Fertile farmland for crops, orchards, and agricultural operations",image:"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=600&q=75",link:"/search?type=farm"},{name:"Hunting & Recreation",desc:"Private retreats for hunting, fishing, and outdoor recreation",image:"https://images.unsplash.com/photo-1511497584788-876760111969?w=600&q=75",link:"/search"},{name:"Equestrian",desc:"Horse-ready properties with pastures, barns, and riding facilities",image:"https://images.unsplash.com/photo-1553284965-83fd3e82fa5a?w=600&q=75",link:"/search"},{name:"Homesteading",desc:"Self-sufficient living with space for gardens and livestock",image:"https://images.unsplash.com/photo-1500076656116-558758c991c1?w=600&q=75",link:"/search"},{name:"Development",desc:"Prime parcels for residential or commercial development",image:"https://images.unsplash.com/photo-1501854140801-50d01698950b?w=600&q=75",link:"/search"},{name:"Timber",desc:"Managed timberland with sustainable harvesting potential",image:"https://images.unsplash.com/photo-1448375240586-882707db888b?w=600&q=75",link:"/search"}],a=Array.from({length:6}).map((o,l)=>{var i,c,u,p;return{name:s[`category_name_${l}`]||((i=n[l])==null?void 0:i.name)||"",desc:s[`category_desc_${l}`]||((c=n[l])==null?void 0:c.desc)||"",image:s[`category_image_${l}`]||((u=n[l])==null?void 0:u.image)||"",link:s[`category_link_${l}`]||((p=n[l])==null?void 0:p.link)||"/search"}}).filter(o=>o.name);return a.length?e.jsx("section",{className:"py-20",style:{backgroundColor:W5s},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("p",{className:"text-xs tracking-[0.4em] uppercase mb-3 font-semibold",style:{color:t},children:[e.jsx(j0,{className:"inline h-4 w-4 mr-2"}),"Explore By Use"]}),e.jsx("h2",{className:"text-3xl md:text-5xl tracking-tight",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif",color:"#2c1810"},children:s.sectionTitle||"Find Your Perfect Property"}),s.subtitle&&e.jsx("p",{className:"text-[#5c4a3a] mt-3 text-lg",children:s.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5",children:a.map((o,l)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:l*.1},onClick:()=>r(o.link),className:"relative group cursor-pointer overflow-hidden rounded-xl aspect-[4/3]",children:[e.jsx("img",{src:o.image,alt:o.name,className:"w-full h-full object-cover group-hover:scale-110 transition-transform duration-700"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-6",children:[e.jsx("h3",{className:"text-xl font-bold text-white mb-1",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:o.name}),e.jsx("p",{className:"text-white/70 text-sm",children:o.desc})]}),e.jsx("div",{className:"absolute top-4 right-4 w-10 h-10 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{backgroundColor:t},children:e.jsx(Sa,{className:"h-4 w-4 text-white"})})]},l))})]})}):null}function Z5s({agentName:t,accentColor:s,config:r}){const n=nr(),a=r.bgImage||"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1920&q=75";return e.jsxs("section",{className:"relative py-28 overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:a,alt:"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-[#2c1810]/80"})]}),e.jsx("div",{className:"relative z-10 max-w-3xl mx-auto px-6 text-center",children:e.jsxs(ps.div,{initial:{opacity:0,y:30},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.7},children:[e.jsx(hl,{className:"h-12 w-12 mx-auto mb-6",style:{color:s}}),e.jsx("h2",{className:"text-4xl md:text-6xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:r.headline||"What's Your Land Worth?"}),e.jsx("p",{className:"text-white/70 text-lg md:text-xl leading-relaxed mb-10 max-w-xl mx-auto",children:r.subtitle||`Get a free, no-obligation land valuation from ${t} — a local expert who knows the market inside and out.`}),e.jsx("button",{onClick:()=>n(r.buttonLink||"/contact"),className:"px-10 py-4 text-sm font-bold tracking-[0.2em] uppercase text-white rounded-lg transition-all duration-300 hover:opacity-90 hover:scale-105",style:{backgroundColor:s},children:r.buttonText||"Get My Free Valuation"})]})})]})}function Y5s({siteConfig:t,accentColor:s,config:r}){const n=nr(),[a,o]=N.useState([]),[l,i]=N.useState(!0);return N.useEffect(()=>{(async()=>{var u;try{const f=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,pageSize:r.count||6,page:1,minAcres:r.minAcres?Number(r.minAcres):5})});if(f.ok){const g=await f.json();o(((u=g.listings)==null?void 0:u.slice(0,r.count||6))||[])}}catch{}finally{i(!1)}})()},[t.id,r.count,r.minAcres]),l?e.jsx("section",{className:"py-20",style:{backgroundColor:"#f5f0eb"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsx("div",{className:"h-8 bg-[#2c1810]/10 rounded w-64 mx-auto mb-12 animate-pulse"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[1,2,3,4].map(c=>e.jsx("div",{className:"h-72 bg-[#2c1810]/5 rounded-xl animate-pulse"},c))})]})}):a.length?e.jsx("section",{className:"py-20",style:{backgroundColor:"#f5f0eb"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("p",{className:"text-xs tracking-[0.4em] uppercase mb-3 font-semibold",style:{color:s},children:[e.jsx(AL,{className:"inline h-4 w-4 mr-2"}),"Expansive Properties"]}),e.jsx("h2",{className:"text-3xl md:text-5xl tracking-tight",style:{fontFamily:"'Playfair Display', Lora, Georgia, serif",color:"#2c1810"},children:r.sectionTitle||"Featured Acreage"}),r.subtitle&&e.jsx("p",{className:"text-[#5c4a3a] mt-3 text-lg",children:r.subtitle})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:a.map((c,u)=>{var p,f;return e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:u*.1},onClick:()=>n(`/listing/${c.mlsNumber}`),className:"group cursor-pointer rounded-xl overflow-hidden bg-white shadow-md hover:shadow-xl transition-shadow duration-300",children:[e.jsxs("div",{className:"relative aspect-[16/9] overflow-hidden",children:[e.jsx("img",{src:((p=c.photos)==null?void 0:p[0])||"https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=800&q=75",alt:c.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"}),c.acres&&e.jsxs("div",{className:"absolute top-4 left-4 px-3 py-1.5 rounded-full text-xs font-bold text-white",style:{backgroundColor:s},children:[c.acres," Acres"]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",style:{color:"#2c1810",fontFamily:"'Playfair Display', Lora, Georgia, serif"},children:["$",(f=c.price)==null?void 0:f.toLocaleString()]}),r.showPricePerAcre!==!1&&c.acres&&c.price&&e.jsxs("p",{className:"text-sm",style:{color:s},children:["$",Math.round(c.price/c.acres).toLocaleString(),"/acre"]})]}),e.jsx(Sa,{className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity text-[#5c4a3a]"})]}),e.jsx("p",{className:"text-[#5c4a3a] text-sm",children:c.address}),e.jsxs("p",{className:"text-[#8a7a6a] text-xs",children:[c.city,", ",c.state]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 text-xs text-[#8a7a6a]",children:[c.bedrooms>0&&e.jsxs("span",{children:[c.bedrooms," Beds"]}),c.bathrooms>0&&e.jsxs("span",{children:[c.bathrooms," Baths"]}),c.sqft&&e.jsxs("span",{children:[c.sqft.toLocaleString()," Sqft"]})]})]})]},c.mlsNumber)})})]})}):null}const Q5s=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${t}`,v9=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){const s=Number.parseFloat(t);return Number.isFinite(s)?s:null}return null},X5s=t=>[t.address,t.city,t.state,t.zip].filter(Boolean).join(", ");function P3e({listings:t,onListingClick:s,hoveredMlsNumber:r}){const n=N.useRef(null),a=N.useRef(null),o=N.useRef(new Map),l=N.useRef(null),i=N.useRef(new Map),[c,u]=N.useState(null),[p,f]=N.useState({});N.useEffect(()=>{(async()=>{const{data:w}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&u(w.value)})()},[]),N.useEffect(()=>{if(!(!n.current||!c||a.current))return Eo.accessToken=c,a.current=new Eo.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",zoom:4,center:[-98.5795,39.8283]}),a.current.addControl(new Eo.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[c]);const g=N.useMemo(()=>t.map(_=>{var k,S;const w=v9(_.latitude)??((k=p[_.mlsNumber])==null?void 0:k.lat)??null,j=v9(_.longitude)??((S=p[_.mlsNumber])==null?void 0:S.lng)??null;return w===null||j===null?null:{listing:_,latitude:w,longitude:j}}).filter(_=>_!==null),[t,p]);N.useEffect(()=>{if(!c||t.length===0)return;const _=t.filter(k=>!(v9(k.latitude)!==null&&v9(k.longitude)!==null)&&!i.current.has(k.mlsNumber));if(_.length===0)return;let w=!1;return(async()=>{const k=await Promise.all(_.map(async M=>{var P,O;const L=X5s(M);if(!L)return{mlsNumber:M.mlsNumber,coords:null};try{const $=await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${encodeURIComponent(c)}&limit=1&country=US&types=address,place,postcode`);if(!$.ok)return{mlsNumber:M.mlsNumber,coords:null};const U=await $.json(),[B,V]=((O=(P=U==null?void 0:U.features)==null?void 0:P[0])==null?void 0:O.center)??[];return!Number.isFinite(V)||!Number.isFinite(B)?{mlsNumber:M.mlsNumber,coords:null}:{mlsNumber:M.mlsNumber,coords:{lat:V,lng:B}}}catch{return{mlsNumber:M.mlsNumber,coords:null}}}));if(w)return;const S={};k.forEach(({mlsNumber:M,coords:L})=>{i.current.set(M,L),L&&(S[M]=L)}),Object.keys(S).length>0&&f(M=>({...M,...S}))})(),()=>{w=!0}},[t,c]);const v=N.useCallback(_=>{var k;const w=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_.price),j=(k=_.photos)!=null&&k[0]?``:`
`;return`
${j}
${w}
${_.address}
${_.bedrooms} bd ${_.bathrooms} ba ${_.sqft>0?`${_.sqft.toLocaleString()} sqft`:""}
`},[]);return N.useEffect(()=>{if(!a.current||!c||(o.current.forEach(w=>w.remove()),o.current.clear(),g.length===0))return;const _=new Eo.LngLatBounds;g.forEach(({listing:w,latitude:j,longitude:k})=>{const S=document.createElement("div");S.style.cssText="cursor: pointer;";const M=document.createElement("div");M.className="lead-site-map-pill",M.setAttribute("data-mls",w.mlsNumber),M.innerHTML=`${Q5s(w.price)}`,M.style.cssText=` background: white; border: 2px solid #2563eb; border-radius: 20px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: #1e3a5f; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.15); white-space: nowrap; transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease; font-family: system-ui, -apple-system, sans-serif; pointer-events: auto; `,M.addEventListener("mouseenter",()=>{M.style.background="#2563eb",M.style.color="white",M.style.transform="scale(1.1)"}),M.addEventListener("mouseleave",()=>{r!==w.mlsNumber&&(M.style.background="white",M.style.color="#1e3a5f",M.style.transform="scale(1)")}),S.appendChild(M);const L=new Eo.Marker({element:S,anchor:"bottom"}).setLngLat([k,j]).addTo(a.current);S.addEventListener("click",P=>{var $;P.stopPropagation(),($=l.current)==null||$.remove();const O=new Eo.Popup({offset:25,closeButton:!0,maxWidth:"240px",className:"lead-site-map-popup"}).setLngLat([k,j]).setHTML(v(w)).addTo(a.current);setTimeout(()=>{const U=O.getElement(),B=U==null?void 0:U.querySelector("[data-mls]");B&&(B.addEventListener("click",()=>{s(w.mlsNumber)}),B.style.cursor="pointer")},50),l.current=O}),o.current.set(w.mlsNumber,L),_.extend([k,j])});try{_.isEmpty()||a.current.fitBounds(_,{padding:60,maxZoom:14})}catch{}},[g,c,v,s]),N.useEffect(()=>{o.current.forEach((_,w)=>{const j=_.getElement().querySelector(".lead-site-map-pill");j&&(w===r?(j.style.background="#2563eb",j.style.color="white",j.style.transform="scale(1.15)",j.style.zIndex="10"):(j.style.background="white",j.style.color="#1e3a5f",j.style.transform="scale(1)",j.style.zIndex="1"))})},[r]),c?e.jsx("div",{ref:n,className:"w-full h-full"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100 text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(J5s,{className:"h-10 w-10 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Map not configured"})]})})}function J5s({className:t}){return e.jsxs("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]})}const eMs=50;function tMs({siteConfig:t}){var ue;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(xe=>({label:xe,type:"city"})),...(s.searchZipCodes||[]).map(xe=>({label:xe,type:"zip"})),...(s.searchCounties||[]).map(xe=>({label:xe,type:"county"}))],n=nr(),[a,o]=uc(),[l,i]=N.useState(!1),[c,u]=N.useState("list"),[p,f]=N.useState(null),g=a.get("q")||"",v=a.get("county")||"",_=a.get("minPrice")||"",w=a.get("maxPrice")||"",j=a.get("beds")||"",k=a.get("baths")||"",S=a.get("propertyType")||"",M=a.get("minSqft")||"",L=a.get("maxSqft")||"",[P,O]=N.useState(g),[$,U]=N.useState(!0),{data:B,isLoading:V,fetchNextPage:X,hasNextPage:Y,isFetchingNextPage:ee}=V2e({queryKey:["lead-site-search",t.id,g,v,_,w,j,k,S,M,L,$],queryFn:async({pageParam:xe=1})=>{const{data:_e,error:$e}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:g||void 0,county:v||void 0,minPrice:_?parseInt(_):void 0,maxPrice:w?parseInt(w):void 0,minBeds:j?parseInt(j):void 0,minBaths:k?parseInt(k):void 0,propertyType:S||void 0,minSqft:M?parseInt(M):void 0,maxSqft:L?parseInt(L):void 0,limit:eMs,page:xe}});if($e)throw $e;return _e},getNextPageParam:(xe,_e)=>{if(_e.reduce((Me,Ie)=>Me+Ie.listings.length,0)xe.listings))??[],ce=((ue=B==null?void 0:B.pages[0])==null?void 0:ue.total)??0,ne=N.useCallback(xe=>{xe.preventDefault();const _e=new URLSearchParams;P&&_e.set("q",P),v&&_e.set("county",v),_&&_e.set("minPrice",_),w&&_e.set("maxPrice",w),j&&_e.set("beds",j),k&&_e.set("baths",k),S&&_e.set("propertyType",S),M&&_e.set("minSqft",M),L&&_e.set("maxSqft",L),o(_e),U(!0)},[P,v,_,w,j,k,S,M,L,o]),re=N.useCallback((xe,_e)=>{const $e=new URLSearchParams(a);_e?$e.set(xe,_e):$e.delete(xe),o($e),U(!0)},[a,o]),oe=xe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(xe),fe=N.useCallback(xe=>{n(`/listing/${xe}`)},[n]),ge=Q.length>0;return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("div",{className:"bg-white border-b border-gray-200 z-40 shrink-0",children:e.jsxs("div",{className:"px-4 sm:px-6 py-3",children:[e.jsxs("form",{onSubmit:ne,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 z-10"}),r.length>0?e.jsx(Dme,{suggestions:r,value:P,onChange:O,onSelect:xe=>{O(xe);const _e=new URLSearchParams(a);_e.set("q",xe),o(_e),U(!0)},placeholder:"City, zip, county, or address...",inputClassName:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}):e.jsx("input",{type:"text",value:P,onChange:xe=>O(xe.target.value),placeholder:"City, zip, county, or address...",className:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsx("button",{type:"submit",className:"px-5 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Search"}),e.jsx("button",{type:"button",onClick:()=>i(!l),className:`px-3 py-2.5 border rounded-lg text-sm transition-colors ${l?"bg-blue-50 border-blue-300 text-blue-700":"border-gray-300 text-gray-600 hover:bg-gray-50"}`,children:e.jsx(y1,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:v,onChange:xe=>re("county",xe.target.value),placeholder:"County",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[140px]"}),e.jsxs("select",{value:j,onChange:xe=>re("beds",xe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Beds"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"}),e.jsx("option",{value:"5",children:"5+"})]}),e.jsxs("select",{value:k,onChange:xe=>re("baths",xe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Baths"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"})]}),e.jsxs("select",{value:S,onChange:xe=>re("propertyType",xe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[160px]",children:[e.jsx("option",{value:"",children:"Property Type"}),e.jsx("option",{value:"Residential",children:"Residential"}),e.jsx("option",{value:"Condo",children:"Condo"}),e.jsx("option",{value:"Townhouse",children:"Townhouse"}),e.jsx("option",{value:"Multi",children:"Multi-Family"}),e.jsx("option",{value:"Land",children:"Land"}),e.jsx("option",{value:"Farm",children:"Farm"}),e.jsx("option",{value:"Commercial",children:"Commercial"})]}),e.jsxs("select",{value:_,onChange:xe=>re("minPrice",xe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Min Price"}),e.jsx("option",{value:"100000",children:"$100k"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"})]}),e.jsxs("select",{value:w,onChange:xe=>re("maxPrice",xe.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"Max Price"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"}),e.jsx("option",{value:"2000000",children:"$2M"})]}),e.jsx("input",{type:"number",value:M,onChange:xe=>re("minSqft",xe.target.value),placeholder:"Min sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"}),e.jsx("input",{type:"number",value:L,onChange:xe=>re("maxSqft",xe.target.value),placeholder:"Max sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"})]}),ge&&e.jsxs("div",{className:"flex lg:hidden mt-2 gap-1",children:[e.jsxs("button",{onClick:()=>u("list"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="list"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(rh,{className:"h-3.5 w-3.5"})," List"]}),e.jsxs("button",{onClick:()=>u("map"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium rounded-lg transition-colors ${c==="map"?"bg-blue-600 text-white":"bg-gray-100 text-gray-600"}`,children:[e.jsx(g0,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:$?V?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Searching listings..."})]})}):ge?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:` w-full lg:w-[65%] overflow-y-auto border-r border-gray-200 bg-gray-50 shrink-0 ${c==="map"?"hidden lg:block":"block"} `,children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 bg-white flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-gray-700 font-semibold",children:[g?`${g} Real Estate`:"All Listings"," · ",ce," listing",ce!==1?"s":""," found"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Showing ",Q.length," of ",ce]})]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:Q.map(xe=>{var _e;return e.jsxs("button",{onClick:()=>n(`/listing/${xe.mlsNumber}`),onMouseEnter:()=>f(xe.mlsNumber),onMouseLeave:()=>f(null),className:`w-full bg-white rounded-xl border overflow-hidden hover:shadow-lg transition-all text-left group flex flex-col ${p===xe.mlsNumber?"border-blue-400 shadow-lg ring-1 ring-blue-200":"border-gray-200"}`,children:[e.jsxs("div",{className:"relative w-full aspect-[4/3] bg-gray-200 overflow-hidden",children:[(_e=xe.photos)!=null&&_e[0]?e.jsx("img",{src:xe.photos[0],alt:xe.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:$e=>{const Me=$e.target;Me.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:e.jsx(ia,{className:"h-8 w-8"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"px-2 py-0.5 bg-white/90 backdrop-blur text-[11px] font-semibold rounded text-gray-700",children:xe.status})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-xl font-bold text-white drop-shadow-md",children:oe(xe.price)}),e.jsxs("p",{className:"text-xs text-white/90 mt-0.5 truncate drop-shadow-sm",children:[xe.address,", ",xe.city,", ",xe.state]})]})]}),e.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-4 text-xs text-gray-600 border-t border-gray-100",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"})," ",xe.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(su,{className:"h-3.5 w-3.5"})," ",xe.bathrooms," ba"]}),xe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ax,{className:"h-3.5 w-3.5"})," ",xe.sqft.toLocaleString()," sqft"]})]})]},xe.mlsNumber)})}),Y&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>X(),disabled:ee,className:"px-6 py-3 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50 flex items-center gap-2",children:ee?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More Listings (${Q.length} of ${ce})`})})]}),e.jsx("div",{className:` lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"} `,children:e.jsx(P3e,{listings:Q,onListingClick:fe,hoveredMlsNumber:p})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mr,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"No Results"}),e.jsx("p",{className:"text-gray-500",children:"Try a different search term or adjust your filters."})]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(sn,{className:"h-12 w-12 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"Search for Properties"}),e.jsx("p",{className:"text-gray-500",children:"Enter a city, zip code, county, or address — or click Search to browse all listings."})]})})})]})}const sMs=50;function rMs({siteConfig:t}){var Ie;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(ke=>({label:ke,type:"city"})),...(s.searchZipCodes||[]).map(ke=>({label:ke,type:"zip"})),...(s.searchCounties||[]).map(ke=>({label:ke,type:"county"}))],n=nr(),[a,o]=uc(),[l,i]=N.useState(!1),[c,u]=N.useState("list"),[p,f]=N.useState(null),g="#c9a96e",v=a.get("q")||"",_=a.get("county")||"",w=a.get("minPrice")||"",j=a.get("maxPrice")||"",k=a.get("beds")||"",S=a.get("baths")||"",M=a.get("propertyType")||"",L=a.get("minSqft")||"",P=a.get("maxSqft")||"",[O,$]=N.useState(v),[U,B]=N.useState(!0),V=!!(_||w||j||k||S||M||L||P),{data:X,isLoading:Y,fetchNextPage:ee,hasNextPage:Q,isFetchingNextPage:ce}=V2e({queryKey:["lead-site-search",t.id,v,_,w,j,k,S,M,L,P,U],queryFn:async({pageParam:ke=1})=>{const pe={leadSiteId:t.id,query:v||void 0,county:_||void 0,minPrice:w?parseInt(w):void 0,maxPrice:j?parseInt(j):void 0,minBeds:k?parseInt(k):void 0,minBaths:S?parseInt(S):void 0,propertyType:M||void 0,minSqft:L?parseInt(L):void 0,maxSqft:P?parseInt(P):void 0,limit:sMs,page:ke},we=async Qe=>{const{data:Te,error:pt}=await H.functions.invoke("lead-site-search",{body:Qe});if(pt)throw pt;return Te},Le=await we(pe);if(v&&!V&&Le.listings.length===0){const Qe={...pe,query:void 0};return{...await we(Qe),fallbackQuery:v}}return Le},getNextPageParam:(ke,pe)=>{if(pe.reduce((Le,Qe)=>Le+Qe.listings.length,0)ke.listings))??[],re=((Ie=X==null?void 0:X.pages[0])==null?void 0:Ie.total)??0,oe=X!=null&&X.pages[0]&&"fallbackQuery"in X.pages[0]?X.pages[0].fallbackQuery:void 0,fe=N.useCallback(ke=>{ke.preventDefault();const pe=new URLSearchParams;O&&pe.set("q",O),_&&pe.set("county",_),w&&pe.set("minPrice",w),j&&pe.set("maxPrice",j),k&&pe.set("beds",k),S&&pe.set("baths",S),M&&pe.set("propertyType",M),L&&pe.set("minSqft",L),P&&pe.set("maxSqft",P),o(pe),B(!0)},[O,_,w,j,k,S,M,L,P,o]),ge=N.useCallback((ke,pe)=>{const we=new URLSearchParams(a);pe?we.set(ke,pe):we.delete(ke),o(we),B(!0)},[a,o]),ue=ke=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ke),xe=N.useCallback(ke=>{n(`/listing/${ke}`)},[n]),_e=ne.length>0,$e="bg-transparent border border-white/15 text-white px-3 py-2.5 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/30",Me="bg-[#161312] border border-white/15 text-white/70 px-3 py-2.5 text-sm focus:outline-none focus:border-white/40 transition-colors";return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 bg-[#0d0b0a]",children:[e.jsx("div",{className:"bg-[#0d0b0a] border-b border-white/10 z-40 shrink-0",children:e.jsxs("div",{className:"px-4 sm:px-6 py-3",children:[e.jsxs("form",{onSubmit:fe,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/30 z-10"}),r.length>0?e.jsx(Dme,{suggestions:r,value:O,onChange:$,onSelect:ke=>{$(ke);const pe=new URLSearchParams(a);pe.set("q",ke),o(pe),B(!0)},placeholder:"City, zip, county, or address...",inputClassName:`w-full pl-10 pr-4 ${$e}`}):e.jsx("input",{type:"text",value:O,onChange:ke=>$(ke.target.value),placeholder:"City, zip, county, or address...",className:`w-full pl-10 pr-4 ${$e}`})]}),e.jsx("button",{type:"submit",className:"px-5 py-2.5 text-xs tracking-[0.2em] uppercase text-black font-medium transition-all hover:opacity-90",style:{backgroundColor:g},children:"Search"}),e.jsx("button",{type:"button",onClick:()=>i(!l),className:`px-3 py-2.5 border text-sm transition-colors ${l?"border-white/30 text-white":"border-white/15 text-white/40 hover:text-white/70"}`,children:e.jsx(y1,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:_,onChange:ke=>ge("county",ke.target.value),placeholder:"County",className:`min-w-[140px] ${$e}`}),e.jsxs("select",{value:k,onChange:ke=>ge("beds",ke.target.value),className:Me,children:[e.jsx("option",{value:"",children:"Beds"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"}),e.jsx("option",{value:"5",children:"5+"})]}),e.jsxs("select",{value:S,onChange:ke=>ge("baths",ke.target.value),className:Me,children:[e.jsx("option",{value:"",children:"Baths"}),e.jsx("option",{value:"1",children:"1+"}),e.jsx("option",{value:"2",children:"2+"}),e.jsx("option",{value:"3",children:"3+"}),e.jsx("option",{value:"4",children:"4+"})]}),e.jsxs("select",{value:M,onChange:ke=>ge("propertyType",ke.target.value),className:`min-w-[160px] ${Me}`,children:[e.jsx("option",{value:"",children:"Property Type"}),e.jsx("option",{value:"Residential",children:"Residential"}),e.jsx("option",{value:"Condo",children:"Condo"}),e.jsx("option",{value:"Townhouse",children:"Townhouse"}),e.jsx("option",{value:"Multi",children:"Multi-Family"}),e.jsx("option",{value:"Land",children:"Land"})]}),e.jsxs("select",{value:w,onChange:ke=>ge("minPrice",ke.target.value),className:Me,children:[e.jsx("option",{value:"",children:"Min Price"}),e.jsx("option",{value:"100000",children:"$100k"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"})]}),e.jsxs("select",{value:j,onChange:ke=>ge("maxPrice",ke.target.value),className:Me,children:[e.jsx("option",{value:"",children:"Max Price"}),e.jsx("option",{value:"200000",children:"$200k"}),e.jsx("option",{value:"300000",children:"$300k"}),e.jsx("option",{value:"500000",children:"$500k"}),e.jsx("option",{value:"750000",children:"$750k"}),e.jsx("option",{value:"1000000",children:"$1M"}),e.jsx("option",{value:"2000000",children:"$2M"})]}),e.jsx("input",{type:"number",value:L,onChange:ke=>ge("minSqft",ke.target.value),placeholder:"Min sqft",className:`w-[120px] ${$e}`}),e.jsx("input",{type:"number",value:P,onChange:ke=>ge("maxSqft",ke.target.value),placeholder:"Max sqft",className:`w-[120px] ${$e}`})]}),_e&&e.jsxs("div",{className:"flex lg:hidden mt-2 gap-1",children:[e.jsxs("button",{onClick:()=>u("list"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium transition-colors ${c==="list"?"text-black":"text-white/40 border border-white/15"}`,style:c==="list"?{backgroundColor:g}:{},children:[e.jsx(rh,{className:"h-3.5 w-3.5"})," List"]}),e.jsxs("button",{onClick:()=>u("map"),className:`flex-1 flex items-center justify-center gap-1.5 py-2 text-xs font-medium transition-colors ${c==="map"?"text-black":"text-white/40 border border-white/15"}`,style:c==="map"?{backgroundColor:g}:{},children:[e.jsx(g0,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:U?Y?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-white/20 mx-auto mb-4",style:{borderTopColor:g}}),e.jsx("p",{className:"text-white/30",children:"Searching listings..."})]})}):_e?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:`w-full lg:w-[65%] overflow-y-auto border-r border-white/5 bg-[#0d0b0a] shrink-0 ${c==="map"?"hidden lg:block":"block"}`,children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-white/70",children:[oe?"All Active Listings":v?`${v} Real Estate`:"All Listings"," · ",re," listing",re!==1?"s":""]}),e.jsxs("p",{className:"text-xs text-white/30",children:["Showing ",ne.length," of ",re]})]}),oe&&e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 text-xs text-white/45",children:["No exact matches for “",oe,"” in this demo feed, so showing all available listings instead."]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:ne.map(ke=>{var pe;return e.jsxs("button",{onClick:()=>n(`/listing/${ke.mlsNumber}`),onMouseEnter:()=>f(ke.mlsNumber),onMouseLeave:()=>f(null),className:`w-full bg-[#161312] border overflow-hidden hover:border-white/20 transition-all text-left group flex flex-col ${p===ke.mlsNumber?"border-white/30":"border-white/5"}`,children:[e.jsxs("div",{className:"relative w-full aspect-[4/3] bg-[#1a1715] overflow-hidden",children:[(pe=ke.photos)!=null&&pe[0]?e.jsx("img",{src:ke.photos[0],alt:ke.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",onError:we=>{we.target.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/10",children:e.jsx(ia,{className:"h-8 w-8"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:"px-2 py-0.5 text-[10px] tracking-wider uppercase text-white/80",style:{backgroundColor:`${g}cc`},children:ke.status})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-xl font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:ue(ke.price)}),e.jsxs("p",{className:"text-xs text-white/70 mt-0.5 truncate",children:[ke.address,", ",ke.city,", ",ke.state]})]})]}),e.jsxs("div",{className:"px-3 py-2.5 flex items-center gap-4 text-xs text-white/30 tracking-wider uppercase border-t border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"})," ",ke.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(su,{className:"h-3.5 w-3.5"})," ",ke.bathrooms," ba"]}),ke.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ax,{className:"h-3.5 w-3.5"})," ",ke.sqft.toLocaleString()," sqft"]})]})]},ke.mlsNumber)})}),Q&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>ee(),disabled:ce,className:"px-6 py-3 text-xs tracking-[0.2em] uppercase border border-white/20 text-white/60 hover:bg-white hover:text-black transition-all duration-500 disabled:opacity-50 flex items-center gap-2",children:ce?e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More (${ne.length} of ${re})`})})]}),e.jsx("div",{className:`lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"}`,children:e.jsx(P3e,{listings:ne,onListingClick:xe,hoveredMlsNumber:p})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Mr,{className:"h-12 w-12 text-white/10 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"No Results"}),e.jsx("p",{className:"text-white/30 mt-2",children:"Try a different search or adjust your filters."})]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(sn,{className:"h-12 w-12 text-white/10 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Search for Properties"}),e.jsx("p",{className:"text-white/30 mt-2",children:"Enter a city, zip code, or address to begin."})]})})})]})}const Wye="ls_visitor_";function Uct(t,s){const[r,n]=N.useState(0),[a,o]=N.useState(!1),[l,i]=N.useState(!1),c=t==null?void 0:t.id,u=(t==null?void 0:t.leadRegistrationMode)??"disabled",p=(t==null?void 0:t.registrationTriggerCount)??1;N.useEffect(()=>{if(!c)return;const w=parseInt(localStorage.getItem(`${Wye}views_${c}`)||"0",10);n(w)},[c]);const f=N.useCallback((w,j,k)=>{if(!c||u==="disabled")return;const S=r+1;n(S),localStorage.setItem(`${Wye}views_${c}`,String(S)),H.from("lead_site_property_views").insert({lead_site_id:c,mls_number:w,auth_user_id:j||null,visitor_fingerprint:localStorage.getItem(`${Wye}fp_${c}`)||null,property_address:(k==null?void 0:k.propertyAddress)||null,photo_url:(k==null?void 0:k.photoUrl)||null}).then(),!s&&!l&&S>=p&&o(!0)},[c,u,r,s,l,p]);N.useEffect(()=>{s&&a&&o(!1)},[s,a]);const g=N.useCallback(()=>{o(!1),i(!0)},[]),v=N.useCallback(()=>{o(!1)},[]),_=u==="required"&&!s&&r>=p;return{viewCount:r,showRegistration:a,isGated:_,mode:u,recordView:f,dismissRegistration:g,completeRegistration:v,setShowRegistration:o}}function Vct({photos:t}){const[s,r]=N.useState(!1),[n,a]=N.useState(0);if(!t||t.length===0)return null;const o=c=>{a(c),r(!0)},l=()=>a(c=>(c+1)%t.length),i=()=>a(c=>(c-1+t.length)%t.length);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-1.5 rounded-xl overflow-hidden",children:[e.jsx("div",{className:"md:col-span-2 md:row-span-2 aspect-[4/3] cursor-pointer relative overflow-hidden",onClick:()=>o(0),children:e.jsx("img",{src:t[0],alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})}),t.slice(1,5).map((c,u)=>e.jsxs("div",{className:"aspect-[4/3] cursor-pointer relative overflow-hidden hidden md:block",onClick:()=>o(u+1),children:[e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),u===3&&t.length>5&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("span",{className:"text-white text-lg font-semibold",children:["+",t.length-5," more"]})})]},u))]}),t.length>1&&e.jsxs("button",{onClick:()=>o(0),className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-3 py-1.5 bg-white/90 backdrop-blur-sm text-gray-800 text-sm font-medium rounded-lg shadow hover:bg-white transition-colors",children:[e.jsx(xL,{className:"h-4 w-4"}),"View all ",t.length," photos"]})]}),s&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",children:[e.jsxs("span",{className:"text-sm font-medium",children:[n+1," / ",t.length]}),e.jsx("button",{onClick:()=>r(!1),className:"p-2 hover:bg-white/10 rounded-full transition-colors",children:e.jsx(Mr,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex-1 flex items-center justify-center px-4 relative min-h-0",children:[e.jsx("img",{src:t[n],alt:"",className:"max-w-full max-h-full object-contain"}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"absolute left-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(Xo,{className:"h-6 w-6"})}),e.jsx("button",{onClick:l,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white transition-colors",children:e.jsx(oa,{className:"h-6 w-6"})})]})]}),e.jsx("div",{className:"px-4 py-3 overflow-x-auto",children:e.jsx("div",{className:"flex gap-2 justify-center",children:t.map((c,u)=>e.jsx("button",{onClick:()=>a(u),className:`w-16 h-12 rounded overflow-hidden shrink-0 border-2 transition-all ${u===n?"border-white opacity-100":"border-transparent opacity-50 hover:opacity-75"}`,children:e.jsx("img",{src:c,alt:"",className:"w-full h-full object-cover"})},u))})})]})]})}function Hct({listing:t}){var n,a;const s=[];t.lotSize&&s.push({label:"Lot Size",value:t.lotSize,icon:e.jsx(j0,{className:"h-4 w-4"})}),t.garageSpaces&&s.push({label:"Garage",value:`${t.garageSpaces} spaces`,icon:e.jsx(DM,{className:"h-4 w-4"})}),t.stories&&s.push({label:"Stories",value:`${t.stories}`,icon:e.jsx(qM,{className:"h-4 w-4"})}),t.heating&&s.push({label:"Heating",value:t.heating,icon:e.jsx(VL,{className:"h-4 w-4"})}),t.cooling&&s.push({label:"Cooling",value:t.cooling,icon:e.jsx(o0,{className:"h-4 w-4"})}),t.fireplace&&s.push({label:"Fireplace",value:"Yes",icon:e.jsx(sh,{className:"h-4 w-4"})}),t.pool&&s.push({label:"Pool",value:t.pool,icon:e.jsx(QL,{className:"h-4 w-4"})}),t.basement&&s.push({label:"Basement",value:t.basement,icon:e.jsx(qM,{className:"h-4 w-4"})}),t.parking&&s.push({label:"Parking",value:t.parking,icon:e.jsx(DM,{className:"h-4 w-4"})});const r=[];if(t.hoaFee){const o=t.hoaFrequency?`/${t.hoaFrequency.toLowerCase()}`:"/mo";r.push({label:"HOA Fee",value:`$${t.hoaFee.toLocaleString()}${o}`})}if(t.taxAmount){const o=t.taxYear?` (${t.taxYear})`:"";r.push({label:"Annual Taxes",value:`$${t.taxAmount.toLocaleString()}${o}`})}if(t.sqft>0&&t.price>0&&r.push({label:"Price / Sq Ft",value:`$${Math.round(t.price/t.sqft).toLocaleString()}`}),t.listDate){const o=Math.floor((Date.now()-new Date(t.listDate).getTime())/864e5);o>=0&&o<9999&&r.push({label:"Days on Market",value:`${o}`})}return s.length===0&&r.length===0?null:e.jsxs("div",{className:"space-y-6",children:[r.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Financial Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:r.map(o=>e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-0.5",children:o.label}),e.jsxs("p",{className:"font-semibold text-gray-900 flex items-center gap-1",children:[e.jsx(hl,{className:"h-3.5 w-3.5 text-gray-400"}),o.value.replace("$","")]})]},o.label))})]}),s.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Property Details"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-3",children:s.map(o=>e.jsxs("div",{className:"flex items-center gap-2 py-2 border-b border-gray-100",children:[e.jsx("span",{className:"text-gray-400",children:o.icon}),e.jsx("span",{className:"text-sm text-gray-500",children:o.label}),e.jsx("span",{className:"text-sm font-medium text-gray-900 ml-auto",children:o.value})]},o.label))})]}),((n=t.features)==null?void 0:n.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Features"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.features.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-blue-50 text-blue-700 text-xs rounded-full font-medium",children:o},l))})]}),((a=t.appliances)==null?void 0:a.length)>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Appliances"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.appliances.map((o,l)=>e.jsx("span",{className:"px-2.5 py-1 bg-gray-100 text-gray-700 text-xs rounded-full font-medium",children:o},l))})]})]})}function Gct({latitude:t,longitude:s,address:r}){const n=N.useRef(null),a=N.useRef(null),o=N.useMemo(()=>{const l=Number(t),i=Number(s);return!Number.isFinite(l)||!Number.isFinite(i)?null:{lat:l,lng:i}},[t,s]);return N.useEffect(()=>{if(!n.current||a.current||!o)return;Eo.accessToken="pk.eyJ1IjoibGV2ZWx1cHJlIiwiYSI6ImNtOGZwMGNrYzBjNjIyanF5c2RwNTFhOXMifQ.sTe5rOhf_2nkqgr8Z_0e4Q";const l=new Eo.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",center:[o.lng,o.lat],zoom:14,interactive:!0});return l.addControl(new Eo.NavigationControl({showCompass:!1}),"top-right"),new Eo.Marker({color:"#2563eb"}).setLngLat([o.lng,o.lat]).setPopup(new Eo.Popup({offset:25}).setText(r)).addTo(l),a.current=l,()=>{l.remove(),a.current=null}},[o,r]),o?e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-3",children:"Location"}),e.jsx("div",{ref:n,className:"w-full h-64 rounded-xl overflow-hidden border border-gray-200"})]}):null}function Wct({listPrice:t}){const[s,r]=N.useState(20),[n,a]=N.useState(6.5),[o,l]=N.useState(30),i=N.useMemo(()=>{const f=t*(1-s/100),g=n/100/12,v=o*12;return g===0?f/v:f*g*Math.pow(1+g,v)/(Math.pow(1+g,v)-1)},[t,s,n,o]),c=t*(s/100),u=t-c,p=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(f);return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(cL,{className:"h-5 w-5 text-blue-600"}),e.jsx("h3",{className:"font-semibold text-gray-900",children:"Mortgage Calculator"})]}),e.jsxs("div",{className:"text-center mb-5",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Estimated Monthly Payment"}),e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:p(i)})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Down Payment"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[s,"% (",p(c),")"]})]}),e.jsx("input",{type:"range",min:0,max:50,step:5,value:s,onChange:f=>r(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Interest Rate"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[n,"%"]})]}),e.jsx("input",{type:"range",min:2,max:12,step:.25,value:n,onChange:f=>a(Number(f.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-600",children:"Loan Term"}),e.jsxs("span",{className:"font-medium text-gray-900",children:[o," years"]})]}),e.jsx("div",{className:"flex gap-2",children:[15,20,30].map(f=>e.jsxs("button",{onClick:()=>l(f),className:`flex-1 py-1.5 text-sm font-medium rounded-lg border transition-colors ${o===f?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[f," yr"]},f))})]}),e.jsxs("div",{className:"pt-3 border-t border-gray-100 space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Loan Amount"}),e.jsx("span",{className:"font-medium",children:p(u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Interest"}),e.jsx("span",{className:"font-medium",children:p(i*o*12-u)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Cost"}),e.jsx("span",{className:"font-medium",children:p(i*o*12+c)})]})]})]})]})}function Kct({siteConfig:t,currentListing:s}){const r=nr(),{data:n}=mt({queryKey:["similar-listings",t.id,s.mlsNumber],queryFn:async()=>{const{data:o,error:l}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:s.city,minPrice:Math.round(s.price*.75),maxPrice:Math.round(s.price*1.25),minBeds:Math.max(0,s.bedrooms-1),propertyType:s.propertyType||void 0}});if(l)throw l;return((o==null?void 0:o.listings)||[]).filter(c=>c.mlsNumber!==s.mlsNumber).slice(0,6)},enabled:!!s.city});if(!n||n.length===0)return null;const a=o=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Similar Listings Nearby"}),e.jsxs("button",{onClick:()=>r("/search"),className:"text-sm text-blue-600 hover:text-blue-700 flex items-center gap-0.5",children:["View all ",e.jsx(oa,{className:"h-4 w-4"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:n.map(o=>{var l;return e.jsxs("div",{onClick:()=>r(`/listing/${o.mlsNumber}`),className:"bg-white border border-gray-200 rounded-xl overflow-hidden cursor-pointer hover:shadow-md transition-shadow group",children:[e.jsx("div",{className:"aspect-[16/10] overflow-hidden",children:(l=o.photos)!=null&&l[0]?e.jsx("img",{src:o.photos[0],alt:"",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full bg-gray-100 flex items-center justify-center text-gray-400 text-sm",children:"No photo"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"font-bold text-gray-900",children:a(o.price)}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[o.address,", ",o.city]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"})," ",o.bedrooms]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(su,{className:"h-3.5 w-3.5"})," ",o.bathrooms]}),o.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ax,{className:"h-3.5 w-3.5"})," ",o.sqft.toLocaleString()]})]})]})]},o.mlsNumber)})})]})}function nMs({siteConfig:t}){var L,P,O;const{mlsNumber:s}=lo(),r=nr(),[n,a]=N.useState(!1),[o,l]=N.useState({name:"",email:"",phone:"",message:""}),[i,c]=N.useState(!1),{user:u}=F3(),p=Uct(t,!!u),[f,g]=N.useState(!1);N.useEffect(()=>{!u||!s||H.from("lead_site_saved_listings").select("id").eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s).maybeSingle().then(({data:$})=>g(!!$))},[u,s,t.id]);const v=async()=>{var $;!u||!s||(f?(await H.from("lead_site_saved_listings").delete().eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s),g(!1),me.success("Removed from saved")):(await H.from("lead_site_saved_listings").insert({user_id:u.id,lead_site_id:t.id,mls_number:s,property_address:_?`${_.address}, ${_.city}, ${_.state}`:null,photo_url:(($=_==null?void 0:_.photos)==null?void 0:$[0])||null}),g(!0),me.success("Saved to favorites")))},{data:_,isLoading:w,error:j}=mt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const $=new AbortController,U=window.setTimeout(()=>$.abort(),15e3);try{const B=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-listing",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,mlsNumber:s}),signal:$.signal}),V=await B.json().catch(()=>null);if(!B.ok)throw console.error("Lead site listing fetch error:",V),new Error((V==null?void 0:V.error)||"Failed to load listing");return console.log("Lead site listing data received:",!!V,V==null?void 0:V.mlsNumber),V}finally{window.clearTimeout(U)}},enabled:!!s});N.useEffect(()=>{var $;s&&t&&_&&p.recordView(s,u==null?void 0:u.id,{propertyAddress:_.address?`${_.address}, ${_.city}, ${_.state}`:void 0,photoUrl:(($=_.photos)==null?void 0:$[0])||void 0})},[s,t==null?void 0:t.id,_==null?void 0:_.address]);const k=async $=>{$.preventDefault(),c(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,source_page:`/listing/${s}`,lead_type:"listing_inquiry",metadata:{mlsNumber:s}}),ZE(t.id,{name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,lead_type:"listing_inquiry",source_page:`/listing/${s}`,mls_number:s}),me.success("Message sent! The agent will be in touch."),l({name:"",email:"",phone:"",message:""}),a(!1)}catch{me.error("Something went wrong. Please try again.")}finally{c(!1)}},S=async()=>{const $=window.location.href;if(navigator.share)try{await navigator.share({title:(_==null?void 0:_.address)||"Property Listing",url:$})}catch{}else await navigator.clipboard.writeText($),me.success("Link copied to clipboard")},M=$=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format($);return w?e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent"})}):_?e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 relative",children:[e.jsx(Bct,{listing:_,siteConfig:t}),e.jsx(Lme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${_.address}, ${_.city}`,path:`/listing/${_.mlsNumber}`}]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm",children:[e.jsx(Qa,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors",children:[e.jsx(nd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:v,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm border rounded-lg transition-colors ${f?"bg-red-50 text-red-600 border-red-200":"text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:[e.jsx(Ya,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(Vct,{photos:_.photos||[]}),e.jsxs("div",{className:p.isGated?"filter blur-sm pointer-events-none select-none":"",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:M(_.price)}),e.jsxs("p",{className:"text-gray-600 mt-1 flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),_.address,", ",_.city,", ",_.state," ",_.zip]})]}),e.jsx("span",{className:"px-3 py-1 bg-green-100 text-green-800 text-sm font-semibold rounded-full shrink-0",children:_.status})]}),e.jsxs("p",{className:"text-xs text-gray-400",children:["MLS# ",_.mlsNumber]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-6 py-4 border-y border-gray-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mh,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bedrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"beds"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(su,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.bathrooms}),e.jsx("span",{className:"text-gray-500 text-sm",children:"baths"})]}),_.sqft>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ax,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.sqft.toLocaleString()}),e.jsx("span",{className:"text-gray-500 text-sm",children:"sqft"})]}),_.yearBuilt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-gray-400"}),e.jsx("span",{className:"font-semibold",children:_.yearBuilt}),e.jsx("span",{className:"text-gray-500 text-sm",children:"built"})]}),_.propertyType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600",children:_.propertyType}),_.propertySubType&&e.jsxs("span",{className:"text-xs text-gray-400",children:["• ",_.propertySubType]})]})]}),_.virtualTourUrl&&e.jsxs("a",{href:_.virtualTourUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-lg text-sm font-medium hover:bg-blue-100 transition-colors",children:[e.jsx(en,{className:"h-4 w-4"})," Take a Virtual Tour"]}),_.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 text-sm leading-relaxed whitespace-pre-line",children:_.description})]}),e.jsx(Hct,{listing:_}),_.latitude&&_.longitude&&e.jsx(Gct,{latitude:_.latitude,longitude:_.longitude,address:`${_.address}, ${_.city}`})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[((L=t.agent)==null?void 0:L.avatar_url)&&e.jsx("img",{src:t.agent.avatar_url,alt:"",className:"w-12 h-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900",children:(P=t.agent)==null?void 0:P.full_name}),e.jsx("p",{className:"text-sm text-gray-500",children:((O=t.agent)==null?void 0:O.title)||"Real Estate Agent"})]})]}),n?e.jsxs("form",{onSubmit:k,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:$=>l(U=>({...U,name:$.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email",value:o.email,onChange:$=>l(U=>({...U,email:$.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("input",{type:"tel",placeholder:"Phone (optional)",value:o.phone,onChange:$=>l(U=>({...U,phone:$.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("textarea",{placeholder:"Message",value:o.message,onChange:$=>l(U=>({...U,message:$.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-20 resize-none"}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:i?"Sending...":"Send Message"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors",children:"Ask About This Property"}),e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors",children:"Schedule a Showing"})]})]}),_.price>0&&e.jsx(Wct,{listPrice:_.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(Kct,{siteConfig:t,currentListing:_})})]}),e.jsx(FR,{open:p.showRegistration,mode:p.mode,siteConfig:t,onComplete:p.completeRegistration,onSkip:p.dismissRegistration})]}):e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-20 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:j?"Error loading listing":"Listing not found"}),j&&e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Please try again in a moment."}),e.jsx("button",{onClick:()=>r("/search"),className:"mt-4 text-blue-600 hover:underline",children:"Back to search"})]})}function aMs({siteConfig:t}){var P,O,$;const{mlsNumber:s}=lo(),r=nr(),[n,a]=N.useState(!1),[o,l]=N.useState({name:"",email:"",phone:"",message:""}),[i,c]=N.useState(!1),{user:u}=F3(),p=Uct(t,!!u),[f,g]=N.useState(!1),v="#c9a96e";N.useEffect(()=>{!u||!s||H.from("lead_site_saved_listings").select("id").eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s).maybeSingle().then(({data:U})=>g(!!U))},[u,s,t.id]);const _=async()=>{var U;!u||!s||(f?(await H.from("lead_site_saved_listings").delete().eq("user_id",u.id).eq("lead_site_id",t.id).eq("mls_number",s),g(!1),me.success("Removed from saved")):(await H.from("lead_site_saved_listings").insert({user_id:u.id,lead_site_id:t.id,mls_number:s,property_address:w?`${w.address}, ${w.city}, ${w.state}`:null,photo_url:((U=w==null?void 0:w.photos)==null?void 0:U[0])||null}),g(!0),me.success("Saved to favorites")))},{data:w,isLoading:j,error:k}=mt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const U=new AbortController,B=window.setTimeout(()=>U.abort(),15e3);try{const V=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-listing",{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,mlsNumber:s}),signal:U.signal}),X=await V.json().catch(()=>null);if(!V.ok)throw new Error((X==null?void 0:X.error)||"Failed to load listing");return X}finally{window.clearTimeout(B)}},enabled:!!s});N.useEffect(()=>{var U;s&&t&&w&&p.recordView(s,u==null?void 0:u.id,{propertyAddress:w.address?`${w.address}, ${w.city}, ${w.state}`:void 0,photoUrl:((U=w.photos)==null?void 0:U[0])||void 0})},[s,t==null?void 0:t.id,w==null?void 0:w.address]);const S=async U=>{U.preventDefault(),c(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,source_page:`/listing/${s}`,lead_type:"listing_inquiry",metadata:{mlsNumber:s}}),ZE(t.id,{name:o.name,email:o.email,phone:o.phone||null,message:o.message||`Interested in listing ${s}`,lead_type:"listing_inquiry",source_page:`/listing/${s}`,mls_number:s}),me.success("Message sent! The agent will be in touch."),l({name:"",email:"",phone:"",message:""}),a(!1)}catch{me.error("Something went wrong.")}finally{c(!1)}},M=async()=>{const U=window.location.href;if(navigator.share)try{await navigator.share({title:(w==null?void 0:w.address)||"Property",url:U})}catch{}else await navigator.clipboard.writeText(U),me.success("Link copied")},L=U=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(U);return j?e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center bg-[#0d0b0a]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-white/20",style:{borderTopColor:v}})}):w?e.jsx("div",{className:"bg-[#0d0b0a] min-h-screen",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 relative",children:[e.jsx(Bct,{listing:w,siteConfig:t}),e.jsx(Lme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${w.address}, ${w.city}`,path:`/listing/${w.mlsNumber}`}]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("button",{onClick:()=>r(-1),className:"flex items-center gap-2 text-white/40 hover:text-white text-sm transition-colors",children:[e.jsx(Qa,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:M,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-white/40 border border-white/10 hover:border-white/30 transition-colors",children:[e.jsx(nd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:_,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm border transition-colors ${f?"text-red-400 border-red-400/30":"text-white/40 border-white/10 hover:border-white/30"}`,children:[e.jsx(Ya,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(Vct,{photos:w.photos||[]}),e.jsxs("div",{className:p.isGated?"filter blur-sm pointer-events-none select-none":"",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 mt-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:L(w.price)}),e.jsxs("p",{className:"text-white/50 mt-1 flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),w.address,", ",w.city,", ",w.state," ",w.zip]})]}),e.jsx("span",{className:"px-3 py-1 text-xs tracking-wider uppercase shrink-0",style:{backgroundColor:`${v}20`,color:v},children:w.status})]}),e.jsxs("p",{className:"text-xs text-white/20",children:["MLS# ",w.mlsNumber]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-6 py-4 border-y border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mh,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.bedrooms}),e.jsx("span",{className:"text-white/40 text-sm",children:"beds"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(su,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.bathrooms}),e.jsx("span",{className:"text-white/40 text-sm",children:"baths"})]}),w.sqft>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ax,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.sqft.toLocaleString()}),e.jsx("span",{className:"text-white/40 text-sm",children:"sqft"})]}),w.yearBuilt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-white/20"}),e.jsx("span",{className:"font-semibold text-white",children:w.yearBuilt}),e.jsx("span",{className:"text-white/40 text-sm",children:"built"})]}),w.propertyType&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4 text-white/20"}),e.jsx("span",{className:"text-sm text-white/50",children:w.propertyType})]})]}),w.virtualTourUrl&&e.jsxs("a",{href:w.virtualTourUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 border border-white/15 text-sm text-white/60 hover:text-white hover:border-white/30 transition-colors",children:[e.jsx(en,{className:"h-4 w-4"})," Virtual Tour"]}),w.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-white mb-3 text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"About This Property"}),e.jsx("p",{className:"text-white/50 text-sm leading-relaxed whitespace-pre-line",children:w.description})]}),e.jsx(Hct,{listing:w}),w.latitude&&w.longitude&&Number.isFinite(w.latitude)&&Number.isFinite(w.longitude)&&e.jsx(Gct,{latitude:w.latitude,longitude:w.longitude,address:`${w.address}, ${w.city}`})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border border-white/10 p-6 sticky top-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[((P=t.agent)==null?void 0:P.avatar_url)&&e.jsx("img",{src:t.agent.avatar_url,alt:"",className:"w-12 h-12 object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(O=t.agent)==null?void 0:O.full_name}),e.jsx("p",{className:"text-xs text-white/30 tracking-wider uppercase",children:(($=t.agent)==null?void 0:$.title)||"Agent"})]})]}),n?e.jsxs("form",{onSubmit:S,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:U=>l(B=>({...B,name:U.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("input",{type:"email",required:!0,placeholder:"Email",value:o.email,onChange:U=>l(B=>({...B,email:U.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("input",{type:"tel",placeholder:"Phone",value:o.phone,onChange:U=>l(B=>({...B,phone:U.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20"}),e.jsx("textarea",{placeholder:"Message",value:o.message,onChange:U=>l(B=>({...B,message:U.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-2 text-sm focus:outline-none focus:border-white/40 placeholder-white/20 h-20 resize-none"}),e.jsx("button",{type:"submit",disabled:i,className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-black disabled:opacity-50 transition-all hover:opacity-90",style:{backgroundColor:v},children:i?"Sending...":"Send Message"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-black transition-all hover:opacity-90",style:{backgroundColor:v},children:"Ask About This Property"}),e.jsx("button",{onClick:()=>a(!0),className:"w-full py-3 text-xs tracking-[0.2em] uppercase text-white/60 border border-white/15 hover:bg-white hover:text-black transition-all duration-500",children:"Schedule a Showing"})]})]}),w.price>0&&e.jsx(Wct,{listPrice:w.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(Kct,{siteConfig:t,currentListing:w})})]}),e.jsx(FR,{open:p.showRegistration,mode:p.mode,siteConfig:t,onComplete:p.completeRegistration,onSkip:p.dismissRegistration})]})}):e.jsx("div",{className:"bg-[#0d0b0a] min-h-[60vh] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-xl text-white/70",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:k?"Error loading listing":"Listing not found"}),e.jsx("button",{onClick:()=>r("/search"),className:"mt-4 text-sm hover:text-white transition-colors",style:{color:v},children:"Back to search"})]})})}function iMs({siteConfig:t}){const s=nr(),r=t.agent;return e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.full_name,className:"w-32 h-32 rounded-2xl object-cover mx-auto mb-6 shadow-lg"}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:(r==null?void 0:r.full_name)||"About"}),e.jsx("p",{className:"text-lg text-gray-500",children:(r==null?void 0:r.title)||"Real Estate Professional"})]}),(r==null?void 0:r.bio)&&e.jsx("div",{className:"prose prose-gray max-w-none mb-12",children:e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:r.bio})}),e.jsxs("div",{className:"bg-blue-50 rounded-2xl p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 mb-2",children:"Ready to get started?"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Whether you're buying or selling, I'm here to help you every step of the way."}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsx("button",{onClick:()=>s("/contact"),className:"px-6 py-3 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-colors",children:"Contact Me"}),e.jsx("button",{onClick:()=>s("/search"),className:"px-6 py-3 border border-gray-300 text-gray-700 font-semibold rounded-lg hover:bg-white transition-colors",children:"Search Listings"})]})]})]})}function oMs({siteConfig:t}){const s=nr(),r=t.agent,n="#c9a96e";return e.jsxs("div",{className:"bg-[#0d0b0a] min-h-screen",children:[e.jsxs("section",{className:"relative h-[50vh] flex items-center justify-center overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[r!=null&&r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"",className:"w-full h-full object-cover opacity-30"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-[#1a1715] to-[#0d0b0a]"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[#0d0b0a]/60 via-transparent to-[#0d0b0a]"})]}),e.jsx("div",{className:"relative z-10 text-center px-6",children:e.jsxs(ps.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:n},children:"About"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}})]}),e.jsx("h1",{className:"text-4xl md:text-6xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:(r==null?void 0:r.full_name)||"About Me"}),e.jsx("p",{className:"text-white/40 mt-4 text-lg tracking-wider uppercase",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:(r==null?void 0:r.title)||"Real Estate Professional"})]})})]}),e.jsx("section",{className:"max-w-7xl mx-auto px-6 lg:px-8 py-20",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-start",children:[(r==null?void 0:r.avatar_url)&&e.jsx(ps.div,{initial:{opacity:0,x:-30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8},children:e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:r.avatar_url,alt:r.full_name,className:"w-full aspect-[3/4] object-cover"}),e.jsx("div",{className:"absolute -bottom-4 -right-4 w-full h-full border border-white/10 -z-10"})]})}),e.jsxs(ps.div,{initial:{opacity:0,x:30},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.8,delay:.2},children:[e.jsx("div",{className:"w-16 h-0.5 mb-8",style:{backgroundColor:n}}),e.jsx("h2",{className:"text-3xl md:text-4xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"My Story"}),r!=null&&r.bio?e.jsx("p",{className:"text-white/60 leading-relaxed text-lg whitespace-pre-line",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:r.bio}):e.jsx("p",{className:"text-white/60 leading-relaxed text-lg",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Dedicated to delivering an exceptional real estate experience with deep local market expertise and an unwavering commitment to client success."}),e.jsx("div",{className:"grid grid-cols-2 gap-6 mt-12",children:[{icon:dn,label:"Homes Sold",value:"500+"},{icon:un,label:"Years Experience",value:"15+"},{icon:hr,label:"Happy Clients",value:"1000+"},{icon:tc,label:"Awards",value:"25+"}].map((a,o)=>e.jsxs("div",{className:"border border-white/10 p-6 text-center",children:[e.jsx(a.icon,{className:"h-5 w-5 mx-auto mb-3",style:{color:n}}),e.jsx("p",{className:"text-2xl text-white font-light",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:a.value}),e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mt-2",children:a.label})]},o))}),e.jsxs("div",{className:"mt-12 space-y-4",children:[(r==null?void 0:r.phone)&&e.jsxs("a",{href:`tel:${r.phone}`,className:"flex items-center gap-3 text-white/40 hover:text-white transition-colors",children:[e.jsx(Mn,{className:"h-4 w-4",style:{color:n}}),e.jsx("span",{className:"text-sm tracking-wider",children:r.phone})]}),(r==null?void 0:r.email)&&e.jsxs("a",{href:`mailto:${r.email}`,className:"flex items-center gap-3 text-white/40 hover:text-white transition-colors",children:[e.jsx(lr,{className:"h-4 w-4",style:{color:n}}),e.jsx("span",{className:"text-sm tracking-wider",children:r.email})]})]})]})]})}),e.jsx("section",{className:"py-24 border-t border-white/5",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl text-white tracking-tight mb-6",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Ready to Get Started?"}),e.jsx("p",{className:"text-white/40 text-lg mb-10",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Whether you're buying or selling, I'm here to help you every step of the way."}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>s("/contact"),className:"px-10 py-4 text-xs tracking-[0.3em] uppercase text-black transition-all duration-500 hover:opacity-90",style:{backgroundColor:n},children:"Contact Me"}),e.jsx("button",{onClick:()=>s("/search"),className:"px-10 py-4 text-xs tracking-[0.3em] uppercase text-white/70 border border-white/20 hover:bg-white hover:text-black transition-all duration-500",children:"Browse Listings"})]})]})})]})}function lMs({siteConfig:t}){const[s,r]=N.useState({name:"",email:"",phone:"",message:""}),[n,a]=N.useState(!1),o=async i=>{i.preventDefault(),a(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:s.name,email:s.email,phone:s.phone||null,message:s.message,source_page:"/contact",lead_type:"contact"}),ZE(t.id,{name:s.name,email:s.email,phone:s.phone||null,message:s.message,lead_type:"contact",source_page:"/contact"}),me.success("Message sent! We'll be in touch soon."),r({name:"",email:"",phone:"",message:""})}catch{me.error("Something went wrong. Please try again.")}finally{a(!1)}},l=t.agent;return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Get In Touch"}),e.jsx("p",{className:"text-gray-500",children:"Have a question or ready to start your home search? Reach out!"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-12",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-8",children:[(l==null?void 0:l.avatar_url)&&e.jsx("img",{src:l.avatar_url,alt:"",className:"w-16 h-16 rounded-xl object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg text-gray-900",children:l==null?void 0:l.full_name}),e.jsx("p",{className:"text-gray-500",children:(l==null?void 0:l.title)||"Real Estate Agent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[(l==null?void 0:l.email)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center",children:e.jsx(lr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Email"}),e.jsx("a",{href:`mailto:${l.email}`,className:"text-gray-900 hover:text-blue-600",children:l.email})]})]}),(l==null?void 0:l.phone)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center",children:e.jsx(Mn,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Phone"}),e.jsx("a",{href:`tel:${l.phone}`,className:"text-gray-900 hover:text-blue-600",children:l.phone})]})]})]})]}),e.jsxs("form",{onSubmit:o,className:"bg-white border border-gray-200 rounded-xl p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:i=>r(c=>({...c,name:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email *"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:i=>r(c=>({...c,email:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:s.phone,onChange:i=>r(c=>({...c,phone:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Message *"}),e.jsx("textarea",{required:!0,value:s.message,onChange:i=>r(c=>({...c,message:i.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 h-28 resize-none",placeholder:"Tell me about what you're looking for..."})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:n?"Sending...":"Send Message"})]})]})]})}function cMs({siteConfig:t}){const[s,r]=N.useState({name:"",email:"",phone:"",message:""}),[n,a]=N.useState(!1),o=t.agent,l="#c9a96e",i=async c=>{c.preventDefault(),a(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:s.name,email:s.email,phone:s.phone||null,message:s.message,source_page:"/contact",lead_type:"contact"}),ZE(t.id,{name:s.name,email:s.email,phone:s.phone||null,message:s.message,lead_type:"contact",source_page:"/contact"}),me.success("Message sent! We'll be in touch soon."),r({name:"",email:"",phone:"",message:""})}catch{me.error("Something went wrong. Please try again.")}finally{a(!1)}};return e.jsxs("div",{className:"bg-[#0d0b0a] min-h-screen",children:[e.jsx("section",{className:"pt-32 pb-16 px-6 text-center",children:e.jsxs(ps.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},children:[e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:l}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:l},children:"Contact"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:l}})]}),e.jsx("h1",{className:"text-4xl md:text-6xl text-white tracking-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Get In Touch"}),e.jsx("p",{className:"text-white/40 mt-4 text-lg max-w-xl mx-auto",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Ready to start your real estate journey? Let's connect."})]})}),e.jsx("div",{className:"max-w-6xl mx-auto px-6 lg:px-8 pb-24",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16",children:[e.jsxs(ps.div,{initial:{opacity:0,x:-20},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6},children:[e.jsxs("div",{className:"flex items-center gap-5 mb-10",children:[(o==null?void 0:o.avatar_url)&&e.jsx("img",{src:o.avatar_url,alt:"",className:"w-20 h-20 object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-xl",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:o==null?void 0:o.full_name}),e.jsx("p",{className:"text-white/30 text-xs tracking-[0.2em] uppercase mt-1",children:(o==null?void 0:o.title)||"Real Estate Professional"})]})]}),e.jsxs("div",{className:"space-y-6",children:[(o==null?void 0:o.email)&&e.jsxs("a",{href:`mailto:${o.email}`,className:"flex items-center gap-4 group",children:[e.jsx("div",{className:"w-12 h-12 border border-white/10 flex items-center justify-center group-hover:border-white/30 transition-colors",children:e.jsx(lr,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mb-1",children:"Email"}),e.jsx("p",{className:"text-white/70 hover:text-white transition-colors",children:o.email})]})]}),(o==null?void 0:o.phone)&&e.jsxs("a",{href:`tel:${o.phone}`,className:"flex items-center gap-4 group",children:[e.jsx("div",{className:"w-12 h-12 border border-white/10 flex items-center justify-center group-hover:border-white/30 transition-colors",children:e.jsx(Mn,{className:"h-5 w-5",style:{color:l}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-white/30 tracking-[0.2em] uppercase mb-1",children:"Phone"}),e.jsx("p",{className:"text-white/70 hover:text-white transition-colors",children:o.phone})]})]})]}),e.jsxs("div",{className:"mt-16 border-l-2 pl-6",style:{borderColor:l},children:[e.jsx("p",{className:"text-white/40 text-lg leading-relaxed",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:'"Every client deserves a luxury experience — regardless of price point."'}),e.jsx("p",{className:"text-white/20 text-xs tracking-[0.2em] uppercase mt-4",children:o==null?void 0:o.full_name})]})]}),e.jsx(ps.div,{initial:{opacity:0,x:20},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.6,delay:.1},children:e.jsxs("form",{onSubmit:i,className:"border border-white/10 p-8 lg:p-10 space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Name *"}),e.jsx("input",{type:"text",required:!0,value:s.name,onChange:c=>r(u=>({...u,name:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"Your full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Email *"}),e.jsx("input",{type:"email",required:!0,value:s.email,onChange:c=>r(u=>({...u,email:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"your@email.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Phone"}),e.jsx("input",{type:"tel",value:s.phone,onChange:c=>r(u=>({...u,phone:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-white/30 tracking-[0.2em] uppercase mb-2",children:"Message *"}),e.jsx("textarea",{required:!0,value:s.message,onChange:c=>r(u=>({...u,message:c.target.value})),className:"w-full bg-transparent border-b border-white/15 text-white pb-3 text-sm focus:outline-none focus:border-white/40 transition-colors placeholder-white/15 h-32 resize-none",placeholder:"Tell me about your real estate needs..."})]}),e.jsx("button",{type:"submit",disabled:n,className:"w-full py-4 text-xs tracking-[0.3em] uppercase text-black disabled:opacity-50 transition-all duration-500 hover:opacity-90",style:{backgroundColor:l},children:n?"Sending...":"Send Message"})]})})]})})]})}function dMs({siteConfig:t}){const s=nr(),{user:r,profile:n,signOut:a}=F3(),[o,l]=N.useState("saved"),[i,c]=N.useState([]),[u,p]=N.useState([]),[f,g]=N.useState({name:"",phone:"",email:""}),[v,_]=N.useState(!1);N.useEffect(()=>{if(!r){s("/");return}w(),n&&g({name:n.name,phone:n.phone||"",email:n.email})},[r,n]);const w=async()=>{if(!r)return;const{data:M}=await H.from("lead_site_saved_listings").select("*").eq("user_id",r.id).eq("lead_site_id",t.id).order("saved_at",{ascending:!1});c(M||[]);const{data:L}=await H.from("lead_site_property_views").select("*").eq("auth_user_id",r.id).eq("lead_site_id",t.id).order("viewed_at",{ascending:!1}).limit(50),P=new Set,O=(L||[]).filter($=>P.has($.mls_number)?!1:(P.add($.mls_number),!0));p(O)},j=async M=>{await H.from("lead_site_saved_listings").delete().eq("user_id",r.id).eq("lead_site_id",t.id).eq("mls_number",M),c(L=>L.filter(P=>P.mls_number!==M)),me.success("Removed from saved")},k=async M=>{M.preventDefault(),_(!0);try{await H.from("lead_site_consumer_profiles").update({name:f.name,phone:f.phone||null}).eq("user_id",r.id).eq("lead_site_id",t.id),me.success("Profile updated")}catch{me.error("Failed to update profile")}finally{_(!1)}};if(!r)return null;const S=[{key:"saved",label:"Saved Listings",icon:Ya,count:i.length},{key:"viewed",label:"Recently Viewed",icon:un,count:u.length},{key:"profile",label:"My Profile",icon:Wi}];return e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"My Account"}),e.jsxs("p",{className:"text-gray-500 text-sm mt-1",children:["Welcome back, ",(n==null?void 0:n.name)||"there","!"]})]}),e.jsxs("button",{onClick:async()=>{await a(),s("/")},className:"flex items-center gap-2 text-sm text-gray-500 hover:text-gray-700 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors",children:[e.jsx(hS,{className:"h-4 w-4"})," Sign Out"]})]}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200 mb-6",children:S.map(M=>{const L=M.icon;return e.jsxs("button",{onClick:()=>l(M.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${o===M.key?"border-blue-600 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[e.jsx(L,{className:"h-4 w-4"}),M.label,"count"in M&&typeof M.count=="number"&&e.jsx("span",{className:"ml-1 text-xs bg-gray-100 text-gray-600 px-1.5 py-0.5 rounded-full",children:M.count})]},M.key)})}),o==="saved"&&e.jsx("div",{children:i.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(Ya,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No saved listings yet"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Browse properties and tap the heart to save them."}),e.jsx("button",{onClick:()=>s("/search"),className:"mt-4 px-5 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700",children:"Search Properties"})]}):e.jsx("div",{className:"space-y-3",children:i.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors",children:[e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center gap-3 flex-1 text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Saved ",new Date(M.saved_at).toLocaleDateString()]})]}),e.jsx(oa,{className:"h-4 w-4 text-gray-400 ml-auto"})]}),e.jsx("button",{onClick:()=>j(M.mls_number),className:"p-2 text-gray-400 hover:text-red-500 ml-2",children:e.jsx(Nr,{className:"h-4 w-4"})})]},M.mls_number))})}),o==="viewed"&&e.jsx("div",{children:u.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(un,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No recently viewed properties"}),e.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"Properties you view will appear here."})]}):e.jsx("div",{className:"space-y-3",children:u.map(M=>e.jsxs("button",{onClick:()=>s(`/listing/${M.mls_number}`),className:"flex items-center justify-between w-full p-4 bg-white border border-gray-200 rounded-xl hover:bg-gray-50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-gray-900",children:["MLS# ",M.mls_number]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Viewed ",new Date(M.viewed_at).toLocaleDateString()]})]}),e.jsx(oa,{className:"h-4 w-4 text-gray-400"})]},M.id))})}),o==="profile"&&e.jsx("div",{className:"max-w-md",children:e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Name"}),e.jsx("input",{type:"text",value:f.name,onChange:M=>g(L=>({...L,name:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),e.jsx("input",{type:"email",value:f.email,disabled:!0,className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm bg-gray-50 text-gray-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Email cannot be changed"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Phone"}),e.jsx("input",{type:"tel",value:f.phone,onChange:M=>g(L=>({...L,phone:M.target.value})),className:"w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This is also used as your password"})]}),e.jsx("button",{type:"submit",disabled:v,className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50",children:v?"Saving...":"Save Changes"})]})})]})}function x9e({siteConfig:t,isLuxury:s=!1}){var v;const r=s,n="#c9a96e",a=nr(),{slug:o}=lo(),[l,i]=N.useState("all"),{data:c,isLoading:u}=mt({queryKey:["public-blog-posts",t.id,l],queryFn:async()=>{let _=H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("published_at",{ascending:!1});l!=="all"&&(_=_.eq("post_type",l));const{data:w,error:j}=await _;if(j)throw j;return w},enabled:!o}),{data:p,isLoading:f}=mt({queryKey:["public-blog-post",t.id,o],queryFn:async()=>{const{data:_,error:w}=await H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("slug",o).eq("is_published",!0).maybeSingle();if(w)throw w;return _},enabled:!!o});if(o)return f?e.jsx("div",{className:`min-h-screen flex items-center justify-center ${r?"bg-[#0d0b0a]":""}`,children:e.jsx("div",{className:`h-6 w-6 animate-spin rounded-full border-2 border-t-transparent ${r?"border-white":"border-gray-900"}`})}):p?e.jsxs("div",{className:`min-h-screen ${r?"bg-[#0d0b0a]":"bg-white"}`,children:[e.jsx(QCs,{title:p.title,description:p.excerpt||p.title,publishedAt:p.published_at||p.created_at,imageUrl:p.cover_image_url,slug:p.slug,siteConfig:t}),e.jsx(Lme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Blog",path:"/blog"},{name:p.title,path:`/blog/${p.slug}`}]}),p.cover_image_url&&e.jsxs("div",{className:"h-72 md:h-96 w-full relative",children:[e.jsx("img",{src:p.cover_image_url,alt:p.title,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 to-transparent"})]}),e.jsxs("article",{className:"max-w-3xl mx-auto px-6 py-12",children:[e.jsxs("button",{onClick:()=>a("/blog"),className:`flex items-center gap-1.5 text-sm mb-6 transition-colors ${r?"text-white/40 hover:text-white":"text-gray-500 hover:text-gray-900"}`,children:[e.jsx(Qa,{className:"h-4 w-4"})," All Posts"]}),e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${p.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:p.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),p.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"})," ",p.neighborhood]})]}),e.jsx("h1",{className:`text-3xl md:text-4xl font-bold mb-4 ${r?"text-white":"text-gray-900"}`,style:r?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:p.title}),p.published_at&&e.jsx("p",{className:`text-sm mb-8 ${r?"text-white/30":"text-gray-400"}`,children:new Date(p.published_at).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),e.jsx("div",{className:`prose prose-lg max-w-none ${r?"prose-invert prose-headings:text-white prose-p:text-white/70 prose-a:text-[#c9a96e]":"prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600"}`,dangerouslySetInnerHTML:{__html:p.content}})]})]}):e.jsx("div",{className:`min-h-screen flex items-center justify-center ${r?"bg-[#0d0b0a]":"bg-gray-50"}`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:`text-2xl font-bold mb-2 ${r?"text-white":"text-gray-900"}`,children:"Post Not Found"}),e.jsx("button",{onClick:()=>a("/blog"),className:"text-blue-600 hover:underline",children:"← Back to blog"})]})});const g=((v=t.agent)==null?void 0:v.full_name)||"Your Agent";return e.jsxs("div",{className:`min-h-screen ${r?"bg-[#0d0b0a]":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-white py-20 px-6 ${r?"bg-[#0d0b0a] border-b border-white/5":"bg-gradient-to-br from-gray-900 to-gray-800"}`,children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[r&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:n},children:"Blog"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:n}})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",style:r?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Local Insights"}),e.jsxs("p",{className:`text-lg max-w-2xl mx-auto ${r?"text-white/40":"text-gray-300"}`,children:["Neighborhood guides, market insights, and local expertise from ",g,"."]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 -mt-6 mb-8",children:e.jsx("div",{className:`rounded-2xl shadow-lg p-2 flex gap-1 ${r?"bg-[#161312] border border-white/10":"bg-white"}`,children:[{value:"all",label:"All Posts"},{value:"blog_post",label:"Blog"},{value:"neighborhood_guide",label:"Neighborhoods"}].map(_=>e.jsx("button",{onClick:()=>i(_.value),className:`flex-1 py-2.5 px-4 rounded-xl text-sm font-medium transition-all ${l===_.value?r?"bg-white/10 text-white shadow-md":"bg-gray-900 text-white shadow-md":r?"text-white/40 hover:bg-white/5":"text-gray-600 hover:bg-gray-100"}`,children:_.label},_.value))})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 pb-20",children:u?e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent mx-auto"})}):c!=null&&c.length?e.jsx("div",{className:"grid gap-6",children:c.map((_,w)=>e.jsx(ps.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:w*.05},onClick:()=>a(`/blog/${_.slug}`),className:`rounded-2xl overflow-hidden transition-all cursor-pointer group border ${r?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-xl border-gray-100"}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[_.cover_image_url&&e.jsx("div",{className:"sm:w-64 h-48 sm:h-auto flex-shrink-0",children:e.jsx("img",{src:_.cover_image_url,alt:_.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsxs("div",{className:"flex-1 p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:`text-xs font-medium px-2.5 py-1 rounded-full ${_.post_type==="neighborhood_guide"?r?"bg-emerald-900/30 text-emerald-400":"bg-emerald-50 text-emerald-700":r?"bg-blue-900/30 text-blue-400":"bg-blue-50 text-blue-700"}`,children:_.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),_.neighborhood&&e.jsxs("span",{className:`text-xs flex items-center gap-1 ${r?"text-white/40":"text-gray-500"}`,children:[e.jsx(ia,{className:"h-3 w-3"})," ",_.neighborhood]})]}),e.jsx("h2",{className:`text-xl font-bold transition-colors mb-2 ${r?"text-white group-hover:text-[#c9a96e]":"text-gray-900 group-hover:text-blue-600"}`,children:_.title}),_.excerpt&&e.jsx("p",{className:`text-sm line-clamp-2 mb-3 ${r?"text-white/50":"text-gray-600"}`,children:_.excerpt}),_.published_at&&e.jsx("p",{className:`text-xs ${r?"text-white/30":"text-gray-400"}`,children:new Date(_.published_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})},_.id))}):e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"No posts yet. Check back soon!"})})})]})}function uMs({siteConfig:t,isLuxury:s=!1}){var i;const r=((i=t.agent)==null?void 0:i.full_name)||"Your Agent",n=s,a="#c9a96e",{data:o}=mt({queryKey:["public-lead-site-events",t.id],queryFn:async()=>{const{data:c,error:u}=await H.from("lead_site_events").select("*").eq("lead_site_id",t.id).eq("is_published",!0).gte("event_date",new Date().toISOString()).order("event_date",{ascending:!0});if(u)throw u;return c}}),{data:l}=mt({queryKey:["public-lead-site-businesses",t.id],queryFn:async()=>{const{data:c,error:u}=await H.from("lead_site_businesses").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0});if(u)throw u;return c}});return e.jsxs("div",{className:`min-h-screen ${n?"bg-[#0d0b0a]":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-white py-20 px-6 ${n?"bg-[#0d0b0a] border-b border-white/5":"bg-gradient-to-br from-gray-900 to-gray-800"}`,children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[n&&e.jsxs("div",{className:"flex items-center justify-center gap-4 mb-6",children:[e.jsx("div",{className:"h-px w-12",style:{backgroundColor:a}}),e.jsx("span",{className:"text-xs tracking-[0.5em] uppercase",style:{color:a},children:"Community"}),e.jsx("div",{className:"h-px w-12",style:{backgroundColor:a}})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",style:n?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Community"}),e.jsxs("p",{className:`text-lg max-w-2xl mx-auto ${n?"text-white/40":"text-gray-300"}`,children:["Local events, favorite spots, and everything that makes this area special — curated by ",r,"."]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-16 space-y-20",children:[o&&o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:`h-10 w-10 rounded-xl flex items-center justify-center ${n?"bg-white/5":"bg-blue-100"}`,children:e.jsx(hn,{className:`h-5 w-5 ${n?"text-[#c9a96e]":"text-blue-600"}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:`text-2xl font-bold ${n?"text-white":"text-gray-900"}`,children:"Upcoming Events"}),e.jsx("p",{className:`text-sm ${n?"text-white/40":"text-gray-500"}`,children:"What's happening in the community"})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:o.map((c,u)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:u*.05},className:`rounded-2xl overflow-hidden transition-all border group ${n?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-lg border-gray-100"}`,children:[c.image_url&&e.jsx("div",{className:"h-40 overflow-hidden",children:e.jsx("img",{src:c.image_url,alt:c.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsx("div",{className:"p-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:`flex-shrink-0 w-14 h-14 rounded-xl flex flex-col items-center justify-center ${n?"bg-white/5":"bg-blue-50"}`,children:[e.jsx("span",{className:`text-[10px] font-bold uppercase leading-none ${n?"text-[#c9a96e]":"text-blue-600"}`,children:ms(new Date(c.event_date),"MMM")}),e.jsx("span",{className:`text-xl font-bold leading-none mt-0.5 ${n?"text-[#c9a96e]":"text-blue-600"}`,children:ms(new Date(c.event_date),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:`font-bold text-lg mb-1 ${n?"text-white":"text-gray-900"}`,children:c.title}),c.description&&e.jsx("p",{className:`text-sm line-clamp-2 mb-2 ${n?"text-white/50":"text-gray-600"}`,children:c.description}),e.jsxs("div",{className:`flex flex-wrap items-center gap-3 text-xs ${n?"text-white/40":"text-gray-500"}`,children:[c.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-3 w-3"})," ",c.location]}),e.jsx("span",{children:ms(new Date(c.event_date),"h:mm a")})]}),c.external_url&&e.jsxs("a",{href:c.external_url,target:"_blank",rel:"noopener",className:`inline-flex items-center gap-1 text-xs mt-3 font-medium ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:["Learn More ",e.jsx(en,{className:"h-3 w-3"})]})]})]})})]},c.id))})]}),l&&l.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:`h-10 w-10 rounded-xl flex items-center justify-center ${n?"bg-white/5":"bg-amber-100"}`,children:e.jsx(KM,{className:`h-5 w-5 ${n?"text-[#c9a96e]":"text-amber-600"}`})}),e.jsxs("div",{children:[e.jsxs("h2",{className:`text-2xl font-bold ${n?"text-white":"text-gray-900"}`,children:[r,"'s Local Picks"]}),e.jsx("p",{className:`text-sm ${n?"text-white/40":"text-gray-500"}`,children:"Places I love and recommend in the area"})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:l.map((c,u)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:u*.05},className:`rounded-2xl overflow-hidden transition-all border group ${n?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white shadow-sm hover:shadow-lg border-gray-100"}`,children:[c.image_url?e.jsx("div",{className:"h-36 overflow-hidden",children:e.jsx("img",{src:c.image_url,alt:c.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}):e.jsx("div",{className:`h-24 flex items-center justify-center ${n?"bg-white/5":"bg-gradient-to-br from-amber-50 to-orange-50"}`,children:e.jsx(KM,{className:`h-8 w-8 ${n?"text-white/20":"text-amber-300"}`})}),e.jsxs("div",{className:"p-4",children:[c.category&&e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider mb-1 block ${n?"text-[#c9a96e]":"text-amber-600"}`,children:c.category}),e.jsx("h3",{className:`font-bold mb-1 ${n?"text-white":"text-gray-900"}`,children:c.name}),c.description&&e.jsx("p",{className:`text-sm line-clamp-2 mb-3 ${n?"text-white/50":"text-gray-600"}`,children:c.description}),e.jsx("div",{className:`flex flex-wrap items-center gap-3 text-xs ${n?"text-white/40":"text-gray-500"}`,children:c.address&&e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(ia,{className:"h-3 w-3 flex-shrink-0"})," ",c.address]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[c.phone&&e.jsxs("a",{href:`tel:${c.phone}`,className:`text-xs flex items-center gap-1 ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(Mn,{className:"h-3 w-3"})," Call"]}),c.website_url&&e.jsxs("a",{href:c.website_url,target:"_blank",rel:"noopener",className:`text-xs flex items-center gap-1 ${n?"text-[#c9a96e] hover:text-[#d4b87a]":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(ru,{className:"h-3 w-3"})," Website"]})]})]})]},c.id))})]}),(!o||o.length===0)&&(!l||l.length===0)&&e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:`text-lg ${n?"text-white/30":"text-gray-400"}`,children:"Community content coming soon!"})})]})]})}function hMs({siteConfig:t,themeConfig:s,isLuxury:r=!1}){var ee,Q,ce,ne;const n=nr(),[a]=uc(),o=((ee=t.agent)==null?void 0:ee.full_name)||"Your Agent",l=o.split(" ")[0],i=r?"#c9a96e":(s==null?void 0:s.accentColor)||((Q=t.themeConfig)==null?void 0:Q.accentColor)||"#3b82f6",c=r,[u,p]=N.useState({name:"",email:"",phone:"",address:"",timeline:"",message:""}),[f,g]=N.useState(!1),[v,_]=N.useState(!1),[w,j]=N.useState(null),[k,S]=N.useState(!0),[M,L]=N.useState("");N.useEffect(()=>{(async()=>{const oe=a.get("city");if(oe){L(oe);return}const{data:fe}=await H.from("lead_site_city_pages").select("city_name").eq("site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0}).limit(1);fe!=null&&fe[0]&&L(fe[0].city_name)})()},[t.id,a]),N.useEffect(()=>{if(!M){S(!1);return}(async()=>{S(!0);try{const{data:oe,error:fe}=await H.functions.invoke("lead-site-seller-stats",{body:{leadSiteId:t.id,city:M}});!fe&&oe&&j(oe)}catch(oe){console.warn("Failed to load seller stats:",oe)}finally{S(!1)}})()},[t.id,M]);const P=async re=>{re.preventDefault(),g(!0);try{await H.from("lead_site_leads").insert({lead_site_id:t.id,name:u.name,email:u.email,phone:u.phone||null,message:u.message||null,source_page:"/sell",lead_type:"seller",metadata:{address:u.address,timeline:u.timeline}}),ZE(t.id,{name:u.name,email:u.email,phone:u.phone||null,message:`Seller Lead — ${u.address||"Address not provided"} Timeline: ${u.timeline||"Not specified"} ${u.message||""}`,lead_type:"seller",source_page:"/sell"}),_(!0),me.success("Your request has been submitted!")}catch{me.error("Something went wrong. Please try again.")}finally{g(!1)}},O=re=>re>=1e6?`$${(re/1e6).toFixed(1)}M`:`$${Math.round(re/1e3)}K`,$=`https://${t.subdomainSlug}.thelocalmove.com`,U=`Sell Your Home | ${o}`,B=`Thinking of selling your home? Get a free market analysis from ${o}. See recent sales, market trends, and what your home could be worth.`,V=(w==null?void 0:w.marketCondition)==="seller"?"It's a Seller's Market":(w==null?void 0:w.marketCondition)==="buyer"?"It's a Buyer's Market":"The Market Is Balanced",X=(w==null?void 0:w.marketCondition)==="seller"?"Demand exceeds supply. Sellers have the advantage with faster sales and stronger offers.":(w==null?void 0:w.marketCondition)==="buyer"?"More inventory than buyers. Pricing strategy and presentation are critical.":"Supply and demand are relatively even. Well-priced homes sell quickly.",Y=[{step:"1",title:"Free Home Valuation",desc:"Get a data-driven market analysis of your home's current value."},{step:"2",title:"Strategic Pricing",desc:"Price your home to attract maximum interest and competitive offers."},{step:"3",title:"Professional Marketing",desc:"Professional photos, virtual tours, targeted digital marketing, and MLS exposure."},{step:"4",title:"Showings & Offers",desc:"Coordinate showings, review offers, and negotiate the best terms for you."},{step:"5",title:"Close & Celebrate",desc:"Navigate inspections, appraisals, and closing with expert guidance."}];return e.jsxs("div",{className:`min-h-screen ${c?"bg-[#0d0b0a]":"bg-white"}`,children:[e.jsxs($l,{children:[e.jsx("title",{children:U}),e.jsx("meta",{name:"description",content:B}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:B}),e.jsx("link",{rel:"canonical",href:`${$}/sell`})]}),e.jsx(zR,{siteConfig:t,pagePath:"/sell"}),e.jsxs("section",{className:`relative ${c?"bg-[#0d0b0a]":"bg-gray-950"} text-white overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 opacity-20",style:{background:`radial-gradient(ellipse at 30% 40%, ${i}44, transparent 60%), radial-gradient(ellipse at 70% 60%, ${i}22, transparent 50%)`}}),e.jsx("div",{className:"relative max-w-7xl mx-auto px-6 lg:px-8 py-24 md:py-32",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-16 items-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium mb-6",style:{backgroundColor:`${i}20`,color:i},children:[e.jsx(Jo,{className:"h-4 w-4"}),(w==null?void 0:w.marketCondition)==="seller"?"Seller's Market":"Free Home Valuation"]}),e.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight leading-[1.1] mb-6 ",style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:["What's Your Home ",e.jsx("span",{style:{color:i},children:"Really Worth?"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-gray-400 leading-relaxed mb-8 max-w-lg",children:["Get a complimentary, data-driven market analysis from ",l,". See what homes in your area are actually selling for — not just what they're listed at."]}),e.jsxs("div",{className:"flex flex-wrap gap-6 text-sm text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:i}})," No obligation"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:i}})," Real MLS data"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sa,{className:"h-4 w-4",style:{color:i}})," Expert guidance"]})]})]}),e.jsx("div",{className:`${c?"bg-[#161312] border border-white/10":"bg-white"} rounded-2xl p-8 shadow-2xl ${c?"text-white":"text-gray-900"}`,children:v?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${i}15`},children:e.jsx(sa,{className:"h-8 w-8",style:{color:i}})}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"You're All Set!"}),e.jsxs("p",{className:"text-gray-500 mb-6",children:[l," will review your information and send you a personalized market analysis within 24 hours."]}),e.jsxs("button",{onClick:()=>n("/search"),className:"text-sm font-medium flex items-center gap-1 mx-auto",style:{color:i},children:["Browse current listings ",e.jsx(Sa,{className:"h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:`text-xl font-bold mb-1 ${c?"text-white":""}`,children:"Get Your Free Home Valuation"}),e.jsxs("p",{className:`text-sm mb-6 ${c?"text-white/50":"text-gray-500"}`,children:[l," will send you a personalized market analysis."]}),e.jsx("form",{onSubmit:P,className:"space-y-3.5",children:(()=>{const re=`w-full px-4 py-3 border rounded-xl text-sm focus:outline-none focus:ring-2 focus:border-transparent ${c?"bg-white/5 border-white/10 text-white placeholder:text-white/30":"bg-gray-50 border-gray-200"}`,oe={"--tw-ring-color":i};return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your property address *",value:u.address,onChange:fe=>p(ge=>({...ge,address:fe.target.value})),className:re,style:oe}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Full name *",value:u.name,onChange:fe=>p(ge=>({...ge,name:fe.target.value})),className:re,style:oe}),e.jsx("input",{type:"tel",placeholder:"Phone",value:u.phone,onChange:fe=>p(ge=>({...ge,phone:fe.target.value})),className:re,style:oe})]}),e.jsx("input",{type:"email",required:!0,placeholder:"Email address *",value:u.email,onChange:fe=>p(ge=>({...ge,email:fe.target.value})),className:re,style:oe}),e.jsxs("select",{value:u.timeline,onChange:fe=>p(ge=>({...ge,timeline:fe.target.value})),className:`${re} ${c?"text-white/70":"text-gray-700"}`,style:oe,children:[e.jsx("option",{value:"",children:"When are you looking to sell?"}),e.jsx("option",{value:"asap",children:"As soon as possible"}),e.jsx("option",{value:"1-3months",children:"1–3 months"}),e.jsx("option",{value:"3-6months",children:"3–6 months"}),e.jsx("option",{value:"6-12months",children:"6–12 months"}),e.jsx("option",{value:"just-curious",children:"Just curious about my value"})]}),e.jsx("textarea",{placeholder:"Anything else you'd like us to know?",value:u.message,onChange:fe=>p(ge=>({...ge,message:fe.target.value})),className:`${re} h-20 resize-none`,style:oe}),e.jsx("button",{type:"submit",disabled:f,className:"w-full py-3.5 text-white font-semibold rounded-xl transition-all hover:opacity-90 disabled:opacity-50 text-sm",style:{backgroundColor:i},children:f?"Submitting...":"Get My Free Valuation"}),e.jsxs("p",{className:`text-[11px] text-center ${c?"text-white/30":"text-gray-400"}`,children:["By submitting, you agree to be contacted by ",l," about your property."]})]})})()})]})})]})})]}),w&&!k&&e.jsx("section",{className:`py-20 ${c?"bg-[#111] border-t border-white/5":"bg-gray-50"}`,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-semibold uppercase tracking-wider mb-4 ${c?"bg-green-900/30 text-green-400":"bg-green-100 text-green-700"}`,children:[e.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})," Live MLS Data"]}),e.jsxs("h2",{className:`text-3xl md:text-4xl font-bold tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:[M," Market Snapshot"]}),e.jsx("p",{className:`mt-3 max-w-2xl mx-auto ${c?"text-white/40":"text-gray-500"}`,children:"Real-time data from the MLS — see exactly what's happening in your market right now."})]}),e.jsxs("div",{className:`mb-10 rounded-2xl p-6 text-center ${c?"bg-white/5 border border-white/10":""}`,style:c?{}:{backgroundColor:w.marketCondition==="seller"?"#f0fdf4":w.marketCondition==="buyer"?"#fef2f2":"#eff6ff"},children:[e.jsx("h3",{className:"text-xl font-bold mb-1",style:{color:c?i:w.marketCondition==="seller"?"#15803d":w.marketCondition==="buyer"?"#b91c1c":"#1d4ed8"},children:V}),e.jsx("p",{className:`text-sm max-w-xl mx-auto ${c?"text-white/50":"text-gray-600"}`,children:X}),e.jsxs("p",{className:`text-xs mt-2 ${c?"text-white/30":"text-gray-400"}`,children:[w.monthsOfInventory," months of inventory · ",w.activeCount," active · ",w.soldCount," sold (6 mo)"]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6",children:[{icon:hl,label:"Median Sold Price",value:w.medianSoldPrice>0?O(w.medianSoldPrice):"—",color:"#10b981"},{icon:un,label:"Avg Days on Market",value:w.avgDaysOnMarket>0?`${w.avgDaysOnMarket} days`:"—",color:"#f59e0b"},{icon:yS,label:"Sale-to-List Ratio",value:w.listToSaleRatio>0?`${w.listToSaleRatio}%`:"—",color:"#8b5cf6"},{icon:yo,label:"Avg Price / Sq Ft",value:w.avgPricePerSqft>0?`$${w.avgPricePerSqft}`:"—",color:"#3b82f6"}].map(re=>e.jsxs("div",{className:`rounded-xl border p-5 text-center ${c?"bg-[#161312] border-white/10":"bg-white border-gray-100 shadow-sm"}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mx-auto mb-3",style:{backgroundColor:`${re.color}12`},children:e.jsx(re.icon,{className:"h-5 w-5",style:{color:re.color}})}),e.jsx("p",{className:`text-2xl md:text-3xl font-bold ${c?"text-white":"text-gray-900"}`,children:re.value}),e.jsx("p",{className:`text-xs mt-1 ${c?"text-white/40":"text-gray-500"}`,children:re.label})]},re.label))})]})}),(w==null?void 0:w.recentlySold)&&w.recentlySold.length>0&&e.jsx("section",{className:"py-20 ",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-12",children:[e.jsx("h2",{className:`text-3xl md:text-4xl font-bold tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"What Sellers Are Getting"}),e.jsxs("p",{className:`mt-3 ${c?"text-white/40":"text-gray-500"}`,children:["Recently sold homes in ",M," — real prices, real results."]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:w.recentlySold.map((re,oe)=>{var fe,ge,ue;return e.jsxs("div",{className:`rounded-xl border overflow-hidden transition-shadow ${c?"bg-[#161312] border-white/10 hover:border-white/20":"bg-white border-gray-100 shadow-sm hover:shadow-md"}`,children:[e.jsxs("div",{className:`aspect-[16/10] relative ${c?"bg-white/5":"bg-gray-100"}`,children:[(fe=re.photos)!=null&&fe[0]?e.jsx("img",{src:re.photos[0],alt:re.address,className:"w-full h-full object-cover"}):e.jsx("div",{className:`w-full h-full flex items-center justify-center ${c?"text-white/20":"text-gray-300"}`,children:e.jsx(dn,{className:"h-10 w-10"})}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 bg-red-600 text-white text-xs font-bold rounded-full",children:"SOLD"})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[e.jsxs("p",{className:`text-xl font-bold ${c?"text-white":"text-gray-900"}`,children:["$",(ge=re.soldPrice)==null?void 0:ge.toLocaleString()]}),re.listPrice>0&&re.soldPrice>0&&e.jsxs("span",{className:`text-xs font-semibold ${re.soldPrice>=re.listPrice?"text-green-600":"text-red-500"}`,children:[re.soldPrice>=re.listPrice?"+":"",((re.soldPrice-re.listPrice)/re.listPrice*100).toFixed(1),"%"]})]}),e.jsxs("p",{className:`text-sm mb-2 flex items-center gap-1 ${c?"text-white/50":"text-gray-600"}`,children:[e.jsx(ia,{className:`h-3.5 w-3.5 flex-shrink-0 ${c?"text-white/30":"text-gray-400"}`}),re.address,", ",re.city]}),e.jsxs("div",{className:`flex items-center gap-3 text-xs ${c?"text-white/40":"text-gray-500"}`,children:[e.jsxs("span",{children:[re.bedrooms," bed"]}),e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[re.bathrooms," bath"]}),e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[(ue=re.sqft)==null?void 0:ue.toLocaleString()," sqft"]}),re.daysOnMarket>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:c?"text-white/20":"text-gray-300",children:"•"}),e.jsxs("span",{children:[re.daysOnMarket," DOM"]})]})]})]})]},re.mlsNumber||oe)})})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 lg:px-8",children:[e.jsxs("div",{className:"text-center mb-14",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold tracking-tight",children:["How Selling With ",l," Works"]}),e.jsx("p",{className:"text-gray-400 mt-3 max-w-xl mx-auto",children:"A clear, proven process from listing to closing — no surprises."})]}),e.jsx("div",{className:"space-y-0",children:Y.map((re,oe)=>e.jsxs("div",{className:"relative flex gap-6 pb-10 last:pb-0",children:[oee.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${i}12`},children:e.jsx(re.icon,{className:"h-5 w-5",style:{color:i}})}),e.jsxs("div",{children:[e.jsx("h3",{className:`font-semibold mb-0.5 ${c?"text-white":"text-gray-900"}`,children:re.title}),e.jsx("p",{className:`text-sm leading-relaxed ${c?"text-white/50":"text-gray-500"}`,children:re.desc})]})]},re.title))})]}),e.jsx("div",{className:"flex justify-center",children:(ce=t.agent)!=null&&ce.avatar_url?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.agent.avatar_url,alt:o,className:"w-72 h-72 md:w-80 md:h-80 rounded-2xl object-cover shadow-xl"}),e.jsxs("div",{className:`absolute -bottom-4 -right-4 rounded-xl shadow-lg p-4 border ${c?"bg-[#161312] border-white/10":"bg-white border-gray-100"}`,children:[e.jsx("p",{className:`text-xs mb-0.5 ${c?"text-white/40":"text-gray-500"}`,children:"Your local expert"}),e.jsx("p",{className:`font-bold ${c?"text-white":"text-gray-900"}`,children:o}),e.jsx("p",{className:`text-xs ${c?"text-white/40":"text-gray-500"}`,children:((ne=t.agent)==null?void 0:ne.title)||"REALTOR®"})]})]}):e.jsx("div",{className:`w-72 h-72 rounded-2xl flex items-center justify-center ${c?"bg-white/5":"bg-gray-100"}`,children:e.jsx(dn,{className:`h-16 w-16 ${c?"text-white/20":"text-gray-300"}`})})})]})})}),e.jsx("section",{className:`py-20 ${c?"bg-[#111] border-t border-white/5":"bg-gray-50"}`,children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 lg:px-8",children:[e.jsx("h2",{className:`text-3xl font-bold text-center mb-10 tracking-tight ${c?"text-white":"text-gray-900"}`,style:c?{fontFamily:"'Playfair Display', Georgia, serif"}:{},children:"Frequently Asked Questions"}),e.jsx(mMs,{agentName:l,city:M,accentColor:i,isLuxury:c})]})}),e.jsx("section",{className:"py-20 bg-gray-950 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:"Ready to Find Out What Your Home Is Worth?"}),e.jsxs("p",{className:"text-gray-400 mb-8 text-lg",children:["Get your free, no-obligation market analysis from ",l," today."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsx("button",{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:i},children:"Get My Free Valuation"}),e.jsxs("button",{onClick:()=>n("/contact"),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:["Contact ",l]})]})]})})]})}function mMs({agentName:t,city:s,accentColor:r,isLuxury:n=!1}){const[a,o]=N.useState(null),l=s||"your area",i=n,c=[{q:`How do I know what my home is worth in ${l}?`,a:`${t} provides a complimentary Comparative Market Analysis (CMA) using current MLS data — recent sales, active listings, and market trends in ${l}. This gives you an accurate, data-driven estimate of your home's value.`},{q:"How long does it take to sell a home?",a:`The timeline varies based on market conditions, pricing, and property condition. In ${l}, well-priced homes typically sell within the average days-on-market for the area. ${t} will give you a realistic timeline based on current data.`},{q:"What should I do to prepare my home for sale?",a:`${t} will walk through your home and provide a personalized checklist — from decluttering and minor repairs to staging recommendations. The goal is to maximize your home's appeal without over-investing.`},{q:"How much does it cost to sell a home?",a:"Typical costs include agent commissions, closing costs (1-3% of sale price), and any agreed-upon repairs or concessions. Your net proceeds depend on your sale price, mortgage payoff, and these costs. We'll provide a detailed net sheet upfront."},{q:"Should I make repairs before listing?",a:`It depends on the repair and the market. ${t} will help you identify high-ROI improvements versus things that won't meaningfully impact your sale price. In a strong seller's market, fewer repairs may be needed.`},{q:`What's the best time of year to sell in ${l}?`,a:`While spring and summer tend to see more buyer activity, ${l}'s market has its own patterns. ${t} can show you seasonal trends from MLS data to help you choose the optimal listing window.`}],u={"@context":"https://schema.org","@type":"FAQPage",mainEntity:c.map(p=>({"@type":"Question",name:p.q,acceptedAnswer:{"@type":"Answer",text:p.a}}))};return e.jsxs(e.Fragment,{children:[e.jsx($l,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(u)})}),e.jsx("div",{className:"space-y-3",children:c.map((p,f)=>e.jsxs("div",{className:`rounded-xl border overflow-hidden ${i?"bg-[#161312] border-white/10":"bg-white border-gray-200"}`,children:[e.jsxs("button",{onClick:()=>o(a===f?null:f),className:"w-full flex items-center justify-between px-6 py-4 text-left",children:[e.jsx("span",{className:`font-medium text-sm pr-4 ${i?"text-white":"text-gray-900"}`,children:p.q}),e.jsx(oa,{className:`h-4 w-4 flex-shrink-0 transition-transform ${a===f?"rotate-90":""} ${i?"text-white/30":"text-gray-400"}`})]}),a===f&&e.jsx("div",{className:`px-6 pb-5 text-sm leading-relaxed border-t pt-4 ${i?"text-white/50 border-white/5":"text-gray-600 border-gray-100"}`,children:p.a})]},f))})]})}function pMs(t,s,r){return[{question:`What is the housing market like in ${t}, ${s}?`,answer:`The ${t} real estate market offers a diverse range of properties from single-family homes to condos. Contact ${r} for a personalized market analysis with the latest pricing trends, inventory levels, and neighborhood insights.`},{question:`What are the best neighborhoods in ${t}?`,answer:`${t} has many desirable neighborhoods, each with unique character, school districts, and amenities. ${r} can help you identify the best fit based on your lifestyle, commute, and budget. Explore the community guide for detailed neighborhood profiles.`},{question:`How much does a home cost in ${t}, ${s}?`,answer:`Home prices in ${t} vary by neighborhood, property type, and condition. Browse current listings to see real-time pricing, or reach out to ${r} for a free home valuation if you're considering selling.`},{question:`Is ${t} a good place to buy a home?`,answer:`${t} offers strong community amenities, quality schools, and a growing local economy that make it attractive for homebuyers. ${r} can walk you through market conditions and help you determine if now is the right time to buy.`},{question:`How do I find a real estate agent in ${t}?`,answer:`${r} is a local ${t} real estate expert specializing in buying, selling, and investment properties. With deep knowledge of the area's neighborhoods, pricing trends, and school districts, ${r} provides personalized guidance throughout your real estate journey.`},{question:`What are the property taxes in ${t}, ${s}?`,answer:`Property tax rates in ${t} vary by county and school district. ${r} can provide specific tax information for any property you're interested in, helping you understand the full cost of homeownership in the area.`}]}function fMs({city:t,state:s="",agentName:r,accentColor:n="#3b82f6"}){const a=pMs(t,s,r),[o,l]=N.useState(null);return e.jsxs("section",{className:"py-16 bg-gray-50",children:[e.jsx(YCs,{faqs:a}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase text-gray-400 mb-2 font-medium text-center",children:"Common Questions"}),e.jsxs("h2",{className:"text-3xl font-bold text-gray-900 tracking-tight text-center mb-10",children:["Frequently Asked Questions About ",t]}),e.jsx("div",{className:"space-y-3",children:a.map((i,c)=>{const u=o===c;return e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden transition-shadow hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>l(u?null:c),className:"w-full flex items-center justify-between px-6 py-5 text-left",children:[e.jsx("span",{className:"font-semibold text-gray-900 pr-4",children:i.question}),u?e.jsx(xf,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}):e.jsx(oo,{className:"h-5 w-5 text-gray-400 flex-shrink-0"})]}),u&&e.jsx("div",{className:"px-6 pb-5",children:e.jsx("p",{className:"text-gray-600 leading-relaxed",children:i.answer})})]},c)})})]})]})}function xMs({cityName:t,citySlug:s,agentName:r,total:n,medianPrice:a,avgDom:o,accentColor:l,heroImageUrl:i}){const c=nr();return e.jsxs("section",{className:"relative min-h-[480px] flex items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:`url(${i||"https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&q=80"})`}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/60 via-black/50 to-black/70"}),e.jsxs("div",{className:"relative z-10 max-w-4xl mx-auto px-6 py-20 text-center text-white",children:[e.jsxs("nav",{className:"flex items-center justify-center gap-2 text-sm text-white/60 mb-6",children:[e.jsx(pa,{to:"/",className:"hover:text-white transition-colors",children:"Home"}),e.jsx("span",{children:"›"}),e.jsx(pa,{to:"/search",className:"hover:text-white transition-colors",children:"Search"}),e.jsx("span",{children:"›"}),e.jsx("span",{className:"text-white",children:t})]}),e.jsxs(ps.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-4xl md:text-5xl lg:text-6xl font-bold mb-4 tracking-tight",children:["Homes for Sale in ",t]}),e.jsxs(ps.p,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.1},className:"text-lg text-white/80 max-w-2xl mx-auto mb-8",children:["Browse available properties in ",t," with ",r,", your local real estate expert."]}),e.jsxs(ps.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:.2},className:"flex flex-wrap items-center justify-center gap-4 mb-8",children:[n>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:n.toLocaleString()}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Active Listings"})]}),a&&a>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsxs("span",{className:"text-2xl font-bold",children:["$",(a/1e3).toFixed(0),"K"]}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Median Price"})]}),o&&o>0&&e.jsxs("div",{className:"px-5 py-2.5 bg-white/10 backdrop-blur-md rounded-full border border-white/20",children:[e.jsx("span",{className:"text-2xl font-bold",children:Math.round(o)}),e.jsx("span",{className:"text-sm text-white/70 ml-2",children:"Avg Days on Market"})]})]}),e.jsxs(ps.button,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},onClick:()=>c(`/search?q=${encodeURIComponent(t)}`),className:"inline-flex items-center gap-2 px-7 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:l},children:[e.jsx(sn,{className:"h-5 w-5"}),"Search All ",t," Listings"]})]})]})}function gMs({cityName:t,description:s,highlights:r,agentName:n,accentColor:a}){return!s&&r.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:a},children:"Discover the Area"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Why Live in ",t,"?"]})]}),s&&e.jsx(ps.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"max-w-3xl mx-auto mb-14",children:e.jsx("div",{className:"text-gray-600 leading-relaxed text-[17px] space-y-4",children:s.split(` `).map((o,l)=>e.jsx("p",{children:o},l))})}),r.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:r.map((o,l)=>e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:l*.06},className:"group bg-gray-50 hover:bg-white rounded-2xl p-6 border border-gray-100 hover:border-gray-200 hover:shadow-lg transition-all duration-300",children:[e.jsx("span",{className:"text-3xl mb-3 block",children:o.icon}),e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1.5",children:o.title}),e.jsx("p",{className:"text-gray-500 text-sm leading-relaxed",children:o.text})]},l))})]})})}function yMs({listings:t,cityName:s,accentColor:r}){const n=nr(),a=N.useRef(null),[o,l]=N.useState(!1),[i,c]=N.useState(!1),u=()=>{const f=a.current;f&&(l(f.scrollLeft>10),c(f.scrollLeft{const f=a.current;if(f)return u(),f.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),()=>{f.removeEventListener("scroll",u),window.removeEventListener("resize",u)}},[t]);const p=f=>{const g=a.current;g&&g.scrollBy({left:f==="left"?-680:680,behavior:"smooth"})};return t.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden bg-white",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6",children:[e.jsxs("div",{className:"flex items-end justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx(ps.p,{initial:{opacity:0,y:10},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-sm tracking-[0.2em] uppercase font-semibold mb-2",style:{color:r},children:"Featured Properties"}),e.jsxs(ps.h2,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.05},className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[s," Listings"]}),e.jsx(ps.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:"Currently available properties on the market"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>p("left"),disabled:!o,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(Xo,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>p("right"),disabled:!i,className:"p-3 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 hover:border-gray-300 transition-all disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(oa,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:a,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[t.map((f,g)=>{var v,_,w;return e.jsx(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:g*.05},onClick:()=>n(`/listing/${f.mlsNumber}`),className:"group min-w-[300px] sm:min-w-[320px] max-w-[340px] flex-shrink-0 snap-start cursor-pointer",children:e.jsxs("div",{className:"bg-white rounded-2xl overflow-hidden shadow-[0_2px_20px_-4px_rgba(0,0,0,0.08)] hover:shadow-[0_8px_40px_-8px_rgba(0,0,0,0.15)] transition-all duration-500 h-full flex flex-col",children:[e.jsxs("div",{className:"relative h-56 overflow-hidden",children:[e.jsx("img",{src:((v=f.photos)==null?void 0:v[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:`${f.address}, ${f.city}`,className:"w-full h-full object-cover group-hover:scale-[1.06] transition-transform duration-700 ease-out",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent"}),e.jsx("div",{className:"absolute top-3 left-3 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide uppercase text-white backdrop-blur-md",style:{backgroundColor:`${r}cc`},children:f.status||"Active"}),e.jsx("div",{className:"absolute bottom-3 left-3",children:e.jsxs("p",{className:"text-2xl font-bold text-white drop-shadow-lg",children:["$",(_=f.price)==null?void 0:_.toLocaleString()]})})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("p",{className:"text-gray-900 font-semibold text-[15px] leading-snug mb-1 truncate",children:f.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[f.city,", ",f.state," ",f.zip]}),e.jsxs("div",{className:"flex items-center gap-4 mt-auto pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Mh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(su,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:f.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(mS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(w=f.sqft)==null?void 0:w.toLocaleString()," sqft"]})]})]})]})]})},f.mlsNumber)}),e.jsx(ps.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>n(`/search?q=${encodeURIComponent(s)}`),className:"min-w-[200px] flex-shrink-0 snap-start cursor-pointer flex items-center justify-center",children:e.jsxs("div",{className:"text-center group",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-3 transition-transform group-hover:scale-110",style:{backgroundColor:`${r}15`},children:e.jsx(Sa,{className:"h-6 w-6",style:{color:r}})}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 group-hover:text-gray-900 transition-colors",children:"View All"})]})})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-12 bg-gradient-to-l from-white to-transparent pointer-events-none md:hidden"})]})]})}):null}function vMs({listings:t,cityName:s,accentColor:r}){const n=nr(),[a,o]=N.useState(null);return!t.some(i=>i.latitude&&i.longitude)&&t.length===0?null:e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs(ps.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-10",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:r},children:"Explore the Map"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:["Properties in ",s]}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Click any marker to view property details"})]}),e.jsx(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:.1},className:"rounded-2xl overflow-hidden border border-gray-200 shadow-sm",style:{height:"500px"},children:e.jsx(P3e,{listings:t,onListingClick:i=>n(`/listing/${i}`),hoveredMlsNumber:a})})]})})}function bMs({cityName:t,total:s,medianPrice:r,avgDom:n,pricePerSqft:a,accentColor:o}){if(s===0&&!r)return null;const l=[{icon:dn,label:"Active Listings",value:s>0?s.toLocaleString():"—",sublabel:"Currently on market"},{icon:hl,label:"Median Price",value:r?`$${(r/1e3).toFixed(0)}K`:"—",sublabel:"Active listings"},{icon:un,label:"Avg Days on Market",value:n?Math.round(n).toString():"—",sublabel:"Time to sell"},{icon:Jo,label:"Price per Sq Ft",value:a?`$${Math.round(a)}`:"—",sublabel:"Average $/sqft"}];return e.jsx("section",{className:"py-16 md:py-20 bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[e.jsxs(ps.div,{initial:{opacity:0,y:15},whileInView:{opacity:1,y:0},viewport:{once:!0},className:"text-center mb-12",children:[e.jsx("p",{className:"text-sm tracking-[0.25em] uppercase font-semibold mb-3",style:{color:o},children:"Market Snapshot"}),e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold text-gray-900 tracking-tight",children:[t," Real Estate at a Glance"]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-5",children:l.map((i,c)=>{const u=i.icon;return e.jsxs(ps.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:c*.08},className:"bg-white rounded-2xl p-6 border border-gray-100 shadow-sm text-center",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-4",style:{backgroundColor:`${o}15`},children:e.jsx(u,{className:"h-6 w-6",style:{color:o}})}),e.jsx("p",{className:"text-3xl font-bold text-gray-900 mb-1",children:i.value}),e.jsx("p",{className:"text-sm font-semibold text-gray-700 mb-0.5",children:i.label}),e.jsx("p",{className:"text-xs text-gray-400",children:i.sublabel})]},c)})})]})})}function _Ms({cityName:t,agentName:s,accentColor:r}){const n=nr();return e.jsx("section",{className:"py-20 bg-gray-900 text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 text-center",children:[e.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4 tracking-tight",children:["Ready to Find Your Home in ",t,"?"]}),e.jsxs("p",{className:"text-gray-400 mb-10 text-lg leading-relaxed",children:[s," knows ",t," inside and out. Get personalized guidance on the best neighborhoods, pricing, and available properties."]}),e.jsxs("div",{className:"flex flex-wrap gap-4 justify-center",children:[e.jsxs("button",{onClick:()=>n("/contact"),className:"px-8 py-3.5 text-white font-semibold rounded-xl transition-colors text-lg",style:{backgroundColor:r},children:["Contact ",s]}),e.jsx("button",{onClick:()=>n(`/search?q=${encodeURIComponent(t)}`),className:"px-8 py-3.5 border border-white/20 text-white hover:bg-white/10 font-semibold rounded-xl transition-colors text-lg",children:"Browse All Listings"})]})]})})}function wMs({siteConfig:t,citySlugOverride:s}){var M;const r=lo(),n=s||r.citySlug;nr();const[a,o]=N.useState([]),[l,i]=N.useState(!0),[c,u]=N.useState(0),[p,f]=N.useState(null),g=N.useMemo(()=>(n||"").split("-").map(L=>L.charAt(0).toUpperCase()+L.slice(1)).join(" "),[n]),v=((M=t.agent)==null?void 0:M.full_name)||"Your Agent",_=t.accentColor||"#3b82f6",w=`https://${t.subdomainSlug}.thelocalmove.com`,j=`Homes for Sale in ${g} | ${v}`,k=`Browse ${g} homes for sale with ${v}. View listings, pricing, photos, and neighborhood info. Your trusted local real estate expert.`;N.useEffect(()=>{n&&(async()=>{const{data:P}=await H.from("lead_site_city_pages").select("description, highlights, hero_image_url").eq("site_id",t.id).eq("city_slug",n||"").eq("is_published",!0).maybeSingle();P&&f({description:P.description,highlights:Array.isArray(P.highlights)?P.highlights:[],hero_image_url:P.hero_image_url})})()},[t.id,n]),N.useEffect(()=>{g&&(async()=>{i(!0);try{const O=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({leadSiteId:t.id,filterCities:[g],limit:1e3,page:1}),signal:AbortSignal.timeout(15e3)});if(O.ok){const $=await O.json();o($.listings||[]),u($.total||0)}}catch{}finally{i(!1)}})()},[g,t.id]);const S=N.useMemo(()=>{if(!a.length)return{medianPrice:null,avgDom:null,pricePerSqft:null};const L=a.map(V=>V.price).filter(V=>!!V&&V>0).sort((V,X)=>V-X),P=L.length>0?L[Math.floor(L.length/2)]:null,O=a.map(V=>V.dom||V.daysOnMarket).filter(V=>typeof V=="number"&&V>=0),$=O.length>0?O.reduce((V,X)=>V+X,0)/O.length:null,U=a.filter(V=>V.price&&V.sqft&&V.sqft>0),B=U.length>0?U.reduce((V,X)=>V+X.price/X.sqft,0)/U.length:null;return{medianPrice:P,avgDom:$,pricePerSqft:B}},[a]);return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(zR,{siteConfig:t,pagePath:`/homes-for-sale-in-${n}`}),e.jsx(Lme,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${g} Homes`,path:`/homes-for-sale-in-${n}`}]}),e.jsxs($l,{children:[e.jsx("title",{children:j}),e.jsx("meta",{name:"description",content:k}),e.jsx("link",{rel:"canonical",href:`${w}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:title",content:j}),e.jsx("meta",{property:"og:description",content:k}),e.jsx("meta",{property:"og:url",content:`${w}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:site_name",content:t.siteTitle||v}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{property:"og:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:j}),e.jsx("meta",{name:"twitter:description",content:k}),((p==null?void 0:p.hero_image_url)||t.ogImageUrl)&&e.jsx("meta",{name:"twitter:image",content:(p==null?void 0:p.hero_image_url)||t.ogImageUrl||""})]}),e.jsx(xMs,{cityName:g,citySlug:n||"",agentName:v,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,accentColor:_,heroImageUrl:(p==null?void 0:p.hero_image_url)||void 0}),e.jsx(gMs,{cityName:g,description:(p==null?void 0:p.description)||null,highlights:(p==null?void 0:p.highlights)||[],agentName:v,accentColor:_}),e.jsx(bMs,{cityName:g,total:c,medianPrice:S.medianPrice,avgDom:S.avgDom,pricePerSqft:S.pricePerSqft,accentColor:_}),!l&&e.jsx(yMs,{listings:a.slice(0,12),cityName:g,accentColor:_}),!l&&a.length>0&&e.jsx(vMs,{listings:a,cityName:g,accentColor:_}),e.jsx(fMs,{city:g,agentName:v,accentColor:_}),e.jsx(_Ms,{cityName:g,agentName:v,accentColor:_})]})}function jMs(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=KCs();if(r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-blue-600 border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Loading..."})]})});if(n||!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 p-6",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Site Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This lead site is not available or has not been set up yet."})]})});const a=(s==null?void 0:s.themeTier)==="luxury",o=(s==null?void 0:s.themeTier)==="land-ranch",l=o?c5s:a?o5s:a5s,i=o?e.jsx(O5s,{siteConfig:t,themeConfig:s??void 0}):a?e.jsx(v5s,{siteConfig:t,themeConfig:s??void 0}):e.jsx(u5s,{siteConfig:t,themeConfig:s??void 0});return e.jsx(ZCs,{siteConfig:t,children:e.jsx(l,{siteConfig:t,children:e.jsxs(Z2e,{children:[e.jsx(Ns,{path:"/",element:i}),e.jsx(Ns,{path:"/search",element:a?e.jsx(rMs,{siteConfig:t}):e.jsx(tMs,{siteConfig:t})}),e.jsx(Ns,{path:"/listing/:mlsNumber",element:a?e.jsx(aMs,{siteConfig:t}):e.jsx(nMs,{siteConfig:t})}),e.jsx(Ns,{path:"/about",element:a?e.jsx(oMs,{siteConfig:t}):e.jsx(iMs,{siteConfig:t})}),e.jsx(Ns,{path:"/contact",element:a?e.jsx(cMs,{siteConfig:t}):e.jsx(lMs,{siteConfig:t})}),e.jsx(Ns,{path:"/account",element:e.jsx(dMs,{siteConfig:t})}),e.jsx(Ns,{path:"/blog",element:e.jsx(x9e,{siteConfig:t,isLuxury:a})}),e.jsx(Ns,{path:"/blog/:slug",element:e.jsx(x9e,{siteConfig:t,isLuxury:a})}),e.jsx(Ns,{path:"/sell",element:e.jsx(hMs,{siteConfig:t,themeConfig:s??void 0,isLuxury:a})}),e.jsx(Ns,{path:"/community",element:e.jsx(uMs,{siteConfig:t,isLuxury:a})}),e.jsx(Ns,{path:"/*",element:e.jsx(NMs,{siteConfig:t})})]})})})}function NMs({siteConfig:t}){const r=dc().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(wMs,{siteConfig:t,citySlugOverride:r[1]}):null}const kMs=({team:t,onSelect:s})=>{const{data:r}=mt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await H.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await H.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Rt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(gr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(st,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(hr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(kn,{className:"h-6 w-6",children:[e.jsx(Ua,{src:r.leaderProfile.avatar_url||""}),e.jsx(Sn,{className:"text-xs",children:(r.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Dm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),r.leaderProfile.name||"Team Leader"]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Au,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize text-xs",children:t.contact_visibility.replace("_"," ")})]}),t.lead_pond_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(st,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},SMs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Os(),l=o||(a.length>0?a[0].id:n),i=s?void 0:l||void 0,{teams:c,isLoading:u,createTeam:p,updateTeam:f,deleteTeam:g,addMember:v,removeMember:_,updateMemberRole:w}=M3(i),[j,k]=N.useState(!1),[S,M]=N.useState(null),{data:L}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:U}=await H.from("brokerages").select("id, name").order("name");if(U)throw U;return $||[]},enabled:s}),{data:P}=mt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:U}=await H.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(U)throw U;return $||[]},enabled:!!l}),O=async $=>{const U=$.brokerage_id||l||null,B=await p.mutateAsync({name:$.name,brokerage_id:U,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await v.mutateAsync({team_id:B.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const V of $.memberIds)await v.mutateAsync({team_id:B.id,user_id:V,role:"team_member"});k(!1)};return!r&&!s?e.jsx(Ts,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(Ts,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ktt,{open:j,onOpenChange:k,onCreateTeam:O,isCreating:p.isPending,brokerageAgents:P||[],isAdmin:s,allBrokerages:L,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(vs,{className:"h-5 w-32 mb-3"}),e.jsx(vs,{className:"h-4 w-48 mb-4"}),e.jsx(vs,{className:"h-8 w-full"})]})},$))}),!u&&c.length===0&&!S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>k(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&c.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map($=>e.jsx(kMs,{team:$,onSelect:()=>M($)},$.id))}),S&&e.jsx(Ntt,{team:S,brokerageAgents:P||[],onBack:()=>M(null),onUpdate:$=>f.mutateAsync({id:S.id,...$}).then(U=>M(U)),onAddMember:($,U)=>v.mutateAsync({team_id:S.id,user_id:$,role:U}),onRemoveMember:$=>_.mutateAsync({team_id:S.id,member_id:$}),onUpdateRole:($,U)=>w.mutateAsync({team_id:S.id,member_id:$,role:U}),onDeleteTeam:()=>g.mutate(S.id),isUpdating:f.isPending,isAddingMember:v.isPending})]})})},CMs=()=>{const{data:t,isLoading:s}=Ux(),{useTeamMembers:r}=M3(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Ts,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(vs,{className:"h-8 w-48"}),e.jsx(vs,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Ts,{title:"My Team",description:"Your team",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(hr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(Ts,{title:"My Team",description:o.name,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),e.jsx(st,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),e.jsxs(_a,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(fa,{className:"flex-wrap",children:[e.jsx(ns,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(ns,{value:"contacts",children:[e.jsx(aS,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(ns,{value:"lead-pond",children:[e.jsx(Jg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(ns,{value:"shared-assets",children:[e.jsx(Om,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(ws,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(vs,{className:"h-16 w-full"},l))}):n.map(l=>{var i,c,u,p;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(kn,{className:"h-10 w-10",children:[e.jsx(Ua,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(Sn,{children:(((c=l.profile)==null?void 0:c.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:((u=l.profile)==null?void 0:u.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?e.jsxs(st,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Dm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(st,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(ws,{value:"contacts",className:"space-y-4",children:e.jsx(Kke,{})}),o.lead_pond_enabled&&e.jsx(ws,{value:"lead-pond",className:"space-y-4",children:e.jsx(Zke,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(ws,{value:"shared-assets",className:"space-y-4",children:e.jsx(jtt,{teamId:t.teamId})})]})]})})};function MMs(){const{user:t}=Os(),s=Xt(),r=mt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await H.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(k)throw k;return j},enabled:!!t}),n=mt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await H.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(k)throw k;return j},enabled:!!t}),a=mt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await H.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(k)throw k;return j},enabled:!!t}),o=mt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await H.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(k)throw k;return j},enabled:!!t}),l=mt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:k}=await H.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(k)throw k;return j},enabled:!!t}),i=Lt({mutationFn:async()=>{const{data:j,error:k}=await H.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(k)throw k;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:M}=await H.from("agent_booking_types").insert(S.map(O=>({...O,user_id:t.id})));if(M)throw M;const L=[1,2,3,4,5].map(O=>({user_id:t.id,day_of_week:O,start_time:"09:00",end_time:"17:00"})),{error:P}=await H.from("agent_availability_slots").insert(L);if(P)throw P;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:j=>me.error(j.message)}),c=Lt({mutationFn:async j=>{const{error:k}=await H.from("agent_booking_settings").update(j).eq("user_id",t.id);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:j=>me.error(j.message)}),u=Lt({mutationFn:async j=>{const k={...j,user_id:t.id};if(j.id){const{error:S}=await H.from("agent_booking_types").update(k).eq("id",j.id);if(S)throw S}else{const{error:S}=await H.from("agent_booking_types").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:j=>me.error(j.message)}),p=Lt({mutationFn:async j=>{const{error:k}=await H.from("agent_booking_types").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:j=>me.error(j.message)}),f=Lt({mutationFn:async j=>{const k={...j,user_id:t.id};if(j.id){const{error:S}=await H.from("agent_availability_slots").update(k).eq("id",j.id);if(S)throw S}else{const{error:S}=await H.from("agent_availability_slots").insert(k);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>me.error(j.message)}),g=Lt({mutationFn:async j=>{const{error:k}=await H.from("agent_availability_slots").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>me.error(j.message)}),v=Lt({mutationFn:async j=>{const{error:k}=await H.from("agent_blocked_dates").insert({...j,user_id:t.id});if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:j=>me.error(j.message)}),_=Lt({mutationFn:async j=>{const{error:k}=await H.from("agent_blocked_dates").delete().eq("id",j);if(k)throw k},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:j=>me.error(j.message)}),w=Lt({mutationFn:async({id:j,reason:k})=>{const{error:S}=await H.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:k}).eq("id",j);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:j=>me.error(j.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:c,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:g,addBlockedDate:v,removeBlockedDate:_,cancelBooking:w}}const g9e={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function TMs({types:t,onSave:s,onDelete:r}){const[n,a]=N.useState(null),[o,l]=N.useState(!1),i=()=>{a({name:"",description:"",duration_minutes:30,color:"#3B82F6",icon:"Calendar",is_active:!0,qualification_enabled:!1}),l(!0)},c=p=>{a({...p}),l(!0)},u=()=>{n!=null&&n.name&&(s(n),l(!1),a(null))};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Rt,{children:"Booking Types"}),e.jsx(gr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:g9e[p.icon]||"📅"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium",children:p.name}),!p.is_active&&e.jsx(st,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(st,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(CL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(p),children:e.jsx(za,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(p.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsxs(_s,{children:[n!=null&&n.id?"Edit":"New"," Booking Type"]})}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:n.name||"",onChange:p=>a({...n,name:p.target.value}),placeholder:"e.g. Listing Consultation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:n.description||"",onChange:p=>a({...n,description:p.target.value}),placeholder:"Brief description for prospects",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",min:15,max:180,step:15,value:n.duration_minutes||30,onChange:p=>a({...n,duration_minutes:parseInt(p.target.value)||30})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"h-10 w-10 rounded border cursor-pointer"}),e.jsx(ze,{value:n.color||"#3B82F6",onChange:p=>a({...n,color:p.target.value}),className:"flex-1"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(g9e).map(([p,f])=>e.jsx("button",{onClick:()=>a({...n,icon:p}),className:`w-10 h-10 rounded-lg text-lg flex items-center justify-center border transition-colors ${n.icon===p?"border-primary bg-primary/10":"hover:bg-muted"}`,children:f},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Meeting Link Override (optional)"}),e.jsx(ze,{value:n.meeting_link_override||"",onChange:p=>a({...n,meeting_link_override:p.target.value||null}),placeholder:"Use a different link for this type"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(qr,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{children:"Active"}),e.jsx(qr,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const y9e=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function AMs({slots:t,onSave:s,onDelete:r}){const[n,a]=N.useState(null),[o,l]=N.useState("09:00"),[i,c]=N.useState("17:00"),u=y9e.map((f,g)=>t.filter(v=>v.day_of_week===g)),p=()=>{n!==null&&(s({day_of_week:n,start_time:o,end_time:i,is_active:!0}),a(null),l("09:00"),c("17:00"))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(gr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:y9e.map((f,g)=>{const v=u[g];return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0",children:[e.jsx("div",{className:"w-24 pt-1",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[v.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):v.map(_=>{var w,j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=_.start_time)==null?void 0:w.slice(0,5),onBlur:k=>s({id:_.id,start_time:k.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=_.end_time)==null?void 0:j.slice(0,5),onBlur:k=>s({id:_.id,end_time:k.target.value})}),e.jsx(qr,{checked:_.is_active,onCheckedChange:k=>s({id:_.id,is_active:k})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(_.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},_.id)}),n===g?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:_=>l(_.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:_=>c(_.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(g),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const EMs={confirmed:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",cancelled:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400",completed:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",no_show:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};function PMs({bookings:t,onCancel:s}){const r=t.filter(o=>o.status==="confirmed"&&new Date(o.booking_date)>=new Date(new Date().toDateString())),n=t.filter(o=>o.status!=="confirmed"||new Date(o.booking_date){var i,c;return e.jsxs("div",{className:"flex items-start justify-between p-4 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(st,{className:`text-xs ${EMs[o.status]||""}`,children:o.status})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Od,{className:"h-3.5 w-3.5"}),ms(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(c=o.end_time)==null?void 0:c.slice(0,5)]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.guest_email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Mn,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(st,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx(jc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsx(Rt,{children:"Upcoming Bookings"}),e.jsxs(gr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function IMs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=N.useState(!1),[o,l]=N.useState(""),[i,c]=N.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),c(""))};return e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(hL,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(gr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(ze,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(ze,{placeholder:"Reason (optional)",value:i,onChange:p=>c(p.target.value),className:"flex-1"}),e.jsx(K,{size:"sm",onClick:u,children:"Add"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>a(!1),children:"Cancel"})]}),t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No blocked dates"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(p=>e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full border bg-muted/50 text-sm",children:[e.jsx("span",{children:ms(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Mr,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function LMs(){const{settings:t,bookingTypes:s,availability:r,blockedDates:n,bookings:a,isLoading:o,initializeSettings:l,updateSettings:i,upsertBookingType:c,deleteBookingType:u,upsertAvailability:p,deleteAvailability:f,addBlockedDate:g,removeBlockedDate:v,cancelBooking:_}=MMs(),[w,j]=N.useState(""),[k,S]=N.useState(15);w||t!=null&&t.meeting_link;const M=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Ts,{children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):t?e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(Od,{className:"h-6 w-6 text-primary"}),"LevelUp Scheduler"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your booking types, availability, and appointments"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(M),me.success("Booking link copied!")},children:[e.jsx(yi,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(qr,{id:"scheduler-active",checked:t.is_active,onCheckedChange:L=>i.mutate({is_active:L})})]})]})]}),e.jsxs(_a,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"types",children:"Booking Types"}),e.jsx(ns,{value:"availability",children:"Availability"}),e.jsx(ns,{value:"settings",children:"Settings"}),e.jsxs(ns,{value:"bookings",children:["Bookings",a.filter(L=>L.status==="confirmed").length>0&&e.jsx(st,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(L=>L.status==="confirmed").length})]})]}),e.jsx(ws,{value:"types",children:e.jsx(TMs,{types:s,onSave:L=>c.mutate(L),onDelete:L=>u.mutate(L)})}),e.jsx(ws,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(AMs,{slots:r,onSave:L=>p.mutate(L),onDelete:L=>f.mutate(L)}),e.jsx(IMs,{blockedDates:n,onAdd:L=>g.mutate(L),onRemove:L=>v.mutate(L)})]})}),e.jsx(ws,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(Pt,{children:[e.jsxs(Rt,{className:"flex items-center gap-2",children:[e.jsx(BL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(gr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{M&&(navigator.clipboard.writeText(M),me.success("Copied!"))},children:e.jsx(yi,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(be,{htmlFor:"meeting-link",children:[e.jsx(ml,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(ze,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:L=>i.mutate({meeting_link:L.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:L=>i.mutate({buffer_minutes:parseInt(L.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:L=>i.mutate({min_notice_hours:parseInt(L.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(be,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:L=>i.mutate({max_advance_days:parseInt(L.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(ws,{value:"bookings",children:e.jsx(PMs,{bookings:a,onCancel:L=>_.mutate({id:L})})})]})]})}):e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 md:p-8 space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center",children:e.jsx(Od,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(L=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:L.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:L.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.desc})]})]},L.title))}),e.jsx(al,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(fn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const v9e=[{id:"event_registration",label:"Event Registration",description:"Capture RSVPs for open houses, expos, seminars"},{id:"buyer_consultation",label:"Buyer Consultation",description:"Pre-qualify buyers with targeted questions"},{id:"home_valuation",label:"Home Valuation Request",description:`"What's your home worth?" lead capture`},{id:"lead_capture",label:"General Lead Capture",description:"Flexible form for any lead gen purpose"},{id:"lead_magnet",label:"Lead Magnet / Giveaway",description:"Offer a free download (PDF, guide, checklist) in exchange for contact info"},{id:"just_listed",label:"Just Listed",description:"Showcase a new listing with photos & details + contact CTA"},{id:"just_sold",label:"Just Sold",description:'Celebrate a sale & capture "Want results like this?" leads'}];function DMs(){const{user:t}=Os(),s=ri(),{toast:r}=Ha(),n=nr(),a=Xt(),[o,l]=N.useState(!1),[i,c]=N.useState(null),[u,p]=N.useState(null),[f,g]=N.useState({title:"",description:"",page_type:"lead_capture"}),{data:v=[],isLoading:_}=mt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:S,error:M}=await H.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(M)throw M;return S},enabled:!!s}),w=Lt({mutationFn:async()=>{const S=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:M}=await H.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),L=f.page_type==="just_listed"||f.page_type==="just_sold",{data:P,error:O}=await H.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:S,hero_headline:L?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(M==null?void 0:M.name)||null,agent_phone:(M==null?void 0:M.phone)||null,agent_email:(M==null?void 0:M.email)||t.email||null,agent_photo_url:(M==null?void 0:M.avatar_url)||null,property_status:L?f.page_type.replace("just_",""):null}).select().single();if(O)throw O;const $=OMs(f.page_type);if($.length>0){const{error:U}=await H.from("landing_page_fields").insert($.map((B,V)=>({...B,page_id:P.id,sort_order:V})));if(U)throw U}return P},onSuccess:S=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),g({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${S.id}`)},onError:S=>r({title:"Error",description:S.message,variant:"destructive"})}),j=Lt({mutationFn:async S=>{const{error:M}=await H.from("landing_pages").delete().eq("id",S);if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),c(null),r({title:"Landing page deleted"})}}),k=S=>`https://pages.relevelup.com/${S}`;return e.jsxs(Ts,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," New Page"]})]}),_?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):v.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(wn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:v.map(S=>{var M;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:S.title}),e.jsx(st,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(st,{variant:"outline",className:"text-[10px]",children:((M=v9e.find(L=>L.id===S.page_type))==null?void 0:M.label)||S.page_type})]}),S.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:S.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-3 w-3"})," ",S.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[S.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(k(S.slug)),children:e.jsx(p1,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(k(S.slug)),r({title:"Link copied!"})},children:e.jsx(yi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:k(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(en,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(ou,{children:[e.jsx(lu,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(fx,{className:"h-4 w-4"})})}),e.jsxs(Bd,{align:"end",children:[e.jsxs(Aa,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx(za,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Aa,{onClick:()=>c(S.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},S.id)})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(js,{children:e.jsx(_s,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Page Title"}),e.jsx(ze,{value:f.title,onChange:S=>g(M=>({...M,title:S.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description (optional)"}),e.jsx(Pr,{value:f.description,onChange:S=>g(M=>({...M,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Page Template"}),e.jsxs(Ks,{value:f.page_type,onValueChange:S=>g(M=>({...M,page_type:S})),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:v9e.map(S=>e.jsx(Mt,{value:S.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:S.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:S.description})]})},S.id))})]})]})]}),e.jsxs(Un,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>w.mutate(),disabled:!f.title.trim()||w.isPending,children:w.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(Mc,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(sc,{children:[e.jsxs(rc,{children:[e.jsx(ac,{children:"Delete Landing Page?"}),e.jsx(ic,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(nc,{children:[e.jsx(oc,{children:"Cancel"}),e.jsx(Fl,{onClick:()=>i&&j.mutate(i),children:"Delete"})]})]})}),e.jsx(xs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(RR,{value:u,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:u}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u&&(navigator.clipboard.writeText(u),r({title:"URL copied!"}))},children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function OMs(t){const s=[{field_type:"text",label:"Full Name",placeholder:"Your name",is_required:!0},{field_type:"email",label:"Email",placeholder:"your@email.com",is_required:!0},{field_type:"phone",label:"Phone",placeholder:"(555) 123-4567",is_required:!1}];switch(t){case"event_registration":return[...s,{field_type:"select",label:"How did you hear about this event?",options:JSON.stringify(["Social Media","Friend/Referral","Email","Flyer/Sign","Other"]),is_required:!1},{field_type:"textarea",label:"Any questions or special needs?",placeholder:"Let us know...",is_required:!1}];case"buyer_consultation":return[...s,{field_type:"select",label:"Interested in",options:JSON.stringify(["Buying","Selling","Both"]),is_required:!0},{field_type:"select",label:"Timeline",options:JSON.stringify(["0-3 months","3-6 months","6-12 months","Just exploring"]),is_required:!1},{field_type:"toggle",label:"Already working with a Realtor?",is_required:!1},{field_type:"toggle",label:"Do you have property to sell?",is_required:!1},{field_type:"textarea",label:"Anything else we should know?",placeholder:"Tell us about your situation...",is_required:!1}];case"home_valuation":return[...s,{field_type:"text",label:"Property Address",placeholder:"123 Main St, City, State",is_required:!0},{field_type:"select",label:"Reason for Valuation",options:JSON.stringify(["Thinking of selling","Refinancing","Curiosity","Estate planning","Other"]),is_required:!1},{field_type:"select",label:"Timeline to Sell",options:JSON.stringify(["ASAP","1-3 months","3-6 months","6+ months","Not sure"]),is_required:!1}];case"lead_magnet":return[...s,{field_type:"select",label:"Are you currently working with a Realtor?",options:JSON.stringify(["Yes","No","Not yet"]),is_required:!1}];case"just_listed":return[...s,{field_type:"select",label:"I am interested in",options:JSON.stringify(["Scheduling a showing","Getting more details","Similar properties","Selling my home"]),is_required:!0},{field_type:"textarea",label:"Message",placeholder:"Tell me more about this property...",is_required:!1}];case"just_sold":return[...s,{field_type:"select",label:"I am looking to",options:JSON.stringify(["Sell my home","Buy a home","Both","Just curious"]),is_required:!0},{field_type:"text",label:"My Property Address",placeholder:"123 Main St, City, State",is_required:!1}];default:return[...s,{field_type:"textarea",label:"Message",placeholder:"How can we help you?",is_required:!1}]}}const RMs=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"textarea",label:"Long Text"},{value:"select",label:"Dropdown"},{value:"multiselect",label:"Multi-Select"},{value:"toggle",label:"Yes / No Toggle"}];function FMs(){const{pageId:t}=lo(),s=nr(),{user:r}=Os(),n=ri(),{toast:a}=Ha(),o=Xt(),[l,i]=N.useState(null),[c,u]=N.useState(!1),{data:p,isLoading:f}=mt({queryKey:["landing-page",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_pages").select("*").eq("id",t).single();if(re)throw re;return ne},enabled:!!t}),{data:g=[],isLoading:v}=mt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(re)throw re;return ne},enabled:!!t}),{data:_=[]}=mt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:ne,error:re}=await H.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(re)throw re;return ne},enabled:!!t}),{data:w=[]}=mt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:ne,error:re}=await H.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(re)throw re;return ne},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[j,k]=N.useState({title:"",hero_headline:"",hero_subtext:"",hero_image_url:null,logo_url:null,primary_color:"#406E71",accent_color:"#2a4c64",agent_name:"",agent_phone:"",agent_email:"",agent_photo_url:null,success_message:"Thank you! We'll be in touch soon.",is_published:!1,description:"",lead_magnet_file_url:null,lead_magnet_file_name:null,lead_magnet_external_url:null,listing_id:null,property_address:"",property_price:"",property_beds:"",property_baths:"",property_sqft:"",property_description:"",property_photos:[],property_status:"just_listed"}),[S,M]=N.useState([]);N.useEffect(()=>{p&&k({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),N.useEffect(()=>{g.length>0&&M(g.map(ne=>({id:ne.id,field_type:ne.field_type,label:ne.label,placeholder:ne.placeholder,is_required:ne.is_required,options:typeof ne.options=="string"?ne.options:ne.options?JSON.stringify(ne.options):null,sort_order:ne.sort_order})))},[g]);const L=Lt({mutationFn:async()=>{const{error:ne}=await H.from("landing_pages").update({title:j.title,hero_headline:j.hero_headline,hero_subtext:j.hero_subtext||null,hero_image_url:j.hero_image_url,logo_url:j.logo_url,primary_color:j.primary_color,accent_color:j.accent_color,agent_name:j.agent_name||null,agent_phone:j.agent_phone||null,agent_email:j.agent_email||null,agent_photo_url:j.agent_photo_url,success_message:j.success_message,is_published:j.is_published,description:j.description||null,lead_magnet_file_url:j.lead_magnet_file_url,lead_magnet_file_name:j.lead_magnet_file_name,lead_magnet_external_url:j.lead_magnet_external_url,listing_id:j.listing_id,property_address:j.property_address||null,property_price:j.property_price||null,property_beds:j.property_beds||null,property_baths:j.property_baths||null,property_sqft:j.property_sqft||null,property_description:j.property_description||null,property_photos:j.property_photos,property_status:j.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(ne)throw ne;if(await H.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:re}=await H.from("landing_page_fields").insert(S.map((oe,fe)=>({page_id:t,field_type:oe.field_type,label:oe.label,placeholder:oe.placeholder||null,is_required:oe.is_required,options:oe.options?JSON.parse(oe.options):null,sort_order:fe})));if(re)throw re}},onSuccess:()=>{o.invalidateQueries({queryKey:["landing-page",t]}),o.invalidateQueries({queryKey:["landing-page-fields",t]}),a({title:"Page saved!"})},onError:ne=>a({title:"Error",description:ne.message,variant:"destructive"})}),P=async(ne,re)=>{const oe=ne.name.split(".").pop(),fe=`landing-pages/${r.id}/${re}-${Date.now()}.${oe}`,{error:ge}=await H.storage.from("recruit-landing").upload(fe,ne);if(ge)throw ge;const{data:{publicUrl:ue}}=H.storage.from("recruit-landing").getPublicUrl(fe);return ue},O=async(ne,re)=>{var fe;const oe=(fe=ne.target.files)==null?void 0:fe[0];if(oe){i(re);try{const ge=await P(oe,re);k(ue=>({...ue,[re]:ge})),a({title:"Image uploaded!"})}catch(ge){a({title:"Upload failed",description:ge.message,variant:"destructive"})}finally{i(null)}}},$=async ne=>{var oe;const re=(oe=ne.target.files)==null?void 0:oe[0];if(re){i("lead_magnet");try{const fe=await P(re,"lead-magnet");k(ge=>({...ge,lead_magnet_file_url:fe,lead_magnet_file_name:re.name})),a({title:"File uploaded!"})}catch(fe){a({title:"Upload failed",description:fe.message,variant:"destructive"})}finally{i(null)}}},U=async ne=>{const re=ne.target.files;if(!(!re||re.length===0)){i("property_photos");try{const oe=[];for(const fe of Array.from(re)){const ge=await P(fe,"property-photo");oe.push(ge)}k(fe=>({...fe,property_photos:[...fe.property_photos,...oe]})),a({title:`${oe.length} photo(s) uploaded!`})}catch(oe){a({title:"Upload failed",description:oe.message,variant:"destructive"})}finally{i(null)}}},B=async ne=>{const re=w.find(fe=>fe.id===ne);if(!re)return;const{data:oe}=await H.from("listing_photos").select("photo_url").eq("listing_id",ne).order("sort_order");k(fe=>({...fe,listing_id:ne,property_address:re.property_address||`${re.city}, ${re.state}`,property_price:re.price?`$${re.price.toLocaleString()}`:"",property_beds:re.bedrooms?String(re.bedrooms):"",property_baths:re.bathrooms?String(re.bathrooms):"",property_sqft:re.square_footage?re.square_footage.toLocaleString():"",property_description:re.description||"",property_photos:(oe==null?void 0:oe.map(ge=>ge.photo_url))||fe.property_photos})),a({title:"Listing data imported!"})},V=()=>{M(ne=>[...ne,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:ne.length}])},X=(ne,re)=>{M(oe=>oe.map((fe,ge)=>ge===ne?{...fe,...re}:fe))},Y=ne=>{M(re=>re.filter((oe,fe)=>fe!==ne))},ee=p?`https://pages.relevelup.com/${p.slug}`:"",Q=(p==null?void 0:p.page_type)==="lead_magnet",ce=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||v?e.jsx(Ts,{title:"Loading...",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):p?e.jsxs(Ts,{title:j.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(Qa,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:j.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(st,{variant:j.is_published?"default":"secondary",className:"text-[10px]",children:j.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Dn,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(hr,{className:"h-3 w-3"})," ",_.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(p1,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(ee),a({title:"Link copied!"})},children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1"})," Copy Link"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:ee,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(en,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>L.mutate(),disabled:L.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-2"}),L.isPending?"Saving...":"Save"]})]})]}),e.jsxs(_a,{defaultValue:"design",children:[e.jsxs(fa,{children:[e.jsx(ns,{value:"design",children:"Design"}),Q&&e.jsx(ns,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(ns,{value:"property",children:"Property Details"}),e.jsxs(ns,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(ns,{value:"submissions",children:["Submissions (",_.length,")"]}),e.jsx(ns,{value:"settings",children:"Settings"})]}),e.jsxs(ws,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Page Title (internal)"}),e.jsx(ze,{value:j.title,onChange:ne=>k(re=>({...re,title:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description (internal)"}),e.jsx(ze,{value:j.description,onChange:ne=>k(re=>({...re,description:ne.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Headline"}),e.jsx(ze,{value:j.hero_headline,onChange:ne=>k(re=>({...re,hero_headline:ne.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Subtext"}),e.jsx(Pr,{value:j.hero_subtext,onChange:ne=>k(re=>({...re,hero_subtext:ne.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.hero_image_url&&e.jsx("img",{src:j.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),l==="hero_image_url"?"Uploading...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>O(ne,"hero_image_url")})]}),j.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(ne=>({...ne,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.logo_url&&e.jsx("img",{src:j.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>O(ne,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.agent_photo_url&&e.jsx("img",{src:j.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),l==="agent_photo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>O(ne,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.primary_color,onChange:ne=>k(re=>({...re,primary_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:j.primary_color,onChange:ne=>k(re=>({...re,primary_color:ne.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.accent_color,onChange:ne=>k(re=>({...re,accent_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:j.accent_color,onChange:ne=>k(re=>({...re,accent_color:ne.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Name"}),e.jsx(ze,{value:j.agent_name,onChange:ne=>k(re=>({...re,agent_name:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Phone"}),e.jsx(ze,{value:j.agent_phone,onChange:ne=>k(re=>({...re,agent_phone:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Email"}),e.jsx(ze,{value:j.agent_email,onChange:ne=>k(re=>({...re,agent_email:ne.target.value}))})]})]})})]})]}),Q&&e.jsx(ws,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(be,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.lead_magnet_file_name&&e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(vi,{className:"h-3 w-3"})," ",j.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:$})]}),j.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(ne=>({...ne,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"flex-1 border-t"}),e.jsx("span",{children:"OR"}),e.jsx("div",{className:"flex-1 border-t"})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1",children:[e.jsx(ml,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(ze,{value:j.lead_magnet_external_url||"",onChange:ne=>k(re=>({...re,lead_magnet_external_url:ne.target.value||null})),placeholder:"https://drive.google.com/... or https://dropbox.com/...",className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link to a file on Google Drive, Dropbox, or any URL"})]})]})]})}),ce&&e.jsxs(ws,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(dn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(Ks,{value:j.listing_id||"",onValueChange:ne=>B(ne),children:[e.jsx(Gs,{children:e.jsx(Ys,{placeholder:"Select a listing to import..."})}),e.jsx(Ws,{children:w.map(ne=>{var re;return e.jsxs(Mt,{value:ne.id,children:[ne.property_address||`${ne.city}, ${ne.state}`," — $",(re=ne.price)==null?void 0:re.toLocaleString()]},ne.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Property Address"}),e.jsx(ze,{value:j.property_address,onChange:ne=>k(re=>({...re,property_address:ne.target.value})),placeholder:"123 Main St, City, State"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Price"}),e.jsx(ze,{value:j.property_price,onChange:ne=>k(re=>({...re,property_price:ne.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Beds"}),e.jsx(ze,{value:j.property_beds,onChange:ne=>k(re=>({...re,property_beds:ne.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Baths"}),e.jsx(ze,{value:j.property_baths,onChange:ne=>k(re=>({...re,property_baths:ne.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Sq Ft"}),e.jsx(ze,{value:j.property_sqft,onChange:ne=>k(re=>({...re,property_sqft:ne.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Description"}),e.jsx(Pr,{value:j.property_description,onChange:ne=>k(re=>({...re,property_description:ne.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[j.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:j.property_photos.map((ne,re)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ne,alt:`Property ${re+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k(oe=>({...oe,property_photos:oe.property_photos.filter((fe,ge)=>ge!==re)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},re))}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="property_photos",children:e.jsxs("span",{children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:U})]})]})]})]}),e.jsxs(ws,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:V,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:S.map((ne,re)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Mu,{className:"h-4 w-4 mt-2 text-muted-foreground cursor-grab"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Field Type"}),e.jsxs(Ks,{value:ne.field_type,onValueChange:oe=>X(re,{field_type:oe}),children:[e.jsx(Gs,{children:e.jsx(Ys,{})}),e.jsx(Ws,{children:RMs.map(oe=>e.jsx(Mt,{value:oe.value,children:oe.label},oe.value))})]})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Label"}),e.jsx(ze,{value:ne.label,onChange:oe=>X(re,{label:oe.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Placeholder"}),e.jsx(ze,{value:ne.placeholder||"",onChange:oe=>X(re,{placeholder:oe.target.value}),placeholder:"Optional hint text"})]})]}),(ne.field_type==="select"||ne.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(be,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(ze,{value:ne.options?(typeof ne.options=="string"?JSON.parse(ne.options):ne.options).join(", "):"",onChange:oe=>X(re,{options:JSON.stringify(oe.target.value.split(",").map(fe=>fe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{checked:ne.is_required,onCheckedChange:oe=>X(re,{is_required:oe})}),e.jsx(be,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Y(re),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},re))})]}),e.jsx(ws,{value:"submissions",className:"mt-4",children:_.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:_.map(ne=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:ne.contact_name||"Anonymous"}),ne.synced_to_crm&&e.jsx(st,{variant:"outline",className:"text-[10px]",children:"Synced"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mt-0.5",children:[ne.contact_email&&e.jsx("span",{className:"mr-3",children:ne.contact_email}),ne.contact_phone&&e.jsx("span",{children:ne.contact_phone})]}),ne.answers&&typeof ne.answers=="object"&&e.jsx("div",{className:"mt-2 text-sm space-y-1",children:Object.entries(ne.answers).map(([re,oe])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[re,":"]})," ",e.jsx("span",{children:String(oe)})]},re))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ne.created_at).toLocaleDateString()})]})})},ne.id))})}),e.jsxs(ws,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(qr,{checked:j.is_published,onCheckedChange:ne=>k(re=>({...re,is_published:ne}))})]}),j.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:ee})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsx(Rt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Pr,{value:j.success_message,onChange:ne=>k(re=>({...re,success_message:ne.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsx(js,{children:e.jsx(_s,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(RR,{value:ee,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:ee})]})]})})]}):e.jsx(Ts,{title:"Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Page not found"}),e.jsx(K,{variant:"link",onClick:()=>s("/mission-control/landing-pages"),children:"Go back"})]})})}function b9e({value:t}){return t>0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600 dark:text-emerald-400",children:[e.jsx(aL,{className:"h-3 w-3"}),t,"%"]}):t<0?e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-red-600 dark:text-red-400",children:[e.jsx(nL,{className:"h-3 w-3"}),Math.abs(t),"%"]}):e.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[e.jsx(y0,{className:"h-3 w-3"}),"0%"]})}const zMs={Phone:Mn,MessageSquare:so,Mail:lr,Gift:So,PenTool:Y_,Video:Cn},_9e=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function BMs(){const t=nr(),{contactsWithScores:s,stats:r}=Oue(),{data:n}=eR(365),{data:a}=BNe(),{data:o}=JO(),l=RNe(),i=N.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const M=new Date,L=zc(M),P=dx(M),O=zc(N4(M,1)),$=dx(N4(M,1)),U=n.filter(X=>Bg(new Date(X.completed_at),{start:L,end:P})).length,B=n.filter(X=>Bg(new Date(X.completed_at),{start:O,end:$})).length,V=B>0?Math.round((U-B)/B*100):U>0?100:0;return{touchesThisMonth:U,touchesLastMonth:B,touchTrend:V}},[n]),c=N.useMemo(()=>{if(!n)return 0;const M=new Date,L=zc(M),P=dx(M);return new Set(n.filter(O=>Bg(new Date(O.completed_at),{start:L,end:P})).map(O=>O.contact_id)).size},[n]),u=N.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const M=new Date,L=zc(M),P=dx(M),O=a.filter($=>$.close_date&&Bg(Rl($.close_date),{start:L,end:P}));return{closedThisMonth:O.length,totalGCI:O.reduce(($,U)=>$+(Number(U.commission_amount)||0),0)}},[a]),p=N.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const M=new Date,L=zc(M),P=zc(N4(M,1)),O=dx(N4(M,1)),$=s.filter(V=>new Date(V.created_at)>=L).length,U=s.filter(V=>Bg(new Date(V.created_at),{start:P,end:O})).length,B=U>0?Math.round(($-U)/U*100):$>0?100:0;return{newThisMonth:$,newLastMonth:U,trend:B}},[s]),f=N.useMemo(()=>{if(!n||!o)return[];const M=new Date,L=zc(M),P=dx(M),O=n.filter(B=>Bg(new Date(B.completed_at),{start:L,end:P})),$={};O.forEach(B=>{const V=B.action_type_id;$[V]=($[V]||0)+1});const U=O.length||1;return o.filter(B=>$[B.id]).map(B=>({id:B.id,name:B.name,icon:B.icon,count:$[B.id]||0,percent:Math.round(($[B.id]||0)/U*100)})).sort((B,V)=>V.count-B.count)},[n,o]),g=N.useMemo(()=>[...s].filter(M=>M.relationshipScore.status==="at-risk"||M.relationshipScore.status==="cooling").sort((M,L)=>{const P=M.relationshipScore.daysSinceTouch??9999;return(L.relationshipScore.daysSinceTouch??9999)-P}).slice(0,5),[s]),v=N.useMemo(()=>{if(!n)return[];const M=new Date,L=zc(M),P=dx(M),O=new Set(n.filter($=>Bg(new Date($.completed_at),{start:L,end:P})).map($=>$.contact_id));return s.filter($=>$.relationshipScore.status==="warm"&&O.has($.id)&&$.relationshipScore.touchCountLast12Months>=2).sort(($,U)=>U.relationshipScore.score-$.relationshipScore.score).slice(0,5)},[s,n]),_=N.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const M=new Set(n.map(V=>{const X=new Date(V.completed_at);return`${X.getFullYear()}-${X.getMonth()}-${X.getDate()}`})),L=new Date;L.setHours(0,0,0,0);let P=0,O=new Date(L);for(;M.has(`${O.getFullYear()}-${O.getMonth()}-${O.getDate()}`);)P++,O.setDate(O.getDate()-1);let $=0,U=0;if(Array.from(M).sort().length>0){const V=n.map(X=>{const Y=new Date(X.completed_at);return Y.setHours(0,0,0,0),Y.getTime()}).filter((X,Y,ee)=>ee.indexOf(X)===Y).sort((X,Y)=>X-Y);U=1;for(let X=1;X[...s].sort((M,L)=>M.relationshipScore.score-L.relationshipScore.score),[s]),j=w.filter(M=>M.relationshipScore.status==="warm"),k=w.filter(M=>M.relationshipScore.status==="cooling"),S=w.filter(M=>M.relationshipScore.status==="at-risk");return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Relationship Scorecard"}),e.jsxs("p",{className:"text-muted-foreground",children:[ms(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),_.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx(sh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:_.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Ya,{className:"h-4 w-4"}),"Avg Score"]}),e.jsx("div",{className:"text-3xl font-bold",children:r.averageScore}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"out of 100"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Ch,{className:"h-4 w-4"}),"Touches"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:i.touchesThisMonth}),e.jsx(b9e,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(hr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:c}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Jo,{className:"h-4 w-4"}),"New Contacts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-3xl font-bold",children:p.newThisMonth}),e.jsx(b9e,{value:p.trend})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"added this month"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(zm,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Bi,{value:l.progress,className:"h-3"}),l.progress>=100&&e.jsxs("p",{className:"text-xs text-emerald-600 dark:text-emerald-400 mt-2 flex items-center gap-1",children:[e.jsx(vo,{className:"h-3 w-3"}),"Goal reached! 🎉"]}),l.progress<100&&l.progress>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[l.weeklyGoal-l.actionsThisWeek," more to hit your goal"]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(sh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),_.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),_.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:_.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),_.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-2",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ch,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((M,L)=>{const P=zMs[M.icon||""]||Ch;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:M.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[M.count," (",M.percent,"%)"]})]}),e.jsx(Bi,{value:M.percent,className:It("h-1.5 bg-muted [&>div]:",_9e[L%_9e.length])})]},M.id)})})})]})]}),g.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(st,{variant:"secondary",children:[g.length," contacts"]})]}),e.jsx(gr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:g.map(M=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(P8,{score:M.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${M.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`tel:${M.phone}`)},children:e.jsx(Mn,{className:"h-4 w-4"})}),M.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:L=>{L.stopPropagation(),window.open(`mailto:${M.email}`)},children:e.jsx(lr,{className:"h-4 w-4"})}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})]})]},M.id))})})]}),v.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs(Rt,{className:"text-lg flex items-center gap-2",children:[e.jsx(tc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(gr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:v.map(M=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-full bg-emerald-500/10 border border-emerald-500/20 cursor-pointer hover:bg-emerald-500/20 transition-colors",onClick:()=>t(`/mission-control/contacts/${M.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[M.first_name," ",M.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:M.relationshipScore.score})]},M.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Bi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Bi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Bi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(bL,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Deals Closed This Month"}),e.jsx("p",{className:"text-2xl font-bold",children:u.closedThisMonth})]})]}),u.totalGCI>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"GCI This Month"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:["$",u.totalGCI.toLocaleString()]})]})]})})}),e.jsxs(_a,{defaultValue:"at-risk",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"at-risk",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),"At Risk (",r.atRisk,")"]}),e.jsxs(ns,{value:"cooling",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"}),"Cooling (",r.cooling,")"]}),e.jsxs(ns,{value:"warm",className:"gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),"Warm (",r.warm,")"]})]}),[{key:"at-risk",contacts:S},{key:"cooling",contacts:k},{key:"warm",contacts:j}].map(({key:M,contacts:L})=>e.jsx(ws,{value:M,children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:L.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(St,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(St,{children:"Score"}),e.jsx(St,{className:"w-10"})]})}),e.jsx(Bn,{children:L.slice(0,20).map(P=>e.jsxs(Cs,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${P.id}`),children:[e.jsxs(dt,{className:"font-medium",children:[P.first_name," ",P.last_name]}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:P.relationshipScore.daysSinceTouch===null?"Never":P.relationshipScore.daysSinceTouch===0?"Today":`${P.relationshipScore.daysSinceTouch}d ago`}),e.jsx(dt,{className:"hidden md:table-cell",children:P.relationshipScore.touchCountLast12Months}),e.jsx(dt,{children:e.jsx(P8,{score:P.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})})]},P.id))})]})})})},M))]})]})})}function Zct(){const{user:t}=Os(),s=Xt(),{data:r,isLoading:n}=mt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await H.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Lt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await H.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?me.error("That slug is already taken. Try another."):me.error("Failed to create page")}}),o=Lt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page");const{error:p}=await H.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Page updated!")},onError:()=>me.error("Failed to update page")}),{data:l=[],isLoading:i}=mt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await H.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),c=Lt({mutationFn:async u=>{if(!(r!=null&&r.id))throw new Error("No intake page. Create your Connect page first.");const{data:p,error:f}=await H.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:c}}function $Ms(){const{user:t}=Os();return mt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await H.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function qMs(t,s){if(!t)return null;const r=t.find(n=>n.contact_id===s);return(r==null?void 0:r.sent_at)||null}const HI=[{key:"email",label:"Missing Email",icon:lr,description:"No email — can't send drips or market updates",check:t=>!t.email,color:"text-red-500",fieldKey:"email",fieldType:"email",placeholder:"email@example.com"},{key:"phone",label:"Missing Phone",icon:Mn,description:"No phone number — can't call or text",check:t=>!t.phone,color:"text-orange-500",fieldKey:"phone",fieldType:"tel",placeholder:"(555) 123-4567"},{key:"address",label:"Missing Address",icon:ia,description:"No address — can't send postcards or popbys",check:t=>!t.address,color:"text-amber-500",fieldKey:"address",fieldType:"text",placeholder:"123 Main St, City, ST 12345"},{key:"birthday",label:"Missing Birthday",icon:Ah,description:"No birthday — missing a key personal touch",check:t=>!t.birthday,color:"text-purple-500",fieldKey:"birthday",fieldType:"date"},{key:"home_anniversary",label:"Missing Home Anniversary",icon:dn,description:"No home anniversary — missing annual outreach opportunity",check:t=>!t.home_anniversary,color:"text-blue-500",fieldKey:"home_anniversary",fieldType:"date"},{key:"tags",label:"No Tags",icon:Fm,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function tM(t){const s=[!!t.email,!!t.phone,!!t.address,!!t.birthday,!!t.home_anniversary,!!(t.tags&&t.tags.length>0)];return Math.round(s.filter(Boolean).length/s.length*100)}function UMs({contact:t,onClose:s}){const r=LNe(),[n,a]=N.useState({email:t.email||"",phone:t.phone||"",address:t.address||"",birthday:t.birthday||"",home_anniversary:t.home_anniversary||""}),o=async()=>{r.mutate({id:t.id,...n},{onSuccess:()=>s()})},l=HI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(lE,{open:!0,onOpenChange:()=>s(),children:e.jsxs(S3,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(cE,{children:[e.jsxs(dE,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(nYe,{children:["Fill in missing fields to improve this contact's completeness (",tM(t),"%)"]})]}),e.jsxs("div",{className:"space-y-5 mt-6",children:[l.length>0&&e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400 mb-1",children:"Missing Fields"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(i=>{const c=i.icon;return e.jsxs(st,{variant:"outline",className:"gap-1",children:[e.jsx(c,{className:"h-3 w-3"}),i.label.replace("Missing ","")]},i.key)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(lr,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(ze,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(c=>({...c,email:i.target.value})),className:It(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(c=>({...c,phone:i.target.value})),className:It(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(ia,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(ze,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(c=>({...c,address:i.target.value})),className:It(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(Ah,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(ze,{type:"date",value:n.birthday,onChange:i=>a(c=>({...c,birthday:i.target.value})),className:It(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(be,{className:"flex items-center gap-1.5",children:[e.jsx(dn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(ze,{type:"date",value:n.home_anniversary,onChange:i=>a(c=>({...c,home_anniversary:i.target.value})),className:It(!t.home_anniversary&&"border-amber-500/50")})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{className:"flex-1",onClick:o,disabled:r.isPending,children:[e.jsx(Uc,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Kye="Quick favor — can you update your info? 🙏",w9e=`Hi {{first_name}}, Hope you're doing well! I'm making sure I have the most up-to-date info for all my important contacts. Could you take 30 seconds to update your details? Just click the link below: {{update_link}} It's super quick — and it helps me make sure I'm reaching you at the right place with anything useful (market updates, birthday wishes, you name it 😊). Thanks so much!`;function VMs(){const t=nr(),{data:s,isLoading:r}=Wm(),{data:n}=Gx(),{intakePage:a}=Zct(),{isGmailConnected:o,gmailEmail:l}=Zx(),{data:i}=$Ms(),[c,u]=N.useState("blocked"),[p,f]=N.useState("all"),[g,v]=N.useState(null),[_,w]=N.useState(!1),[j,k]=N.useState(!1),[S,M]=N.useState(null),[L,P]=N.useState([]),[O,$]=N.useState(""),[U,B]=N.useState(""),V=N.useMemo(()=>s?p==="all"?s:s.filter(pe=>{var we;return(we=pe.tags)==null?void 0:we.some(Le=>Le.relationship_type_id===p)}):[],[s,p]),X=N.useMemo(()=>V.filter(pe=>!pe.email&&!pe.phone),[V]),Y=N.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const pe={};pe.blocked=X,HI.forEach(Te=>{pe[Te.key]=V.filter(Te.check)});const we=V.map(tM),Le=V.length>0?Math.round(we.reduce((Te,pt)=>Te+pt,0)/V.length):0,Qe=we.filter(Te=>Te===100).length;return{contactsByGap:pe,overallCompleteness:Le,fullyComplete:Qe}},[V,X]),ee=N.useMemo(()=>{if(!s||s.length===0)return null;const pe=zc(N4(new Date,1)),we=s.filter(pt=>new Date(pt.created_at)pt+ye,0)/we.length),Qe=Y.overallCompleteness,Te=Qe-Le;return{oldCompleteness:Le,currentCompleteness:Qe,diff:Te,oldCount:we.length}},[s,Y.overallCompleteness]),Q=V.length,ce=N.useCallback(()=>{var at;const pe=Y.contactsByGap[c];if(!(pe!=null&&pe.length))return;const we=c==="blocked"?"Outreach Blocked":((at=HI.find(tt=>tt.key===c))==null?void 0:at.label)||c,Le=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Qe=pe.map(tt=>[tt.first_name,tt.last_name||"",tt.email||"",tt.phone||"",tt.address||"",tt.birthday||"",tt.home_anniversary||"",tM(tt).toString()]),Te=[Le.join(","),...Qe.map(tt=>tt.map(Ae=>`"${Ae.replace(/"/g,'""')}"`).join(","))].join(` `),pt=new Blob([Te],{type:"text/csv"}),ye=URL.createObjectURL(pt),qe=document.createElement("a");qe.href=ye,qe.download=`sphere-gaps-${we.toLowerCase().replace(/\s+/g,"-")}-${ms(new Date,"yyyy-MM-dd")}.csv`,qe.click(),URL.revokeObjectURL(ye),jn({title:`Exported ${pe.length} contacts to CSV`})},[Y.contactsByGap,c]),ne=N.useCallback(async pe=>{if(!a)return null;try{const{data:we,error:Le}=await H.from("contact_intake_tokens").insert({contact_id:pe,intake_page_id:a.id}).select("token").single();if(Le)throw Le;return we.token}catch{return null}},[a]),re=N.useCallback(pe=>a?`https://contacts.relevelup.com/${a.slug}?t=${pe}`:"",[a]),oe=N.useCallback(async pe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const we=await ne(pe);we?(await navigator.clipboard.writeText(re(we)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,ne,re,t]),fe=N.useCallback(async pe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!pe.email){me.error("This contact has no email address");return}const we=await ne(pe.id);if(!we){me.error("Failed to generate link");return}const Le=re(we),Qe=w9e.replace("{{update_link}}",Le).replace(/\{\{first_name\}\}/g,pe.first_name).replace(/\{\{last_name\}\}/g,pe.last_name||""),Te=Kye.replace(/\{\{first_name\}\}/g,pe.first_name).replace(/\{\{last_name\}\}/g,pe.last_name||"");if(o)M({id:pe.id,first_name:pe.first_name,last_name:pe.last_name,email:pe.email}),P([]),$(Te),B(Qe),k(!0);else{const pt=encodeURIComponent(Kye.replace("{{first_name}}",pe.first_name)),ye=encodeURIComponent(Qe.replace(/\{\{first_name\}\}/g,pe.first_name));window.location.href=`mailto:${pe.email}?subject=${pt}&body=${ye}`}},[a,ne,re,o,t]),ge=N.useCallback(async pe=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const we=pe.filter(Te=>Te.email);if(!we.length){me.error("No contacts with email addresses in this group");return}const Le=new Set((i||[]).map(Te=>Te.contact_id)),Qe=we.filter(Te=>!Le.has(Te.id));if(Qe.length===0){me.info(`All ${we.length} contacts with email have already been sent this update request.`);return}if(Qe.lengthrt.id),intake_page_id:a.id}});if(pt)throw pt;const ye=typeof Te=="string"?JSON.parse(Te):Te,qe=Array.isArray(ye)?ye:Array.isArray(ye==null?void 0:ye.tokens)?ye.tokens:[],at=new Map(qe.filter(rt=>(rt==null?void 0:rt.contact_id)&&(rt==null?void 0:rt.token)).map(rt=>[rt.contact_id,rt.token]));if(at.size===0&&(await Promise.all(we.map(async He=>({contactId:He.id,token:await ne(He.id)})))).forEach(({contactId:He,token:ct})=>{ct&&at.set(He,ct)}),at.size===0){me.error("Failed to generate update links. Please try again.");return}const tt=Qe.filter(rt=>at.has(rt.id)).map(rt=>({id:rt.id,first_name:rt.first_name,last_name:rt.last_name,email:rt.email,updateLink:re(at.get(rt.id))})),Ae=w9e;M(null),P(tt),$(Kye),B(Ae),k(!0),me.success(`Ready to email ${tt.length} contacts`)}catch{me.error("Failed to generate links")}finally{w(!1)}},[a,o,re,ne,t]),xe=[{key:"blocked",label:"Outreach Blocked",icon:$v,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...HI].find(pe=>pe.key===c),_e=Y.contactsByGap[c]||[],$e=_e.filter(pe=>pe.email).length,Me=new Set((i||[]).map(pe=>pe.contact_id)),Ie=_e.filter(pe=>pe.email&&Me.has(pe.id)).length,ke=$e-Ie;return e.jsxs(Ts,{children:[e.jsxs("div",{className:"space-y-6 p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Sphere Gaps Analyzer"}),e.jsx("p",{className:"text-muted-foreground",children:"Find missing info in your database to maximize your outreach potential"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ey,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ks,{value:p,onValueChange:f,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Ys,{placeholder:"Filter by tag"})}),e.jsxs(Ws,{children:[e.jsx(Mt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(pe=>e.jsx(Mt,{value:pe.id,children:pe.name},pe.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[Y.overallCompleteness,"%"]}),ee&&ee.diff!==0&&p==="all"&&e.jsxs("div",{className:It("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",ee.diff>0?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:[ee.diff>0?"↑":"↓"," ",Math.abs(ee.diff),"% vs older contacts"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fully Complete"}),e.jsxs("p",{className:"text-2xl font-bold text-emerald-600 dark:text-emerald-400",children:[Y.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Q]})]})]})]}),e.jsx(Bi,{value:Y.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Y.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":Y.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),X.length>0&&e.jsx(Ee,{className:It("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",c==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx($v,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:X.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:HI.map(pe=>{var pt;const we=((pt=Y.contactsByGap[pe.key])==null?void 0:pt.length)||0,Le=Q>0?Math.round(we/Q*100):0,Qe=pe.icon,Te=c===pe.key;return e.jsx(Ee,{className:It("cursor-pointer transition-all hover:shadow-md",Te&&"ring-2 ring-primary"),onClick:()=>u(pe.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Qe,{className:It("h-5 w-5",pe.color)}),e.jsx("span",{className:"text-sm font-medium",children:pe.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:we}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Le,"% of contacts"]})]}),e.jsx(Bi,{value:100-Le,className:"mt-2 h-1.5"})]})},pe.key)})}),e.jsxs(Ee,{children:[e.jsxs(Pt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Rt,{className:"text-lg",children:[(xe==null?void 0:xe.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(st,{variant:"secondary",children:[_e.length," contacts"]}),Ie>0&&e.jsxs(st,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(sa,{className:"h-3 w-3"}),Ie," already emailed"]}),_e.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-1.5",children:[e.jsx(vi,{className:"h-3.5 w-3.5"}),"Export"]}),ke>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>ge(_e),disabled:_,className:"gap-1.5",children:[_?e.jsx(bs,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx($n,{className:"h-3.5 w-3.5"}),"Email ",ke," Update Links"]})]})]})]}),e.jsx(gr,{children:xe==null?void 0:xe.description})]}),e.jsx(Oe,{className:"p-0",children:_e.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(sa,{className:"h-10 w-10 text-emerald-500 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:c==="blocked"?"All contacts have at least an email or phone!":"All contacts have this field filled in!"})]}):e.jsxs(Fn,{children:[e.jsx(zn,{children:e.jsxs(Cs,{children:[e.jsx(St,{children:"Contact"}),e.jsx(St,{className:"hidden md:table-cell",children:"Email"}),e.jsx(St,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(St,{children:"Completeness"}),e.jsx(St,{className:"w-28",children:"Actions"})]})}),e.jsx(Bn,{children:_e.map(pe=>{const we=qMs(i,pe.id);return e.jsxs(Cs,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"cursor-pointer hover:underline",onClick:()=>t(`/mission-control/contacts/${pe.id}`),children:[pe.first_name," ",pe.last_name]}),!pe.email&&!pe.phone&&c!=="blocked"&&e.jsx(st,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),we&&e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsxs(st,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(lr,{className:"h-2.5 w-2.5"}),Vc(new Date(we),{addSuffix:!0})]})}),e.jsxs(ec,{children:["Last bulk emailed ",ms(new Date(we),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:pe.email||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:pe.phone||e.jsx("span",{className:"text-red-400 italic text-xs",children:"Missing"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bi,{value:tM(pe),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[tM(pe),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>v(pe),children:e.jsx(Uv,{className:"h-3.5 w-3.5"})})}),e.jsx(ec,{children:"Quick edit"})]}),(pe.email||pe.phone)&&a&&e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>oe(pe.id),children:e.jsx(yi,{className:"h-3.5 w-3.5"})})}),e.jsx(ec,{children:"Copy update link"})]}),pe.email&&a&&e.jsxs(Nc,{children:[e.jsx(kc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>fe(pe),children:e.jsx(lr,{className:"h-3.5 w-3.5"})})}),e.jsx(ec,{children:"Email update link"})]})]})})]},pe.id)})})]})})]})]}),g&&e.jsx(UMs,{contact:g,onClose:()=>v(null)}),e.jsx(Kw,{open:j,onOpenChange:k,contact:S||void 0,bulkContacts:L.length>0?L:void 0,defaultSubject:O,defaultBody:U,gmailEmail:l})]})}function HMs(){const{user:t}=Os(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Zct(),[i,c]=N.useState(""),[u,p]=N.useState(""),[f,g]=N.useState(!1);N.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),N.useEffect(()=>{if(t!=null&&t.email&&!s){const M=t.email.split("@")[0];c(M.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const v=s?`https://contacts.relevelup.com/${s.slug}`:"",_=()=>{navigator.clipboard.writeText(v),me.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(ml,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(be,{children:"Your Connect Page URL"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"contacts.relevelup.com/"}),e.jsx(ze,{value:i,onChange:M=>c(M.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"jane-smith",className:"max-w-[200px]"})]})]}),e.jsxs(K,{onClick:()=>n.mutate(i),disabled:!i.trim()||n.isPending,children:[n.isPending?e.jsx(bs,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const w=o.filter(M=>!M.is_processed),j=o.filter(M=>M.is_processed),k=w.length,S=(M,L)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[M.first_name," ",M.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[M.email&&e.jsx("span",{children:M.email}),M.phone&&e.jsx("span",{children:M.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M.real_estate_interest&&M.real_estate_interest!=="not_now"&&e.jsx(st,{variant:"outline",className:"text-xs",children:M.real_estate_interest==="buying"?"🏠 Buying":M.real_estate_interest==="selling"?"📋 Selling":M.real_estate_interest==="both"?"🔄 Both":M.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(un,{className:"h-3 w-3"}),ms(new Date(M.created_at),"MMM d")]}),L&&e.jsx(sa,{className:"h-4 w-4 text-emerald-500"})]})]},M.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(ml,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Rt,{children:"Connect Page"}),e.jsx(gr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(qr,{id:"active-toggle",checked:s.is_active,onCheckedChange:M=>a.mutate({is_active:M})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:v}),e.jsxs(K,{size:"sm",variant:"outline",onClick:_,children:[e.jsx(yi,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:v,target:"_blank",rel:"noopener noreferrer",children:e.jsx(en,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(be,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:M=>p(M.target.value),rows:3,className:"w-full px-3 py-2 text-sm border rounded-md bg-background"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:()=>{a.mutate({welcome_message:u}),g(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>g(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(hr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"New Submissions"}),k>0&&e.jsxs(gr,{children:[k," awaiting sync"]})]})]}),k>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:M,error:L}=await H.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(L)throw L;me.success(`Synced ${M.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",k," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(bs,{className:"h-5 w-5 animate-spin text-muted-foreground"}):w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:w.map(M=>S(M,!1))})})]}),j.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(sa,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Rt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(gr,{children:[j.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[j.slice(0,10).map(M=>S(M,!0)),j.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",j.length-10," more synced contacts"]})]})})]})]})}function GMs(){return e.jsx(Ts,{children:e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Connect Page"}),e.jsx(HMs,{})]})})}const WMs={property_view:{label:"Viewed Listing",icon:Dn,badgeClass:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-700"},new_lead:{label:"New Lead",icon:El,badgeClass:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-200 dark:border-emerald-700"},saved_listing:{label:"Saved Listing",icon:Ya,badgeClass:"bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-700"}},KMs={home:"🏠",search:"🔍",listing:"🏡",city:"🌆",sell:"💰",blog:"📝",dashboard:"📊",other:"📄"};function ZMs({locations:t}){const s=N.useRef(null),r=N.useRef(null),[n,a]=N.useState(null);return N.useEffect(()=>{H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle().then(({data:o})=>{o!=null&&o.value&&a(o.value)})},[]),N.useEffect(()=>{if(!(!s.current||!n||r.current))return Eo.accessToken=n,r.current=new Eo.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:3.5,center:[-98.5795,39.8283],interactive:!0}),r.current.addControl(new Eo.NavigationControl,"top-right"),()=>{var o;(o=r.current)==null||o.remove(),r.current=null}},[n]),N.useEffect(()=>{if(!r.current||!n||t.length===0)return;const o=()=>{if(t.forEach(l=>{if(!Number.isFinite(l.lat)||!Number.isFinite(l.lng))return;const i=Math.min(40,Math.max(16,12+l.visitor_count*3)),c=document.createElement("div");c.style.cssText=` width: ${i}px; height: ${i}px; border-radius: 50%; background: radial-gradient(circle, rgba(64,110,113,0.9), rgba(64,110,113,0.4)); border: 2px solid rgba(64,110,113,0.8); display: flex; align-items: center; justify-content: center; font-size: ${Math.max(9,i*.35)}px; font-weight: 700; color: white; cursor: pointer; transition: transform 0.2s; `,c.textContent=String(l.visitor_count),c.addEventListener("mouseenter",()=>{c.style.transform="scale(1.3)"}),c.addEventListener("mouseleave",()=>{c.style.transform="scale(1)"});const u=document.createElement("div");u.appendChild(c),new Eo.Marker({element:u,anchor:"center"}).setLngLat([l.lng,l.lat]).setPopup(new Eo.Popup({offset:15}).setHTML(`
${l.city}, ${l.region}
${l.visitor_count} visitor${l.visitor_count>1?"s":""}
`)).addTo(r.current)}),t.length>1){const l=new Eo.LngLatBounds;t.forEach(i=>{Number.isFinite(i.lat)&&Number.isFinite(i.lng)&&l.extend([i.lng,i.lat])}),l.isEmpty()||r.current.fitBounds(l,{padding:60,maxZoom:10})}else t.length===1&&r.current.flyTo({center:[t[0].lng,t[0].lat],zoom:8})};r.current.loaded()?o():r.current.on("load",o)},[t,n]),n?e.jsx("div",{ref:s,className:"w-full h-full rounded-xl overflow-hidden"}):e.jsxs("div",{className:"h-full flex items-center justify-center bg-muted/30 rounded-xl text-muted-foreground text-sm",children:[e.jsx(g0,{className:"h-5 w-5 mr-2"})," Map not configured"]})}function Yct(){var P,O,$,U;const{user:t}=Os(),s=nr(),{isGmailConnected:r,gmailEmail:n}=Zx(),[a,o]=N.useState("all"),[l,i]=N.useState("30"),[c,u]=N.useState(""),[p,f]=N.useState(!1),[g,v]=N.useState(null),{data:_,isLoading:w}=mt({queryKey:["lead-site-activity-full",t==null?void 0:t.id,l],queryFn:async()=>{const{data:B,error:V}=await H.rpc("get_lead_site_activity_full",{_user_id:t.id,_days:parseInt(l)});if(V)throw V;const X=B;return{...X,visitor_locations:((X==null?void 0:X.visitor_locations)||[]).map(Y=>({...Y,lat:Number(Y.lat),lng:Number(Y.lng),visitor_count:Number(Y.visitor_count??Y.visit_count??0)}))}},enabled:!!t,refetchInterval:6e4}),j=N.useMemo(()=>{if(!(_!=null&&_.activities))return[];let B=_.activities;if(a!=="all"&&(B=B.filter(V=>V.activity_type===a)),c){const V=c.toLowerCase();B=B.filter(X=>{var Y,ee,Q,ce,ne;return((Y=X.visitor_name)==null?void 0:Y.toLowerCase().includes(V))||((ee=X.visitor_email)==null?void 0:ee.toLowerCase().includes(V))||((Q=X.mls_number)==null?void 0:Q.includes(V))||((ce=X.property_address)==null?void 0:ce.toLowerCase().includes(V))||((ne=X.lead_type)==null?void 0:ne.toLowerCase().includes(V))})}return B},[_==null?void 0:_.activities,a,c]),k=_==null?void 0:_.subdomain,S=B=>k?`https://${k}.thelocalmove.com/listing/${B}`:null,M=_==null?void 0:_.stats,L=B=>{if(B.visitor_email)if(r){const V=(B.visitor_name||"").split(" ");v({id:B.contact_id||"",first_name:V[0]||"",last_name:V.slice(1).join(" ")||null,email:B.visitor_email}),f(!0)}else window.location.href=`mailto:${B.visitor_email}`};return!(_!=null&&_.has_site)&&!w?e.jsx(Ts,{title:"Website Activity",description:"Monitor your website lead activity",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(ru,{className:"h-16 w-16 text-muted-foreground/30 mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Website Connected"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"Set up your Lead Site to start capturing and tracking visitor activity."})]})}):e.jsxs(Ts,{title:"Website Activity",description:"Monitor and act on your website leads",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>s("/mission-control"),children:e.jsx(Qa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(ru,{className:"h-6 w-6 text-primary"}),"Website Activity"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track, respond, and convert your website visitors"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:["7","30","90"].map(B=>e.jsxs(K,{variant:l===B?"default":"outline",size:"sm",onClick:()=>i(B),children:[B,"d"]},B))})]}),M&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Page Views",value:M.total_page_views,sub:M.page_views_7d,icon:wn,color:"text-violet-600 dark:text-violet-400",bg:"bg-violet-500/10"},{label:"Listing Views",value:M.total_views,sub:M.views_7d,icon:Dn,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-500/10"},{label:"New Leads",value:M.total_leads,sub:M.leads_7d,icon:El,color:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/10"},{label:"Saved Listings",value:M.total_saved,sub:M.saved_7d,icon:Ya,color:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/10"}].map(B=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:B.label}),e.jsx("p",{className:`text-2xl font-bold ${B.color}`,children:B.value})]}),e.jsx("div",{className:`p-2.5 rounded-xl ${B.bg}`,children:e.jsx(B.icon,{className:`h-5 w-5 ${B.color}`})})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx("span",{className:`font-semibold ${B.color}`,children:B.sub})," in last 7d"]})]})},B.label))}),e.jsxs(_a,{defaultValue:"overview",className:"space-y-4",children:[e.jsxs(fa,{children:[e.jsxs(ns,{value:"overview",className:"gap-1.5",children:[e.jsx(yo,{className:"h-4 w-4"})," Overview"]}),e.jsxs(ns,{value:"leads",className:"gap-1.5",children:[e.jsx(Yh,{className:"h-4 w-4"})," Lead Inbox"]}),e.jsxs(ns,{value:"map",className:"gap-1.5",children:[e.jsx(g0,{className:"h-4 w-4"})," Visitor Map"]})]}),e.jsxs(ws,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(Jo,{className:"h-4 w-4 text-primary"}),"Most Viewed Listings"]})}),e.jsx(Oe,{className:"pt-0",children:!(_!=null&&_.top_listings)||_.top_listings.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(dn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No listing views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_listings.map((B,V)=>{const X=S(B.mls_number);return e.jsxs("a",{href:X||"#",target:"_blank",rel:"noopener noreferrer",onClick:Y=>{X||Y.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),B.photo_url?e.jsx("div",{className:"h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:B.photo_url,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(dn,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.property_address||`MLS# ${B.mls_number}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Vc(new Date(B.last_viewed),{addSuffix:!0})})]}),e.jsxs(st,{variant:"secondary",className:"shrink-0 text-xs",children:[B.view_count," view",B.view_count!==1?"s":""]}),X&&e.jsx(en,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},B.mls_number)})})})]}),e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4 text-primary"}),"Most Visited Pages"]})}),e.jsx(Oe,{className:"pt-0",children:!(_!=null&&_.top_pages)||_.top_pages.length===0?e.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[e.jsx(wn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/30"}),"No page views yet"]}):e.jsx("div",{className:"space-y-1.5",children:_.top_pages.map((B,V)=>e.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[e.jsx("span",{className:"text-sm font-bold text-muted-foreground w-5 text-right",children:V+1}),e.jsx("span",{className:"text-lg w-8 text-center",children:KMs[B.page_type]||"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:B.page_title||B.page_path}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B.page_path})]}),e.jsx(st,{variant:"secondary",className:"shrink-0 text-xs capitalize",children:B.page_type}),e.jsx(st,{variant:"outline",className:"shrink-0 text-xs",children:B.view_count})]},`${B.page_type}-${B.page_path}`))})})]})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(ia,{className:"h-4 w-4 text-primary"}),"Where Visitors Are Browsing From"]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.slice(0,9).map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-2.5 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ia,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]}),e.jsxs(ws,{value:"leads",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search by name, email, address...",value:c,onChange:B=>u(B.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex gap-2",children:[{key:"all",label:"All",count:((P=_==null?void 0:_.activities)==null?void 0:P.length)||0},{key:"new_lead",label:"Leads",count:((O=_==null?void 0:_.activities)==null?void 0:O.filter(B=>B.activity_type==="new_lead").length)||0},{key:"property_view",label:"Views",count:(($=_==null?void 0:_.activities)==null?void 0:$.filter(B=>B.activity_type==="property_view").length)||0},{key:"saved_listing",label:"Saved",count:((U=_==null?void 0:_.activities)==null?void 0:U.filter(B=>B.activity_type==="saved_listing").length)||0}].map(B=>e.jsxs(K,{variant:a===B.key?"default":"outline",size:"sm",onClick:()=>o(B.key),className:"gap-1.5",children:[B.label,e.jsx(st,{variant:"secondary",className:"text-[10px] h-4 px-1 rounded-full",children:B.count})]},B.key))})]}),w?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(B=>e.jsx("div",{className:"h-20 rounded-xl bg-muted animate-pulse"},B))}):j.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Ch,{className:"h-10 w-10 text-muted-foreground/30 mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:"No activity found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c?"Try adjusting your search.":"Website engagement will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:j.map((B,V)=>{const X=WMs[B.activity_type],Y=X.icon,ee=Vc(new Date(B.occurred_at),{addSuffix:!0}),Q=B.visitor_name&&B.visitor_name!=="Site Visitor";return e.jsx(Ee,{className:`transition-all hover:shadow-md ${B.activity_type==="new_lead"?"border-l-4 border-l-emerald-500":B.activity_type==="saved_listing"?"border-l-4 border-l-rose-500":"border-l-4 border-l-blue-500"}`,children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[B.photo_url?e.jsx("a",{href:B.mls_number&&S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 rounded-lg overflow-hidden w-12 h-12 bg-muted",children:e.jsx("img",{src:B.photo_url,alt:B.property_address||"Property",className:"w-full h-full object-cover"})}):e.jsx("div",{className:`p-2 rounded-lg shrink-0 ${B.activity_type==="new_lead"?"bg-emerald-500/10":B.activity_type==="saved_listing"?"bg-rose-500/10":"bg-blue-500/10"}`,children:e.jsx(Y,{className:`h-4 w-4 ${B.activity_type==="new_lead"?"text-emerald-500":B.activity_type==="saved_listing"?"text-rose-500":"text-blue-500"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Q?e.jsx("button",{className:"font-semibold text-sm text-primary hover:underline text-left truncate",onClick:()=>{B.contact_id&&s(`/mission-control/contacts/${B.contact_id}`)},children:B.visitor_name}):e.jsx("span",{className:"font-medium text-sm text-muted-foreground",children:B.visitor_name||"Site Visitor"}),e.jsx(st,{variant:"outline",className:`text-[10px] shrink-0 ${X.badgeClass}`,children:X.label}),B.lead_type&&e.jsx(st,{variant:"secondary",className:"text-[10px] capitalize",children:B.lead_type.replace(/_/g," ")})]}),B.property_address&&B.mls_number&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-0.5 text-xs font-medium text-foreground hover:text-primary transition-colors truncate",children:[e.jsx(ia,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:B.property_address}),e.jsx(en,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),ee]}),B.mls_number&&!B.property_address&&e.jsxs("a",{href:S(B.mls_number)||"#",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:["MLS# ",B.mls_number]})]}),B.message&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 line-clamp-2 italic",children:['"',B.message,'"']})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[B.visitor_email&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:r?"Compose via Gmail":"Send Email",onClick:()=>L(B),children:e.jsx(lr,{className:"h-4 w-4"})}),B.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Call",onClick:()=>window.location.href=`tel:${B.visitor_phone}`,children:e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-primary",title:"Text",onClick:()=>window.location.href=`sms:${B.visitor_phone}`,children:e.jsx(so,{className:"h-4 w-4"})})]}),B.contact_id&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",title:"View Contact",onClick:()=>s(`/mission-control/contacts/${B.contact_id}`),children:e.jsx(oa,{className:"h-4 w-4"})})]})]})})},`${B.activity_type}-${B.occurred_at}-${V}`)})})]}),e.jsxs(ws,{value:"map",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsxs(Rt,{className:"text-base flex items-center gap-2",children:[e.jsx(g0,{className:"h-4 w-4 text-primary"}),"Visitor Locations",(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(st,{variant:"secondary",className:"text-xs ml-2",children:[_.visitor_locations.reduce((B,V)=>B+V.visitor_count,0)," visitors from ",_.visitor_locations.length," cities"]})]})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"h-[450px] rounded-xl overflow-hidden border",children:e.jsx(ZMs,{locations:(_==null?void 0:_.visitor_locations)||[]})})})]}),(_==null?void 0:_.visitor_locations)&&_.visitor_locations.length>0&&e.jsxs(Ee,{children:[e.jsx(Pt,{className:"pb-3",children:e.jsx(Rt,{className:"text-base",children:"Location Breakdown"})}),e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:_.visitor_locations.map(B=>e.jsxs("div",{className:"flex items-center gap-2.5 p-3 rounded-lg bg-muted/40",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(ia,{className:"h-3.5 w-3.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[B.city,", ",B.region]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:B.country})]}),e.jsx("span",{className:"text-sm font-bold text-primary",children:B.visitor_count})]},`${B.city}-${B.region}`))})})]})]})]})]}),r&&g&&e.jsx(Kw,{open:p,onOpenChange:f,contact:g,gmailEmail:n})]})}const YMs=Object.freeze(Object.defineProperty({__proto__:null,default:Yct},Symbol.toStringTag,{value:"Module"})),QMs=N.lazy(()=>ol(()=>import("./MobileAgentApp-M2Rpmg2S.js"),[])),XMs=N.lazy(()=>ol(()=>import("./PostcardManager-Dpmj0iZt.js"),__vite__mapDeps([0,1]))),JMs=N.lazy(()=>ol(()=>import("./HomeReelManager-DEDqMZXK.js"),[])),eTs=N.lazy(()=>ol(()=>import("./AdminCredits-BmD1pZcm.js"),[])),tTs=N.lazy(()=>ol(()=>import("./DirectMail-BT1mbUa8.js").then(t=>t.D),__vite__mapDeps([2,1]))),sTs=N.lazy(()=>ol(()=>import("./InnerCirclePopbyMap-cUna0YLA.js"),[])),rTs=N.lazy(()=>ol(()=>import("./LiveVisitorFeed-CaJlYZDE.js"),[])),nTs=N.lazy(()=>ol(()=>import("./LeadSites-CPwhlLFV.js"),[])),j9e=N.lazy(()=>ol(()=>import("./LeadSiteEditor-wa9JFUT7.js"),__vite__mapDeps([3,4]))),aTs=N.lazy(()=>ol(()=>import("./AdminLeadSiteThemes-z6bxcM3Q.js"),__vite__mapDeps([5,4]))),iTs=N.lazy(()=>ol(()=>import("./AdminMlsFeeds-BA0cEEiq.js"),[])),oTs=N.lazy(()=>ol(()=>import("./AdminLeadSiteAnalytics-CmYYWYwz.js"),[])),lTs=N.lazy(()=>ol(()=>import("./AdminWebsiteInterests-BDkiYstI.js"),[])),cTs=N.lazy(()=>ol(()=>import("./AdminMlsFeeTracker-BjVDhwql.js"),[])),dTs=N.lazy(()=>ol(()=>import("./MLSListings-DyG7qCWQ.js"),[])),uTs=N.lazy(()=>ol(()=>import("./MLSListingDetail-GIXoYCzE.js"),[])),hTs=N.lazy(()=>ol(()=>import("./MarketReportPage-DPC1Vt8G.js"),[]));N.lazy(()=>ol(()=>Promise.resolve().then(()=>YMs),void 0));const mTs=N.lazy(()=>ol(()=>import("./EmailCampaigns-kXqOXd-Q.js"),[])),pTs=N.lazy(()=>ol(()=>import("./EmailCampaignComposer-h1rbYnW1.js"),__vite__mapDeps([6,7]))),fTs=N.lazy(()=>ol(()=>import("./EmailCampaignDetail-BEbTNNkG.js"),[])),xTs=N.lazy(()=>ol(()=>import("./SharedCampaignTemplates-BWA-RRJh.js"),__vite__mapDeps([8,9,7]))),gTs=N.lazy(()=>ol(()=>import("./AgentTemplates-CJV04EeJ.js"),__vite__mapDeps([10,9,7]))),N9e=N.lazy(()=>ol(()=>import("./TheLocalMoveHome-BYUieDLr.js"),[])),yTs=new jvt({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:5*60*1e3}}}),vTs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},bTs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},_Ts=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},wTs=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},jTs=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},NTs=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},kTs=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},STs=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},CTs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},Qct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},MTs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!Qct(),TTs=()=>e.jsx(Mvt,{client:yTs,children:e.jsx($Ue,{children:e.jsxs(G1,{children:[e.jsx(Ugt,{}),e.jsx(_yt,{}),e.jsx(z1t,{children:e.jsx(qwt,{children:e.jsx(Uwt,{children:e.jsxs(Hwt,{children:[e.jsx(Vwt,{}),e.jsx(jNt,{}),e.jsx(zNt,{}),NTs()?e.jsx(qCs,{}):bTs()?e.jsx(n4t,{}):vTs()?e.jsx(Skt,{}):_Ts()?e.jsx(o4t,{}):wTs()?e.jsx(GEt,{}):jTs()?e.jsx(c6t,{}):kTs()?e.jsx(UCs,{}):STs()?e.jsx(VCs,{}):CTs()?e.jsx(HCs,{}):Qct()?e.jsx(N.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(N9e,{})}):MTs()?e.jsx(jMs,{}):e.jsxs(Z2e,{children:[e.jsx(Ns,{path:"/",element:e.jsx(y6t,{})}),e.jsx(Ns,{path:"/the-local-move",element:e.jsx(N.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(N9e,{})})}),e.jsx(Ns,{path:"/privacy-policy",element:e.jsx(v6t,{})}),e.jsx(Ns,{path:"/terms-of-service",element:e.jsx(b6t,{})}),e.jsx(Ns,{path:"/data-deletion",element:e.jsx(_6t,{})}),e.jsx(Ns,{path:"/public/listings",element:e.jsx(yWe,{})}),e.jsx(Ns,{path:"/public/listing/:slugOrId",element:e.jsx(lLt,{})}),e.jsx(Ns,{path:"/card/:slug",element:e.jsx(cLt,{})}),e.jsx(Ns,{path:"/join-brokerage/:slug",element:e.jsx(V3s,{})}),e.jsx(Ns,{path:"/recruit-video/:shareToken",element:e.jsx(G3s,{})}),e.jsx(Ns,{path:"/connect/:slug",element:e.jsx(rQe,{})}),e.jsx(Ns,{path:"/auth",element:e.jsx(j6t,{})}),e.jsx(Ns,{path:"/subscription-success",element:e.jsx(N6t,{})}),e.jsx(Ns,{path:"/subscription",element:e.jsx(ar,{children:e.jsx(gIt,{})})}),e.jsxs(Ns,{path:"/share/video",element:e.jsx(nLt,{}),children:[e.jsx(Ns,{path:":shareToken",element:e.jsx(PIe,{})}),e.jsx(Ns,{path:":shareToken/r/:recipientToken",element:e.jsx(PIe,{})})]}),e.jsx(Ns,{path:"/p/:shareToken",element:e.jsx(dCs,{})}),e.jsx(Ns,{path:"/portal/:slug",element:e.jsx(gCs,{})}),e.jsx(Ns,{path:"/og/video/:token",element:e.jsx(aLt,{})}),e.jsx(Ns,{path:"/setup-brokerage",element:e.jsx(ar,{children:e.jsx(yIt,{})})}),e.jsx(Ns,{path:"/claim-account",element:e.jsx(TIe,{})}),e.jsx(Ns,{path:"/claim",element:e.jsx(TIe,{})}),e.jsx(Ns,{path:"/join",element:e.jsx(vIt,{})}),e.jsx(Ns,{path:"/trial",element:e.jsx(AIt,{})}),e.jsx(Ns,{path:"/trial/success",element:e.jsx(EIt,{})}),e.jsx(Ns,{path:"/dashboard",element:e.jsx(ar,{children:e.jsx(A8t,{})})}),e.jsx(Ns,{path:"/profile",element:e.jsx(ar,{children:e.jsx(p$t,{})})}),e.jsx(Ns,{path:"/apps",element:e.jsx(ar,{children:e.jsx(M$t,{})})}),e.jsx(Ns,{path:"/admin",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(A8e,{})})}),e.jsx(Ns,{path:"/admin/dashboard",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(A8e,{})})}),e.jsx(Ns,{path:"/admin/apps",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(fVt,{})})}),e.jsx(Ns,{path:"/admin/members",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(jVt,{})})}),e.jsx(Ns,{path:"/admin/invite-codes",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(NVt,{})})}),e.jsx(Ns,{path:"/admin/events",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(AVt,{})})}),e.jsx(Ns,{path:"/events",element:e.jsx(ar,{children:e.jsx(N$t,{})})}),e.jsx(Ns,{path:"/events/:eventId",element:e.jsx(ar,{children:e.jsx(S$t,{})})}),e.jsx(Ns,{path:"/templates",element:e.jsx(ar,{children:e.jsx(T$t,{})})}),e.jsx(Ns,{path:"/templates/:templateId",element:e.jsx(ar,{children:e.jsx(I$t,{})})}),e.jsx(Ns,{path:"/admin/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(PVt,{})})}),e.jsx(Ns,{path:"/academy",element:e.jsx(ar,{children:e.jsx(L$t,{})})}),e.jsx(Ns,{path:"/academy/:videoId",element:e.jsx(ar,{children:e.jsx(O$t,{})})}),e.jsx(Ns,{path:"/admin/academy",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(LVt,{})})}),e.jsx(Ns,{path:"/toolbox",element:e.jsx(ar,{children:e.jsx(R$t,{})})}),e.jsx(Ns,{path:"/toolbox/:kitId",element:e.jsx(ar,{children:e.jsx(F$t,{})})}),e.jsx(Ns,{path:"/admin/toolbox",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(DVt,{})})}),e.jsx(Ns,{path:"/social-swag",element:e.jsx(ar,{children:e.jsx(z$t,{})})}),e.jsx(Ns,{path:"/social-swag-2",element:e.jsx(ar,{children:e.jsx(RUt,{})})}),e.jsx(Ns,{path:"/social-swag/:swagId",element:e.jsx(ar,{children:e.jsx(FUt,{})})}),e.jsx(Ns,{path:"/social-connections",element:e.jsx(ar,{children:e.jsx(W3s,{})})}),e.jsx(Ns,{path:"/social-connections/callback",element:e.jsx(ar,{children:e.jsx(K3s,{})})}),e.jsx(Ns,{path:"/social-connections/linkedin-callback",element:e.jsx(ar,{children:e.jsx(Y3s,{})})}),e.jsx(Ns,{path:"/social-connections/google-callback",element:e.jsx(ar,{children:e.jsx(Z3s,{})})}),e.jsx(Ns,{path:"/admin/social-swag",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(OVt,{})})}),e.jsx(Ns,{path:"/admin/social-swag-2",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(bGt,{})})}),e.jsx(Ns,{path:"/community",element:e.jsx(ar,{children:e.jsx(rVt,{})})}),e.jsx(Ns,{path:"/support",element:e.jsx(ar,{children:e.jsx(nVt,{})})}),e.jsx(Ns,{path:"/admin/community",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(_Gt,{})})}),e.jsx(Ns,{path:"/admin/support-tickets",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(c1s,{})})}),e.jsx(Ns,{path:"/admin/email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(u1s,{})})}),e.jsx(Ns,{path:"/admin/agent-email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(h1s,{})})}),e.jsx(Ns,{path:"/admin/analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(i1s,{})})}),e.jsx(Ns,{path:"/admin/brokerage-resources",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(o1s,{})})}),e.jsx(Ns,{path:"/admin/dashboard-management",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(l1s,{})})}),e.jsx(Ns,{path:"/brokerage/dashboard",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(N1s,{})})}),e.jsx(Ns,{path:"/brokerage/teams",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(SMs,{})})}),e.jsx(Ns,{path:"/brokerage/recruiting",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(fSs,{})})}),e.jsx(Ns,{path:"/my-team",element:e.jsx(ar,{children:e.jsx(CMs,{})})}),e.jsx(Ns,{path:"/my-brokerage",element:e.jsx(ar,{children:e.jsx(A1s,{})})}),e.jsx(Ns,{path:"/brokerage-content",element:e.jsx(ar,{children:e.jsx(O1s,{})})}),e.jsx(Ns,{path:"/brokerage-content/:contentId",element:e.jsx(ar,{children:e.jsx($1s,{})})}),e.jsx(Ns,{path:"/brokerage-resources",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(dVt,{})})}),e.jsx(Ns,{path:"/brokerage-resources/:resourceId",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(uVt,{})})}),e.jsx(Ns,{path:"/newsletters",element:e.jsx(ar,{children:e.jsx(q1s,{})})}),e.jsx(Ns,{path:"/newsletters/:id",element:e.jsx(ar,{children:e.jsx(V1s,{})})}),e.jsx(Ns,{path:"/wishlist",element:e.jsx(ar,{children:e.jsx(W1s,{})})}),e.jsx(Ns,{path:"/wishlist/:itemId",element:e.jsx(ar,{children:e.jsx(K1s,{})})}),e.jsx(Ns,{path:"/admin/wishlist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Z1s,{})})}),e.jsx(Ns,{path:"/admin/levelup-brief",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Y1s,{})})}),e.jsx(Ns,{path:"/admin/newsletters",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(G1s,{})})}),e.jsx(Ns,{path:"/admin/additional-services",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Q1s,{})})}),e.jsx(Ns,{path:"/admin/discounts",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(X1s,{})})}),e.jsx(Ns,{path:"/admin/subscriptions",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(J1s,{})})}),e.jsx(Ns,{path:"/admin/referrals",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(ebs,{})})}),e.jsx(Ns,{path:"/admin/prospector",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(X4s,{})})}),e.jsx(Ns,{path:"/admin/recruiting",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(pSs,{})})}),e.jsx(Ns,{path:"/admin/beta/social-post-generator",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(x3s,{})})}),e.jsx(Ns,{path:"/admin/credits",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(eTs,{})})})}),e.jsx(Ns,{path:"/admin/beta/postcard-manager",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(XMs,{})})})}),e.jsx(Ns,{path:"/admin/beta/homereel",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(JMs,{})})})}),e.jsx(Ns,{path:"/admin/lms",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(A3s,{})})}),e.jsx(Ns,{path:"/admin/lms/stats",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(D3s,{})})}),e.jsx(Ns,{path:"/admin/lms/:courseId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(E3s,{})})}),e.jsx(Ns,{path:"/levelup-u",element:e.jsx(ar,{children:e.jsx(O3s,{})})}),e.jsx(Ns,{path:"/levelup-u/:courseId",element:e.jsx(ar,{children:e.jsx(F3s,{})})}),e.jsx(Ns,{path:"/admin/brokerage-content-activity",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(xSs,{})})}),e.jsx(Ns,{path:"/admin/onboarding-checklist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(sbs,{})})}),e.jsx(Ns,{path:"/admin/marketplace",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(T4s,{})})}),e.jsx(Ns,{path:"/admin/agent-points",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Jks,{})})}),e.jsx(Ns,{path:"/admin/reward-store",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(V4s,{})})}),e.jsx(Ns,{path:"/admin/integrations",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(G4s,{})})}),e.jsx(Ns,{path:"/admin/integrations/callback",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Q4s,{})})}),e.jsx(Ns,{path:"/admin/email-campaigns",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(mTs,{})})})}),e.jsx(Ns,{path:"/admin/email-campaigns/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(xTs,{})})})}),e.jsx(Ns,{path:"/email-campaigns/templates",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(gTs,{})})})}),e.jsx(Ns,{path:"/admin/email-campaigns/new",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(pTs,{})})})}),e.jsx(Ns,{path:"/admin/email-campaigns/:id",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(fTs,{})})})}),e.jsx(Ns,{path:"/reward-store",element:e.jsx(ar,{children:e.jsx(nCs,{})})}),e.jsx(Ns,{path:"/additional-services",element:e.jsx(ar,{children:e.jsx(mbs,{})})}),e.jsx(Ns,{path:"/additional-services/:serviceId",element:e.jsx(ar,{children:e.jsx(pbs,{})})}),e.jsx(Ns,{path:"/ai-toolkit",element:e.jsx(ar,{children:e.jsx(fbs,{})})}),e.jsx(Ns,{path:"/mission-control",element:e.jsx(ar,{children:e.jsx(Lbs,{})})}),e.jsx(Ns,{path:"/mission-control/contacts",element:e.jsx(ar,{children:e.jsx(y_s,{})})}),e.jsx(Ns,{path:"/mission-control/contacts/:contactId",element:e.jsx(ar,{children:e.jsx(G_s,{})})}),e.jsx(Ns,{path:"/mission-control/plans",element:e.jsx(ar,{children:e.jsx(W_s,{})})}),e.jsx(Ns,{path:"/mission-control/popbys",element:e.jsx(ar,{children:e.jsx(Y_s,{})})}),e.jsx(Ns,{path:"/mission-control/popbys/map",element:e.jsx(ar,{children:e.jsx(sTs,{})})}),e.jsx(Ns,{path:"/admin/notification-settings",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(K4s,{})})}),e.jsx(Ns,{path:"/admin/agent-os",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(nbs,{})})}),e.jsx(Ns,{path:"/mission-control/listings",element:e.jsx(ar,{children:e.jsx(bws,{})})}),e.jsx(Ns,{path:"/mission-control/listings/new",element:e.jsx(ar,{children:e.jsx(w7e,{})})}),e.jsx(Ns,{path:"/mission-control/listings/:listingId",element:e.jsx(ar,{children:e.jsx(Dws,{})})}),e.jsx(Ns,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(ar,{children:e.jsx(w7e,{})})}),e.jsx(Ns,{path:"/admin/listing-exchange",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Wks,{})})}),e.jsx(Ns,{path:"/mission-control/pipeline",element:e.jsx(ar,{children:e.jsx(eks,{})})}),e.jsx(Ns,{path:"/mission-control/tasks",element:e.jsx(ar,{children:e.jsx(dks,{})})}),e.jsx(Ns,{path:"/mission-control/my-card",element:e.jsx(ar,{children:e.jsx(Aks,{})})}),e.jsx(Ns,{path:"/mission-control/integrations",element:e.jsx(ar,{children:e.jsx(Bks,{})})}),e.jsx(Ns,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(ar,{children:e.jsx($ks,{})})}),e.jsx(Ns,{path:"/mission-control/integrations/canva/callback",element:e.jsx(qks,{})}),e.jsx(Ns,{path:"/mission-control/integrations/meta/callback",element:e.jsx(ar,{children:e.jsx(Uks,{})})}),e.jsx(Ns,{path:"/mission-control/scorecard",element:e.jsx(ar,{children:e.jsx(dws,{})})}),e.jsx(Ns,{path:"/admin/scorecard",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Hks,{})})}),e.jsx(Ns,{path:"/admin/scorecard/:userId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Dze,{})})}),e.jsx(Ns,{path:"/mission-control/scorecard/:userId",element:e.jsx(ar,{children:e.jsx(Dze,{})})}),e.jsx(Ns,{path:"/mission-control/relationship-scorecard",element:e.jsx(ar,{children:e.jsx(BMs,{})})}),e.jsx(Ns,{path:"/mission-control/sphere-gaps",element:e.jsx(ar,{children:e.jsx(VMs,{})})}),e.jsx(Ns,{path:"/mission-control/website-activity",element:e.jsx(ar,{children:e.jsx(Yct,{})})}),e.jsx(Ns,{path:"/mission-control/connect-page",element:e.jsx(ar,{children:e.jsx(GMs,{})})}),e.jsx(Ns,{path:"/admin/membership-reviews",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Kks,{})})}),e.jsx(Ns,{path:"/admin/weekly-digest",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Qks,{})})}),e.jsx(Ns,{path:"/mission-control/video/record",element:e.jsx(ar,{children:e.jsx(Fjs,{})})}),e.jsx(Ns,{path:"/mission-control/video-library",element:e.jsx(ar,{children:e.jsx(Jjs,{})})}),e.jsx(Ns,{path:"/marketplace",element:e.jsx(ar,{children:e.jsx(Q3s,{})})}),e.jsx(Ns,{path:"/marketplace/:productId",element:e.jsx(ar,{children:e.jsx(X3s,{})})}),e.jsx(Ns,{path:"/marketplace/cart",element:e.jsx(ar,{children:e.jsx(J3s,{})})}),e.jsx(Ns,{path:"/marketplace/orders",element:e.jsx(ar,{children:e.jsx(eCs,{})})}),e.jsx(Ns,{path:"/marketplace/orders/:orderId",element:e.jsx(ar,{children:e.jsx(sCs,{})})}),e.jsx(Ns,{path:"/marketplace/success",element:e.jsx(ar,{children:e.jsx(rCs,{})})}),e.jsx(Ns,{path:"/admin/agent-cards",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(e4s,{})})}),e.jsx(Ns,{path:"/admin/presentation-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Z4s,{})})}),e.jsx(Ns,{path:"/admin/guest-book-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Y4s,{})})}),e.jsx(Ns,{path:"/mission-control/smart-drips",element:e.jsx(ar,{children:e.jsx(BCs,{})})}),e.jsx(Ns,{path:"/mission-control/direct-mail",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(tTs,{})})})}),e.jsx(Ns,{path:"/mission-control/presentations",element:e.jsx(ar,{children:e.jsx(aCs,{})})}),e.jsx(Ns,{path:"/mission-control/presentations/new",element:e.jsx(ar,{children:e.jsx(a9e,{})})}),e.jsx(Ns,{path:"/mission-control/presentations/:id",element:e.jsx(ar,{children:e.jsx(a9e,{})})}),e.jsx(Ns,{path:"/mission-control/guest-book",element:e.jsx(ar,{children:e.jsx(fCs,{})})}),e.jsx(Ns,{path:"/mission-control/guest-book/live/:id",element:e.jsx(ar,{children:e.jsx(rTs,{})})}),e.jsx(Ns,{path:"/guestbook/:slug",element:e.jsx(XWe,{})}),e.jsx(Ns,{path:"/mission-control/card-studio",element:e.jsx(ar,{children:e.jsx(jCs,{})})}),e.jsx(Ns,{path:"/mission-control/scheduler",element:e.jsx(ar,{children:e.jsx(LMs,{})})}),e.jsx(Ns,{path:"/c/:shareToken",element:e.jsx(Dct,{})}),e.jsx(Ns,{path:"/book/:slug",element:e.jsx(Rct,{})}),e.jsx(Ns,{path:"/page/:slug",element:e.jsx(Fct,{})}),e.jsx(Ns,{path:"/mission-control/landing-pages",element:e.jsx(ar,{children:e.jsx(DMs,{})})}),e.jsx(Ns,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(ar,{children:e.jsx(FMs,{})})}),e.jsx(Ns,{path:"/my-website/:siteId/edit",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(j9e,{})})})}),e.jsx(Ns,{path:"/my-website/mls-listings",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(dTs,{})})})}),e.jsx(Ns,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(uTs,{})})})}),e.jsx(Ns,{path:"/my-website/market-report",element:e.jsx(ar,{children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(hTs,{})})})}),e.jsx(Ns,{path:"/admin/lead-sites",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(nTs,{})})})}),e.jsx(Ns,{path:"/admin/lead-sites/themes",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(aTs,{})})})}),e.jsx(Ns,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(j9e,{})})})}),e.jsx(Ns,{path:"/admin/mls-feeds",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(iTs,{})})})}),e.jsx(Ns,{path:"/admin/lead-site-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(oTs,{})})})}),e.jsx(Ns,{path:"/admin/website-interests",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(lTs,{})})})}),e.jsx(Ns,{path:"/admin/mls-fee-tracker",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(cTs,{})})})}),e.jsx(Ns,{path:"/m/*",element:e.jsx(N.Suspense,{fallback:e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),children:e.jsx(QMs,{})})}),e.jsx(Ns,{path:"*",element:e.jsx(Oct,{})})]}),")"]})})})})]})})}),Jp=window.location.hostname,ATs=Jp.includes("lovable.app")||Jp.includes("lovableproject.com"),ETs=(()=>{try{return window.self!==window.top}catch{return!0}})(),PTs=Jp.startsWith("cards.")||Jp.startsWith("cardstudio.")||Jp.startsWith("listings.")||Jp.startsWith("presentations.")||Jp.startsWith("guestbook.")||Jp.startsWith("clients.")||Jp.startsWith("booking.")||Jp.startsWith("contacts.")||Jp.startsWith("pages.")||Jp.endsWith(".thelocalmove.com")&&!Jp.startsWith("dashboard.");var D9e;ATs||ETs||PTs?((D9e=navigator.serviceWorker)==null||D9e.getRegistrations().then(t=>{t.forEach(s=>s.unregister())}),"caches"in window&&caches.keys().then(t=>t.forEach(s=>caches.delete(s)))):"serviceWorker"in navigator&&ol(async()=>{const{registerSW:t}=await import("./virtual_pwa-register-dGVsg5lo.js");return{registerSW:t}},[]).then(({registerSW:t})=>{t({onNeedRefresh(){},onOfflineReady(){}})});Z$e(document.getElementById("root")).render(e.jsx(TTs,{}));export{lo as $,qs as A,Qa as B,yo as C,th as D,Dn as E,za as F,ia as G,dn as H,_Y as I,hn as J,ZAe as K,Ya as L,so as M,fxe as N,A1t as O,Mn as P,sme as Q,n_s as R,Qo as S,Fm as T,hr as U,nit as V,o_s as W,Mr as X,bSe as Y,ba as Z,ol as _,nr as a,Uc as a$,Zx as a0,Lt as a1,ru as a2,$n as a3,Kw as a4,Jo as a5,y1 as a6,bs as a7,Mh as a8,su as a9,zn as aA,Cs as aB,St as aC,Bn as aD,dt as aE,st as aF,qr as aG,xs as aH,fs as aI,js as aJ,_s as aK,be as aL,ze as aM,Ks as aN,Gs as aO,Ys as aP,Ws as aQ,Mt as aR,Un as aS,UTs as aT,ms as aU,So as aV,Pr as aW,vl as aX,dae as aY,X4 as aZ,Ca as a_,mS as aa,nd as ab,DM as ac,qM as ad,sh as ae,o0 as af,Jg as ag,Xo as ah,en as ai,Lm as aj,hS as ak,Z2e as al,Ns as am,Ee as an,Pt as ao,Rt as ap,hl as aq,gr as ar,Oe as as,_a as at,fa as au,ns as av,Al as aw,ws as ax,K as ay,Fn as az,Os as b,G1 as b$,yi as b0,Nr as b1,Ts as b2,dS as b3,qi as b4,di as b5,fn as b6,W_ as b7,uJ as b8,Rm as b9,mR as bA,l4e as bB,a3 as bC,Mu as bD,Nc as bE,kc as bF,a1 as bG,ec as bH,nse as bI,$o as bJ,qo as bK,Ro as bL,Ki as bM,pL as bN,sa as bO,Cl as bP,aJ as bQ,JX as bR,oL as bS,ch as bT,pV as bU,wn as bV,$M as bW,YL as bX,Mx as bY,Wr as bZ,Yj as b_,il as ba,Fae as bb,Yg as bc,Hv as bd,Bi as be,vi as bf,UM as bg,Wo as bh,yu as bi,Cn as bj,_0 as bk,xS as bl,y0 as bm,uIt as bn,kn as bo,Ua as bp,Sn as bq,e4e as br,ece as bs,Zse as bt,a4e as bu,t4e as bv,o4e as bw,JTs as bx,kV as by,r4e as bz,It as c,Cu as c$,QM as c0,Yu as c1,LL as c2,Oo as c3,jn as c4,lpt as c5,Po as c6,ht as c7,Ubs as c8,qbs as c9,Dm as cA,aZ as cB,Au as cC,Su as cD,Kh as cE,i4e as cF,qv as cG,eAs as cH,aAs as cI,gGt as cJ,j0 as cK,ff as cL,Jn as cM,l1 as cN,Ph as cO,rAs as cP,nAs as cQ,kp as cR,Ime as cS,El as cT,Sp as cU,fL as cV,Sx as cW,_d as cX,xSe as cY,p1 as cZ,al as c_,Hbs as ca,Eo as cb,NQ as cc,fJ as cd,gi as ce,VTs as cf,SWe as cg,HTs as ch,GTs as ci,WTs as cj,x1 as ck,zZe as cl,ml as cm,ps as cn,X_ as co,lE as cp,S3 as cq,cE as cr,dE as cs,Ire as ct,Bl as cu,Cx as cv,IL as cw,$ee as cx,KM as cy,AL as cz,uc as d,lae as d0,RR as d1,Sa as d2,Om as d3,rS as d4,gS as d5,jf as d6,pT as d7,Fat as d8,W0 as d9,Q4 as dA,J4 as dB,Bo as dC,wS as dD,vS as dE,fke as dF,Ha as dG,$l as dH,aS as dI,zm as dJ,Nj as dK,H_ as dL,cS as dM,lL as dN,dW as dO,Kee as dP,Yh as dQ,Yv as dR,yR as da,hp as db,Rat as dc,h3 as dd,m3 as de,z1 as df,Nh as dg,iL as dh,Ax as di,Uv as dj,ane as dk,sS as dl,gke as dm,vke as dn,I9t as dp,Bat as dq,Eke as dr,Tke as ds,Ake as dt,tS as du,oS as dv,zM as dw,BM as dx,rh as dy,x0 as dz,mt as e,sn as f,uE as g,Tbs as h,oa as i,e as j,lr as k,Xt as l,sIt as m,Vc as n,Wi as o,un as p,Iue as q,N as r,H as s,Gx as t,dc as u,mE as v,yp as w,xf as x,oo as y,me as z};